# HG changeset patch # User Ingo Weinzierl # Date 1302786529 0 # Node ID c47a640cfdae3826f3d13d811fe6201f85e7bfc6 # Parent eafe59ecfb7e57b82ae7af293022c355f7f39f89 Enhanced the bootstrap - the CallContext.Listener is initialized (if configured). artifacts/trunk@1692 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r eafe59ecfb7e -r c47a640cfdae ChangeLog --- a/ChangeLog Thu Apr 14 13:02:46 2011 +0000 +++ b/ChangeLog Thu Apr 14 13:08:49 2011 +0000 @@ -1,3 +1,10 @@ +2011-04-14 Ingo Weinzierl + + * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java, + artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java: + Enhanced the bootstrap - the CallContext.Listener is initialized (if + configured). + 2011-04-14 Ingo Weinzierl * artifacts/src/main/java/de/intevation/artifacts/CallContext.java: diff -r eafe59ecfb7e -r c47a640cfdae artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Thu Apr 14 13:02:46 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Thu Apr 14 13:08:49 2011 +0000 @@ -430,6 +430,7 @@ setupArtifactFactories(bootstrap); setupServices(bootstrap); setupUserFactory(bootstrap); + setupCallContextListener(bootstrap); context = bootstrap.getContext(); exportSecret = bootstrap.getExportSecret(); @@ -481,6 +482,14 @@ } } + /** + * Used to extract the callContextListener from the bootstrap. + * + * @param bootstrap The bootstrap parameters. + */ + protected void setupCallContextListener(FactoryBootstrap bootstrap) { + setCallContextListener(bootstrap.getCallContextListener()); + } /** * Used to extract the user factory from the bootstrap. diff -r eafe59ecfb7e -r c47a640cfdae artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java Thu Apr 14 13:02:46 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java Thu Apr 14 13:08:49 2011 +0000 @@ -13,6 +13,7 @@ import de.intevation.artifacts.ArtifactCollectionFactory; import de.intevation.artifacts.ArtifactContextFactory; import de.intevation.artifacts.ArtifactFactory; +import de.intevation.artifacts.CallContext; import de.intevation.artifacts.ServiceFactory; import de.intevation.artifacts.UserFactory; @@ -95,6 +96,12 @@ "/artifact-database/export-secret/text()"; /** + * XPAth that points to a configuration node for a CallContext.Listener. + */ + public static final String CALLCONTEXT_LISTENER = + "/artifact-database/callcontext-listener"; + + /** * Default export signing secret. * PLEASE CHANGE THE SECRET VIA THE XPATH EXPORT_SECRET * IN THE CONFIGURATION.. @@ -130,6 +137,11 @@ protected ArtifactCollectionFactory collectionFactory; /** + * The CallContext.Listener. + */ + protected CallContext.Listener callContextListener; + + /** * byte array holding the export signing secret. */ protected byte [] exportSecret; @@ -344,6 +356,38 @@ } } + + protected void loadCallContextListener() { + logger.info("loading CallContext.Listener"); + + Node listener = Config.getNodeXPath(CALLCONTEXT_LISTENER); + + if (listener == null) { + return; + } + + String className = Config.getStringXPath(listener, "text()"); + + try { + Class clazz = Class.forName(className); + callContextListener = (CallContext.Listener) clazz.newInstance(); + + callContextListener.setup(Config.getConfig(), listener); + } + catch (ClassNotFoundException cnfe) { + logger.error(cnfe.getLocalizedMessage(), cnfe); + } + catch (InstantiationException ie) { + logger.error(ie.getLocalizedMessage(), ie); + } + catch (ClassCastException cce) { + logger.error(cce.getLocalizedMessage(), cce); + } + catch (IllegalAccessException iae) { + logger.error(iae.getLocalizedMessage(), iae); + } + } + /** * Fetches the export signing secret from the global configuration. * If none is found if defaults to the DEFAULT_EXORT_SECRET which @@ -370,6 +414,7 @@ loadArtifactFactories(); loadServiceFactories(); loadUserFactory(); + loadCallContextListener(); } /** @@ -422,5 +467,14 @@ public byte [] getExportSecret() { return exportSecret; } + + /** + * Returns a CallContext.Listener if configured or null. + * + * @return a CallContext.Listener. + */ + public CallContext.Listener getCallContextListener() { + return callContextListener; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :