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.context.notification
Class ServerNotificationManager

    java.lang.Object
      org.mule.context.notification.ServerNotificationManager

All Implemented Interfaces:
  Runnable, javax.resource.spi.work.Work, MuleContextAware, ServerNotificationHandler, Disposable

    public class ServerNotificationManager

extends Object
implements javax.resource.spi.work.Work, Disposable, ServerNotificationHandler, MuleContextAware

A reworking of the event manager that allows efficient behaviour without global on/off switches in the config.

The configuration and resulting policy are separate; the policy is a summary of the configuration that contains information to decide whether a particular message can be handled, and which updates that with experience gained handling messages. When the configuration is changed the policy is rebuilt. In this way we get a fairly efficient system without needing controls elsewhere.

However, measurements showed that there was still a small impact on speed in some cases. To improve behaviour further the `OptimisedNotificationHandler` was added. This allows a service that generates notifications to cache locally a handler optimised for a particular class.

The dynamic flag stops this caching from occurring. This reduces efficiency slightly (about 15% cost on simple VM messages, less on other transports)

Note that, because of subclass relationships, we need to be very careful about exactly what is enabled and disabled:

- Disabling an event or interface disables all uses of that class or any subclass.
- Enquiring whether an event is enabled returns true if any subclass is enabled.

Field Summary
`protected Log` | `logger`
`static String` | `NULL_SUBSCRIPTION`

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

Constructor Summary
`ServerNotificationManager()`

Method Summary
`void` | `addAllListenerSubscriptionPairs(Collection<?> pairs)`
`void` | `addInterfaceToType(Class<? extends ServerNotificationListener> iface, Class<? extends ServerNotification> event)`
`void` | `addListener(ServerNotificationListener<?> listener)`
`void` | `addListenerSubscription(ServerNotificationListener<?> listener, String subscription)`
`void` | `addListenerSubscriptionPair(ListenerSubscriptionPair pair)`
`void` | `disableInterface(Class<? extends ServerNotificationListener> iface)`
`void` | `disableType(Class<? extends ServerNotification> type)`
`void` | `dispose()` A lifecycle method where implementor should free up any resources.
`void` | `fireNotification(ServerNotification notification)`
`edu.emory.mathcs.backport.java.util.Queue` | `getEventQueue()`
`Map<Class<? extends ServerNotificationListener>,Set<Class<? extends ServerNotification>>>` | `getInterfaceToTypes()`
`Set<ListenerSubscriptionPair>` | `getListeners()`
`boolean` | `isListenerRegistered(ServerNotificationListener listener)`
`boolean` | `isNotificationDynamic()`
`boolean` | `isNotificationEnabled(Class<? extends ServerNotification> type)` This returns a very "conservative" value - it is true if the notification or any subclass would be accepted.
`protected void` | `notifyListeners(ServerNotification notification)`
`void` | `release()`
`void` | `removeAllListeners(Collection<ServerNotificationListener> listeners)`
`void` | `removeListener(ServerNotificationListener<?> listener)` This removes *all* registrations that reference this listener
`void` | `run()`
`void` | `setAllListenerSubscriptionPairs(Collection<?> pairs)` Deprecated. Use addAllListenerSubscriptionPairs which better describes the "add" operation that occurs.
`void` | `setDisabledInterfaces(Collection<Class<? extends ServerNotificationListener>> interfaces)`
`void` | `setDisabledTypes(Collection<Class<? extends ServerNotificationListener>> types)`
`void` | `setInterfaceToTypes(Map<Class<? extends ServerNotificationListener>,Set<Class<? extends ServerNotification>>> interfaceToEvents)`
`void` | `setMuleContext(MuleContext context)`
`void` | `setNotificationDynamic(boolean dynamic)`
`void` | `start(WorkManager workManager, javax.resource.spi.work.WorkListener workListener)`

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

Field Detail

### NULL_SUBSCRIPTION

    public static final String NULL_SUBSCRIPTION

See Also:
  Constant Field Values

### logger

    protected Log logger

Constructor Detail

### ServerNotificationManager

    public ServerNotificationManager()

Method Detail

### isNotificationDynamic

    public boolean isNotificationDynamic()

  Specified by:
    `isNotificationDynamic` in interface `ServerNotificationHandler`

### setMuleContext

    public void setMuleContext(MuleContext context)

  Specified by:
    `setMuleContext` in interface `MuleContextAware`

### setNotificationDynamic

    public void setNotificationDynamic(boolean dynamic)

### start

    public void start(WorkManager workManager,
                      javax.resource.spi.work.WorkListener workListener)
               throws LifecycleException

  Throws:
    `LifecycleException`

### addInterfaceToType

    public void addInterfaceToType(Class<? extends ServerNotificationListener> iface,
                                   Class<? extends ServerNotification> event)

### setInterfaceToTypes

    public void setInterfaceToTypes(Map<Class<? extends ServerNotificationListener>,Set<Class<? extends ServerNotification>>> interfaceToEvents)
                             throws ClassNotFoundException

  Throws:
    `ClassNotFoundException`

### addListenerSubscriptionPair

    public void addListenerSubscriptionPair(ListenerSubscriptionPair pair)

### addListener

    public void addListener(ServerNotificationListener<?> listener)

### addListenerSubscription

    public void addListenerSubscription(ServerNotificationListener<?> listener,
                                        String subscription)

### addAllListenerSubscriptionPairs

    public void addAllListenerSubscriptionPairs(Collection<?> pairs)

### setAllListenerSubscriptionPairs

    @Deprecated
    public void setAllListenerSubscriptionPairs(Collection<?> pairs)

  Deprecated. Use addAllListenerSubscriptionPairs which better describes the "add" operation that occurs.

  Parameters:
    `pairs` -

### removeListener

    public void removeListener(ServerNotificationListener<?> listener)

  This removes *all* registrations that reference this listener

### removeAllListeners

    public void removeAllListeners(Collection<ServerNotificationListener> listeners)

### disableInterface

    public void disableInterface(Class<? extends ServerNotificationListener> iface)
                          throws ClassNotFoundException

  Throws:
    `ClassNotFoundException`

### setDisabledInterfaces

    public void setDisabledInterfaces(Collection<Class<? extends ServerNotificationListener>> interfaces)
                               throws ClassNotFoundException

  Throws:
    `ClassNotFoundException`

### disableType

    public void disableType(Class<? extends ServerNotification> type)
                     throws ClassNotFoundException

  Throws:
    `ClassNotFoundException`

### setDisabledTypes

    public void setDisabledTypes(Collection<Class<? extends ServerNotificationListener>> types)
                          throws ClassNotFoundException

  Throws:
    `ClassNotFoundException`

### isListenerRegistered

    public boolean isListenerRegistered(ServerNotificationListener listener)

  Specified by:
    `isListenerRegistered` in interface `ServerNotificationHandler`
  Returns:

### fireNotification

    public void fireNotification(ServerNotification notification)

  Specified by:
    `fireNotification` in interface `ServerNotificationHandler`

### isNotificationEnabled

    public boolean isNotificationEnabled(Class<? extends ServerNotification> type)

  Description copied from interface: `ServerNotificationHandler`
  This returns a very "conservative" value - it is true if the notification or any subclass would be accepted. So if it returns false then you can be sure that there is no need to send the notification. On the other hand, if it returns true there is no guarantee that the notification "really" will be dispatched to any listener.

  Specified by:
    `isNotificationEnabled` in interface `ServerNotificationHandler`
  Parameters:
    `type` - Either the notification class being generated or some superclass
  Returns:
    false if there is no need to dispatch the notification

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

### notifyListeners

    protected void notifyListeners(ServerNotification notification)

### release

    public void release()

  Specified by:
    `release` in interface `javax.resource.spi.work.Work`

### run

    public void run()

  Specified by:
    `run` in interface `Runnable`

### getEventQueue

    public edu.emory.mathcs.backport.java.util.Queue getEventQueue()

  Returns:
    DIRECT reference to an event queue

### getInterfaceToTypes

    public Map<Class<? extends ServerNotificationListener>,Set<Class<? extends ServerNotification>>> getInterfaceToTypes()

### getListeners

    public Set<ListenerSubscriptionPair> getListeners()

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-2010 MuleSoft, Inc.. All Rights Reserved.