commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rahul Akolkar" <rahul.akol...@gmail.com>
Subject Re: [SCXML] Want to access payload associated with a TriggerEvent
Date Fri, 08 Sep 2006 20:56:19 GMT
On 9/8/06, Madhwaraj Rao <madhwaraj_rao@yahoo.com> wrote:
> Hi,
>
> I am trying to access the payload associated with a
> TriggerEvent in the EntryListener.onEntry() method. Is
> this possible?
<snip/>

No. The event payload is meant to be accessible only within
(expressions within) the SCXML document, and only for the duration the
event is being triggered, no longer.

As an aside, if you want the payload to persist, or be available in
the environment the executor instance is in, you can write (<assign>)
the needed bits to the root context, which serves as the bridge
between the state machine instance and the environment (therefore,
data can be "shared" across either sides).


> For example,
> I fire an event as:
> stopWatch.fireEvent(StopWatch.EVENT_UNSPLIT, new
> String("Unsplit Object"));
>
> and in my registered EntryListener.onEntry() method I
> need to access the payload corressponding to the event
> that caused a transition to the current state (that I
> entered).
>
> How do I access the payload corressponding to the
> event "watch.unsplit"?
>
> When I look in the SCXMLExecutor code, there is a
> hierarchy of Hashmaps, the first of which needs to be
> accesed by a private member (EVENT_DATA_MAP). This
> Hashmap contains the payload keyed by the event name.
>
> How can I access the secondary Hashmap from the
> AbstractStateMachine? Or is there a better way to
> doing this?
>
<snap/>

The AbstractStateMachine used by the StopWatch example demonstrates
one particular Commons SCXML usage pattern -- probably the simplest --
and the SCXMLListener (here, EntryListener) is generally usually used
in conjunction with one or more other interaction patterns. I suggest
looking at the other patterns [1] and usecases [2],[3] to see what
best fits your needs.

-Rahul

[1] http://jakarta.apache.org/commons/scxml/guide/using-commons-scxml.html
[2] http://jakarta.apache.org/commons/scxml/usecases.html
[3] http://issues.apache.org/jira/browse/SCXML-20 (see attachment
scxmlservlet.war)


> Thanks,
> --
> Raj
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message