SCXML and Script and context access

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SCXML and Script and context access

Sinisa Zec
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:%[hidden email]%3e> <[hidden email]>

development

___________________________________________________________

 

Reply | Threaded
Open this post in threaded view
|

Re: SCXML and Script and context access

Ate Douma
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:%[hidden email]%3e> <[hidden email]>
>
> development
>
> ___________________________________________________________
>
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: SCXML and Script and context access

Woonsan Ko-3
In reply to this post by Sinisa Zec
On Tue, Aug 18, 2015 at 6:27 AM, Sinisa Zec <[hidden email]> 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:%[hidden email]%3e> <[hidden email]>
>
> development
>
> ___________________________________________________________
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]