public abstract class SimpleAbstractJmsMessageMapper extends java.lang.Object implements JmsSenderMapper, JmsSenderMapperFactory, JmsReceiverMapper, JmsReceiverMapperFactory
This class is the recommended way to implement a simple stateless bi-directional mapper,
with trivial implementations of methods that most implementors will not need to be concerned with.
Most implementations will only need to override the mapApamaToJmsMessage(JmsSenderMapperContext, MappableApamaEvent)
and mapJmsToApamaMessage(JmsReceiverMapperContext, javax.jms.Message)
methods, usually with
EventType
fields for each of the Apama event types the mapper can handle.
This class also provides optional senderMapperDelegate/receiverMapperDelegate bean properties that identify another mapper to use for any messages that this mapper does not handle. The associated methods are used for the XML configuration but should not be called by subclasses.
For more advanced cases, do not use this class but instead implement the factory interfaces directly, with separate classes for the sender and receiver mappers. This is particularly important when the mapping operations are stateful, for example if they rely on a cache which should not be shared across all the mapper instances created by the factory to avoid thread-safety concerns or costly and unnecessary synchronization.
Constructor and Description |
---|
SimpleAbstractJmsMessageMapper() |
Modifier and Type | Method and Description |
---|---|
JmsReceiverMapper |
createJmsReceiverMapper()
Provides a trivial implementation of this factory method.
|
JmsSenderMapper |
createJmsSenderMapper()
Provides a trivial implementation of this factory method.
|
void |
destroy()
Provides a trivial no-op implementation of this method.
|
JmsReceiverMapperFactory |
getReceiverMapperDelegate()
|
JmsSenderMapperFactory |
getSenderMapperDelegate()
|
void |
init()
Initialization method to be called after all configuration properties have been assigned, to initialize this factory and validate the
configuration.
|
abstract JmsSenderMessageHolder |
mapApamaToJmsMessage(JmsSenderMapperContext context,
MappableApamaEvent event)
Converts an Apama event string and (possibly null) unique
ids for duplicate elimination to a JmsSenderMessageHolder object containing the message
and message sending parameters.
|
abstract MappableApamaEvent |
mapJmsToApamaMessage(JmsReceiverMapperContext context,
javax.jms.Message message)
Converts a JMS message object to an Apama event string (and unique message id for dup elimination, if available).
|
void |
setReceiverMapperDelegate(JmsReceiverMapperFactory factory)
The optional receiverMapperDelegate bean property specifies the factory of a receiver mapper which
should be used for any messages not handled directly by this mapper.
|
void |
setSenderMapperDelegate(JmsSenderMapperFactory factory)
The optional senderMapperDelegate bean property specifies the factory of a sender mapper which
should be used for any events not handled directly by this mapper.
|
public void init() throws java.lang.Exception
JmsSenderMapperFactory
If the configuration is invalid in any way then an exception should be thrown from this method. This method must be idempotent, as it may be called more than once during initialization (although always on the configuration loading thread, so there is no need for synchronization here).
init
in interface JmsReceiverMapperFactory
init
in interface JmsSenderMapperFactory
java.lang.Exception
public final void destroy()
destroy
in interface JmsReceiverMapper
destroy
in interface JmsSenderMapper
public abstract JmsSenderMessageHolder mapApamaToJmsMessage(JmsSenderMapperContext context, MappableApamaEvent event) throws java.lang.Exception
JmsSenderMapper
Threading: a separate instance of the mapper interface will be created for each thread, so implementations of this method are not required to be thread-safe, and should in fact be careful to avoid synchronizing on data structures shared with other mapper instance to ensure mapping can be performed in parallel. Implementors may use read-only (unsynchronized) shared configuration state, including Apama EventType objects, but caches and other read-write data structures should be stored in instances of this object to ensure optimum performance and scalability.
mapApamaToJmsMessage
in interface JmsSenderMapper
context
- Should never be nullevent
- Should never be nulljava.lang.Exception
public abstract MappableApamaEvent mapJmsToApamaMessage(JmsReceiverMapperContext context, javax.jms.Message message) throws java.lang.Exception, javax.jms.JMSException
JmsReceiverMapper
Threading: a separate instance of the mapper interface will be created for each thread, so implementations of this method are not required to be thread-safe, and should in fact be careful to avoid synchronizing on data structures shared with other mapper instance to ensure mapping can be performed in parallel. Implementors may use read-only (unsynchronized) shared configuration state, including Apama EventType objects, but caches and other read-write data structures should be stored in instances of this object to ensure optimum performance and scalability.
mapJmsToApamaMessage
in interface JmsReceiverMapper
context
- Never null.message
- Never null.java.lang.Exception
- If the mapping could not be performed for some reason.javax.jms.JMSException
public final JmsSenderMapper createJmsSenderMapper()
createJmsSenderMapper
in interface JmsSenderMapperFactory
public final JmsReceiverMapper createJmsReceiverMapper()
createJmsReceiverMapper
in interface JmsReceiverMapperFactory
public final void setSenderMapperDelegate(JmsSenderMapperFactory factory)
The delegate mapper factory will typically be specified by setting the ref="springidofmapper" attribute in the XML Spring configuration.
factory
- May be null (the default) if no delegation is required.public final JmsSenderMapperFactory getSenderMapperDelegate()
public final void setReceiverMapperDelegate(JmsReceiverMapperFactory factory)
The delegate mapper factory will typically be specified by setting the ref="springidofmapper" attribute in the XML Spring configuration.
factory
- May be null (the default) if no delegation is required.public final JmsReceiverMapperFactory getReceiverMapperDelegate()
Submit a bug or feature
Copyright (c) 2013-2017 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.