Rio Project 4.2 API Documentation



org.rioproject.watch
Class WatchInjector

java.lang.Object
  extended by org.rioproject.watch.WatchInjector

public class WatchInjector
extends Object

The WatchInjector provides support for declarative Watch management, by taking a WatchDescriptor and creating SamplingWatch instances which are then registered for an instantiated service.

If the watch already exists in the bean's WatchRegistry, the watch will not be added.

The bean must declare a Java bean getter method that has as it's return type one of the following:

The read property return type is verified prior to watch creation. For example, given a bean called Foo, which declares a method called getCount() :
 public class Foo  {
     ...
     public long getCount() {
         return(value);
     }
     ...
 }
 
Finally, in the OperationalString, Watch declaration is accomplished using the embedded the <Monitor> element, for example:
 <SLA ID="backlog" Low="100" High="500">
     <PolicyHandler type="scaling" max="10"
                       lowerDampener="3000" upperDampener="3000"/>
     <Monitor name="entryCounter" property="count" period="10000"/>
 </SLA>
 
This declaration creates a SamplingWatch with a name of entryCounter, which adds the value returned from the getCount() method every 10 seconds.

Author:
Dennis Reedy

Constructor Summary
WatchInjector(Object impl, ServiceBeanContext context)
           
 
Method Summary
protected  Watch createWatch(WatchDescriptor wDesc, Object bean, Configuration config)
           
protected  Watch createWatch(WatchDescriptor wDesc, Object bean, Method accessor, Configuration config)
           
 String[] getWatchNames()
          Get all created Watch names
 Watch inject(WatchDescriptor wDesc)
          Add a WatchDescriptor, creating the Watch
 Watch inject(WatchDescriptor wDesc, Object bean, Method accessor)
          Add a WatchDescriptor, creating the Watch
 void modify(WatchDescriptor wDesc)
          Modify an injected Watch
 void remove(String name)
          Unregister and remove an injected Watch
 void remove(WatchDescriptor wDesc)
          Unregister and remove an injected Watch
 void terminate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WatchInjector

public WatchInjector(Object impl,
                     ServiceBeanContext context)
              throws IntrospectionException
Throws:
IntrospectionException
Method Detail

inject

public Watch inject(WatchDescriptor wDesc)
             throws Exception
Add a WatchDescriptor, creating the Watch

Parameters:
wDesc - The WatchDescriptor to add, must not be null
Returns:
The created Watch, or null if it could not be created. If the watch already exists, the current Watch wil be returned
Throws:
Exception - if there are problems getting the configuration from the context

inject

public Watch inject(WatchDescriptor wDesc,
                    Object bean,
                    Method accessor)
             throws Exception
Add a WatchDescriptor, creating the Watch

Parameters:
wDesc - The WatchDescriptor to add, must not be null
bean - The target bean to poll data from
accessor - Method to get data from, must not be null
Returns:
The created Watch, or null if it could not be created. If the watch already exists, the current Watch wil be returned
Throws:
Exception - if there are problems getting the configuration from the context

terminate

public void terminate()

createWatch

protected Watch createWatch(WatchDescriptor wDesc,
                            Object bean,
                            Configuration config)
                     throws Exception
Throws:
Exception

createWatch

protected Watch createWatch(WatchDescriptor wDesc,
                            Object bean,
                            Method accessor,
                            Configuration config)
                     throws Exception
Throws:
Exception

getWatchNames

public String[] getWatchNames()
Get all created Watch names

Returns:
The names of all watches that have been created and registered by this utility. If there are no watches created and registered by this utility a zero-length array is returned. A new array is allocated each time

modify

public void modify(WatchDescriptor wDesc)
            throws ConfigurationException
Modify an injected Watch

Parameters:
wDesc - The WatchDescriptor to modify, must not be null
Throws:
ConfigurationException - if there are errors reading the configuration

remove

public void remove(WatchDescriptor wDesc)
Unregister and remove an injected Watch

Parameters:
wDesc - The WatchDescriptor to remove, must not be null

remove

public void remove(String name)
Unregister and remove an injected Watch

Parameters:
name - The Watch name (id) to remove, must not be null

Copyright © Rio Project.

Copyright © 2006-2011 Rio Project. All Rights Reserved.