com.iparelan.util.beans
Class BeanTools.PropertyChangeableProxyInvocationHandler<T extends PropertyChangeable>

java.lang.Object
  extended by com.iparelan.util.beans.BeanTools.PropertyChangeableProxyInvocationHandler<T>
Type Parameters:
T - The proxied JavaBean type.
All Implemented Interfaces:
PropertyChangeListener, InvocationHandler, EventListener
Enclosing class:
BeanTools

private static final class BeanTools.PropertyChangeableProxyInvocationHandler<T extends PropertyChangeable>
extends Object
implements InvocationHandler, PropertyChangeListener

An InvocationHandler bound to a proxied bean. The InvocationHandler intercepts PropertyChangeable method invocations on the bean as well as PropertyChangedEvents fired by the bean.

PropertyChangeable methods are intercepted and forwarded to a proxied com.iparelan.util.beans.PropertyChangeSupport. PropertyChangedEvents are re-fired to listeners. The re-fired events appear to come from the proxy, not the proxied bean.

Note: Ordinarly, an InvocationHandler may be bound to several proxies. This InvocationHandler is designed to be bound to a single bean proxy and a single proxied PropertyChangeSupport.


Field Summary
private  AtomicBoolean enforceSingleInitializationDynamically
           
private  PropertyChangeSupport pcsProxy
           
private  T proxiedBean
           
private  WeakReference<T> proxy
           
 
Constructor Summary
BeanTools.PropertyChangeableProxyInvocationHandler(T proxiedBean)
           
 
Method Summary
 Object invoke(Object theProxy, Method beanMethod, Object[] args)
           
 void propertyChange(PropertyChangeEvent evt)
           
private  void setProxies(T proxy, PropertyChangeSupport pcsProxy)
          Code that would ideally be initalization code but cannot be due to an ordering dependency.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

enforceSingleInitializationDynamically

private final AtomicBoolean enforceSingleInitializationDynamically

proxiedBean

private final T extends PropertyChangeable proxiedBean

pcsProxy

private PropertyChangeSupport pcsProxy

proxy

private WeakReference<T extends PropertyChangeable> proxy
Constructor Detail

BeanTools.PropertyChangeableProxyInvocationHandler

BeanTools.PropertyChangeableProxyInvocationHandler(T proxiedBean)
Method Detail

setProxies

private void setProxies(T proxy,
                        PropertyChangeSupport pcsProxy)
Code that would ideally be initalization code but cannot be due to an ordering dependency. The proxy must be created with an invocation handler, but the proxy is need by the invocation handler. The order is: create the invocation handler, then create the proxy, finally pass the proxy to the invocation handler with this method.

Parameters:
proxy - The proxy for the bean.
pcsProxy - The com.iparelan.util.beans.PropertyChangeSupport proxy for the bean.

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

invoke

public Object invoke(Object theProxy,
                     Method beanMethod,
                     Object[] args)
Specified by:
invoke in interface InvocationHandler


Copyright © 2008 Iparelan Solutions, LLC. All rights reserved.