org.mobicents.slee.management.rules
Class RulesScanner

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended by org.jboss.system.ServiceMBeanSupport
          extended by org.mobicents.slee.management.rules.RulesScanner
All Implemented Interfaces:
javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, org.jboss.system.Service, org.jboss.system.ServiceMBean, RulesScannerMBean

public class RulesScanner
extends org.jboss.system.ServiceMBeanSupport
implements RulesScannerMBean

A URL-based scanner. Supports local directory scanning for file-based urls. This MBean searchs for rules file like .xls, .XLS, .csv, .CSV and .drl if found in the directory specified by user, this MBean will create RuleBase and will bind to JNDI with the name of file as jndi name under subcontext java:rulebase/ for example for MyRules.xls rule file, RuleBase will be bound at java:rulebase/MyRules.xls


Nested Class Summary
protected  class RulesScanner.BindURL
          A container and help class for a bind URL.
 class RulesScanner.ScannerThread
          Should use Timer/TimerTask instead? This has some issues with interaction with ScanEnabled attribute.
 
Field Summary
protected  java.util.Set boundSet
          A set of scanned urls which have been bounded to JNDI.
protected  boolean doRecursiveSearch
          Whether to search inside directories whose names containing no dots
protected  org.jboss.net.protocol.URLLister.URLFilter filter
          Allow a filter for scanned directories
protected  org.jboss.net.protocol.URLListerFactory listerFactory
          Helper for listing local/remote directory URLs
static java.lang.String RULES_BASE_JNDI_PREFIX
           
protected  boolean scanEnabled
          True if period based scanning is enabled.
protected  RulesScanner.ScannerThread scannerThread
           
protected  long scanPeriod
          The scan period in milliseconds
protected  java.net.URL serverHomeURL
           
protected  long stopTimeOut
          The stop timeout
protected  java.util.List urlList
          The list of URLs to scan.
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
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
RulesScanner()
           
 
Method Summary
 void addURL(java.lang.String urlspec)
           
 void addURL(java.net.URL url)
           
protected  void bind(RulesScanner.BindURL du, boolean rebind)
          A helper to deploy the given URL with the deployer.
protected  void createService()
           
protected  void destroyService()
           
 java.lang.String getFilter()
           
 boolean getRecursiveSearch()
           
 java.util.List getURLList()
           
 boolean hasURL(java.lang.String urlspec)
           
 boolean hasURL(java.net.URL url)
           
 boolean isScanEnabled()
          Check if period based scanning is enabled.
protected  java.net.URL makeURL(java.lang.String urlspec)
          A helper to make a URL from a full url, or a filespec.
 javax.management.ObjectName preRegister(javax.management.MBeanServer server, javax.management.ObjectName name)
           
 void removeURL(java.lang.String urlspec)
           
 void removeURL(java.net.URL url)
           
 void scan()
          Scan for changes in Rules files .drl, .xls, .cvs.
 void setFilter(java.lang.String classname)
           
 void setRecursiveSearch(boolean recurse)
           
 void setScanEnabled(boolean flag)
          Disable or enable the period based deployment scanning.
 void setScanPeriod(long period)
          Set the scan period for the scanner.
 void setURLList(java.util.List list)
           
 void setURLs(java.lang.String listspec)
           
protected  void startService()
           
protected  void stopService()
           
protected  void unbind(RulesScanner.BindURL du)
           
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, destroy, getDeploymentInfo, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, 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.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Field Detail

RULES_BASE_JNDI_PREFIX

public static final java.lang.String RULES_BASE_JNDI_PREFIX
See Also:
Constant Field Values

stopTimeOut

protected long stopTimeOut
The stop timeout


scanPeriod

protected long scanPeriod
The scan period in milliseconds


scanEnabled

protected boolean scanEnabled
True if period based scanning is enabled.


serverHomeURL

protected java.net.URL serverHomeURL

urlList

protected java.util.List urlList
The list of URLs to scan.


boundSet

protected java.util.Set boundSet
A set of scanned urls which have been bounded to JNDI.


listerFactory

protected org.jboss.net.protocol.URLListerFactory listerFactory
Helper for listing local/remote directory URLs


doRecursiveSearch

protected boolean doRecursiveSearch
Whether to search inside directories whose names containing no dots


scannerThread

protected RulesScanner.ScannerThread scannerThread

filter

protected org.jboss.net.protocol.URLLister.URLFilter filter
Allow a filter for scanned directories

Constructor Detail

RulesScanner

public RulesScanner()
Method Detail

setRecursiveSearch

public void setRecursiveSearch(boolean recurse)
Specified by:
setRecursiveSearch in interface RulesScannerMBean

getRecursiveSearch

public boolean getRecursiveSearch()
Specified by:
getRecursiveSearch in interface RulesScannerMBean

addURL

public void addURL(java.net.URL url)
Specified by:
addURL in interface RulesScannerMBean

addURL

public void addURL(java.lang.String urlspec)
            throws java.net.MalformedURLException
Specified by:
addURL in interface RulesScannerMBean
Throws:
java.net.MalformedURLException

getURLList

public java.util.List getURLList()
Specified by:
getURLList in interface RulesScannerMBean

hasURL

public boolean hasURL(java.net.URL url)
Specified by:
hasURL in interface RulesScannerMBean

hasURL

public boolean hasURL(java.lang.String urlspec)
               throws java.net.MalformedURLException
Specified by:
hasURL in interface RulesScannerMBean
Throws:
java.net.MalformedURLException

isScanEnabled

public boolean isScanEnabled()
Description copied from interface: RulesScannerMBean
Check if period based scanning is enabled.

Specified by:
isScanEnabled in interface RulesScannerMBean
Returns:
True if enabled, false if disabled.

setScanEnabled

public void setScanEnabled(boolean flag)
Description copied from interface: RulesScannerMBean
Disable or enable the period based deployment scanning.

Manual scanning can still be performed by calling RulesScannerMBean.scan().

Specified by:
setScanEnabled in interface RulesScannerMBean
Parameters:
flag - True to enable or false to disable period based scanning.

removeURL

public void removeURL(java.net.URL url)
Specified by:
removeURL in interface RulesScannerMBean

removeURL

public void removeURL(java.lang.String urlspec)
               throws java.net.MalformedURLException
Specified by:
removeURL in interface RulesScannerMBean
Throws:
java.net.MalformedURLException

setFilter

public void setFilter(java.lang.String classname)
               throws java.lang.ClassNotFoundException,
                      java.lang.IllegalAccessException,
                      java.lang.InstantiationException
Specified by:
setFilter in interface RulesScannerMBean
Throws:
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException

getFilter

public java.lang.String getFilter()
Specified by:
getFilter in interface RulesScannerMBean

scan

public void scan()
          throws java.lang.Exception
Description copied from interface: RulesScannerMBean
Scan for changes in Rules files .drl, .xls, .cvs.

Specified by:
scan in interface RulesScannerMBean
Throws:
java.lang.IllegalStateException - Not initialized.
java.lang.Exception - Scan failed.

unbind

protected void unbind(RulesScanner.BindURL du)

bind

protected void bind(RulesScanner.BindURL du,
                    boolean rebind)
A helper to deploy the given URL with the deployer.


setScanPeriod

public void setScanPeriod(long period)
Description copied from interface: RulesScannerMBean
Set the scan period for the scanner.

Specified by:
setScanPeriod in interface RulesScannerMBean
Parameters:
period - This is the time in milliseconds between scans.

setURLList

public void setURLList(java.util.List list)
Specified by:
setURLList in interface RulesScannerMBean

setURLs

public void setURLs(java.lang.String listspec)
             throws java.net.MalformedURLException
Specified by:
setURLs in interface RulesScannerMBean
Throws:
java.net.MalformedURLException

makeURL

protected java.net.URL makeURL(java.lang.String urlspec)
                        throws java.net.MalformedURLException
A helper to make a URL from a full url, or a filespec.

Throws:
java.net.MalformedURLException

preRegister

public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
                                               javax.management.ObjectName name)
                                        throws java.lang.Exception
Specified by:
preRegister in interface javax.management.MBeanRegistration
Overrides:
preRegister in class org.jboss.system.ServiceMBeanSupport
Throws:
java.lang.Exception

createService

protected void createService()
                      throws java.lang.Exception
Overrides:
createService in class org.jboss.system.ServiceMBeanSupport
Throws:
java.lang.Exception

startService

protected void startService()
                     throws java.lang.Exception
Overrides:
startService in class org.jboss.system.ServiceMBeanSupport
Throws:
java.lang.Exception

stopService

protected void stopService()
                    throws java.lang.Exception
Overrides:
stopService in class org.jboss.system.ServiceMBeanSupport
Throws:
java.lang.Exception

destroyService

protected void destroyService()
                       throws java.lang.Exception
Overrides:
destroyService in class org.jboss.system.ServiceMBeanSupport
Throws:
java.lang.Exception


Copyright © 2009. All Rights Reserved.