Class DynamicSharedService
- java.lang.Object
-
- com.adaptris.core.SharedComponent
-
- com.adaptris.core.SharedServiceImpl
-
- com.adaptris.core.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 toresolve
the lookup name usingInterlokMessage.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.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.SharedServiceImpl
eventHandler, log
-
-
Constructor Summary
Constructors Constructor Description DynamicSharedService()
DynamicSharedService(java.lang.String lookupName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the component.void
doService(AdaptrisMessage msg)
Apply the service to the message.protected long
expirationMillis()
protected java.util.Map<java.lang.String,Service>
getCache()
TimeInterval
getExpiration()
Time (LRU) before expiration.java.lang.String
getLookupName()
Set the name of the service that will be looked up fromSharedComponentList.getServices()
,java.lang.Integer
getMaxEntries()
Max entries to store in the internal cache.void
init()
Initialises the component.boolean
isBranching()
Returns true if the implementation supports branching.protected int
maxEntries()
void
prepare()
Prepare for initialisation.void
setExpiration(TimeInterval expiration)
Time (LRU) before expiration.void
setLookupName(java.lang.String lookupName)
Set the name of the service that will be looked up fromSharedComponentList.getServices()
,void
setMaxEntries(java.lang.Integer maxEntries)
Max entries to store in the internal cache.<T extends DynamicSharedService>
TwithExpiration(TimeInterval i)
<T extends DynamicSharedService>
TwithMaxEntries(java.lang.Integer i)
-
Methods inherited from class com.adaptris.core.SharedServiceImpl
applyService, changeState, continueOnFailure, createName, createQualifier, deepClone, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, isTrackingEndpoint, registerEventHandler, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
-
Methods inherited from class com.adaptris.core.SharedComponent
triggerJndiLookup
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
start, stop
-
-
-
-
Method Detail
-
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 underlyingException
s
-
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
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s
-
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:
BranchingServiceCollection
-
getCache
protected java.util.Map<java.lang.String,Service> getCache()
-
maxEntries
protected int maxEntries()
-
withMaxEntries
public <T extends DynamicSharedService> T withMaxEntries(java.lang.Integer i)
-
withExpiration
public <T extends DynamicSharedService> T withExpiration(TimeInterval i)
-
expirationMillis
protected long expirationMillis()
-
getMaxEntries
public java.lang.Integer getMaxEntries()
Max entries to store in the internal cache.
-
setMaxEntries
public void setMaxEntries(java.lang.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 java.lang.String getLookupName()
Set the name of the service that will be looked up fromSharedComponentList.getServices()
,allows you to
resolve
the lookup name usingInterlokMessage.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(java.lang.String lookupName)
Set the name of the service that will be looked up fromSharedComponentList.getServices()
,allows you to
resolve
the lookup name usingInterlokMessage.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.
-
-