Mercurial > dive4elements > framework
diff artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java @ 89:d348fe1fd822
More javadoc (fixes small glitches, too).
artifacts/trunk@845 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 26 Mar 2010 16:16:32 +0000 |
parents | f69e5b87f05f |
children | 5332d956729c |
line wrap: on
line diff
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java Fri Mar 26 15:05:11 2010 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java Fri Mar 26 16:16:32 2010 +0000 @@ -20,33 +20,75 @@ { private static Logger logger = Logger.getLogger(FactoryBootstrap.class); + /** + * XPath to figure out the class name of the context factory from + * the global configuration. + */ public static final String CONTEXT_FACTORY = "/artifact-database/factories/context-factory/text()"; + /** + * The name of the default context factory. + */ public static final String DEFAULT_CONTEXT_FACTORY = "de.intevation.artifactdatabase.DefaultArtifactContextFactory"; + /** + * XPath to figure out the names of the artifact factories from + * the global configuration to be exposed by the artifact database. + */ public static final String ARTIFACT_FACTORIES = "/artifact-database/factories/artifact-factories/artifact-factory"; + /** + * XPath to figure out the names of the service factories from + * the global configuration to build the services offered by the + * artifact database. + */ public static final String SERVICE_FACTORIES = "/artifact-database/factories/service-factories/service-factory"; + /** + * XPath to figure out the secret used to sign the artifact exports + * made by the artfifact database server. + */ public static final String EXPORT_SECRET = "/artifact-database/export-secret/text()"; - public static final String DEFAULT_EXORT_SECRET = + /** + * Default export signing secret. + * <strong>PLEASE CHANGE THE SECRET VIA THE XPATH EXPORT_SECRET + * IN THE CONFIGURATION.</strong>. + */ + public static final String DEFAULT_EXPORT_SECRET = "!!!CHANGE ME! I'M NO SECRET!!!"; + /** + * Reference to the global context build by the global context factory. + */ protected Object context; + /** + * List of the artifact factories to be exposed by the + * artifact database. + */ protected ArtifactFactory [] artifactFactories; + /** + * List of service factories which creates services that are + * exposed by the artifact database. + */ protected ServiceFactory [] serviceFactories; + /** + * byte array holding the export signing secret. + */ protected byte [] exportSecret; + /** + * Default constructor + */ public FactoryBootstrap() { } @@ -83,6 +125,10 @@ context = factory.createArtifactContext(Config.getConfig()); } + /** + * Scans the global configuration to load the configured + * artifact factories and sets them up. + */ protected void loadArtifactFactories() { logger.info("loading artifact factories"); @@ -122,7 +168,8 @@ if (factory != null) { factory.setup(config, nodes.item(i)); loadedFactories.add(factory); - logger.info("Registering '" + factory.getName() + "' as artifact factory."); + logger.info("Registering '" + + factory.getName() + "' as artifact factory."); } } @@ -130,6 +177,10 @@ new ArtifactFactory[loadedFactories.size()]); } + /** + * Scans the global configuration for the configured service factories + * and sets them up. + */ protected void loadServiceFactories() { logger.info("loading service factories"); @@ -177,17 +228,25 @@ new ServiceFactory[loadedFactories.size()]); } + /** + * Fetches the export signing secret from the global configuration. + * If none is found if defaults to the DEFAULT_EXORT_SECRET which + * is insecure. + */ protected void setupExportSecret() { String secret = Config.getStringXPath(EXPORT_SECRET); if (secret == null) { logger.warn("NO EXPORT SECRET SET! USING INSECURE DEFAULT!"); - secret = DEFAULT_EXORT_SECRET; + secret = DEFAULT_EXPORT_SECRET; } exportSecret = StringUtils.getUTF8Bytes(secret); } + /** + * Loads all the dynamic classes configured by the global configuration. + */ public void boot() { setupExportSecret(); buildContext(); @@ -195,18 +254,35 @@ loadServiceFactories(); } + /** + * Returns the list of ready to use artifact factories. + * @return The list of artifact factories. + */ public ArtifactFactory [] getArtifactFactories() { return artifactFactories; } + /** + * Returns the ready to use service factories. + * @return The list of service factories. + */ public ServiceFactory [] getServiceFactories() { return serviceFactories; } + /** + * Returns the global context created by the global context factory. + * @return The global context. + */ public Object getContext() { return context; } + /** + * Returns the signing secret to be used when ex- and importing + * artifacts from and into the artifact database. + * @return the byte array containg the signing secret. + */ public byte [] getExportSecret() { return exportSecret; }