comparison artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java @ 263:c0fb96f88ad1

Make used HTTP server exchangeable. artifacts/trunk@1974 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 22 May 2011 11:21:40 +0000
parents c47a640cfdae
children d52947ce8629
comparison
equal deleted inserted replaced
262:5cab846eb2a3 263:c0fb96f88ad1
14 import de.intevation.artifacts.ArtifactContextFactory; 14 import de.intevation.artifacts.ArtifactContextFactory;
15 import de.intevation.artifacts.ArtifactFactory; 15 import de.intevation.artifacts.ArtifactFactory;
16 import de.intevation.artifacts.CallContext; 16 import de.intevation.artifacts.CallContext;
17 import de.intevation.artifacts.ServiceFactory; 17 import de.intevation.artifacts.ServiceFactory;
18 import de.intevation.artifacts.UserFactory; 18 import de.intevation.artifacts.UserFactory;
19
20
21 import de.intevation.artifactdatabase.rest.HTTPServer;
19 22
20 import java.util.ArrayList; 23 import java.util.ArrayList;
21 24
22 import org.apache.log4j.Logger; 25 import org.apache.log4j.Logger;
23 26
99 * XPAth that points to a configuration node for a CallContext.Listener. 102 * XPAth that points to a configuration node for a CallContext.Listener.
100 */ 103 */
101 public static final String CALLCONTEXT_LISTENER = 104 public static final String CALLCONTEXT_LISTENER =
102 "/artifact-database/callcontext-listener"; 105 "/artifact-database/callcontext-listener";
103 106
107
108 public static final String HTTP_SERVER =
109 "/artifact-database/rest-server/http-server/text()";
110
111 public static final String DEFAULT_HTTP_SERVER =
112 "de.intevation.artifactdatabase.rest.Standalone";
113
104 /** 114 /**
105 * Default export signing secret. 115 * Default export signing secret.
106 * <strong>PLEASE CHANGE THE SECRET VIA THE XPATH EXPORT_SECRET 116 * <strong>PLEASE CHANGE THE SECRET VIA THE XPATH EXPORT_SECRET
107 * IN THE CONFIGURATION.</strong>. 117 * IN THE CONFIGURATION.</strong>.
108 */ 118 */
143 153
144 /** 154 /**
145 * byte array holding the export signing secret. 155 * byte array holding the export signing secret.
146 */ 156 */
147 protected byte [] exportSecret; 157 protected byte [] exportSecret;
158
159 protected HTTPServer httpServer;
148 160
149 161
150 /** 162 /**
151 * Default constructor 163 * Default constructor
152 */ 164 */
373 callContextListener = (CallContext.Listener) clazz.newInstance(); 385 callContextListener = (CallContext.Listener) clazz.newInstance();
374 386
375 callContextListener.setup(Config.getConfig(), listener); 387 callContextListener.setup(Config.getConfig(), listener);
376 } 388 }
377 catch (ClassNotFoundException cnfe) { 389 catch (ClassNotFoundException cnfe) {
378 logger.error(cnfe.getLocalizedMessage(), cnfe); 390 logger.error(cnfe.getLocalizedMessage(), cnfe);
391 }
392 catch (InstantiationException ie) {
393 logger.error(ie.getLocalizedMessage(), ie);
394 }
395 catch (ClassCastException cce) {
396 logger.error(cce.getLocalizedMessage(), cce);
397 }
398 catch (IllegalAccessException iae) {
399 logger.error(iae.getLocalizedMessage(), iae);
400 }
401 }
402
403 protected void loadHTTPServer() {
404 logger.info("loading HTTPServer");
405
406 String className = Config.getStringXPath(
407 HTTP_SERVER, DEFAULT_HTTP_SERVER);
408
409 try {
410 Class clazz = Class.forName(className);
411 httpServer = (HTTPServer)clazz.newInstance();
412
413 httpServer.setup(Config.getConfig());
414 }
415 catch (ClassNotFoundException cnfe) {
416 logger.error(cnfe.getLocalizedMessage(), cnfe);
379 } 417 }
380 catch (InstantiationException ie) { 418 catch (InstantiationException ie) {
381 logger.error(ie.getLocalizedMessage(), ie); 419 logger.error(ie.getLocalizedMessage(), ie);
382 } 420 }
383 catch (ClassCastException cce) { 421 catch (ClassCastException cce) {
413 loadCollectionFactory(); 451 loadCollectionFactory();
414 loadArtifactFactories(); 452 loadArtifactFactories();
415 loadServiceFactories(); 453 loadServiceFactories();
416 loadUserFactory(); 454 loadUserFactory();
417 loadCallContextListener(); 455 loadCallContextListener();
456 loadHTTPServer();
418 } 457 }
419 458
420 /** 459 /**
421 * Returns the artifact collection factory. 460 * Returns the artifact collection factory.
422 * 461 *
474 * @return a CallContext.Listener. 513 * @return a CallContext.Listener.
475 */ 514 */
476 public CallContext.Listener getCallContextListener() { 515 public CallContext.Listener getCallContextListener() {
477 return callContextListener; 516 return callContextListener;
478 } 517 }
518
519 public HTTPServer getHTTPServer() {
520 return httpServer;
521 }
479 } 522 }
480 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 523 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org