MuleEventMulticaster (Mule ESB 2.2.1 API)
Keywords: org.mule.module.spring.events.MuleEventMulticaster class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mule.module.spring.events
Class MuleEventMulticaster

    java.lang.Object
      org.mule.module.spring.events.MuleEventMulticaster

All Implemented Interfaces:
  MuleContextAware, Callable, EventListener, Initialisable, org.springframework.context.ApplicationContextAware, org.springframework.context.event.ApplicationEventMulticaster

    public class MuleEventMulticaster

extends Object
implements org.springframework.context.event.ApplicationEventMulticaster, org.springframework.context.ApplicationContextAware, MuleContextAware, Callable, Initialisable

`MuleEventMulticaster` is an implementation of a Spring ApplicationeventMulticaster. This implementation allows Mule event to be sent and received through the Spring ApplicationContext. This allows any Spring bean to receive and send events from any transport that Mule supports such as Jms, Http, Tcp, Pop3, Smtp, File, etc. All a bean needs to do to receive and send events is to implement MuleEventListener. Beans can also have subscriptions to certain events by implementing MuleSubscriptionEventListener, where the bean can provide a list of endpoints on which to receive events i.e. `<bean id="myListener" class="com.foo.MyListener"> <property name="subscriptions"> <list> <value>jms://customer.support</value> <value>pop3://support:123456@mail.mycompany.com</value> </list> </property> </bean>`

Endpoints are specified as a Mule Url which is used to register a listener for the subscription In the previous version of the MuleEventMulticaster it was possible to specify wildcard endpoints. This is still possible but you need to tell the multicaster which specific endpoints to listen on and then your subscription listeners can use wildcards. To register the specific endpoints on the MuleEvent Multicaster you use the subscriptions property.

`<bean id="applicationEventMulticaster" class="org.mule.module.spring.events.MuleEventMulticaster"> <property name="subscriptions"> <list> <value>jms://orders.queue</value> <value>jms://another.orders.queue</value> </list> </property> </bean>

<bean id="myListener" class="com.foo.MyListener"> <property name="subscriptions"> <list> <value>jms://*.orders.*.</value> </list> </property> </bean>

`

See Also:
  `MuleEventListener`, `MuleSubscriptionEventListener`, `ApplicationEventMulticaster`

Field Summary
`protected org.springframework.context.ApplicationContext` | `applicationContext` The Spring acpplication context
`protected boolean` | `asynchronous` Determines whether events will be processed asynchronously
`protected edu.emory.mathcs.backport.java.util.concurrent.ExecutorService` | `asyncPool` An ExecutorService for handling asynchronous events
`static String` | `EVENT_MULTICASTER_DESCRIPTOR_NAME`
`protected ExceptionListener` | `exceptionListener` Used to store parsed endpoints
`protected Set` | `listeners` The set of listeners for this Multicaster
`protected static Log` | `logger` logger used by this class
`protected MuleContext` | `muleContext`
`protected Service` | `service` The mule instance compoennt for the Multicaster
`protected Class` | `subscriptionFilter` The filter used to match subscriptions
`protected String[]` | `subscriptions` A list of endpoints the eventMulticaster will receive events on Note that if this eventMulticaster has a Mule Descriptor associated with it, these endpoints are ignored and the ones on the Mule Descriptor are used.

Fields inherited from interface org.mule.api.lifecycle.Initialisable
`PHASE_NAME`

Constructor Summary
`MuleEventMulticaster()`

Method Summary
`void` | `addApplicationListener(org.springframework.context.ApplicationListener listener)` Adds a listener to the the Multicaster.
`protected ObjectFilter` | `createFilter(String pattern)`
`protected void` | `dispatchEvent(MuleApplicationEvent applicationEvent)` Will dispatch an application event through Mule
`protected Service` | `getDefaultService()`
`Class` | `getSubscriptionFilter()` the type of filter used to filter subscriptions
`String[]` | `getSubscriptions()` A list of endpoints the eventMulticaster will receive events on Note that if this eventMulticaster has a Mule Descriptor associated with it, these endpoints are ignored and the ones on the Mule Descriptor are used.
`void` | `initialise()` Method used to perform any initialisation work.
`boolean` | `isAsynchronous()` Determines whether events will be processed asynchronously
`void` | `multicastEvent(org.springframework.context.ApplicationEvent e)` Method is used to dispatch events to listeners registered with the EventManager or dispatches events to Mule depending on the type and state of the event received.
`Object` | `onCall(MuleEventContext context)` This is the callback method used by Mule to give Mule events to this Multicaster
`protected void` | `registerConnectors()`
`protected void` | `registerMulticasterComponent()`
`protected void` | `registerTransformers()`
`void` | `removeAllListeners()` Removes all the listeners from the multicaster
`void` | `removeApplicationListener(org.springframework.context.ApplicationListener listener)` Removes a listener from the multicaster
`void` | `setApplicationContext(org.springframework.context.ApplicationContext applicationContext)` Set the current Spring application context
`void` | `setAsynchronous(boolean asynchronous)` Determines whether events will be processed asynchronously
`protected void` | `setExceptionListener(ExceptionListener listener)`
`void` | `setMuleContext(MuleContext context)`
`void` | `setSubscriptionFilter(Class subscriptionFilter)` sets the type of filter used to filter subscriptions
`void` | `setSubscriptions(String[] subscriptions)` A list of endpoints the eventMulticaster will receive events on Note that if this eventMulticaster has a Mule Descriptor associated with it, these endpoints are ignored and the ones on the Mule Descriptor are used.
`protected void` | `setSubscriptionsOnService(Service service)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### EVENT_MULTICASTER_DESCRIPTOR_NAME

    public static final String EVENT_MULTICASTER_DESCRIPTOR_NAME

See Also:
  Constant Field Values

### logger

    protected static final Log logger

  logger used by this class

### listeners

    protected final Set listeners

  The set of listeners for this Multicaster

### asynchronous

    protected boolean asynchronous

  Determines whether events will be processed asynchronously

### asyncPool

    protected edu.emory.mathcs.backport.java.util.concurrent.ExecutorService asyncPool

  An ExecutorService for handling asynchronous events

### subscriptions

    protected String[] subscriptions

  A list of endpoints the eventMulticaster will receive events on Note that if this eventMulticaster has a Mule Descriptor associated with it, these endpoints are ignored and the ones on the Mule Descriptor are used. These are here for convenience, the event multicaster will use these to create a default MuleDescriptor for itself at runtime

### applicationContext

    protected org.springframework.context.ApplicationContext applicationContext

  The Spring acpplication context

### service

    protected Service service

  The mule instance compoennt for the Multicaster

### subscriptionFilter

    protected Class subscriptionFilter

  The filter used to match subscriptions

### exceptionListener

    protected ExceptionListener exceptionListener

  Used to store parsed endpoints

### muleContext

    protected MuleContext muleContext

Constructor Detail

### MuleEventMulticaster

    public MuleEventMulticaster()

Method Detail

### setMuleContext

    public void setMuleContext(MuleContext context)

  Specified by:
    `setMuleContext` in interface `MuleContextAware`

### 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

### addApplicationListener

    public void addApplicationListener(org.springframework.context.ApplicationListener listener)

  Adds a listener to the the Multicaster. If asynchronous is set to true, an `AsynchronousMessageListener` is used to wrap the listener. This listener will be initialised with a threadpool. The configuration for the threadpool can be set on this multicaster or inherited from the MuleManager configuration, which is good for most cases.

  Specified by:
    `addApplicationListener` in interface `org.springframework.context.event.ApplicationEventMulticaster`
  Parameters:
    `listener` - the ApplicationListener to register with this Multicaster
  See Also:
    `AsynchronousEventListener`, `ThreadingProfile`

### removeApplicationListener

    public void removeApplicationListener(org.springframework.context.ApplicationListener listener)

  Removes a listener from the multicaster

  Specified by:
    `removeApplicationListener` in interface `org.springframework.context.event.ApplicationEventMulticaster`
  Parameters:
    `listener` - the listener to remove

### removeAllListeners

    public void removeAllListeners()

  Removes all the listeners from the multicaster

  Specified by:
    `removeAllListeners` in interface `org.springframework.context.event.ApplicationEventMulticaster`

### multicastEvent

    public void multicastEvent(org.springframework.context.ApplicationEvent e)

  Method is used to dispatch events to listeners registered with the EventManager or dispatches events to Mule depending on the type and state of the event received. If the event is not a Mule event it will be dispatched to any listeners registered that are NOT MuleEventListeners. If the event is a Mule event and there is no source event attached to it, it is assumed that the event was dispatched by an object in the context using context.publishEvent() and will be dispatched by Mule. If the event does have a source event attached to it, it is assumed that the event was dispatched by Mule and will be delivered to any listeners subscribed to the event.

  Specified by:
    `multicastEvent` in interface `org.springframework.context.event.ApplicationEventMulticaster`
  Parameters:
    `e` - the application event received by the context

### isAsynchronous

    public boolean isAsynchronous()

  Determines whether events will be processed asynchronously

  Returns:
    tru if asynchronous. The default is false

### setAsynchronous

    public void setAsynchronous(boolean asynchronous)

  Determines whether events will be processed asynchronously

  Parameters:
    `asynchronous` - true if aysnchronous

### onCall

    public Object onCall(MuleEventContext context)
                  throws TransformerException,
                         MalformedEndpointException

  This is the callback method used by Mule to give Mule events to this Multicaster

  Specified by:
    `onCall` in interface `Callable`
  Parameters:
    `context` - the context received by Mule
  Returns:
    Object this object can be anything. When the `LifecycleAdapter` for the service receives this object it will first see if the Object is an `MuleMessage` if not and the Object is not null a new message will be created using the returned object as the payload. This new event will then get published via the configured outbound router if-
    1. One has been configured for the component.
    2. the `setStopFurtherProcessing(true)` wasn't called on the event context event.
  Throws:
    `TransformerException`
    `MalformedEndpointException`

### dispatchEvent

    protected void dispatchEvent(MuleApplicationEvent applicationEvent)
                          throws ApplicationEventException

  Will dispatch an application event through Mule

  Parameters:
    `applicationEvent` - the Spring event to be dispatched
  Throws:
    `ApplicationEventException` - if the event cannot be dispatched i.e. if the underlying transport throws an exception

### setApplicationContext

    public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                               throws org.springframework.beans.BeansException

  Set the current Spring application context

  Specified by:
    `setApplicationContext` in interface `org.springframework.context.ApplicationContextAware`
  Parameters:
    `applicationContext` - application context
  Throws:
    `org.springframework.beans.BeansException`

### registerMulticasterComponent

    protected void registerMulticasterComponent()
                                         throws MuleException

  Throws:
    `MuleException`

### setSubscriptionsOnService

    protected void setSubscriptionsOnService(Service service)
                                      throws MuleException

  Throws:
    `MuleException`

### registerConnectors

    protected void registerConnectors()
                               throws MuleException

  Throws:
    `MuleException`

### registerTransformers

    protected void registerTransformers()
                                 throws MuleException

  Throws:
    `MuleException`

### getDefaultService

    protected Service getDefaultService()
                                 throws MuleException

  Throws:
    `MuleException`

### createFilter

    protected ObjectFilter createFilter(String pattern)

### getSubscriptionFilter

    public Class getSubscriptionFilter()

  the type of filter used to filter subscriptions

  Returns:
    the class of the filter to use. The default is WildcardFilter
  See Also:
    `WildcardFilter`

### setSubscriptionFilter

    public void setSubscriptionFilter(Class subscriptionFilter)

  sets the type of filter used to filter subscriptions

  Parameters:
    `subscriptionFilter` - the class of the filter to use.

### getSubscriptions

    public String[] getSubscriptions()

  A list of endpoints the eventMulticaster will receive events on Note that if this eventMulticaster has a Mule Descriptor associated with it, these endpoints are ignored and the ones on the Mule Descriptor are used. These are here for convenience, the event multicaster will use these to create a default MuleDescriptor for itself at runtime

  Returns:
    endpoints List being listened on

### setSubscriptions

    public void setSubscriptions(String[] subscriptions)

  A list of endpoints the eventMulticaster will receive events on Note that if this eventMulticaster has a Mule Descriptor associated with it, these endpoints are ignored and the ones on the Mule Descriptor are used. These are here for convenience, the event multicaster will use these to create a default MuleDescriptor for itself at runtime

  Parameters:
    `subscriptions` - a list of enpoints to listen on

### setExceptionListener

    protected void setExceptionListener(ExceptionListener listener)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.