Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java @ 311:1d517e051e95
Made backend listeners loadable at boot time.
artifacts/trunk@2436 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 01 Aug 2011 14:17:09 +0000 |
parents | d96bcb40dbf9 |
children | f2277458823e |
comparison
equal
deleted
inserted
replaced
310:63122b9dee1d | 311:1d517e051e95 |
---|---|
121 "de.intevation.artifactdatabase.rest.Standalone"; | 121 "de.intevation.artifactdatabase.rest.Standalone"; |
122 | 122 |
123 public static final String LIFETIME_LISTENERS = | 123 public static final String LIFETIME_LISTENERS = |
124 "/artifact-database/lifetime-listeners/listener"; | 124 "/artifact-database/lifetime-listeners/listener"; |
125 | 125 |
126 public static final String BACKEND_LISTENERS = | |
127 "/artifact-database/backend-listeners/listener"; | |
128 | |
126 /** | 129 /** |
127 * Default export signing secret. | 130 * Default export signing secret. |
128 * <strong>PLEASE CHANGE THE SECRET VIA THE XPATH EXPORT_SECRET | 131 * <strong>PLEASE CHANGE THE SECRET VIA THE XPATH EXPORT_SECRET |
129 * IN THE CONFIGURATION.</strong>. | 132 * IN THE CONFIGURATION.</strong>. |
130 */ | 133 */ |
166 protected List<Hook> postFeedHooks; | 169 protected List<Hook> postFeedHooks; |
167 | 170 |
168 protected List<Hook> postAdvanceHooks; | 171 protected List<Hook> postAdvanceHooks; |
169 | 172 |
170 protected List<LifetimeListener> lifetimeListeners; | 173 protected List<LifetimeListener> lifetimeListeners; |
174 | |
175 protected List<BackendListener> backendListeners; | |
171 | 176 |
172 /** | 177 /** |
173 * byte array holding the export signing secret. | 178 * byte array holding the export signing secret. |
174 */ | 179 */ |
175 protected byte [] exportSecret; | 180 protected byte [] exportSecret; |
487 logger.error(iae.getLocalizedMessage(), iae); | 492 logger.error(iae.getLocalizedMessage(), iae); |
488 } | 493 } |
489 } | 494 } |
490 | 495 |
491 lifetimeListeners = ltls; | 496 lifetimeListeners = ltls; |
497 } | |
498 | |
499 protected void loadBackendListeners() { | |
500 logger.info("loading backend listeners"); | |
501 | |
502 NodeList nodes = Config.getNodeSetXPath(BACKEND_LISTENERS); | |
503 | |
504 if (nodes == null) { | |
505 logger.debug("no backend listeners configure"); | |
506 return; | |
507 } | |
508 | |
509 List<BackendListener> bls = new ArrayList<BackendListener>(); | |
510 | |
511 for (int i = 0, N = nodes.getLength(); i < N; ++i) { | |
512 Node node = nodes.item(i); | |
513 String className = node.getTextContent(); | |
514 if (className == null | |
515 || (className = className.trim()).length() == 0) { | |
516 continue; | |
517 } | |
518 try { | |
519 Class clazz = Class.forName(className); | |
520 BackendListener listener = | |
521 (BackendListener)clazz.newInstance(); | |
522 | |
523 bls.add(listener); | |
524 } | |
525 catch (ClassNotFoundException cnfe) { | |
526 logger.error(cnfe.getLocalizedMessage(), cnfe); | |
527 } | |
528 catch (InstantiationException ie) { | |
529 logger.error(ie.getLocalizedMessage(), ie); | |
530 } | |
531 catch (ClassCastException cce) { | |
532 logger.error(cce.getLocalizedMessage(), cce); | |
533 } | |
534 catch (IllegalAccessException iae) { | |
535 logger.error(iae.getLocalizedMessage(), iae); | |
536 } | |
537 } | |
538 | |
539 backendListeners = bls; | |
492 } | 540 } |
493 | 541 |
494 protected void loadHooks() { | 542 protected void loadHooks() { |
495 logger.info("loading hooks"); | 543 logger.info("loading hooks"); |
496 | 544 |
582 loadUserFactory(); | 630 loadUserFactory(); |
583 loadCallContextListener(); | 631 loadCallContextListener(); |
584 loadHTTPServer(); | 632 loadHTTPServer(); |
585 loadHooks(); | 633 loadHooks(); |
586 loadLifetimeListeners(); | 634 loadLifetimeListeners(); |
635 loadBackendListeners(); | |
587 } | 636 } |
588 | 637 |
589 /** | 638 /** |
590 * Returns the artifact collection factory. | 639 * Returns the artifact collection factory. |
591 * | 640 * |
659 } | 708 } |
660 | 709 |
661 public List<LifetimeListener> getLifetimeListeners() { | 710 public List<LifetimeListener> getLifetimeListeners() { |
662 return lifetimeListeners; | 711 return lifetimeListeners; |
663 } | 712 } |
713 | |
714 public List<BackendListener> getBackendListeners() { | |
715 return backendListeners; | |
716 } | |
664 } | 717 } |
665 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 718 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |