Class SharedComponentList
- java.lang.Object
-
- com.adaptris.core.SharedComponentList
-
- All Implemented Interfaces:
ComponentLifecycle
,ComponentLifecycleExtension
@ComponentProfile(summary="A Collection of Shared Components", tag="base") public class SharedComponentList extends java.lang.Object implements ComponentLifecycle, ComponentLifecycleExtension
A common store for components.In the adapter configuration file this class is aliased as shared-components which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Constructor Summary
Constructors Constructor Description SharedComponentList()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addConnection(AdaptrisConnection c)
Convenience method to add a service collection performing verification.java.util.Collection<AdaptrisConnection>
addConnections(java.util.Collection<AdaptrisConnection> coll)
Convenience method to add connections performing verification.boolean
addService(Service c)
Convenience method to add a connection performing verification.java.util.Collection<Service>
addServices(java.util.Collection<Service> coll)
Convenience method to add service collections performing verification.void
bindJNDI(java.lang.String componentId)
Bind a previously added Connection to JNDI.void
close()
Closes the component.boolean
containsConnection(java.lang.String id)
Does the underlying connection list contain this id.boolean
containsService(java.lang.String id)
Does the underlying service collection list contain this id.java.util.Collection<java.lang.String>
getConnectionIds()
Return a list of connection-ids that are registered.java.util.List<AdaptrisConnection>
getConnections()
Returns a clone of the connections list.java.lang.Boolean
getDebug()
SharedComponentLifecycleStrategy
getLifecycleStrategy()
java.util.Collection<java.lang.String>
getServiceIds()
Return a list of service-ids that are registered.java.util.List<Service>
getServices()
Returns a clone of the shared-servicesTransactionManager
getTransactionManager()
void
init()
Initialises the component.void
prepare()
Prepare for initialisation.java.util.Collection<AdaptrisConnection>
removeConnection(java.lang.String id)
Remove a connection by it's ID.java.util.Collection<Service>
removeService(java.lang.String id)
Remove a service collection by it's ID.void
setConnections(java.util.List<AdaptrisConnection> l)
Set the connections.void
setDebug(java.lang.Boolean debug)
void
setLifecycleStrategy(SharedComponentLifecycleStrategy ls)
void
setServices(java.util.List<Service> serviceLists)
void
setTransactionManager(TransactionManager tm)
void
start()
Starts the component.void
stop()
Stop the component
-
-
-
Method Detail
-
getConnections
public java.util.List<AdaptrisConnection> getConnections()
Returns a clone of the connections list.This method is purely to allow the underlying XML marshaller to do it's thing, you are strongly encouraged to use the corresponding methods
addConnection(AdaptrisConnection)
,addConnections(Collection)
,removeConnection(String)
instead to manipulate the contents of the list.- Returns:
- the list of connections.
-
setConnections
public void setConnections(java.util.List<AdaptrisConnection> l)
Set the connections.Note that this simply calls
Collection.clear()
andaddConnections(Collection)
rather than setting the underlying object directly.- Parameters:
l
- the list to set.- Throws:
java.lang.IllegalArgumentException
- if one or more connections had no unique-id, or if one or more connections would be rejected because of duplication.
-
getServices
public java.util.List<Service> getServices()
Returns a clone of the shared-servicesThis method is purely to allow the underlying XML marshaller to do it's thing, you are strongly encouraged to use the corresponding methods
addService(Service)
,addServices(Collection)
,removeService(String)
instead to manipulate the contents of the list.- Returns:
- the list of connections.
-
setServices
public void setServices(java.util.List<Service> serviceLists)
-
init
public void init() throws CoreException
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
init
in interfaceComponentLifecycle
- Throws:
CoreException
- wrapping any underlyingException
s
-
start
public void start() throws CoreException
Description copied from interface:ComponentLifecycle
Starts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.- Specified by:
start
in interfaceComponentLifecycle
- Throws:
CoreException
- wrapping any underlyingException
s
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing aRuntimeException
may cause unintended consequences- Specified by:
stop
in interfaceComponentLifecycle
-
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- Specified by:
close
in interfaceComponentLifecycle
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
bindJNDI
public void bindJNDI(java.lang.String componentId) throws CoreException
Bind a previously added Connection to JNDI.When runtime additions of a connection occurs (generally via
AdapterManagerMBean.addSharedConnection(String)
), they are not automatically bound to the internal JNDI. Use this method after adding a connection to bind the connection to JNDI.- Parameters:
componentId
- the connection ID of connection to bind.- Throws:
CoreException
- wrapping other exceptions.
-
getConnectionIds
public java.util.Collection<java.lang.String> getConnectionIds()
Return a list of connection-ids that are registered.- Returns:
- a set of connection-ids
-
getServiceIds
public java.util.Collection<java.lang.String> getServiceIds()
Return a list of service-ids that are registered.- Returns:
- a set of service-ids
-
addService
public boolean addService(Service c)
Convenience method to add a connection performing verification.- Parameters:
c
- the connection to add- Returns:
- true if the object was successfully added, false if there was already a connection with that unique-id
- Throws:
java.lang.IllegalArgumentException
- if the connection has no unique-id.
-
addServices
public java.util.Collection<Service> addServices(java.util.Collection<Service> coll)
Convenience method to add service collections performing verification.- Parameters:
coll
- the service collections to add- Returns:
- a collection of things that were rejected.
- Throws:
java.lang.IllegalArgumentException
- if one or more service collections has no unique-id.
-
addConnection
public boolean addConnection(AdaptrisConnection c)
Convenience method to add a service collection performing verification.- Parameters:
c
- the service collection to add- Returns:
- true if the object was successfully added, false if there was already a service collection with that unique-id
- Throws:
java.lang.IllegalArgumentException
- if the service collection has no unique-id.
-
addConnections
public java.util.Collection<AdaptrisConnection> addConnections(java.util.Collection<AdaptrisConnection> coll)
Convenience method to add connections performing verification.- Parameters:
coll
- the connections to add- Returns:
- a collection of things that were rejected.
- Throws:
java.lang.IllegalArgumentException
- if one or more connections has no unique-id.
-
removeConnection
public java.util.Collection<AdaptrisConnection> removeConnection(java.lang.String id)
Remove a connection by it's ID.- Parameters:
id
- the unique-id of the connection to remove.- Returns:
- a collection of the removed items
-
removeService
public java.util.Collection<Service> removeService(java.lang.String id)
Remove a service collection by it's ID.- Parameters:
id
- the unique-id of the service collection to remove.- Returns:
- a collection of the removed items
-
containsConnection
public boolean containsConnection(java.lang.String id)
Does the underlying connection list contain this id.- Parameters:
id
- the ID to check for.- Returns:
- true if the ID exists.
-
containsService
public boolean containsService(java.lang.String id)
Does the underlying service collection list contain this id.- Parameters:
id
- the ID to check for.- Returns:
- true if the ID exists.
-
getDebug
public java.lang.Boolean getDebug()
-
setDebug
public void setDebug(java.lang.Boolean debug)
-
getLifecycleStrategy
public SharedComponentLifecycleStrategy getLifecycleStrategy()
-
setLifecycleStrategy
public void setLifecycleStrategy(SharedComponentLifecycleStrategy ls)
-
getTransactionManager
public TransactionManager getTransactionManager()
-
setTransactionManager
public void setTransactionManager(TransactionManager tm)
-
-