EventHandler
is to extract a property value from the first argument of the method in the listener interface (typically an event object) and use it to set the value of a property in the target object. In the following example we create an ActionListener
that sets the nextFocusableComponent
property of the target (myButton) object to the value of the "source" property of the event. This would correspond to the following inner class implementation:EventHandler.create(ActionListener.class, myButton, "nextFocusableComponent", "source")
It's also possible to create an//Equivalent code using an inner class instead of EventHandler. new ActionListener() { public void actionPerformed(ActionEvent e) { myButton.setNextFocusableComponent((Component)e.getSource()); } }
EventHandler
that just passes the incoming event object to the target's action. If the fourth EventHandler.create
argument is an empty string, then the event is just passed along: This would correspond to the following inner class implementation:EventHandler.create(ActionListener.class, target, "doActionEvent", "")
Probably the most common use of//Equivalent code using an inner class instead of EventHandler. new ActionListener() { public void actionPerformed(ActionEvent e) { target.doActionEvent(e); } }
EventHandler
is to extract a property value from the source of the event object and set this value as the value of a property of the target object. In the following example we create an ActionListener
that sets the "label" property of the target object to the value of the "text" property of the source (the value of the "source" property) of the event. This would correspond to the following inner class implementation:EventHandler.create(ActionListener.class, myButton, "label", "source.text")
The event property may be "qualified" with an arbitrary number of property prefixes delimited with the "." character. The "qualifying" names that appear before the "." characters are taken as the names of properties that should be applied, left-most first, to the event object.//Equivalent code using an inner class instead of EventHandler. new ActionListener { public void actionPerformed(ActionEvent e) { myButton.setLabel(((JTextField)e.getSource()).getText()); } }
For example, the following action listener
might be written as the following inner class (assuming all the properties had canonical getter methods and returned the appropriate types):EventHandler.create(ActionListener.class, target, "a", "b.c.d")
The target property may also be "qualified" with an arbitrary number of property prefixs delimited with the "." character. For example, the following action listener://Equivalent code using an inner class instead of EventHandler. new ActionListener { public void actionPerformed(ActionEvent e) { target.setA(e.getB().getC().isD()); } }
EventHandler.create(ActionListener.class, target, "a.b", "c.d")might be written as the following inner class (assuming all the properties had canonical getter methods and returned the appropriate types):
//Equivalent code using an inner class instead of EventHandler. new ActionListener { public void actionPerformed(ActionEvent e) { target.getA().setB(e.getC().isD()); } }
As EventHandler
ultimately relies on reflection to invoke a method we recommend against targeting an overloaded method. For example, if the target is an instance of the class MyTarget
which is defined as:
public class MyTarget { public void doIt(String); public void doIt(Object); }Then the method
doIt
is overloaded. EventHandler will invoke the method that is appropriate based on the source. If the source is null, then either method is appropriate and the one that is invoked is undefined. For that reason we recommend against targeting overloaded methods.
@see java.lang.reflect.Proxy
@see java.util.EventObject
@since 1.4
@author Mark Davidson
@author Philip Milne
@author Hans Muller
@version 1.21, 05/23/06
Some events can be triggered at discrete times as an ODE problem is solved. This occurs for example when the integration process should be stopped as some state is reached (G-stop facility) when the precise date is unknown a priori, or when the derivatives have discontinuities, or simply when the user wants to monitor some states boundaries crossings.
These events are defined as occurring when a g
switching function sign changes.
Since events are only problem-dependent and are triggered by the independent time variable and the state vector, they can occur at virtually any time, unknown in advance. The integrators will take care to avoid sign changes inside the steps, they will reduce the step size when such an event is detected in order to put this event exactly at the end of the current step. This guarantees that step interpolation (which always has a one step scope) is relevant even in presence of discontinuities. This is independent from the stepsize control provided by integrators that monitor the local error (this event handling feature is available for all integrators, including fixed step ones).
@version $Revision: 1067500 $ $Date: 2011-02-05 21:11:30 +0100 (sam. 05 févr. 2011) $ @since 1.2Some events can be triggered at discrete times as an ODE problem is solved. This occurs for example when the integration process should be stopped as some state is reached (G-stop facility) when the precise date is unknown a priori, or when the derivatives have discontinuities, or simply when the user wants to monitor some states boundaries crossings.
These events are defined as occurring when a g
switching function sign changes.
Since events are only problem-dependent and are triggered by the independent time variable and the state vector, they can occur at virtually any time, unknown in advance. The integrators will take care to avoid sign changes inside the steps, they will reduce the step size when such an event is detected in order to put this event exactly at the end of the current step. This guarantees that step interpolation (which always has a one step scope) is relevant even in presence of discontinuities. This is independent from the stepsize control provided by integrators that monitor the local error (this event handling feature is available for all integrators, including fixed step ones).
@since 1.2EventHandler
takes care of processing specific events in an event-based architecture. The interface design is heavily influenced by Matt Welsh's SandStorm server, his demonstration of the SEDA architecture. We have deviated where we felt the design differences where better.
@author Avalon Development TeamEvent handlers have an {@link EventType}. {@link EventType} is a list of ALL handler event types. We need to keepa full list in one place -- and as enums is a good shorthand for an implemenations -- because event handlers can be passed to executors when they are to be run asynchronously. The hbase executor, see ExecutorService, has a switch for passing event type to executor.
Event listeners can be installed and will be called pre- and post- process if this EventHandler is run in a Thread (its a Runnable so if its {@link #run()}method gets called). Implement {@link EventHandlerListener}s, and registering using {@link #setListener(EventHandlerListener)}. @see ExecutorService
As the content diff recurses down the content tree, it will call the {@link #getChildHandler(String,NodeState,NodeState)} method tospecialize the handler instance for each node under which changes are detected. The other handler methods always apply to the properties and direct children of the node for which that handler instance is specialized. The handler is expected to keep track of contextual information like the path or identifier of the current node based on the sequence of those specialization calls.
All names and paths passed to handler methods use unmapped Oak names.
The following features are supported:
Consult the OpenLayers API documentation at the OpenLayers site to see which objects fire events (e.g. Map, Layer, etc) and which events they fire (e.g. "addlayer" fired by Map).
GWT OpenLayers provides a higher level way to register events through addXxxListener methods, which are easier to use, and which provide type-safety. However, these may not be implemented for all events in OpenLayers. The addXxxListener methods are methods on the Object firing the event:
map.addMapMoveListener(new MapMoveListener() { public void onMapMove(MapMoveEvent eventObject) { //handler code here } })@author Erdem Gunay @author Edwin Commandeur
{@code EventHandler} objects are registered with the Framework serviceregistry and are notified with an {@code Event} object when an event is sentor posted.
{@code EventHandler} objects can inspect the received {@code Event} object todetermine its topic and properties.
{@code EventHandler} objects must be registered with a service property{@link EventConstants#EVENT_TOPIC} whose value is the list of topics in whichthe event handler is interested.
For example:
String[] topics = new String[] {"com/isv/*"}; Hashtable ht = new Hashtable(); ht.put(EventConstants.EVENT_TOPIC, topics); context.registerService(EventHandler.class.getName(), this, ht);Event Handler services can also be registered with an {@link EventConstants#EVENT_FILTER} service property to further filter theevents. If the syntax of this filter is invalid, then the Event Handler must be ignored by the Event Admin service. The Event Admin service should log a warning.
Security Considerations. Bundles wishing to monitor {@code Event} objectswill require {@code ServicePermission[EventHandler,REGISTER]} to register an{@code EventHandler} service. The bundle must also have{@code TopicPermission[topic,SUBSCRIBE]} for the topic specified in the eventin order to receive the event. @see Event @ThreadSafe @author $Id: 44528634004c1b036551712f94703a8b5a55cba4 $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|