Interface JmsReceiverMapperFactory

  • All Known Implementing Classes:
    SimpleAbstractJmsMessageMapper

    public interface JmsReceiverMapperFactory
    Holds mapper configuration information and uses it to create instances implementing the single-threaded JmsReceiverMapper interface.

    The configuration of this class should be fully validated as part of init() to ensure errors are flagged to the user as early as possible.

    For simple cases, consider using the SimpleAbstractJmsMessageMapper base class to implement this interface.

    Note: Mappers that are entirely stateless may use the same class to implement both this factory and the JmsReceiverMapper interface, returning the same JmsReceiverMapper instance in all cases. However mappers that have read-write data structures or need to cache data (e.g. XML factories, etc) should store it in the single-threaded JmsReceiverMapper instances to avoid contention and maximize concurrency.

    Threading: see documentation on each method below.

    • Method Detail

      • init

        void init()
           throws java.lang.Exception
        Initialization method to be called once all configuration properties have been assigned, to initialize this factory and validate the configuration.

        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).

        Throws:
        java.lang.Exception
      • createJmsReceiverMapper

        JmsReceiverMapper createJmsReceiverMapper()
        Factory method for creating a mapper that will be used by a single thread.

        Any configuration information needed by the mapper that is not safe for concurrent unsynchronized access should be copied into the new mapper instance. Mappers that do not have any state are allowed to return the same instance every time this method is called.

        The configuration will have been validated by the factory's init() method before this method is called so it is expected that this method should never throw an exception.

        Threading: this method must be thread safe. Implementations may need to take a copy of any configuration data structures (e.g. caches) that could potentially be mutated by other mapper threads. Any data that is not safe for concurrent unsynchronized access should be stored in the JmsReceiverMapper instances created by the factory.

        Returns:
        A mapper instance that is guaranteed to be used only by a single thread.