|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sunw.demo.encapsulatedEvents.EncapsulatedEventAdaptor
sunw.demo.encapsulatedEvents.EncapsulatedEventAdaptor is an abstract base class designed to support the dynamic generation of java.util.EventListener sub-interface adaptor classes.
These dynamically generated adaptor classes can be used to take arbitrary events and "wrap" them in sunw.demo.encapsulatedEvent.EncapsulatedEvent objects. These "encapsulated" events are then fired on the sunw.demo.encapsulatedEventListener interface.
Using this dynamic adaptor class, objects that emits events on arbitrary` sub-interfaces of java.util.EventListener can be encapsulated and delivered onto a single EventListener interface, this allowing late binding of event behaviors and filtering applications.
Field Summary | |
protected java.lang.reflect.Method |
addAdaptorMethod
The Event Source's add |
protected java.util.Vector |
listeners
|
protected java.lang.reflect.Method |
removeAdaptorMethod
The Event Source's remove |
protected java.lang.Object |
source
The Event Source |
Constructor Summary | |
protected |
EncapsulatedEventAdaptor()
default constructor. |
Method Summary | |
protected void |
addAdaptorToSource()
Adds this Adaptor to the Event Source |
void |
addEncapsulatedEventListener(EncapsulatedEventListener el)
|
protected void |
fire(EventObject e,
java.lang.reflect.Method lm)
This method is called from simple EventListener method stubs of dynamic subclasses in order to create and EncapsulatedEvent and deliver it to the registered listeners. |
protected void |
fire(java.lang.Object[] a,
java.lang.reflect.Method lm)
This method is called from cracked EventListener method stubs of dynamic subclasses in order to create and EncapsulatedEvent and deliver it to the registered listeners. |
static EncapsulatedEventAdaptor |
getEncapsulatedEventAdaptor(java.lang.Class lc,
java.lang.Object s)
Generate an Adaptor instance for the Listener Interface and Event Source |
static java.lang.Class |
getEncapsulatedEventAdaptorClass(java.lang.Class lc)
|
int |
getEncapsulatedListenerCount()
|
java.util.Vector |
getEncapsulatedListeners()
|
abstract java.lang.Class |
getListenerClass()
|
java.lang.String |
getListenerClassName()
|
java.lang.Object |
getSource()
|
protected void |
handleEncapsulatedEventException(EncapsulatedEventException ex,
EncapsulatedEventListener eel,
java.lang.reflect.Method lm)
EncapsulatedEventListener's may raise exceptions to the originating event source through an adaptor by throwing the actual exception within an instance of EncapsulatedEventException. |
protected void |
removeAdaptorFromSource()
Removes this Adaptor instance from the Event Source |
void |
removeEncapsulatedEventListener(EncapsulatedEventListener el)
|
void |
setSource(java.lang.Object s)
setSource sets the adaptor instance to listen to the specified source. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected java.lang.Object source
protected java.lang.reflect.Method addAdaptorMethod
protected java.lang.reflect.Method removeAdaptorMethod
protected java.util.Vector listeners
Constructor Detail |
protected EncapsulatedEventAdaptor()
default constructor.
Method Detail |
public static EncapsulatedEventAdaptor getEncapsulatedEventAdaptor(java.lang.Class lc, java.lang.Object s) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException, java.beans.IntrospectionException
lc
- The java.lang.Class object for the listener to adapt.s
- The source object that the adaptor will listen to.public static java.lang.Class getEncapsulatedEventAdaptorClass(java.lang.Class lc) throws java.lang.ClassNotFoundException
lc
- The java.lang.Class object for the listener to adapt.public abstract java.lang.Class getListenerClass()
public java.lang.String getListenerClassName()
public java.lang.Object getSource()
public void setSource(java.lang.Object s) throws java.beans.IntrospectionException, java.lang.Exception
setSource sets the adaptor instance to listen to the specified source. This operation will fail if the source does not emit events on the EventListener subinterface this adaptor implements.
s
- the prospective event source.public void addEncapsulatedEventListener(EncapsulatedEventListener el)
el
- Adds the EncapsulatedEventListener to the listeners for this adaptorpublic void removeEncapsulatedEventListener(EncapsulatedEventListener el)
el
- Removes the EncapsulatedEventListener to the listeners for this adaptorpublic int getEncapsulatedListenerCount()
public java.util.Vector getEncapsulatedListeners()
protected void fire(EventObject e, java.lang.reflect.Method lm) throws java.lang.Exception
This method is called from simple EventListener method stubs of dynamic subclasses in order to create and EncapsulatedEvent and deliver it to the registered listeners.
e
- The EventObject being encapsulatedlm
- The jav.lang.reflect.Method describing the listener Method.protected void fire(java.lang.Object[] a, java.lang.reflect.Method lm) throws java.lang.Exception
This method is called from cracked EventListener method stubs of dynamic subclasses in order to create and EncapsulatedEvent and deliver it to the registered listeners.
a
- The cracked Event arguments being encapsulatedlm
- The jav.lang.reflect.Method describing the listener Method.protected final void handleEncapsulatedEventException(EncapsulatedEventException ex, EncapsulatedEventListener eel, java.lang.reflect.Method lm) throws java.lang.Exception
EncapsulatedEventListener's may raise exceptions to the originating event source through an adaptor by throwing the actual exception within an instance of EncapsulatedEventException.
This method is called to verify that it is allowable to re-raise the exception from the adaptor to the source, by checking that the listener method on the adaptor that the source delivered the original event to is permitted to throw such an exception, otherwise a RuntimeException is raised.
ex
- the exception thrown by the listenereel
- the listener instance that threw itlm
- the adaptors listener method that must re-raise itprotected void addAdaptorToSource()
protected void removeAdaptorFromSource()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |