All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sunw.demo.encapsulatedEvents.EncapsulatedEventAdaptor

java.lang.Object
   |
   +----sunw.demo.encapsulatedEvents.EncapsulatedEventAdaptor

public abstract class EncapsulatedEventAdaptor
extends Object

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.

See Also:
also, also, also, also

Variable Index

 o addAdaptorMethod
The Event Source's addListener method
 o listeners
 o removeAdaptorMethod
The Event Source's removeListener method
 o source
The Event Source

Constructor Index

 o EncapsulatedEventAdaptor()

default constructor.

Method Index

 o addAdaptorToSource()
Adds this Adaptor to the Event Source
 o addEncapsulatedEventListener(EncapsulatedEventListener)
 o fire(EventObject, Method)

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.

 o fire(Object[], Method)

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.

 o getEncapsulatedEventAdaptor(Class, Object)
Generate an Adaptor instance for the Listener Interface and Event Source
 o getEncapsulatedEventAdaptorClass(Class)
 o getEncapsulatedListenerCount()
 o getEncapsulatedListeners()
 o getListenerClass()
 o getListenerClassName()
 o getSource()
 o handleEncapsulatedEventException(EncapsulatedEventException, EncapsulatedEventListener, Method)

EncapsulatedEventListener's may raise exceptions to the originating event source through an adaptor by throwing the actual exception within an instance of EncapsulatedEventException.

 o removeAdaptorFromSource()
Removes this Adaptor instance from the Event Source
 o removeEncapsulatedEventListener(EncapsulatedEventListener)
 o setSource(Object)

setSource sets the adaptor instance to listen to the specified source.

Variables

 o source
 protected Object source
The Event Source

 o addAdaptorMethod
 protected Method addAdaptorMethod
The Event Source's addListener method

 o removeAdaptorMethod
 protected Method removeAdaptorMethod
The Event Source's removeListener method

 o listeners
 protected Vector listeners

Constructors

 o EncapsulatedEventAdaptor
 protected EncapsulatedEventAdaptor()

default constructor.

Methods

 o getEncapsulatedEventAdaptor
 public static EncapsulatedEventAdaptor getEncapsulatedEventAdaptor(Class lc,
                                                                    Object s) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IntrospectionException
Generate an Adaptor instance for the Listener Interface and Event Source

Parameters:
lc - The java.lang.Class object for the listener to adapt.
s - The source object that the adaptor will listen to.
Returns:
The newly instantiated dynamic adaptor
 o getEncapsulatedEventAdaptorClass
 public static Class getEncapsulatedEventAdaptorClass(Class lc) throws ClassNotFoundException
Parameters:
lc - The java.lang.Class object for the listener to adapt.
Returns:
The Class object for the newly generated dynamic adaptor class.
 o getListenerClass
 public abstract Class getListenerClass()
Returns:
the java.lang.Class object for the java.util.EventListener subinterface this instance adapts.
 o getListenerClassName
 public String getListenerClassName()
Returns:
the name of the java.util.EventListener subinterface this instance adapts.
 o getSource
 public synchronized Object getSource()
Returns:
the event source object that this instance is adapting.
 o setSource
 public synchronized void setSource(Object s) throws IntrospectionException, 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.

Parameters:
s - the prospective event source.
 o addEncapsulatedEventListener
 public void addEncapsulatedEventListener(EncapsulatedEventListener el)
Parameters:
el - Adds the EncapsulatedEventListener to the listeners for this adaptor
 o removeEncapsulatedEventListener
 public void removeEncapsulatedEventListener(EncapsulatedEventListener el)
Parameters:
el - Removes the EncapsulatedEventListener to the listeners for this adaptor
 o getEncapsulatedListenerCount
 public int getEncapsulatedListenerCount()
Returns:
s number of listeners currently registered
 o getEncapsulatedListeners
 public Vector getEncapsulatedListeners()
Returns:
s copy of listeners currently registered
 o fire
 protected void fire(EventObject e,
                     Method lm) throws 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.

Parameters:
e - The EventObject being encapsulated
lm - The jav.lang.reflect.Method describing the listener Method.
 o fire
 protected void fire(Object a[],
                     Method lm) throws 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.

Parameters:
a - The cracked Event arguments being encapsulated
lm - The jav.lang.reflect.Method describing the listener Method.
 o handleEncapsulatedEventException
 protected final void handleEncapsulatedEventException(EncapsulatedEventException ex,
                                                       EncapsulatedEventListener eel,
                                                       Method lm) throws 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.

Parameters:
ex - the exception thrown by the listener
eel - the listener instance that threw it
lm - the adaptors listener method that must re-raise it
 o addAdaptorToSource
 protected void addAdaptorToSource()
Adds this Adaptor to the Event Source

 o removeAdaptorFromSource
 protected void removeAdaptorFromSource()
Removes this Adaptor instance from the Event Source


All Packages  Class Hierarchy  This Package  Previous  Next  Index