Class StandaloneProducer
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.StandaloneProducer
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageSender
,ComponentLifecycle
,ComponentLifecycleExtension
,ConnectedService
,MessageEventGenerator
,Service
,StateManagedComponent
- Direct Known Subclasses:
RetryOnceStandaloneProducer
,StandaloneRequestor
@ComponentProfile(summary="Produce a message where as part of a service chain", tag="service") public class StandaloneProducer extends ServiceImp implements AdaptrisMessageSender, ConnectedService
Wrapper for a
AdaptrisConnection
and aAdaptrisMessageProducer
for convenience. Also implementsService
for use inServiceCollection
s.- See Also:
AdaptrisMessageSender
In the adapter configuration file this class is aliased as standalone-producer which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description StandaloneProducer()
Creates a new instance.StandaloneProducer(AdaptrisConnection c, AdaptrisMessageProducer p)
StandaloneProducer(AdaptrisMessageProducer p)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeService()
java.lang.String
createName()
Create a name for anyMleMarker
that is generated.java.lang.String
createQualifier()
Create a qualifier for anyMleMarker
that is generated.void
doService(AdaptrisMessage msg)
Apply the service to the message.AdaptrisConnection
getConnection()
Returns the connection to use.AdaptrisMessageProducer
getProducer()
Returns the producer to use.protected void
initService()
void
prepare()
Prepare for initialisation.void
produce(AdaptrisMessage msg)
Produces theAdaptrisMessage
to the default destination.void
setConnection(AdaptrisConnection conn)
Sets the connection to use, may not be null.void
setProducer(AdaptrisMessageProducer prod)
Sets the producer to use, may not be null.void
start()
Starts the component.void
stop()
Stop the component-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
-
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.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
isTrackingEndpoint
-
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, isBranching, setUniqueId
-
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
-
-
-
Constructor Detail
-
StandaloneProducer
public StandaloneProducer()
Creates a new instance. Defaults to null connection / producer.
-
StandaloneProducer
public StandaloneProducer(AdaptrisMessageProducer p)
-
StandaloneProducer
public StandaloneProducer(AdaptrisConnection c, AdaptrisMessageProducer p)
-
-
Method Detail
-
produce
public void produce(AdaptrisMessage msg) throws ProduceException
Description copied from interface:AdaptrisMessageSender
Produces theAdaptrisMessage
to the default destination.- Specified by:
produce
in interfaceAdaptrisMessageSender
- Parameters:
msg
- the @link AdaptrisMessage} to produce- Throws:
ProduceException
- wrapping any underlying Exceptions
-
initService
protected void initService() throws CoreException
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
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
- Overrides:
start
in classServiceImp
- Throws:
CoreException
- wrapping any underlyingException
s- See Also:
ComponentLifecycle.start()
-
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
- Overrides:
stop
in classServiceImp
- See Also:
ComponentLifecycle.stop()
-
closeService
protected void closeService()
- Specified by:
closeService
in classServiceImp
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Throws:
CoreException
-
getConnection
public AdaptrisConnection getConnection()
Returns the connection to use.
- Specified by:
getConnection
in interfaceConnectedService
- Returns:
- the connection to use
-
getProducer
public AdaptrisMessageProducer getProducer()
Returns the producer to use.
- Returns:
- the producer to use
-
setConnection
public void setConnection(AdaptrisConnection conn)
Sets the connection to use, may not be null.
- Specified by:
setConnection
in interfaceConnectedService
- Parameters:
conn
- the connection to use, may not be null
-
setProducer
public void setProducer(AdaptrisMessageProducer prod)
Sets the producer to use, may not be null.
- Parameters:
prod
- the producer to use, may not be null
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Description copied from interface:Service
Apply the service to the message.
- Specified by:
doService
in interfaceService
- Parameters:
msg
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s- See Also:
#doService(com.adaptris.core.AdaptrisMessage)
-
createName
public java.lang.String createName()
Description copied from interface:MessageEventGenerator
Create a name for anyMleMarker
that is generated.The default implementation is to return the classname of the component in question.
* @return the name for anyMleMarker
that is generated.- Specified by:
createName
in interfaceMessageEventGenerator
- Overrides:
createName
in classServiceImp
-
createQualifier
public java.lang.String createQualifier()
Description copied from interface:MessageEventGenerator
Create a qualifier for anyMleMarker
that is generated.The default implementation is to return the unique-id of the component in question, or the empty string if not configured
- Specified by:
createQualifier
in interfaceMessageEventGenerator
- Overrides:
createQualifier
in classServiceImp
- Returns:
- the qualifier for any
MleMarker
that is generated.
-
-