001/* 002 * Copyright (c) 2009 The openGion Project. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 013 * either express or implied. See the License for the specific language 014 * governing permissions and limitations under the License. 015 */ 016package org.opengion.fukurou.util; 017 018import java.util.Map; 019import java.util.WeakHashMap; 020 021/** 022 * HybsLoaderを生成するためのファクトリクラスです。 023 * HybsLoaderは、ソースディレクトリをキーとして、キャッシュされます。 024 * 025 * @og.rev 5.1.1.0 (2009/12/01) 新規作成 026 * @og.group 業務ロジック 027 * 028 * @version 5.0 029 * @author Hiroki Nakamura 030 * @since JDK1.6, 031 */ 032final public class HybsLoaderFactory { 033 034 private static final Map<String,HybsLoader> loaderMap = new WeakHashMap<String,HybsLoader>(); 035 036 /** 037 * オブジェクトの生成を禁止します。 038 */ 039 private HybsLoaderFactory() {} 040 041 /** 042 * HybsLoaderオブジェクトを取得します。 043 * 044 * @param option HybsLoaderを生成するための設定情報 045 * 046 * @return HybsLoaderオブジェクト 047 */ 048 public static HybsLoader getLoader( final HybsLoaderConfig option ) { 049 HybsLoader loader = null; 050 synchronized( HybsLoaderFactory.class ) { 051 loader = loaderMap.get( option.getSrcDir() ); 052 if( loader == null ) { 053 loader = new HybsLoader( option ); 054 } 055 loaderMap.put( option.getSrcDir(), loader ); 056 } 057 return loader; 058 } 059}