You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Daniel Luis dos Santos <da...@gmail.com> on 2011/10/03 15:17:54 UTC

[scxml] invoking methods on an object

Hello,

I am beggining to use commons-SCXML. For now I created a generic class that wraps the library's code just like the class AbstractStateMachine in the stopwatch example.

Each class from my application that will be governed by a state machine has an instance of this, and has methods to trigger events on it.
What I want to do is have methods from the object be called from state machine events. For example, when I enter a state I want to be able to call a method on the stateful object.

I am trying to use invoke inside <onentry> but the markup is ignored. How can I do this ?

I am using version 0.9 from maven central.

Thanks
Daniel Santos


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


Re: [scxml] invoking methods on an object

Posted by Rahul Akolkar <ra...@gmail.com>.
On Mon, Oct 3, 2011 at 7:07 PM, Daniel Luis dos Santos
<da...@gmail.com> wrote:
> Hi,
>
> Ok invoke is another thing. Meanwhile I did write some custom actions. What I am doing is trying to call the object from within the actions.
> I managed to get an instance to the object by passing a reference to it in the event trigger method in my client code. I then access the parent context inside the custom action and get the '_eventdata' object.
>
<snip/>

OK.


> I was trying to define a variable with the <var> element inside the <onentry> element but the engine warned me it was ignoring it. Do you know why ? I saw in the datamodel section of the site that you can define them. (Although there is not a word of it in the 2011 w3c spec)
>
<snap/>

It was removed from the spec, but is supported by Commons SCXML in its
own namespace. For example, assume the cs prefix is bound like so:

  <?xml version="1.0"?>
  <scxml xmlns="http://www.w3.org/2005/07/scxml"
              xmlns:cs="http://commons.apache.org/scxml"
       ... >

Then you may use var like so:

  <cs:var ... />

-Rahul


> Sorry for my ignorance and dumb questions but I am very new to all this.
>
> Thanks
> Daniel Santos
>
>
>
>
> On Oct 3, 2011, at 11:55 PM, Rahul Akolkar wrote:
>
>> On Mon, Oct 3, 2011 at 9:17 AM, Daniel Luis dos Santos
>> <da...@gmail.com> wrote:
>>> Hello,
>>>
>>> I am beggining to use commons-SCXML. For now I created a generic class that wraps the library's code just like the class AbstractStateMachine in the stopwatch example.
>>>
>>> Each class from my application that will be governed by a state machine has an instance of this, and has methods to trigger events on it.
>> <snip/>
>>
>> Note that the AbstractStateMachine pattern is a starter pattern and is
>> limited if used in isolation. More patterns here:
>>
>>  http://commons.apache.org/scxml/guide/using-commons-scxml.html
>>
>>
>>> What I want to do is have methods from the object be called from state machine events. For example, when I enter a state I want to be able to call a method on the stateful object.
>>>
>>> I am trying to use invoke inside <onentry> but the markup is ignored. How can I do this ?
>>>
>> <snap/>
>>
>> If you're talking about the <invoke> element, that is not an action
>> (its a child of state not onentry) and requires Invoker
>> implementations to be registered with the executor for each "type" of
>> invoke.
>>
>> If you want to call arbitrary Java methods within <onentry>, best to
>> write a custom action for that. More on that here:
>>
>>  http://commons.apache.org/scxml/guide/custom-actions.html
>>
>> -Rahul
>>
>>
>>> I am using version 0.9 from maven central.
>>>
>>> Thanks
>>> Daniel Santos
>>>

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


Re: [scxml] invoking methods on an object

Posted by Daniel Luis dos Santos <da...@gmail.com>.
Hi, 

Ok invoke is another thing. Meanwhile I did write some custom actions. What I am doing is trying to call the object from within the actions.
I managed to get an instance to the object by passing a reference to it in the event trigger method in my client code. I then access the parent context inside the custom action and get the '_eventdata' object.

I was trying to define a variable with the <var> element inside the <onentry> element but the engine warned me it was ignoring it. Do you know why ? I saw in the datamodel section of the site that you can define them. (Although there is not a word of it in the 2011 w3c spec)

Sorry for my ignorance and dumb questions but I am very new to all this.

Thanks
Daniel Santos




On Oct 3, 2011, at 11:55 PM, Rahul Akolkar wrote:

> On Mon, Oct 3, 2011 at 9:17 AM, Daniel Luis dos Santos
> <da...@gmail.com> wrote:
>> Hello,
>> 
>> I am beggining to use commons-SCXML. For now I created a generic class that wraps the library's code just like the class AbstractStateMachine in the stopwatch example.
>> 
>> Each class from my application that will be governed by a state machine has an instance of this, and has methods to trigger events on it.
> <snip/>
> 
> Note that the AbstractStateMachine pattern is a starter pattern and is
> limited if used in isolation. More patterns here:
> 
>  http://commons.apache.org/scxml/guide/using-commons-scxml.html
> 
> 
>> What I want to do is have methods from the object be called from state machine events. For example, when I enter a state I want to be able to call a method on the stateful object.
>> 
>> I am trying to use invoke inside <onentry> but the markup is ignored. How can I do this ?
>> 
> <snap/>
> 
> If you're talking about the <invoke> element, that is not an action
> (its a child of state not onentry) and requires Invoker
> implementations to be registered with the executor for each "type" of
> invoke.
> 
> If you want to call arbitrary Java methods within <onentry>, best to
> write a custom action for that. More on that here:
> 
>  http://commons.apache.org/scxml/guide/custom-actions.html
> 
> -Rahul
> 
> 
>> I am using version 0.9 from maven central.
>> 
>> Thanks
>> Daniel Santos
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 


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


Re: [scxml] invoking methods on an object

Posted by Rahul Akolkar <ra...@gmail.com>.
On Mon, Oct 3, 2011 at 9:17 AM, Daniel Luis dos Santos
<da...@gmail.com> wrote:
> Hello,
>
> I am beggining to use commons-SCXML. For now I created a generic class that wraps the library's code just like the class AbstractStateMachine in the stopwatch example.
>
> Each class from my application that will be governed by a state machine has an instance of this, and has methods to trigger events on it.
<snip/>

Note that the AbstractStateMachine pattern is a starter pattern and is
limited if used in isolation. More patterns here:

  http://commons.apache.org/scxml/guide/using-commons-scxml.html


> What I want to do is have methods from the object be called from state machine events. For example, when I enter a state I want to be able to call a method on the stateful object.
>
> I am trying to use invoke inside <onentry> but the markup is ignored. How can I do this ?
>
<snap/>

If you're talking about the <invoke> element, that is not an action
(its a child of state not onentry) and requires Invoker
implementations to be registered with the executor for each "type" of
invoke.

If you want to call arbitrary Java methods within <onentry>, best to
write a custom action for that. More on that here:

  http://commons.apache.org/scxml/guide/custom-actions.html

-Rahul


> I am using version 0.9 from maven central.
>
> Thanks
> Daniel Santos
>

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