Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/org/dive4elements/artifactdatabase/ArtifactDatabaseImpl.java @ 562:05caf2e731d0
Allow to add additional restful services via configuration.
author | gernotbelger |
---|---|
date | Wed, 10 Oct 2018 20:07:58 +0200 |
parents | 68f01f10624e |
children |
comparison
equal
deleted
inserted
replaced
561:1c2ce0501305 | 562:05caf2e731d0 |
---|---|
405 /** | 405 /** |
406 * Map to access services by there name. | 406 * Map to access services by there name. |
407 */ | 407 */ |
408 protected HashMap name2service; | 408 protected HashMap name2service; |
409 | 409 |
410 private Map<String, Class<?>> restServices; | |
411 | |
410 /** | 412 /** |
411 * The factory that is used to create new artifact collections. | 413 * The factory that is used to create new artifact collections. |
412 */ | 414 */ |
413 protected ArtifactCollectionFactory collectionFactory; | 415 protected ArtifactCollectionFactory collectionFactory; |
414 | 416 |
461 * called. | 463 * called. |
462 */ | 464 */ |
463 protected List<Hook> postDescribeHooks; | 465 protected List<Hook> postDescribeHooks; |
464 | 466 |
465 protected List<LifetimeListener> lifetimeListeners; | 467 protected List<LifetimeListener> lifetimeListeners; |
468 | |
469 private String serverAddress; | |
466 | 470 |
467 /** | 471 /** |
468 * Default constructor. | 472 * Default constructor. |
469 */ | 473 */ |
470 public ArtifactDatabaseImpl() { | 474 public ArtifactDatabaseImpl() { |
491 | 495 |
492 logger.debug("new ArtifactDatabaseImpl"); | 496 logger.debug("new ArtifactDatabaseImpl"); |
493 | 497 |
494 backgroundIds = new HashSet<Integer>(); | 498 backgroundIds = new HashSet<Integer>(); |
495 backgroundMsgs = new HashMap<String, LinkedList<Message>>(); | 499 backgroundMsgs = new HashMap<String, LinkedList<Message>>(); |
500 | |
501 this.serverAddress = bootstrap.getHTTPServer().getServerAddress(); | |
496 | 502 |
497 setupArtifactCollectionFactory(bootstrap); | 503 setupArtifactCollectionFactory(bootstrap); |
498 setupArtifactFactories(bootstrap); | 504 setupArtifactFactories(bootstrap); |
499 setupServices(bootstrap); | 505 setupServices(bootstrap); |
506 setupRestServices(bootstrap); | |
500 setupUserFactory(bootstrap); | 507 setupUserFactory(bootstrap); |
501 setupCallContextListener(bootstrap); | 508 setupCallContextListener(bootstrap); |
502 setupHooks(bootstrap); | 509 setupHooks(bootstrap); |
503 setupLifetimeListeners(bootstrap); | 510 setupLifetimeListeners(bootstrap); |
504 | 511 |
633 name2service.put( | 640 name2service.put( |
634 name, | 641 name, |
635 factory.createService(bootstrap.getContext())); | 642 factory.createService(bootstrap.getContext())); |
636 } | 643 } |
637 | 644 |
645 } | |
646 | |
647 /** | |
648 * Used to extract the service factories from the bootstrap | |
649 * parameters, setting up the services and building the internal | |
650 * lookup tables. | |
651 * @param bootstrap The bootstrap parameters. | |
652 */ | |
653 private void setupRestServices(FactoryBootstrap bootstrap) { | |
654 | |
655 restServices = new HashMap<String,Class<?>>(bootstrap.getRestServiceNames()); | |
638 } | 656 } |
639 | 657 |
640 /** | 658 /** |
641 * Wires a storage backend to this artifact database and | 659 * Wires a storage backend to this artifact database and |
642 * establishes a callback to be able to revive artifacts | 660 * establishes a callback to be able to revive artifacts |
1982 | 2000 |
1983 @Override | 2001 @Override |
1984 public String findArtifactUser(final String artifactIdentifier) { | 2002 public String findArtifactUser(final String artifactIdentifier) { |
1985 return backend.findUserName(artifactIdentifier); | 2003 return backend.findUserName(artifactIdentifier); |
1986 } | 2004 } |
2005 | |
2006 @Override | |
2007 public String getServerAddress() { | |
2008 return this.serverAddress; | |
2009 } | |
2010 | |
2011 @Override | |
2012 public Map<String, Class<?>> getRestServices() { | |
2013 return restServices; | |
2014 } | |
1987 } | 2015 } |
1988 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 2016 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |