You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Sinisa Zec <si...@adcon.hr> on 2015/08/18 12:27:46 UTC

SCXML and Script and context access

Dears,

 

We are using Apache SCXML2 for the project which is based on FSM logic. I am
trying for some time to achieve the following:

 

1.Set some variables in (Groovy)context from Java – X set of variables

2.Read those values in from the <script> in Groovy (it might be any other
but we have chosen Groovy - other suggestions are welcomed).

3.Set the NEW set of variables (in GroovyContext) from Groovy script – Y set
of variables (in principle it is simple mapping)

4.Read the new values (Y set) from context in Java.

 

I didn't find another way for the scenario above, but to initialize Y set of
variables to empty values already in Java, before step 3. from above. 

Do you possible have a different suggestion?

 

Do you think it would be better to try this with Jexl (I did try, but
totally failed to do anything with Context from Jexl script)?

 

Are you possible aware of any useful examples of context manipulation from
<script> (Groovy or any other)?

 

Thank you very much in advance!

 

 

mit freundlichen Grüßen / with best regards / Lijepi pozdrav
Sinisa Zec 


___________________________________________________________

Adcon d.o.o.

Josipa Jurja Strossmayera 341 

31000 Osijek

Hrvatska – Croatia

fix: +385 31 638 136

mobile: +385 91 509 0903

 <http://www.adcon.hr/> www.adcon.hr

 

Sinisa Zec       <mailto:%3csinisa.zec@adcon.hr%3e> <si...@adcon.hr>

development

___________________________________________________________

 


Re: SCXML and Script and context access

Posted by Ate Douma <at...@douma.nu>.
On 2015-08-18 12:27, Sinisa Zec wrote:
> Dears,
>
>
>
> We are using Apache SCXML2 for the project which is based on FSM logic. I am
> trying for some time to achieve the following:
>
>
>
> 1.Set some variables in (Groovy)context from Java – X set of variables
>
> 2.Read those values in from the <script> in Groovy (it might be any other
> but we have chosen Groovy - other suggestions are welcomed).
>
> 3.Set the NEW set of variables (in GroovyContext) from Groovy script – Y set
> of variables (in principle it is simple mapping)
>
> 4.Read the new values (Y set) from context in Java.
>
>
>
> I didn't find another way for the scenario above, but to initialize Y set of
> variables to empty values already in Java, before step 3. from above.
>
> Do you possible have a different suggestion?

What we typically do is providing a predefined POJO (which could be as simple as 
a Map) through the SCXMLExecutor.getRootContext() and use that as an external 
environment variable.
Then you can simply script your variables via that environment variable, e.g. 
env.X and env.Y

>
>
>
> Do you think it would be better to try this with Jexl (I did try, but
> totally failed to do anything with Context from Jexl script)?
Groovy in general is more powerful (and dangerous :) ).

>
>
>
> Are you possible aware of any useful examples of context manipulation from
> <script> (Groovy or any other)?
I don't think we really have concrete examples/tests in Commons SCXML, but it 
should be trivial to do this yourself.

>
>
>
> Thank you very much in advance!
>
>
>
>
>
> mit freundlichen Grüßen / with best regards / Lijepi pozdrav
> Sinisa Zec
>
>
> ___________________________________________________________
>
> Adcon d.o.o.
>
> Josipa Jurja Strossmayera 341
>
> 31000 Osijek
>
> Hrvatska – Croatia
>
> fix: +385 31 638 136
>
> mobile: +385 91 509 0903
>
>   <http://www.adcon.hr/> www.adcon.hr
>
>
>
> Sinisa Zec       <mailto:%3csinisa.zec@adcon.hr%3e> <si...@adcon.hr>
>
> development
>
> ___________________________________________________________
>
>
>
>



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


Re: SCXML and Script and context access

Posted by Woonsan Ko <wo...@apache.org>.
On Tue, Aug 18, 2015 at 6:27 AM, Sinisa Zec <si...@adcon.hr> wrote:
> Dears,
>
>
>
> We are using Apache SCXML2 for the project which is based on FSM logic. I am
> trying for some time to achieve the following:
>
>
>
> 1.Set some variables in (Groovy)context from Java – X set of variables
>
> 2.Read those values in from the <script> in Groovy (it might be any other
> but we have chosen Groovy - other suggestions are welcomed).
>
> 3.Set the NEW set of variables (in GroovyContext) from Groovy script – Y set
> of variables (in principle it is simple mapping)
>
> 4.Read the new values (Y set) from context in Java.
>
>
>
> I didn't find another way for the scenario above, but to initialize Y set of
> variables to empty values already in Java, before step 3. from above.
>
> Do you possible have a different suggestion?
>
>
>
> Do you think it would be better to try this with Jexl (I did try, but
> totally failed to do anything with Context from Jexl script)?
>
>
>
> Are you possible aware of any useful examples of context manipulation from
> <script> (Groovy or any other)?

I have a simple example in my github, Please have a look if you want:
- https://github.com/woonsan/commons-scxml-examples/tree/master/stopwatch

I tried to simplify the StopWatch example found in commons-scxml unit
test. You will be able to see how to pass StopWatch java object
through context and how to access the object in JEXL script in scxml.

HTH,

Woonsan

>
>
>
> Thank you very much in advance!
>
>
>
>
>
> mit freundlichen Grüßen / with best regards / Lijepi pozdrav
> Sinisa Zec
>
>
> ___________________________________________________________
>
> Adcon d.o.o.
>
> Josipa Jurja Strossmayera 341
>
> 31000 Osijek
>
> Hrvatska – Croatia
>
> fix: +385 31 638 136
>
> mobile: +385 91 509 0903
>
>  <http://www.adcon.hr/> www.adcon.hr
>
>
>
> Sinisa Zec       <mailto:%3csinisa.zec@adcon.hr%3e> <si...@adcon.hr>
>
> development
>
> ___________________________________________________________
>
>
>

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