org.oddjob.framework
Class BaseWrapper

java.lang.Object
  extended by org.oddjob.framework.BaseComponent
      extended by org.oddjob.framework.BaseWrapper
All Implemented Interfaces:
Runnable, org.apache.commons.beanutils.DynaBean, ArooaContextAware, ArooaSessionAware, Describeable, PropertyChangeNotifier, Iconic, LogEnabled, Resetable, Stateful, Stoppable
Direct Known Subclasses:
RunnableWrapper, ServiceWrapper

public abstract class BaseWrapper
extends BaseComponent
implements Runnable, Stateful, Resetable, org.apache.commons.beanutils.DynaBean, Stoppable, LogEnabled, Describeable

Base class for proxy creators.


Field Summary
 
Fields inherited from class org.oddjob.framework.BaseComponent
iconHelper
 
Constructor Summary
BaseWrapper()
           
 
Method Summary
protected  void configure()
          Called by sub classes to configure the component.
 boolean contains(String name, String key)
           
 Map<String,String> describe()
          Provides the properties.
 boolean equals(Object other)
           
 Object get(String name)
           
 Object get(String name, int index)
           
 Object get(String name, String key)
           
protected abstract  org.apache.commons.beanutils.DynaBean getDynaBean()
          Sub classes must provide a dyna bean for properties.
 org.apache.commons.beanutils.DynaClass getDynaClass()
           
protected abstract  Object getProxy()
          Subclass must provide the proxy.
protected  int getResult(Object callableResult)
          Get the result.
protected abstract  Object getWrapped()
          Return the object that is being proxied.
static Class<?>[] interfacesFor(Object object)
          Helper class to find interfaces implemented by an object.
protected  org.apache.log4j.Logger logger()
           
 String loggerName()
          Provide the logger name.
 void onDestroy()
          Subclasses override this method to clear up resources.
protected  void onStop()
           
 void remove(String name, String key)
           
protected  void save()
          Implementations override this to save their state on state change.
 void set(String name, int index, Object value)
           
 void set(String name, Object value)
           
 void set(String name, String key, Object value)
           
 void stop()
          Stop executing.
 String toString()
           
 
Methods inherited from class org.oddjob.framework.BaseComponent
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, fireDestroyedState, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession, stateHandler
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 
Methods inherited from interface org.oddjob.Stateful
addStateListener, lastStateEvent, removeStateListener
 
Methods inherited from interface org.oddjob.Resetable
hardReset, softReset
 

Constructor Detail

BaseWrapper

public BaseWrapper()
Method Detail

getWrapped

protected abstract Object getWrapped()
Return the object that is being proxied.

Returns:
The component being proxied.

getDynaBean

protected abstract org.apache.commons.beanutils.DynaBean getDynaBean()
Sub classes must provide a dyna bean for properties.

Returns:

getProxy

protected abstract Object getProxy()
Subclass must provide the proxy.

Returns:

logger

protected org.apache.log4j.Logger logger()
Specified by:
logger in class BaseComponent

loggerName

public String loggerName()
Description copied from interface: LogEnabled
Provide the logger name. The name should be unique for each component that is LogEnabled.

Specified by:
loggerName in interface LogEnabled
Returns:
A logger name. Never Null.

configure

protected void configure()
                  throws ArooaConfigurationException
Called by sub classes to configure the component.

Throws:
ArooaConfigurationException

save

protected void save()
             throws ComponentPersistException
Description copied from class: BaseComponent
Implementations override this to save their state on state change.

Overrides:
save in class BaseComponent
Throws:
ComponentPersistException

equals

public boolean equals(Object other)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

contains

public boolean contains(String name,
                        String key)
Specified by:
contains in interface org.apache.commons.beanutils.DynaBean

get

public Object get(String name)
Specified by:
get in interface org.apache.commons.beanutils.DynaBean

get

public Object get(String name,
                  int index)
Specified by:
get in interface org.apache.commons.beanutils.DynaBean

get

public Object get(String name,
                  String key)
Specified by:
get in interface org.apache.commons.beanutils.DynaBean

getDynaClass

public org.apache.commons.beanutils.DynaClass getDynaClass()
Specified by:
getDynaClass in interface org.apache.commons.beanutils.DynaBean

remove

public void remove(String name,
                   String key)
Specified by:
remove in interface org.apache.commons.beanutils.DynaBean

set

public void set(String name,
                int index,
                Object value)
Specified by:
set in interface org.apache.commons.beanutils.DynaBean

set

public void set(String name,
                Object value)
Specified by:
set in interface org.apache.commons.beanutils.DynaBean

set

public void set(String name,
                String key,
                Object value)
Specified by:
set in interface org.apache.commons.beanutils.DynaBean

stop

public final void stop()
                throws FailedToStopException
Description copied from interface: Stoppable
Stop executing. This method should not return until the Stoppable has actually stopped.

Specified by:
stop in interface Stoppable
Throws:
FailedToStopException

onStop

protected void onStop()
               throws FailedToStopException
Throws:
FailedToStopException

getResult

protected int getResult(Object callableResult)
                 throws ArooaPropertyException,
                        ArooaConversionException
Get the result. Use either the return value from the Callable or the result property if there is one.

Returns:
Throws:
ArooaConversionException
ArooaPropertyException

describe

public Map<String,String> describe()
Description copied from interface: Describeable
Provides the properties.

Specified by:
describe in interface Describeable
Returns:
A map of property values. Must not be null.

onDestroy

public void onDestroy()
Description copied from class: BaseComponent
Subclasses override this method to clear up resources.

Overrides:
onDestroy in class BaseComponent

interfacesFor

public static Class<?>[] interfacesFor(Object object)
Helper class to find interfaces implemented by an object.

Parameters:
object -
Returns:
An array of the interface classes.