ch.elca.el4j.services.gui.model.mixin
Class PropertyChangeListenerMixin

java.lang.Object
  extended by org.springframework.aop.support.IntroductionInfoSupport
      extended by org.springframework.aop.support.DelegatingIntroductionInterceptor
          extended by ch.elca.el4j.services.gui.model.mixin.PropertyChangeListenerMixin
All Implemented Interfaces:
SaveRestoreCapability, PropertyChangeListenerCapability, HibernateValidationCapability, Serializable, org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor, org.jdesktop.swingbinding.validation.ValidationCapability, DynamicIntroductionAdvice, IntroductionInfo, IntroductionInterceptor

public class PropertyChangeListenerMixin
extends DelegatingIntroductionInterceptor
implements PropertyChangeListenerCapability, SaveRestoreCapability, org.jdesktop.swingbinding.validation.ValidationCapability, HibernateValidationCapability

Mixin to enable javaBeans event support and validation in ordinary POJOs. To see each fired property change, set the log4j level for this class to debug It also contains a simple implementation of the SaveRestoreCapability. All Java bean properties of primitive or immutable (see IMMUTABLE_CLASSES) type can be saved and restored.

Author:
Stefan Wismer (SWI)
See Also:
Serialized Form
File-location:
PropertyChangeListenerMixin
Last check-in date:
2009-10-22 16:29:06 +0200 (Do, 22. Okt 2009) by swismer for revision 3979

Field Summary
protected  Map<Method,Object> m_backup
          The stored properties (a map containing the setter-method and its value).
protected  PropertyChangeSupport m_changeSupport
          The support for property change notification.
protected  org.hibernate.validator.ClassValidator m_classValidator
          Hibernate class validator.
protected  Map<Method,Method> m_methodCache
          Getter-to-setter/setter-to-getter method cache.
protected  boolean m_writeBack
          Should bean property be overwritten by proxied property to speed up following accesses?
 
Fields inherited from class org.springframework.aop.support.IntroductionInfoSupport
publishedInterfaces
 
Constructor Summary
PropertyChangeListenerMixin()
          The constructor.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
          
 void addPropertyChangeListener(String key, PropertyChangeListener l)
          
static
<T> List<T>
addPropertyChangeMixin(List<T> list)
          Wrap a list with the change tracking mixin.
static
<K,V> Map<K,V>
addPropertyChangeMixin(Map<K,V> map)
          Wrap a map with the change tracking mixin.
static
<T> T
addPropertyChangeMixin(T object)
          Wrap an object with the change tracking mixin.
protected  Object applyMixinToResult(Object object)
          Add property change listeners to result of method invocation.
protected  void firePropertyChange(String key, Object oldValue, Object newValue)
          
 org.hibernate.validator.ClassValidator getClassValidator()
          
protected  Method getGetter(Method setter)
           
protected  Method getSetter(Method getter)
           
 Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
          
 boolean isValid()
          
 boolean isValid(String property)
          
 void removePropertyChangeListener(PropertyChangeListener l)
          
 void removePropertyChangeListener(String key, PropertyChangeListener l)
          
 void restore()
          Restore all the writable java bean properties.
 void save()
          Save all the writable java bean properties.
 
Methods inherited from class org.springframework.aop.support.DelegatingIntroductionInterceptor
doProceed
 
Methods inherited from class org.springframework.aop.support.IntroductionInfoSupport
getInterfaces, implementInterfacesOnObject, implementsInterface, isMethodOnIntroducedInterface, suppressInterface
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.aop.DynamicIntroductionAdvice
implementsInterface
 

Field Detail

m_writeBack

protected boolean m_writeBack
Should bean property be overwritten by proxied property to speed up following accesses? This field is intended to be overwritten by subclasses.


m_changeSupport

protected PropertyChangeSupport m_changeSupport
The support for property change notification.


m_methodCache

protected Map<Method,Method> m_methodCache
Getter-to-setter/setter-to-getter method cache.


m_backup

protected Map<Method,Object> m_backup
The stored properties (a map containing the setter-method and its value).


m_classValidator

protected org.hibernate.validator.ClassValidator m_classValidator
Hibernate class validator.

Constructor Detail

PropertyChangeListenerMixin

public PropertyChangeListenerMixin()
The constructor.

Method Detail

addPropertyChangeMixin

public static <T> T addPropertyChangeMixin(T object)
Wrap an object with the change tracking mixin.

Type Parameters:
T - the object class
Parameters:
object - the object to be wrapped
Returns:
the same object wrapped with a spring proxy that has the PropertyChangeListenerMixin as Advisor

addPropertyChangeMixin

public static <T> List<T> addPropertyChangeMixin(List<T> list)
Wrap a list with the change tracking mixin.

Type Parameters:
T - the object class
Parameters:
list - the list to be wrapped
Returns:
the corresponding ObservableList

addPropertyChangeMixin

public static <K,V> Map<K,V> addPropertyChangeMixin(Map<K,V> map)
Wrap a map with the change tracking mixin.

Type Parameters:
K - the key class of the map
V - the value class of the map
Parameters:
map - the map to be wrapped
Returns:
the corresponding ObservableMap

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)

Specified by:
addPropertyChangeListener in interface PropertyChangeListenerCapability
See Also:
PropertyChangeSupport.addPropertyChangeListener(PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)

Specified by:
removePropertyChangeListener in interface PropertyChangeListenerCapability
See Also:
PropertyChangeSupport.removePropertyChangeListener(PropertyChangeListener)

addPropertyChangeListener

public void addPropertyChangeListener(String key,
                                      PropertyChangeListener l)

Specified by:
addPropertyChangeListener in interface PropertyChangeListenerCapability
See Also:
PropertyChangeSupport.addPropertyChangeListener(String, PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(String key,
                                         PropertyChangeListener l)

Specified by:
removePropertyChangeListener in interface PropertyChangeListenerCapability
See Also:
PropertyChangeSupport.removePropertyChangeListener(String, PropertyChangeListener)

firePropertyChange

protected void firePropertyChange(String key,
                                  Object oldValue,
                                  Object newValue)


invoke

public Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
              throws Throwable

Specified by:
invoke in interface org.aopalliance.intercept.MethodInterceptor
Overrides:
invoke in class DelegatingIntroductionInterceptor
Throws:
Throwable

applyMixinToResult

protected Object applyMixinToResult(Object object)
Add property change listeners to result of method invocation.

Parameters:
object - the result of the method invocation
Returns:
the wrapped result

getGetter

protected Method getGetter(Method setter)
Parameters:
setter - the setter method
Returns:
the corresponding getter method

getSetter

protected Method getSetter(Method getter)
Parameters:
getter - the getter method
Returns:
the corresponding setter method

save

public void save()
Save all the writable java bean properties. Attention: Only Java bean properties of primitive or immutable (see IMMUTABLE_CLASSES) type can be saved and restored.

Specified by:
save in interface SaveRestoreCapability

restore

public void restore()
Restore all the writable java bean properties. Attention: Only Java bean properties of primitive or immutable (see IMMUTABLE_CLASSES) type can be saved and restored.

Specified by:
restore in interface SaveRestoreCapability

getClassValidator

public org.hibernate.validator.ClassValidator getClassValidator()

Specified by:
getClassValidator in interface HibernateValidationCapability
Returns:
the hibernate classValidator

isValid

public boolean isValid()

Specified by:
isValid in interface org.jdesktop.swingbinding.validation.ValidationCapability

isValid

public boolean isValid(String property)

Specified by:
isValid in interface org.jdesktop.swingbinding.validation.ValidationCapability


Copyright © 2005-2011 ELCA. All Rights Reserved.