@NoExtend public class ServerNotificationManager extends Object implements ServerNotificationHandler, MuleContextAware
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:
Constructor and Description |
---|
ServerNotificationManager() |
public boolean isNotificationDynamic()
isNotificationDynamic
in interface ServerNotificationHandler
public void setMuleContext(MuleContext context)
setMuleContext
in interface MuleContextAware
context
- the Mule node.public void setNotificationDynamic(boolean dynamic)
public void initialise() throws InitialisationException
Initialisable
. It needs to be initialised before every other
object to send notifications.InitialisationException
public void addInterfaceToType(Class<? extends NotificationListener> iface, Class<? extends Notification> event)
public void setInterfaceToTypes(Map<Class<? extends NotificationListener>,Set<Class<? extends Notification>>> interfaceToEvents) throws ClassNotFoundException
ClassNotFoundException
public void addListenerSubscriptionPair(ListenerSubscriptionPair pair)
public void addListener(NotificationListener<?> listener)
public <N extends Notification> void addListenerSubscription(NotificationListener<N> listener, Predicate<N> selector)
public void removeListener(NotificationListener<?> listener)
public void disableInterface(Class<? extends NotificationListener> iface)
public void setDisabledInterfaces(Collection<Class<? extends NotificationListener>> interfaces) throws ClassNotFoundException
ClassNotFoundException
public void disableType(Class<? extends Notification> type)
public boolean isListenerRegistered(NotificationListener listener)
isListenerRegistered
in interface ServerNotificationHandler
public void fireNotification(Notification notification)
ServerNotificationHandler
Notification
. Regardless of if a notification is fired synchronously or asynchronously any Throwable
thrown by the NotificationListener
will not be propagated.fireNotification
in interface ServerNotificationHandler
notification
- the notification to fire.protected void notifyListeners(Notification notification, NotifierCallback notifier)
public boolean isNotificationEnabled(Class<? extends Notification> type)
ServerNotificationHandler
isNotificationEnabled
in interface ServerNotificationHandler
type
- Either the notification class being generated or some superclasspublic void dispose()
Disposable
. It needs to be alive after everything else has
diedpublic static Class toClass(Object value) throws ClassNotFoundException
ClassNotFoundException
public Map<Class<? extends NotificationListener>,Set<Class<? extends Notification>>> getInterfaceToTypes()
public Set<ListenerSubscriptionPair> getListeners()
public boolean isDisposed()
public static ServerNotificationManager createDefaultNotificationManager()
ServerNotificationManager
with the default configuration for Mule notificationsCopyright © 2018. All rights reserved.