Author: gcrieloue Date: 2010-02-25 17:01:41 +0100 (Thu, 25 Feb 2010) New Revision: 128 Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/BigTableLoader.java Log: Ajout d'une map pour les plugins (nom du plugin - plugin) Modified: trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/BigTableLoader.java =================================================================== --- trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/BigTableLoader.java 2010-02-25 14:26:32 UTC (rev 127) +++ trunk/msm/src/main/java/org/nuiton/mapstoragemanager/core/BigTableLoader.java 2010-02-25 16:01:41 UTC (rev 128) @@ -4,6 +4,8 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.util.Collection; +import java.util.HashMap; import java.util.ServiceLoader; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -12,7 +14,7 @@ /** * @author Crieloue Gilles - * + * This class loads the BigTable implementations */ public class BigTableLoader extends URLClassLoader { @@ -27,6 +29,11 @@ private ServiceLoader<BigTable> bigTableSetLoader; /** + * Map Identifiant - BigTable implementation + */ + private HashMap<String, BigTable> plugins = new HashMap<String, BigTable>(); + + /** * Class constructor. * @param pluginsFolderPath the plugins folder path * @param classLoader the parent classloader @@ -49,6 +56,17 @@ } bigTableSetLoader = ServiceLoader.load(BigTable.class, this); + + /** + * Identifiant for the plugin + */ + + //TODO: define better identifiants + int pluginNumber = 0; + for (BigTable bigTableImpl : bigTableSetLoader){ + plugins.put("BigTable"+pluginNumber, bigTableImpl); + pluginNumber++; + } } /** @@ -79,8 +97,26 @@ /** * Returns the BigTable Set Loader. * @return the BigTable Set Loader + * @deprecated Use {@link #getAllBigTable()} */ public final ServiceLoader<BigTable> getBigTableSetLoader() { return bigTableSetLoader; } + + /** + * Returns a BigTable implementation according to an identifiant. + * @param id the identifiant + * @return the BigTable + */ + public BigTable getBigTable(String id){ + return plugins.get(id); + } + + /** + * Returns all the BigTable implementations loaded. + * @return all the BigTable implementations loaded + */ + public Collection<BigTable> getAllBigTable(){ + return plugins.values(); + } }