|
|||||||||||
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.component.proxy.DefaultComponentProxyInvocationHandler
Provides the glue for the Component, and supporting container functionality.
DefaultComponentProxyInvocationHandler
is a Dynamic Proxy
Invocation Handler. Its job is to masquerade as either the Component, or
any one of a number of container-feature-providers. called 'Assistants'.
Mappings from interfaces to delegates (being the component instance, or
interceptor instances) are stored. Invocations on those interfaces are passed
to the corresponding delegates. In addition, Assistants may listen for
ProxyEvent
s - which are distributed immediately before and after
an invocation being passed to a delegate. Listeners are notified in the order
they are registered, according to the ComponentTemplateConfiguration
.
Copyright 2002 Sapient
Proxy
,
Decorator
,
Interceptor
,
ComponentTemplateConfiguration
Field Summary | |
protected String |
componentName
The name of wrapped component. |
protected Map |
delegatesByInterface
Map of interfaces to their respective delegates. |
protected FunctionalInterface |
functionalImplementation
The implementation of the true component. |
private static Method |
GET_COMPONENT_NAME_METHOD
Method that gets the component name if such method exists. |
protected Interceptor |
headInterceptor
A reference to the first interceptor in the chain. |
protected List |
interceptors
This list is a list of interceptors that will be called in the execution of the represented component. |
private org.apache.commons.logging.Log |
log
Provides a handle to Apache-commons logger. |
private ReadWriteLock |
monitor
The monitor object that coordinates read/write calls to the represented component. |
Fields inherited from class org.sape.carbon.core.util.reflection.GenericProxy |
|
Constructor Summary | |
DefaultComponentProxyInvocationHandler()
|
Method Summary | |
void |
addDecorator(Decorator decorator)
Method used during creation of the proxy object to add Assistants to the component. |
protected void |
addDelegate(Class[] representedInterfaces,
Object delegate)
Add a delegate. |
private void |
addInterceptor(Interceptor interceptor)
Adds an interceptor the chain. |
String |
getComponentName()
Gets the component name. |
Object |
getDelegate(Class delegateInterface)
Gets the delegate based on the given interface. |
ReadWriteLock |
getMonitor()
Gets the read-lock monitor. |
protected Object |
handleInvoke(Object proxy,
Method method,
Object[] args)
This method implements the delegation model for the represented component. |
protected String |
proxyToString(Object proxy)
Returns out the name of the component |
void |
setComponentName(String componentName)
Sets the name of the component. |
void |
setFunctionalImplementation(Class[] implementedInterfaces,
FunctionalInterface functionalImplementation)
Method used during creation of the proxy object to add the functional implementation to the component. |
Methods inherited from class org.sape.carbon.core.util.reflection.GenericProxy |
invoke, proxyEquals, proxyHashCode |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.lang.reflect.InvocationHandler |
invoke |
Field Detail |
protected Map delegatesByInterface
protected List interceptors
protected Interceptor headInterceptor
private static Method GET_COMPONENT_NAME_METHOD
private org.apache.commons.logging.Log log
private final ReadWriteLock monitor
protected FunctionalInterface functionalImplementation
protected String componentName
Constructor Detail |
public DefaultComponentProxyInvocationHandler()
Method Detail |
public void addDecorator(Decorator decorator)
addDecorator
in interface ComponentProxyInvocationHandler
ComponentFactory
public void setFunctionalImplementation(Class[] implementedInterfaces, FunctionalInterface functionalImplementation)
setFunctionalImplementation
in interface ComponentProxyInvocationHandler
implementedInterfaces
- all the interfaces (including
super interfaces) implemented by functionalImplementation's
FunctionalInterfacefunctionalImplementation
- the object that implements the
components FunctionalInterfaceComponentFactory
protected void addDelegate(Class[] representedInterfaces, Object delegate)
representedInterfaces
- an array of interfaces for which this
delegate may be invokeddelegate
- an instance of the delegate to be delegated toprivate void addInterceptor(Interceptor interceptor)
interceptor
- the interceptor to addpublic Object getDelegate(Class delegateInterface)
getDelegate
in interface ComponentProxyInvocationHandler
delegateInterface
- the interface to get the delegate for
public ReadWriteLock getMonitor()
getMonitor
in interface ComponentProxyInvocationHandler
public String getComponentName()
getComponentName
in interface ComponentProxyInvocationHandler
public void setComponentName(String componentName)
setComponentName
in interface ComponentProxyInvocationHandler
componentName
- the name of the componentprotected Object handleInvoke(Object proxy, Method method, Object[] args) throws Throwable
handleInvoke
in class GenericProxy
proxy
- the object that is being representedmethod
- the method descriptor for the method calledargs
- an array of arguments passed to that method
Throwable
- when there is an exception thrown from the
delegated method. This may be a Checked
exception if the implemented interface declares
the exception. Otherwise checked exceptions will
be automatically wrapped in an
UndeclaredThrowableException
.
Runtime exceptions are thrown as is.protected String proxyToString(Object proxy)
proxyToString
in class GenericProxy
proxy
- the proxy object to toString
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |