com.iparelan.util.beans
Class BeanTools

java.lang.Object
  extended by com.iparelan.util.UtilObject
      extended by com.iparelan.util.beans.BeanTools

@Copyright(value="Copyright © 2008, Iparelan Solutions, LLC. All rights reserved.")
public final class BeanTools
extends UtilObject

This utility class contains JavaBeans convenience algorithms.

Version:
July 2008
Author:
Greg Mattes

Nested Class Summary
static class BeanTools.NonNullPropertyChangeEventValidator
          A pre-defined validator for PropertyChangeEvents.
private static class BeanTools.PropertyChangeableProxyInvocationHandler<T extends PropertyChangeable>
          An InvocationHandler bound to a proxied bean.
 
Field Summary
static ValidationStrategy<PropertyChangeEvent> NON_NULL_PROPERTY_CHANGE_EVENT_VALIDATOR
          A pre-fabricated validator for PropertyChangeEvents.
 
Fields inherited from class com.iparelan.util.UtilObject
LOGGER, MSGS, UTILITIES_LOGGER_NAME
 
Constructor Summary
BeanTools()
           
 
Method Summary
static
<T extends PropertyChangeable>
T
newPropertyChangeableProxy(T bean, PropertyChangeSupportFactory pcsFactory)
          Produces a dynamic proxy for a PropertyChangeable that intercepts PropertyChangeable method invocations and forwards them to a proxy PropertyChangeSupport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NON_NULL_PROPERTY_CHANGE_EVENT_VALIDATOR

public static final ValidationStrategy<PropertyChangeEvent> NON_NULL_PROPERTY_CHANGE_EVENT_VALIDATOR
A pre-fabricated validator for PropertyChangeEvents.

Constructor Detail

BeanTools

public BeanTools()
Method Detail

newPropertyChangeableProxy

public static <T extends PropertyChangeable> T newPropertyChangeableProxy(T bean,
                                                                          PropertyChangeSupportFactory pcsFactory)
Produces a dynamic proxy for a PropertyChangeable that intercepts PropertyChangeable method invocations and forwards them to a proxy PropertyChangeSupport.

This proxy makes it possible to override the behavior of the PropertyChangeSupport embedded in bean. For example, suppose that it is required that all PropertyChangeEvents are executed on the AWT/Swing Event Dispatch Thread (EDT). This proxy can enforce such a policy if pcsFactory creates PropertyChangeSupport that dispatches PropertyChangeEvents on the EDT.

Parameters:
bean - The JavaBean for which a dynamic proxy is created. May not be null.
pcsFactory - The PropertyChangeSupportFactory that produces a PropertyChangeSupport with desirable behaviors. May not be null.
Returns:
A dynamic proxy for bean that overrides embedded PropertyChangeSupport behavior with the behavior of a PropertyChangeSupport created with pcsFactory. Never null.
Throws:
ValidationException - Iff proxyType is neither a class, nor an interface.
IllegalArgumentException - Iff a valid proxy cannot be created. See the documentation for Proxy for more details.


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