Class DynamicSharedService

All Implemented Interfaces:
AdaptrisComponent, ComponentLifecycle, ComponentLifecycleExtension, EventHandlerAware, MessageEventGenerator, Service, StateManagedComponent

@ComponentProfile(summary="A Service that refers to another Service configured elsewhere", tag="service") public class DynamicSharedService extends SharedServiceImpl

A Service instance that references a Service made available via SharedComponentList.getServices().

This differs from a normal SharedService in that it allows you to resolve the lookup name using InterlokMessage.resolve(String). This reference will then be looked up and used for processing. A small cache (currently 16 items) is used to avoid excessive lifecycle overhead for looked up services.

In the adapter configuration file this class is aliased as dynamic-shared-service which is the preferred alternative to the fully qualified classname when building your configuration.

  • Constructor Details

    • DynamicSharedService

      public DynamicSharedService()
    • DynamicSharedService

      public DynamicSharedService(String lookupName)
  • Method Details

    • init

      public void init() throws CoreException
      Description copied from interface: ComponentLifecycle
      Initialises the component.

      Component initialisation includes config verification, creation of connections etc.

      Throws:
      CoreException - wrapping any underlying Exceptions
    • close

      public void close()
      Description copied from interface: ComponentLifecycle
      Closes the component.

      A closed component should release any connections it uses, etc. and clean up completely. Throwing a RuntimeException may cause unintended consequences

    • prepare

      public void prepare() throws CoreException
      Description copied from interface: ComponentLifecycleExtension
      Prepare for initialisation.
      Throws:
      CoreException
    • doService

      public void doService(AdaptrisMessage msg) throws ServiceException
      Description copied from interface: Service

      Apply the service to the message.

      Parameters:
      msg - the AdaptrisMessage to process
      Throws:
      ServiceException - wrapping any underlying Exceptions
    • isBranching

      public boolean isBranching()
      Description copied from interface: Service

      Returns true if the implementation supports branching.

      Returns:
      true if the implementation supports branching
      See Also:
    • getCache

      protected Map<String,Service> getCache()
    • maxEntries

      protected int maxEntries()
    • withMaxEntries

      public <T extends DynamicSharedService> T withMaxEntries(Integer i)
    • withExpiration

      public <T extends DynamicSharedService> T withExpiration(TimeInterval i)
    • expirationMillis

      protected long expirationMillis()
    • getMaxEntries

      public Integer getMaxEntries()
      Max entries to store in the internal cache.
    • setMaxEntries

      public void setMaxEntries(Integer maxEntries)
      Max entries to store in the internal cache.
    • getExpiration

      public TimeInterval getExpiration()
      Time (LRU) before expiration.
    • setExpiration

      public void setExpiration(TimeInterval expiration)
      Time (LRU) before expiration.
    • getLookupName

      public String getLookupName()
      Set the name of the service that will be looked up from SharedComponentList.getServices(),

      allows you to resolve the lookup name using InterlokMessage.resolve(String). This reference will then be looked up and used for processing. A cache is used to avoid excessive lifecycle overhead for looked up services.

    • setLookupName

      public void setLookupName(String lookupName)
      Set the name of the service that will be looked up from SharedComponentList.getServices(),

      allows you to resolve the lookup name using InterlokMessage.resolve(String). This reference will then be looked up and used for processing. A cache is used to avoid excessive lifecycle overhead for looked up services.