You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Madhwaraj Rao <ma...@yahoo.com> on 2006/09/08 15:38:23 UTC

[SCXML] Want to access payload associated with a TriggerEvent

Hi,

I am trying to access the payload associated with a
TriggerEvent in the EntryListener.onEntry() method. Is
this possible?
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?

Thanks,
--
Raj

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: [SCXML] Want to access payload associated with a TriggerEvent

Posted by Rahul Akolkar <ra...@gmail.com>.
On 9/8/06, Madhwaraj Rao <ma...@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