org.jboss.monitor.services
Class ScriptingListener

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended by org.jboss.system.ServiceMBeanSupport
          extended by org.jboss.system.ListenerServiceMBeanSupport
              extended by org.jboss.monitor.services.ScriptingListener
All Implemented Interfaces:
EventListener, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, javax.management.NotificationListener, ScriptingListenerMBean, org.jboss.system.ListenerServiceMBean, org.jboss.system.Service, org.jboss.system.ServiceMBean

public class ScriptingListener
extends org.jboss.system.ListenerServiceMBeanSupport
implements ScriptingListenerMBean

A simple listener that can subscribe for any combination of notifications, and asynchronously process them using a script written using any of the languages supported by the apache Bean Scripting Framework (BSF). The following variables are setup for the script to use: "log" - service Logger "server" - the MBeanServer "manager" - alarm manager helper "notification" - the Notification to be processed "handback" - the Object sent with the notification By setting up a Timer using the TimerService to periodicaly emit notifications, we can use those notifications as triggers for performing any sort of polling operation. One of the intented uses of this service is to use the "manager" (see org.jboss.monitor.alarm.AlarmManager) in the script, help maintain a list of active system alarms in the ActiveAlarmTable service.

Version:
$Revision: 1.1.2.3 $
Author:
Dimitris Andreadis

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jboss.system.ListenerServiceMBeanSupport
org.jboss.system.ListenerServiceMBeanSupport.SubscriptionInfo
 
Field Summary
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ListenerServiceMBean
SL_FILTER_ELEMENT, SL_FILTER_FACTORY_ATTRIBUTE, SL_MBEAN_ELEMENT, SL_MBEAN_HANDBACK_ATTRIBUTE, SL_MBEAN_NAME_ATTRIBUTE, SL_NOTIFICATION_ELEMENT, SL_NOTIFICATION_TYPE_ATTRIBUTE, SL_ROOT_ELEMENT
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
ScriptingListener()
          CTOR
 
Method Summary
 long getAverageProcessingTime()
          The average notification processing time in msecs
 boolean getDynamicSubscriptions()
           
 long getNotificationsProcessed()
          The number of notification processed
 long getNotificationsReceived()
          The number of notifications received
 String getScript()
           
 String getScriptLanguage()
           
 long getTotalProcessingTime()
          The time spent processing notifications in msecs
 void handleNotification2(javax.management.Notification notification, Object handback)
          Overriden to add handling!
 void setDynamicSubscriptions(boolean dynamicSubscriptions)
          Flag to enable/disable dynamic subscriptions
 void setScript(String script)
          The script to execute when a notification is received
 void setScriptLanguage(String language)
          The language the script is written into
 void startService()
          Start
 void stopService()
          Stop
 
Methods inherited from class org.jboss.system.ListenerServiceMBeanSupport
handleNotification, setSubscriptionList, subscribe, subscribe, subscribe, unsubscribe
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, createService, destroy, destroyService, getDeploymentInfo, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.system.ListenerServiceMBean
setSubscriptionList
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Constructor Detail

ScriptingListener

public ScriptingListener()
CTOR

Method Detail

setScript

public void setScript(String script)
Description copied from interface: ScriptingListenerMBean
The script to execute when a notification is received

Specified by:
setScript in interface ScriptingListenerMBean

getScript

public String getScript()
Specified by:
getScript in interface ScriptingListenerMBean

setScriptLanguage

public void setScriptLanguage(String language)
Description copied from interface: ScriptingListenerMBean
The language the script is written into

Specified by:
setScriptLanguage in interface ScriptingListenerMBean

getScriptLanguage

public String getScriptLanguage()
Specified by:
getScriptLanguage in interface ScriptingListenerMBean

setDynamicSubscriptions

public void setDynamicSubscriptions(boolean dynamicSubscriptions)
Description copied from interface: ScriptingListenerMBean
Flag to enable/disable dynamic subscriptions

Specified by:
setDynamicSubscriptions in interface ScriptingListenerMBean

getDynamicSubscriptions

public boolean getDynamicSubscriptions()
Specified by:
getDynamicSubscriptions in interface ScriptingListenerMBean

getNotificationsReceived

public long getNotificationsReceived()
Description copied from interface: ScriptingListenerMBean
The number of notifications received

Specified by:
getNotificationsReceived in interface ScriptingListenerMBean

getNotificationsProcessed

public long getNotificationsProcessed()
Description copied from interface: ScriptingListenerMBean
The number of notification processed

Specified by:
getNotificationsProcessed in interface ScriptingListenerMBean

getTotalProcessingTime

public long getTotalProcessingTime()
Description copied from interface: ScriptingListenerMBean
The time spent processing notifications in msecs

Specified by:
getTotalProcessingTime in interface ScriptingListenerMBean

getAverageProcessingTime

public long getAverageProcessingTime()
Description copied from interface: ScriptingListenerMBean
The average notification processing time in msecs

Specified by:
getAverageProcessingTime in interface ScriptingListenerMBean

startService

public void startService()
                  throws Exception
Start

Overrides:
startService in class org.jboss.system.ServiceMBeanSupport
Throws:
Exception

stopService

public void stopService()
                 throws Exception
Stop

Overrides:
stopService in class org.jboss.system.ServiceMBeanSupport
Throws:
Exception

handleNotification2

public void handleNotification2(javax.management.Notification notification,
                                Object handback)
Overriden to add handling!

Overrides:
handleNotification2 in class org.jboss.system.ListenerServiceMBeanSupport


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.