org.mule.source
Class StartableCompositeMessageSource

java.lang.Object
  extended by org.mule.source.StartableCompositeMessageSource
All Implemented Interfaces:
FlowConstructAware, MuleContextAware, Disposable, Initialisable, Lifecycle, Startable, Stoppable, CompositeMessageSource, MessageSource
Direct Known Subclasses:
ServiceCompositeMessageSource

public class StartableCompositeMessageSource
extends Object
implements CompositeMessageSource, Lifecycle, FlowConstructAware, MuleContextAware

Implementation of CompositeMessageSource that propagates both injection of FlowConstruct and lifecycle to nested MessageSources.

  • This message source cannot be started without a listener set.
  • If sources are added when this composie is started they will be started as well.
  • If a MessageSource is started in isolation when composite is stopped then messages will be lost.
  • Message will only be received from endpoints if the connector is also started.


    Field Summary
    protected  FlowConstruct flowConstruct
               
    protected  AtomicBoolean initialised
               
    protected  MessageProcessor listener
               
    protected static Log log
               
    protected  MuleContext muleContext
               
    protected  List<MessageSource> sources
               
    protected  AtomicBoolean started
               
    protected  AtomicBoolean starting
               
     
    Fields inherited from interface org.mule.api.lifecycle.Initialisable
    PHASE_NAME
     
    Fields inherited from interface org.mule.api.lifecycle.Startable
    PHASE_NAME
     
    Fields inherited from interface org.mule.api.lifecycle.Stoppable
    PHASE_NAME
     
    Fields inherited from interface org.mule.api.lifecycle.Disposable
    PHASE_NAME
     
    Constructor Summary
    StartableCompositeMessageSource()
               
     
    Method Summary
     void addSource(MessageSource source)
               
     void dispose()
              A lifecycle method where implementor should free up any resources.
     List<MessageSource> getSources()
               
     void initialise()
              Method used to perform any initialisation work.
     void removeSource(MessageSource source)
               
     void setFlowConstruct(FlowConstruct pattern)
               
     void setListener(MessageProcessor listener)
              Set the MessageProcessor listener on a message source which will be invoked when a message is received or generated.
     void setMessageSources(List<MessageSource> sources)
               
     void setMuleContext(MuleContext context)
               
     void start()
               
     void stop()
               
     String toString()
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Field Detail

    log

    protected static final Log log

    listener

    protected MessageProcessor listener

    initialised

    protected AtomicBoolean initialised

    started

    protected AtomicBoolean started

    sources

    protected final List<MessageSource> sources

    starting

    protected AtomicBoolean starting

    flowConstruct

    protected FlowConstruct flowConstruct

    muleContext

    protected MuleContext muleContext
    Constructor Detail

    StartableCompositeMessageSource

    public StartableCompositeMessageSource()
    Method Detail

    addSource

    public void addSource(MessageSource source)
                   throws MuleException
    Specified by:
    addSource in interface CompositeMessageSource
    Throws:
    MuleException

    removeSource

    public void removeSource(MessageSource source)
                      throws MuleException
    Specified by:
    removeSource in interface CompositeMessageSource
    Throws:
    MuleException

    setMessageSources

    public void setMessageSources(List<MessageSource> sources)
                           throws MuleException
    Throws:
    MuleException

    initialise

    public void initialise()
                    throws InitialisationException
    Description copied from interface: Initialisable
    Method used to perform any initialisation work. If a fatal error occurs during initialisation an InitialisationException should be thrown, causing the Mule instance to shutdown. If the error is recoverable, say by retrying to connect, a RecoverableException should be thrown. There is no guarantee that by throwing a Recoverable exception that the Mule instance will not shut down.

    Specified by:
    initialise in interface Initialisable
    Throws:
    InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
    RecoverableException - if an error occurs that can be recovered from

    start

    public void start()
               throws MuleException
    Specified by:
    start in interface Startable
    Throws:
    MuleException

    stop

    public void stop()
              throws MuleException
    Specified by:
    stop in interface Stoppable
    Throws:
    MuleException

    dispose

    public void dispose()
    Description copied from interface: Disposable
    A lifecycle method where implementor should free up any resources. If an exception is thrown it should just be logged and processing should continue. This method should not throw Runtime exceptions.

    Specified by:
    dispose in interface Disposable

    setListener

    public void setListener(MessageProcessor listener)
    Description copied from interface: MessageSource
    Set the MessageProcessor listener on a message source which will be invoked when a message is received or generated.

    Specified by:
    setListener in interface MessageSource

    setFlowConstruct

    public void setFlowConstruct(FlowConstruct pattern)
    Specified by:
    setFlowConstruct in interface FlowConstructAware

    getSources

    public List<MessageSource> getSources()
    Specified by:
    getSources in interface CompositeMessageSource

    toString

    public String toString()
    Overrides:
    toString in class Object

    setMuleContext

    public void setMuleContext(MuleContext context)
    Specified by:
    setMuleContext in interface MuleContextAware


    Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.