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

java.lang.Object
  extended by org.norther.tammi.core.rt.Introspector
      extended by org.norther.tammi.spray.engine.tool.BeanTool
All Implemented Interfaces:
Serializable, EventListener, Poolable, Recyclable, ContextBindingListener
Direct Known Subclasses:
FormTool, ReportTool, RepositoryTool

public class BeanTool
extends Introspector
implements Poolable, ContextBindingListener

A request context tool for bean operations.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
BeanTool()
          Constructs a new tool.
 
Method Summary
 void addValue(Variable variable, String name, int index, Object value)
          Adds the indexed element to the named array attribute of the specified variable.
 void addValue(Variable variable, String name, Object value)
          Adds an element to the named array attribute of the specified variable.
 Variable create()
          Creates an empty variable MBean instance.
 Variable create(Object source)
          Creates a variable MBean instance with imported attributes.
 Variable create(String type)
          Creates a typed variable MBean instance.
 Variable create(String type, Object source)
          Creates a typed variable MBean instance with imported attributes.
 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.
protected  TemplateContext getContext()
          Gets the target context.
protected  ContextToolFilter getContextToolFilter()
          Gets the context tool filter if available.
 Locale getDefaultLocale()
          Gets the default locale.
 String getDescription(Variable variable, MBeanAttributeInfo attribute)
          Gets the specified attribute description.
 String getDetail(Variable variable, MBeanAttributeInfo attribute)
          Gets the specified attribute detail.
 EnumeratedList getEnumeration(Variable variable, MBeanAttributeInfo attribute)
          Gets the specified attribute value enumeration as a list of localized enumeration attributes.
protected  Filter getFilter(Class clazz)
          Gets the first specific filter from the filter chain.
protected  HttpFilterChain getFilterChain()
          Gets the current filter chain if available.
protected  String getFilterKey(Class clazz)
          Gets the key of the first specific key filter from the filter chain.
 String getGroup(Variable variable, MBeanAttributeInfo attribute)
          Gets the specified attribute group.
 Object getKeyValue(Variable variable, String name)
          Gets the named key attribute value of the specified variable.
protected  MBeanServer getMBeanServer()
          Gets the MBean server if available.
protected  String getName()
          Gets the bound name.
protected  Principal getPrincipal()
          Gets the current principal if available.
protected  ServletRequest getRequest()
          Gets the current request if available.
protected  ResourceMap getResourceMap()
          Gets the resource map MBean.
protected  ServletResponse getResponse()
          Gets the current response if available.
 Object getValue(Variable variable, String name)
          Gets the named attribute value of the specified variable.
 Object getValue(Variable variable, String name, int index)
          Gets the indexed element of the named array attribute of the specified variable.
protected  VariableRegistry getVariableRegistry()
          Gets the referent of the variable registry MBean.
protected  boolean isBound()
          Gets the bound state.
 boolean isDisposed()
          Checks whether the recyclable has been disposed.
protected  boolean isFilterChanged()
          Checks whether the current filter has changed since the previous check.
 boolean isLocalizedVariables()
          Checks whether variables are localized.
 int length(Variable variable, String name)
          Returns the length of the specified array attribute.
 void recycle()
          Recycles the object for a new client.
 void recycled(MBeanReference instance)
          A callback specifying the pool, from which this instance was recycled.
 Object removeValue(Variable variable, String name, int index)
          Removes the indexed element from the named array attribute of the specified variable.
 boolean removeValue(Variable variable, String name, Object value)
          Removes an element from the named array attribute of the specified variable.
 void setValue(Variable variable, String name, int index, Object value)
          Sets the indexed element of the named array attribute of the specified variable.
 void setValue(Variable variable, String name, Object value)
          Sets the named attribute value of the specified variable.
 void setValue(Variable variable, String name, Object value, boolean forced)
          Sets the named attribute value of the specified variable optionally by-passing attribute's current writable and mandatory settings.
 String toString(Variable variable, String name)
          Returns the specified attribute value as a localized string.
 String[] toStrings(Variable variable, String name)
          Returns the specified attribute values as a localized string array.
 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.rt.Introspector
clearResourceCache, contains, createVariable, exportTo, exportTo, getComparator, getConverter, getInfo, getInfo, getList, getList, getLocale, getMax, getMin, getPattern, getResource, getResourceBundle, getResourceBundle, getResourceBundleName, getResourceBundleName, hasConverter, importFrom, importFrom, isArray, isBlankAccepted, isCloneable, isCorrelative, isDisabled, isEmptyAccepted, isEnumerated, isInteractive, isLocal, isLocalized, isMandatory, isOrdered, isReadable, isSerialized, isSorted, isTraceable, isTransient, isTrimmed, isVisible, isWritable, setLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanTool

public BeanTool()
Constructs a new tool.

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 Variable create()
Description copied from class: Introspector
Creates an empty variable MBean instance.

Overrides:
create in class Introspector
Returns:
the variable or null.

create

public Variable create(Object source)
Description copied from class: Introspector
Creates a variable MBean instance with imported attributes.

Overrides:
create in class Introspector
Parameters:
source - the source object.
Returns:
the variable or null.

create

public Variable create(String type)
Description copied from class: Introspector
Creates a typed variable MBean instance.

Overrides:
create in class Introspector
Parameters:
type - the variable type.
Returns:
the variable or null.

create

public Variable create(String type,
                       Object source)
Description copied from class: Introspector
Creates a typed variable MBean instance with imported attributes.

Overrides:
create in class Introspector
Parameters:
type - the variable type.
source - the source object.
Returns:
the variable or null.

getValue

public Object getValue(Variable variable,
                       String name)
Description copied from class: Introspector
Gets the named attribute value of the specified variable. The original value is returned without string conversion or localization.

Overrides:
getValue in class Introspector
Parameters:
variable - the variable.
name - the attribute name.
Returns:
the attribute value.

setValue

public void setValue(Variable variable,
                     String name,
                     Object value)
Description copied from class: Introspector
Sets the named attribute value of the specified variable. The value must not be a localized value.

Overrides:
setValue in class Introspector
Parameters:
variable - the variable.
name - the attribute name.
value - the attribute value.

setValue

public void setValue(Variable variable,
                     String name,
                     Object value,
                     boolean forced)
Description copied from class: Introspector
Sets the named attribute value of the specified variable optionally by-passing attribute's current writable and mandatory settings. The value must not be a localized value.

Overrides:
setValue in class Introspector
Parameters:
variable - the variable.
name - the attribute name.
value - the attribute value.
forced - if true, forces the setting.

getValue

public Object getValue(Variable variable,
                       String name,
                       int index)
Description copied from class: Introspector
Gets the indexed element of the named array attribute of the specified variable. The original value is returned without string conversion or localization.

Overrides:
getValue in class Introspector
Parameters:
variable - the variable.
name - the attribute name.
index - the element index.
Returns:
the attribute value.

setValue

public void setValue(Variable variable,
                     String name,
                     int index,
                     Object value)
Description copied from class: Introspector
Sets the indexed element of the named array attribute of the specified variable. The value must not be a localized value.

Overrides:
setValue in class Introspector
Parameters:
variable - the variable.
name - the attribute name.
index - the element index.
value - the attribute value.

addValue

public void addValue(Variable variable,
                     String name,
                     Object value)
Description copied from class: Introspector
Adds an element to the named array attribute of the specified variable. The value must not be a localized value.

Overrides:
addValue in class Introspector
Parameters:
variable - the variable.
name - the attribute name.
value - the attribute value.

addValue

public void addValue(Variable variable,
                     String name,
                     int index,
                     Object value)
Description copied from class: Introspector
Adds the indexed element to the named array attribute of the specified variable. The value must not be a localized value.

Overrides:
addValue in class Introspector
Parameters:
variable - the variable.
name - the attribute name.
index - the element index.
value - the attribute value.

removeValue

public boolean removeValue(Variable variable,
                           String name,
                           Object value)
Description copied from class: Introspector
Removes an element from the named array attribute of the specified variable. The value must not be a localized value.

Overrides:
removeValue in class Introspector
Parameters:
variable - the variable.
name - the attribute name.
value - the value of the element.
Returns:
true if removed.

removeValue

public Object removeValue(Variable variable,
                          String name,
                          int index)
Description copied from class: Introspector
Removes the indexed element from the named array attribute of the specified variable.

Overrides:
removeValue in class Introspector
Parameters:
variable - the variable.
name - the attribute name.
index - the element index.
Returns:
the removed value of the element.

getKeyValue

public Object getKeyValue(Variable variable,
                          String name)
Description copied from class: Introspector
Gets the named key attribute value of the specified variable.

Overrides:
getKeyValue in class Introspector
Parameters:
variable - the variable.
name - the attribute name.
Returns:
the key attribute value.

toString

public String toString(Variable variable,
                       String name)
Description copied from class: Introspector
Returns the specified attribute value as a localized string.

Overrides:
toString in class Introspector
Parameters:
variable - the variable.
name - the attribute name.
Returns:
the attribute value or an empty string.

toStrings

public String[] toStrings(Variable variable,
                          String name)
Description copied from class: Introspector
Returns the specified attribute values as a localized string array.

Overrides:
toStrings in class Introspector
Parameters:
variable - the variable.
name - the attribute name.
Returns:
the attribute values or an empty string array.

length

public int length(Variable variable,
                  String name)
Description copied from class: Introspector
Returns the length of the specified array attribute.

Overrides:
length in class Introspector
Parameters:
variable - the variable.
name - the attribute name.
Returns:
the length of the array attribute.

getDescription

public String getDescription(Variable variable,
                             MBeanAttributeInfo attribute)
Description copied from class: Introspector
Gets the specified attribute description.

Overrides:
getDescription in class Introspector
Parameters:
variable - the variable.
attribute - the attribute.
Returns:
the attribute description.

getGroup

public String getGroup(Variable variable,
                       MBeanAttributeInfo attribute)
Description copied from class: Introspector
Gets the specified attribute group.

Overrides:
getGroup in class Introspector
Parameters:
variable - the variable.
attribute - the attribute.
Returns:
the attribute group or an empty string.

getDetail

public String getDetail(Variable variable,
                        MBeanAttributeInfo attribute)
Description copied from class: Introspector
Gets the specified attribute detail.

Overrides:
getDetail in class Introspector
Parameters:
variable - the variable.
attribute - the attribute.
Returns:
the attribute detail or an empty string.

getEnumeration

public EnumeratedList getEnumeration(Variable variable,
                                     MBeanAttributeInfo attribute)
Description copied from class: Introspector
Gets the specified attribute value enumeration as a list of localized enumeration attributes.

Overrides:
getEnumeration in class Introspector
Parameters:
variable - the variable.
attribute - the attribute.
Returns:
the attribute value enumeration or null.

getDefaultLocale

public Locale getDefaultLocale()
Description copied from class: Introspector
Gets the default locale.

Overrides:
getDefaultLocale in class Introspector
Returns:
the default locale.

isLocalizedVariables

public boolean isLocalizedVariables()
Description copied from class: Introspector
Checks whether variables are localized.

Overrides:
isLocalizedVariables in class Introspector
Returns:
true if localized, false otherwise.

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.

getResourceMap

protected ResourceMap getResourceMap()
Description copied from class: Introspector
Gets the resource map MBean.

Overrides:
getResourceMap in class Introspector
Returns:
the resource map MBean or null if not available.

getVariableRegistry

protected VariableRegistry getVariableRegistry()
Description copied from class: Introspector
Gets the referent of the variable registry MBean.

Overrides:
getVariableRegistry in class Introspector
Returns:
the referent the variable registry MBean.

getRequest

protected ServletRequest getRequest()
Gets the current request if available.

Returns:
the request or null.

getResponse

protected ServletResponse getResponse()
Gets the current response if available.

Returns:
the response or null.

getPrincipal

protected Principal getPrincipal()
Gets the current principal if available.

Returns:
the filter chain or null.

getFilterChain

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

Returns:
the filter chain or null.

getMBeanServer

protected MBeanServer getMBeanServer()
Gets the MBean server if available.

Overrides:
getMBeanServer in class Introspector
Returns:
the MBean server or null.

getFilter

protected Filter getFilter(Class clazz)
Gets the first specific filter from the filter chain.

Parameters:
clazz - the class or interface of the filter.
Returns:
the found filter or null.

getFilterKey

protected String getFilterKey(Class clazz)
Gets the key of the first specific key filter from the filter chain.

Parameters:
clazz - the class or interface of the key filter.
Returns:
the found key.

isFilterChanged

protected boolean isFilterChanged()
Checks whether the current filter has changed since the previous check.

Returns:
true if changed, false otherwise.

getContext

protected TemplateContext getContext()
Gets the target context.

Returns:
the context.

getName

protected String getName()
Gets the bound name.

Returns:
the bound name.

isBound

protected boolean isBound()
Gets the bound state.

Returns:
true if bound, otherwise false.

getContextToolFilter

protected ContextToolFilter getContextToolFilter()
Gets the context tool filter if available.

Returns:
the context tool filter or null.


Copyright © 2004 The Norther Organization. All rights reserved.