org.norther.tammi.spray.engine.tool
Class BrokerTool

java.lang.Object
  extended by org.norther.tammi.core.base.MBeanBroker
      extended by org.norther.tammi.core.config.MBeanConfig
          extended by org.norther.tammi.spray.engine.tool.BrokerTool
All Implemented Interfaces:
Serializable, EventListener, Poolable, Recyclable, ContextBindingListener

public class BrokerTool
extends MBeanConfig
implements Poolable, ContextBindingListener

A request context tool extending MBeanConfig and pushing exceptions into the error stack of the filter chain instead of throwing them.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.core.base.MBeanBroker
MBEAN_BROKER
 
Constructor Summary
BrokerTool()
          Constructs a new broker.
 
Method Summary
 void configure(ObjectName name, String path)
          Configures the specified MBean.
 void configure(String spec, String path)
          Configures the specified MBean.
 void copy(File source, File target)
          Copies a file.
 void copy(URL source, File target)
          Copies a URL.
 ObjectName create(String clazz, ObjectName name, ObjectName loader, Object params, Object sign)
          Creates and registers an MBean with an object name, class loader, parameters and signature.
 ObjectName create(String className, String name, String loader, Object params, Object sign)
          Creates and registers an MBean with a string name, class loader, parameters and signature.
 void dispose()
          Disposes the object after use.
 void disposed()
          A call back indicating that this instance is not needed any more and can be disposed.
 Object get(ObjectName name, String key)
          Gets an attribute value of the specified MBean.
 String getClassName(ObjectName name)
          Gets the class name of the specified MBean.
protected  HttpFilterChain getFilterChain()
          Gets the current filter chain if available.
 MBeanInfo getInfo(ObjectName name)
          Gets MBean info about the specified MBean.
 String getSystemProperty(String name)
          Gets a system property.
 Object instantiate(String clazz, Object params, Object sign)
          Intantiates an object with parameters and a signature.
 Object invoke(ObjectName name, String method, Object params, Object sign)
          Invokes a method of the specified MBean with parameters and a signature.
protected  boolean isBound()
          Gets the bound state.
 boolean isDisposed()
          Checks whether the recyclable has been disposed.
 Class load(String className)
          Loads a class.
 void recycle()
          Recycles the object for a new client.
 void recycled(MBeanReference instance)
          A callback specifying the pool, from which this instance was recycled.
 ObjectName register(Object object, ObjectName name)
          Registers the named MBean.
 ObjectName register(Object object, String name)
          Registers an MBean with a string name.
 void restart(int delay)
          Restarts the server.
 void set(ObjectName name, String key, Object value)
          Sets an attribute value of the specified MBean.
 void setSystemProperty(String name, String value)
          Sets a system property.
 void shutdown()
          Shuts down the server.
 ObjectName toObjectName(String name)
          Converts a string to an object name.
 void unregister(ObjectName name)
          Unregisters the named MBean.
 void valueBound(ContextBindingEvent event)
          Notifies the object that it is being bound to a context.
 void valueUnbound(ContextBindingEvent event)
          Notifies the object that it is being unbound from a context.
 
Methods inherited from class org.norther.tammi.core.config.MBeanConfig
configure, configure, convert, convert, getConfigurator, setConverter, setConverter
 
Methods inherited from class org.norther.tammi.core.base.MBeanBroker
adapt, adapt, adapt, adapt, adapt, adapt, adapt, adapt, adapt, adapt, adapt, create, create, create, create, create, create, create, find, find, find, find, findName, findName, findName, findName, findNames, findNames, findNames, findNames, findNames, findNames, get, get, get, getAllDomains, getBroker, getClassName, getDefaultDomain, getDomain, getDomainName, getDomainNames, getFactory, getInfo, getLoader, getLog, getMBeanServer, getPackage, getPackages, instantiate, instantiate, invoke, invoke, invoke, invoke, invoke, isDefined, isInstanceOf, isInstanceOf, isRegistered, isRegistered, register, register, set, set, set, set, set, setAlias, setAlias, setFactory, setFactory, setMBeanServer, toPackageName, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrokerTool

public BrokerTool()
Constructs a new broker.

Method Detail

recycle

public void recycle()
Description copied from interface: Recyclable
Recycles the object for a new client. Recycle methods with parameters must be added to implementing object and they will be automatically called by pool implementations when the object is taken from the pool for a new client. The parameters must correspond to the parameters of the constructors of the object. For new objects, constructors can call their corresponding recycle methods whenever applicable. The recycle methods must call their super.

Specified by:
recycle in interface Recyclable

dispose

public void dispose()
Description copied from interface: Recyclable
Disposes the object after use. The method is called when the object is returned to its pool. The dispose method must call its super.

Specified by:
dispose in interface Recyclable

isDisposed

public boolean isDisposed()
Description copied from interface: Recyclable
Checks whether the recyclable has been disposed.

Specified by:
isDisposed in interface Recyclable
Returns:
true, if the recyclable is disposed.

recycled

public void recycled(MBeanReference instance)
Description copied from interface: Poolable
A callback specifying the pool, from which this instance was recycled.

Specified by:
recycled in interface Poolable
Parameters:
instance - the pool MBean reference.

disposed

public void disposed()
Description copied from interface: Poolable
A call back indicating that this instance is not needed any more and can be disposed.

Specified by:
disposed in interface Poolable

create

public ObjectName create(String className,
                         String name,
                         String loader,
                         Object params,
                         Object sign)
                  throws LogException
Description copied from class: MBeanBroker
Creates and registers an MBean with a string name, class loader, parameters and signature. A single parameter can be given as an object and multiple parameters as a list or an array. If the parameters are given as a list, the signature must be null or also a list.

Overrides:
create in class MBeanBroker
Parameters:
className - the class name of the MBean.
name - the string name of the MBean.
loader - the string name of the loader.
params - the parameter to the constructor.
sign - the signature of the parameters.
Returns:
the object name of the new MBean.
Throws:
LogException - on errors.

register

public ObjectName register(Object object,
                           String name)
                    throws LogException
Description copied from class: MBeanBroker
Registers an MBean with a string name.

Overrides:
register in class MBeanBroker
Parameters:
object - the object to register.
name - the string name of the MBean.
Returns:
the object name of the registered MBean.
Throws:
LogException - on errors.

configure

public void configure(String spec,
                      String path)
Description copied from class: MBeanConfig
Configures the specified MBean. The MBean can be specified by a broker alias, query pattern or fully qualified object name.

Overrides:
configure in class MBeanConfig
Parameters:
spec - the MBean specification.
path - the configuration path.

getClassName

public String getClassName(ObjectName name)
                    throws LogException
Description copied from class: MBeanBroker
Gets the class name of the specified MBean. The MBean can be specified by a query pattern or fully qualified object name.

Overrides:
getClassName in class MBeanBroker
Parameters:
name - the object name of the MBean.
Returns:
the class name of the MBean.
Throws:
LogException - on errors.

getInfo

public MBeanInfo getInfo(ObjectName name)
Description copied from class: MBeanBroker
Gets MBean info about the specified MBean. The MBean can be specified by a query pattern or fully qualified object name.

Overrides:
getInfo in class MBeanBroker
Parameters:
name - the object name of the MBean.
Returns:
info about the MBean.

get

public Object get(ObjectName name,
                  String key)
Description copied from class: MBeanBroker
Gets an attribute value of the specified MBean. The MBean can be specified by a query pattern or fully qualified object name.

Overrides:
get in class MBeanBroker
Parameters:
name - the object name of the MBean.
key - the attribute key.
Returns:
the value of the attribute.

set

public void set(ObjectName name,
                String key,
                Object value)
Description copied from class: MBeanBroker
Sets an attribute value of the specified MBean. The MBean can be specified by a query pattern or fully qualified object name.

Overrides:
set in class MBeanBroker
Parameters:
name - the MBean name.
key - the attribute key.
value - the attribute value.

invoke

public Object invoke(ObjectName name,
                     String method,
                     Object params,
                     Object sign)
Description copied from class: MBeanBroker
Invokes a method of the specified MBean with parameters and a signature. The MBean can be specified by a query pattern or fully qualified object name. A single parameter can be given as an object and multiple parameters as a list or an array. If the parameters are given as a list, the signature must be null or also a list.

Overrides:
invoke in class MBeanBroker
Parameters:
name - the MBean name.
method - the method name.
params - the parameters to the method.
sign - the signature of the parameters.
Returns:
the return value of the method.

create

public ObjectName create(String clazz,
                         ObjectName name,
                         ObjectName loader,
                         Object params,
                         Object sign)
Description copied from class: MBeanBroker
Creates and registers an MBean with an object name, class loader, parameters and signature. A single parameter can be given as an object and multiple parameters as a list or an array. If the parameters are given as a list, the signature must be null or also a list.

Overrides:
create in class MBeanBroker
Parameters:
clazz - the class name of the MBean.
name - the object name of the MBean.
loader - the object name of the loader.
params - the parameter to the constructor.
sign - the signature of the parameters.
Returns:
the object name of the new MBean.

register

public ObjectName register(Object object,
                           ObjectName name)
Description copied from class: MBeanBroker
Registers the named MBean.

Overrides:
register in class MBeanBroker
Parameters:
object - the object to register.
name - the object name or name pattern of the MBean.
Returns:
the object name of the registered MBean.

unregister

public void unregister(ObjectName name)
Description copied from class: MBeanBroker
Unregisters the named MBean.

Overrides:
unregister in class MBeanBroker
Parameters:
name - the object name of the MBean.

configure

public void configure(ObjectName name,
                      String path)
Description copied from class: MBeanConfig
Configures the specified MBean. The MBean can be specified by a query pattern or fully qualified object name.

Overrides:
configure in class MBeanConfig
Parameters:
name - the object name of the MBean.
path - the configuration path.

instantiate

public Object instantiate(String clazz,
                          Object params,
                          Object sign)
Description copied from class: MBeanBroker
Intantiates an object with parameters and a signature.

Overrides:
instantiate in class MBeanBroker
Parameters:
clazz - the class name of the object.
params - the parameters to the constructor.
sign - the signature of the parameters.
Returns:
the new object instance.

toObjectName

public ObjectName toObjectName(String name)
Description copied from class: MBeanBroker
Converts a string to an object name.

Overrides:
toObjectName in class MBeanBroker
Parameters:
name - the string.
Returns:
the object name.

getSystemProperty

public String getSystemProperty(String name)
Description copied from class: MBeanBroker
Gets a system property.

Overrides:
getSystemProperty in class MBeanBroker
Parameters:
name - the property name.
Returns:
the property value.

setSystemProperty

public void setSystemProperty(String name,
                              String value)
Description copied from class: MBeanBroker
Sets a system property.

Overrides:
setSystemProperty in class MBeanBroker
Parameters:
name - the property name.
value - the property value.

load

public Class load(String className)
Description copied from class: MBeanBroker
Loads a class.

Overrides:
load in class MBeanBroker
Parameters:
className - the class name.
Returns:
the loaded class.

copy

public void copy(File source,
                 File target)
Copies a file.

Overrides:
copy in class MBeanConfig
Parameters:
source - the source file.
target - the target file.

copy

public void copy(URL source,
                 File target)
Copies a URL.

Overrides:
copy in class MBeanConfig
Parameters:
source - the source URL.
target - the target file.

shutdown

public void shutdown()
Shuts down the server.


restart

public void restart(int delay)
Restarts the server.

Parameters:
delay - the restart delay in secs.

valueBound

public void valueBound(ContextBindingEvent event)
Description copied from interface: ContextBindingListener
Notifies the object that it is being bound to a context.

Specified by:
valueBound in interface ContextBindingListener
Parameters:
event - the binding event.

valueUnbound

public void valueUnbound(ContextBindingEvent event)
Description copied from interface: ContextBindingListener
Notifies the object that it is being unbound from a context.

Specified by:
valueUnbound in interface ContextBindingListener
Parameters:
event - the binding event.

getFilterChain

protected HttpFilterChain getFilterChain()
Gets the current filter chain if available.

Returns:
the filter chain or null.

isBound

protected boolean isBound()
Gets the bound state.

Returns:
true if bound, otherwise false.


Copyright © 2004 The Norther Organization. All rights reserved.