|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.sape.carbon.core.util.reflection.GenericProxy | +--org.sape.carbon.core.config.interceptor.DefaultConfigurationInterceptor
The default implementation of ConfigurationInterceptor. This implementation is a java.lang.reflect.InvocationHandler that can handle method calls on both the ConfigurationInterceptor interface and the component's configuration interface. All set requests to the configuration interface manipulate the working configuration. All get requests to the configuration interface manipulate the live configuration. The ConfigurationInterceptor interface handles the management of the working and live configurations.
Copyright 2002 Sapient
Field Summary | |
private static String |
CLONE
Name of the clone method. |
private static Method |
CONFIGURE_METHOD
Holds a reference to the configureComponent method of the class. |
private static String |
GET
Get prefix for properties. |
private static String |
GET_DATA_STRUCTURE
Name of the get data structure method. |
private static Method |
INVOKE_METHOD
Holds a reference to the invoke method of the Invocation class. |
private static String |
IS
Is prefix for boolean properties. |
protected ComponentConfiguration |
liveConfiguration
The component's live configuration |
private org.apache.commons.logging.Log |
log
|
protected Interceptor |
nextInterceptor
Next interceptor in the chain. |
private Thread |
persistingThread
|
protected ComponentProxyInvocationHandler |
proxyInvocationHandler
The invocation handler. |
private static String |
SET
Set prefix for properties. |
private static String |
SET_NAME
Name of the set configuration name method. |
protected Component |
thisComponent
Component being proxied. |
private static Collection |
UNSUPPORTED_OPERATIONS
Holds the list of operations not support by the interceptor. |
protected ComponentConfiguration |
workingConfiguration
The component's working configuration, possibly in an interim/invalid state |
Fields inherited from class org.sape.carbon.core.util.reflection.GenericProxy |
|
Constructor Summary | |
protected |
DefaultConfigurationInterceptor(ComponentConfiguration componentConfiguration,
ComponentProxyInvocationHandler proxyInvocationHandler,
ConfigurationInterceptorConfiguration config)
This constructor is protected to allow extension but not direct instantiation. |
Method Summary | |
void |
applyConfiguration()
Makes the current working configuration live. |
private void |
configureComponent(ComponentConfiguration newConfiguration)
Calls the lifecycle assistant to configure the component. |
Class[] |
getExposedInterfaces()
This implementation returns the ConfigurationInterceptor interface and the component's configuration interface |
ComponentConfiguration |
getLiveConfiguration()
This implementation returns a copy of the component's live configuration. |
ComponentConfiguration |
getWorkingConfiguration()
This implementation returns a copy of the component's working configuration. |
protected Object |
handleInvoke(Object proxy,
Method m,
Object[] args)
This implementation delegates to: The live configuration object when get methods are invoked on the configuration interface The working configuration object when set methods are invoked on the configuration interface This class for methods called on the ConfigurationInterceptor interface |
private void |
initializeWorkingConfiguration()
This method will create a working configuration if it does not exist |
Object |
invoke(Invocation invocation)
This implementation watches for calls to the configure lifecycle method. |
void |
nodeChanged(Node changedNode)
This implementation causes the component to be reconfigured if the interceptor is configured to auto refresh the component. |
void |
nodeRemoved(String removedNodeName)
This impelementation does nothing when a component's config is removed |
void |
persistConfiguration()
Persists the current live configuration in the Config Service. |
void |
refreshConfiguration()
Same as revertConfiguration, but the configuration node containing this component's configuration is refreshed first. |
void |
revertConfiguration()
Reverts the components live configuration back to its state as of the last call to persistConfiguration or the loading of the component if persistConfiguration was never called. |
void |
setComponentReference(Component component)
Called after creation to pass a reference to the component to each of its decorators. |
void |
setNextInterceptor(Interceptor interceptor)
This method sets the next interceptor as the next in the chain from the current interceptor. |
Methods inherited from class org.sape.carbon.core.util.reflection.GenericProxy |
invoke, proxyEquals, proxyHashCode, proxyToString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private org.apache.commons.logging.Log log
protected ComponentConfiguration liveConfiguration
protected ComponentConfiguration workingConfiguration
protected ComponentProxyInvocationHandler proxyInvocationHandler
protected Component thisComponent
protected Interceptor nextInterceptor
private Thread persistingThread
private static final String SET
private static final String GET
private static final String IS
private static final String CLONE
private static final String GET_DATA_STRUCTURE
private static final String SET_NAME
private static final Collection UNSUPPORTED_OPERATIONS
private static final Method CONFIGURE_METHOD
private static final Method INVOKE_METHOD
Constructor Detail |
protected DefaultConfigurationInterceptor(ComponentConfiguration componentConfiguration, ComponentProxyInvocationHandler proxyInvocationHandler, ConfigurationInterceptorConfiguration config)
ConfigurationInterceptorFactory
in this package.
componentConfiguration
- the configuration object this interceptor
will manageproxyInvocationHandler
- the proxy invocation handlerMethod Detail |
public Class[] getExposedInterfaces()
getExposedInterfaces
in interface Decorator
public void setNextInterceptor(Interceptor interceptor)
setNextInterceptor
in interface Interceptor
interceptor
- the next interceptor in the chainpublic void setComponentReference(Component component)
Decorator
setComponentReference
in interface Decorator
component
- a reference to the component that this interceptor is
assistingDecorator.setComponentReference(Component)
public void persistConfiguration() throws ConfigurationException
ConfigurationInterceptor
persistConfiguration
in interface ConfigurationInterceptor
ConfigurationException
- indictes an error persisting
the configurationConfigurationInterceptor.persistConfiguration()
public void revertConfiguration()
ConfigurationInterceptor
revertConfiguration
in interface ConfigurationInterceptor
ConfigurationInterceptor.revertConfiguration()
public void applyConfiguration()
ConfigurationInterceptor
applyConfiguration
in interface ConfigurationInterceptor
ConfigurationInterceptor.applyConfiguration()
public ComponentConfiguration getWorkingConfiguration()
getWorkingConfiguration
in interface ConfigurationInterceptor
ConfigurationInterceptor.getWorkingConfiguration()
public ComponentConfiguration getLiveConfiguration()
getLiveConfiguration
in interface ConfigurationInterceptor
ConfigurationInterceptor.getWorkingConfiguration()
public void refreshConfiguration()
ConfigurationInterceptor
refreshConfiguration
in interface ConfigurationInterceptor
ConfigurationInterceptor.refreshConfiguration()
public Object invoke(Invocation invocation) throws Throwable
invoke
in interface Interceptor
invocation
- the invocation to execute
Throwable
- indicates an error with the configruationpublic void nodeChanged(Node changedNode)
nodeChanged
in interface NodeEventListener
changedNode
- node that was changedpublic void nodeRemoved(String removedNodeName)
nodeRemoved
in interface NodeEventListener
removedNodeName
- name of the removed nodeprotected Object handleInvoke(Object proxy, Method m, Object[] args) throws Throwable
handleInvoke
in class GenericProxy
proxy
- dynamic proxym
- method to be invokedargs
- the arguments to pass to the method
UnsupportedOperationException
- if method getDataStructure,
clone, or setName is called
ConfigurationInterceptorException
- if the Method m is not
assignable from ConfigurationInterceptor or the component's
configuration interface
Throwable
- indicates a generic error in the invocation chainprivate void initializeWorkingConfiguration()
private void configureComponent(ComponentConfiguration newConfiguration)
newConfiguration
- the new config to pass to the component
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |