|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jbpm.wire.binding.SubscribeBinding
public class SubscribeBinding
This Binding
specifies a SubscribeOperation
(subscription to an Observable object).
A subscription is defined by a <subscribe>
xml element.
This element can have a "context" attribute.
The value of this attribute should be the name of a WireContext
in the object's environment.
This WireContext will be used to find the Observable to listen.
If this attribute is not present, the object's WireContext will be used.
This element can have a "event" or "events" attribute. The value of this attribute specifies the list of events name that should be observed. Other events are filtered. If this attribute if not present, all events are observed.
This element can have a "object" or "objects" attribute. The value of this attribute specifies the list of objects that should be observed. If this attribute if not present, the WireContext specified by the "context" attribute is observed.
This element can have a "to" attribute. If this attribute is set to "wire-events", the object will listen to the events fired by the descriptor of the target object. Otherwise, it will listen to the events fired by the target object (which must be an instance of Observable).
This element can have a "method" attribute.
If this attribute is not present, this operation must be applied to a Listener
object.
If this attribute is present, the specified method will be invoked each time the specified events are received.
Arguments given to the method invocation are specified in the <arg> child elements of the <subscribe> element.
For more information on how to declare arguments, see ArgDescriptor
.
<objects> <object name='o' class='Listener'> <subscribe context='contextName' /> </object> </objects>In this example, the object 'o' will observe all events of the WireContext named 'contextName'.
<objects> <object name='l' class='Listener'> <subscribe objects='a, c' /> </object> <object name='a' class='Observable' /> <object name='b' class='Observable' /> <object name='c' class='Observable' /> </objects>In this example, the object 'l' will observe all events from 'a' and 'c', but not events fired by 'b'.
<objects> <object name='l' class='Listener'> <subscribe object='a' event='start'/> </object> <object name='a' class='Observable' /> </objects>In this example, the object 'l' will observe the 'start' event from 'a', but not other events (for example a 'stop' event won't be observed).
public class Foo { void logEvent(String name) { System.out.println("Object " + name + " sent an event."); } }With the following definition:
<objects> <object name='l' class='Foo'> <subscribe object='a' method='logEvent' > <arg> <string value='a'/> </arg> </subscribe> <subscribe object='b' method='logEvent' > <arg> <string value='b'/> </arg> </subscribe> </object> <object name='a' class='Observable' /> <object name='b' class='Observable' /> </objects>When 'a' fires an event,
logEvent("a")
will be invoked;
when 'b' fires an event, logEvent("b")
will be invoked.
Constructor Summary | |
---|---|
SubscribeBinding()
|
Method Summary | |
---|---|
java.lang.Object |
parse(org.w3c.dom.Element element,
Parse parse,
Parser parser)
translates the given element into a domain model java object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SubscribeBinding()
Method Detail |
---|
public java.lang.Object parse(org.w3c.dom.Element element, Parse parse, Parser parser)
Binding
parse
in interface Binding
Parser
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |