|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openpermis.editor.policy.beans.PropertyChangeDispatcher
public class PropertyChangeDispatcher
Dispatcher for property change events.
Create a dispatcher for a bean and a target class which contains PropertyChange
annotations and the dispatcher will automatically dispatch property change events properly.
The dispatcher expects the following signuare:
@PropertyChange(bean=MyBean.class, property="someProperty", parameter=MyValue.class) public someChangeHandler (MyBean source, String property, MyValue oldValue, MyValue newValue) { ... }
The first parameter has to be the source of the property change event and must match the
bean class of the PropertyChange
annotation. Parameters two and three correspond to
the old and new value received in the property change event and must match the parameter
class of the PropertyChange
annotation.
The dispatcher will perform the casts necessary automatically and throw
ClassCastException
s if the cast is not possible. This should not occur unless the
bean sends invalid property change notifications since the parameter types are checked when
the dispatcher is created.
Field Summary | |
---|---|
private Object |
bean
The bean this support class operates on. |
private Object |
lastPropagationId
Cache for the last propagation ID encountered. |
private static org.slf4j.Logger |
LOGGER
The logger object of this class. |
private Map<String,Method> |
methods
The target to dispatch property change events to. |
private boolean |
registered
Indicates if the support class is registered at its bean. |
private Object |
target
The target to dispatch property change events to. |
private static boolean |
TRACE
Verbose debug output flag. |
Constructor Summary | |
---|---|
PropertyChangeDispatcher(Object bean,
Object target)
Creates a bean support object for the specified Java Bean. |
Method Summary | |
---|---|
void |
dispose()
Disposes this bean support instance. |
protected Object |
getBean()
Returns the Java Bean this bean support operates on. |
protected Method |
getPropertyChangeMethod(String property)
Returns the method to execute for property changes on the specified property. |
protected Object |
getTarget()
Returns the target to dispatch property change events to. |
boolean |
isActive()
Check if the dispatcher is active or has been disposed. |
void |
propertyChange(PropertyChangeEvent event)
Listener for property changes. |
protected void |
setActive(boolean active)
Sets the internal flag which indicates if this bean support is active. |
protected void |
warn(String message,
Throwable cause)
Logs a warning with the specified message and cause. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final org.slf4j.Logger LOGGER
private static final boolean TRACE
false
private final Object bean
private final Object target
private final Map<String,Method> methods
private boolean registered
private Object lastPropagationId
Constructor Detail |
---|
public PropertyChangeDispatcher(Object bean, Object target)
bean
- the Java Bean to operate on, must not be null
.target
- the target to dispatch property change events to, must not be null
.Method Detail |
---|
protected final Object getBean()
null
.protected final Object getTarget()
null
.protected final Method getPropertyChangeMethod(String property)
property
- the property for which to find the method.
null
if there is none.protected final void setActive(boolean active)
active
- the new registered flag value.dispose()
,
isActive()
public boolean isActive()
dispose()
true
if the dispatcher is active and dispatches events,
false
if it has been disposed
.public void dispose()
Once disposed you may no longer execute property methods on it.
isActive()
protected void warn(String message, Throwable cause)
message
- the message to log.cause
- the cause.public void propertyChange(PropertyChangeEvent event)
Dispatches to methods annotated with PropertyChange
on the target of this
bean support instance.
propertyChange
in interface PropertyChangeListener
event
- the property change event to dispatch.
|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
PERMIS Role Based Access Control 0.3.0 (Build 14)
2009/05/08 09:06:48
Copyright (c) 2002-2007 Ergon Informatik AG