You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Nestor Urquiza <ne...@yahoo.com> on 2006/04/19 18:51:48 UTC

[SCXML] patterns for bridging

Hello guys,

Recently Rahul gave an excellent list of some patterns
to handle bridging[1].

I am trying to bridge my "system" or "domain" layer to
my "scxml engine".

Could anyone please give advice about which of them
[1] better fit my usecase:

I need to be able to accept an http request, analyze
if specific business rules (to be configured by means
of conditions (guards) in an scxml file) apply, then
execute some internal actions and then move to the
proper final state.

Let us put an example:
-current state is S10 that will go to S12 if event
E101 is received and condition C1 is satisfied. 
-C1 should be true if the request come from a valid IP
and the proper actions related to E1 were succesfully
completed.

So before starting to execute specific-code for E101
the first part of C1 (validIP eq true) should be
satisfied what makes the execution of specific-code
dependant on a setting from the scxml file. Later when
the specific-code finishes, the rest of the condition
(E101 finished correctly) can be validated and the
transition can occur. 

Thanks,
Nestor

[1] See thread named [SCXML] SCXMLListener Exception
Handling Question

__________________________________________________
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] patterns for bridging

Posted by "Mike Sparr - www.goomzee.com" <mi...@goomzee.com>.
We discussed adding functions to EL and Commons EL didn't offer them (like
substringAfter).  I believe you said JEXL offers that and to add bugzilla
request to enhance the EL capabilities?

Mike


On 4/20/06 2:06 PM, "Rahul Akolkar" <ra...@gmail.com> wrote:

> On 4/20/06, Mike Sparr - www.goomzee.com <mi...@goomzee.com> wrote:
>> Rahul,
>> 
>> I see a lot of mentioning of JEXL.  Still need me to add bugzilla request?
>> 
> <snip/>
> 
> Sorry, which one is that?
> 
> -Rahul
> 
> 
>> Mike
>> 
>> 
> <snap/>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 



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


Re: [SCXML] patterns for bridging

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/20/06, Mike Sparr - www.goomzee.com <mi...@goomzee.com> wrote:
> Rahul,
>
> I see a lot of mentioning of JEXL.  Still need me to add bugzilla request?
>
<snip/>

Sorry, which one is that?

-Rahul


> Mike
>
>
<snap/>

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


Re: [SCXML] patterns for bridging

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/20/06, Nestor Urquiza <ne...@yahoo.com> wrote:
> About the _eventdata the question is if given for
> example:
> <transition event="v3:HelloWorld2.done"
> condition="printed eq yes and disconnected eq true">
>      <!--
>          we use _eventdata to access data in the
> event we're processing
>          -->
>        <ccxml:disconnect
> connectionid="_eventdata.getConnectionId"/>
>      </transition>
>
> _eventdata.getConnectionId (getConnectionId is an
> event supported by the object represented by
> _eventdata variable) would be executed before the
> condition is tested.
>
> In the example I am assuming an internal communication
> to happen when _eventdata.getConnectionId set the
> variable disconnected = true.
>
> In any case I think I am answering my question and the
> answer is nope you cannot expect
> _eventdata.getConnectionId to set a variable that will
> in turn be checked in the condition just because the
> _eventdata assignment is a child of the transition
> node and so that particular transition node must be
> selected in order the method
> _eventdata.getConnectionId to be called.
<snip/>

This is correct, the executable content children of a <transition>
will only execute if the guard condition is satisfied.


> Am I missing
> something or seems like at the end the appropiate
> solution for me is to create Action States?
>
<snap/>

Yup, action states it is.

-Rahul


> Thanks,
> Nestor
>
>
<snip/>

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


Re: [SCXML] patterns for bridging

Posted by Nestor Urquiza <ne...@yahoo.com>.
About the _eventdata the question is if given for
example:
<transition event="v3:HelloWorld2.done"
condition="printed eq yes and disconnected eq true">
      <!-- 
          we use _eventdata to access data in the
event we're processing
          -->
        <ccxml:disconnect
connectionid="_eventdata.getConnectionId"/>      
      </transition>

_eventdata.getConnectionId (getConnectionId is an
event supported by the object represented by
_eventdata variable) would be executed before the
condition is tested. 

In the example I am assuming an internal communication
to happen when _eventdata.getConnectionId set the
variable disconnected = true.

In any case I think I am answering my question and the
answer is nope you cannot expect
_eventdata.getConnectionId to set a variable that will
in turn be checked in the condition just because the
_eventdata assignment is a child of the transition
node and so that particular transition node must be
selected in order the method
_eventdata.getConnectionId to be called. Am I missing
something or seems like at the end the appropiate
solution for me is to create Action States?

Thanks,
Nestor



--- Rahul Akolkar <ra...@gmail.com> wrote:

> On 4/20/06, Nestor Urquiza <ne...@yahoo.com>
> wrote:
> > So you think the approach of calling a method as
> part
> > of the condition is a valid alternative or because
> of
> > the fact that it is relying on a common way of
> > evaluating boolean expressions that still jexl
> might
> > not guarrantee you think it is a weak approach and
> I
> > would go with intermediate Action States?
> >
> <snip/>
> 
> IMO, whether you choose an intermediate state should
> depend upon:
> 
>  * Amount of work done in executable content within
> the method you're
> calling (more work implies an action state
> preference, since
> transitions are more or less instantaneous, but this
> is somewhat of a
> theoretical argument).
> 
>  * Amount of logical outcomes coming out of the
> method you're calling.
> If on a certain event, you need to call a method
> that can come back
> with different logical outcomes that dictate the
> transition target,
> you need an action state. As an example, see
> "checkCookie" state in
> the Commons SCXML rendition of the Shale usecases
> log-on dialog [1].
> 
> You will have to try short-circuiting in JEXL
> yourself, sorry I don't know.
> 
> 
> > Also, about payload/_eventdata I do not understand
> if
> > the method going to be called before the
> conditions
> > are evaluated within a transition?
> <snap/>
> 
> What method is that?
> 
> 
> > If yes then I can
> > setup variables using an _eventdata object methods
> > then test for those variables in the condition. Is
> the
> > _eventdata variable behavior already implemented
> in
> > commons?
> >
> <snap/>
> 
> Yes, and is now documented as well ;-) (though
> website is not
> refreshed yet -- in a few).
> 
> -Rahul
> 
> [1]
>
http://jakarta.apache.org/commons/sandbox/scxml/usecases/shale-dialogs/log-on-config.xml
> 
> > Thanks
> >
> <snip/>
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> 
> 


__________________________________________________
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] patterns for bridging

Posted by "Mike Sparr - www.goomzee.com" <mi...@goomzee.com>.
Rahul,

I see a lot of mentioning of JEXL.  Still need me to add bugzilla request?

Mike


On 4/20/06 1:53 PM, "Rahul Akolkar" <ra...@gmail.com> wrote:

> On 4/20/06, Nestor Urquiza <ne...@yahoo.com> wrote:
>> So you think the approach of calling a method as part
>> of the condition is a valid alternative or because of
>> the fact that it is relying on a common way of
>> evaluating boolean expressions that still jexl might
>> not guarrantee you think it is a weak approach and I
>> would go with intermediate Action States?
>> 
> <snip/>
> 
> IMO, whether you choose an intermediate state should depend upon:
> 
>  * Amount of work done in executable content within the method you're
> calling (more work implies an action state preference, since
> transitions are more or less instantaneous, but this is somewhat of a
> theoretical argument).
> 
>  * Amount of logical outcomes coming out of the method you're calling.
> If on a certain event, you need to call a method that can come back
> with different logical outcomes that dictate the transition target,
> you need an action state. As an example, see "checkCookie" state in
> the Commons SCXML rendition of the Shale usecases log-on dialog [1].
> 
> You will have to try short-circuiting in JEXL yourself, sorry I don't know.
> 
> 
>> Also, about payload/_eventdata I do not understand if
>> the method going to be called before the conditions
>> are evaluated within a transition?
> <snap/>
> 
> What method is that?
> 
> 
>> If yes then I can
>> setup variables using an _eventdata object methods
>> then test for those variables in the condition. Is the
>> _eventdata variable behavior already implemented in
>> commons?
>> 
> <snap/>
> 
> Yes, and is now documented as well ;-) (though website is not
> refreshed yet -- in a few).
> 
> -Rahul
> 
> [1] 
> http://jakarta.apache.org/commons/sandbox/scxml/usecases/shale-dialogs/log-on-
> config.xml
> 
>> Thanks
>> 
> <snip/>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 



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


Re: [SCXML] patterns for bridging

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/20/06, Nestor Urquiza <ne...@yahoo.com> wrote:
> So you think the approach of calling a method as part
> of the condition is a valid alternative or because of
> the fact that it is relying on a common way of
> evaluating boolean expressions that still jexl might
> not guarrantee you think it is a weak approach and I
> would go with intermediate Action States?
>
<snip/>

IMO, whether you choose an intermediate state should depend upon:

 * Amount of work done in executable content within the method you're
calling (more work implies an action state preference, since
transitions are more or less instantaneous, but this is somewhat of a
theoretical argument).

 * Amount of logical outcomes coming out of the method you're calling.
If on a certain event, you need to call a method that can come back
with different logical outcomes that dictate the transition target,
you need an action state. As an example, see "checkCookie" state in
the Commons SCXML rendition of the Shale usecases log-on dialog [1].

You will have to try short-circuiting in JEXL yourself, sorry I don't know.


> Also, about payload/_eventdata I do not understand if
> the method going to be called before the conditions
> are evaluated within a transition?
<snap/>

What method is that?


> If yes then I can
> setup variables using an _eventdata object methods
> then test for those variables in the condition. Is the
> _eventdata variable behavior already implemented in
> commons?
>
<snap/>

Yes, and is now documented as well ;-) (though website is not
refreshed yet -- in a few).

-Rahul

[1] http://jakarta.apache.org/commons/sandbox/scxml/usecases/shale-dialogs/log-on-config.xml

> Thanks
>
<snip/>

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


Re: [SCXML] patterns for bridging

Posted by Nestor Urquiza <ne...@yahoo.com>.
So you think the approach of calling a method as part
of the condition is a valid alternative or because of
the fact that it is relying on a common way of
evaluating boolean expressions that still jexl might
not guarrantee you think it is a weak approach and I
would go with intermediate Action States?

Also, about payload/_eventdata I do not understand if
the method going to be called before the conditions
are evaluated within a transition? If yes then I can
setup variables using an _eventdata object methods
then test for those variables in the condition. Is the
_eventdata variable behavior already implemented in
commons?

Thanks


--- Rahul Akolkar <ra...@gmail.com> wrote:

> Trimming copious amounts to keep message size
> manageable ...
> 
> On 4/20/06, Nestor Urquiza <ne...@yahoo.com>
> wrote:
> > --- Rahul Akolkar <ra...@gmail.com> wrote:
> <snip/>
> >
> > I am implementing state oriented business
> application
> > protocol ("scxml engine" + "bridge") that in fact
> will
> > be used between others by http calls ("system")
> not
> > relevant the way ... it can be GET/POST/REST/SOAP
> or
> > whatever terminology someone can come for the same
> > "Receiving calls from a client and answering them
> via
> > HTTP".
> >
> <snap/>
> 
> Thanks for that level set.
> 
> 
> >
> > Could you think about an option to avoid action
> > states?
> >
> <snip/>
> 
> Yes, as you point out below ;-)
> 
> 
> > > While you can hack most state machines to fit
> many
> > > topologies (such as
> > > by having side-effects in guard conditions), the
> >
> > Interesting, given the fact that jexl supports
> method
> > invocation ... don't you think this is a way to
> avoid
> > to much descriptive information in the scxml file?
> >
> <snap/>
> 
> It somewhat comes down to a matter of personal taste
> in readability,
> or how it was modeled. I can see the need for both
> usages, and have
> seen (and used) both.
> 
> 
> > Consider the jexl expression for example:
> > "validVar eq true and
> > contextObjectUsingTheEventName.execute()"
> >
> > Because of the simple and there you could ensure
> that
> > only if the first part is true (pre-cond) you call
> the
> > execute method of an object that is supposed to be
> in
> > the context and you know its name because it maps
> to
> > the state machine event-name and the http-call.
> The
> > result is a boolean that will complete the
> > post-condition and therefore you do not need an
> action
> > state.
> >
> <snip/>
> 
> Yup, makes sense, but Commons SCXML cannot make any
> guarantees about
> things such as whether the underlying EL used
> short-circuits compound
> boolean expressions etc.
> 
> 
> > In other words this is maybe answering the
> alternative
> > way I am looking for. And it is important to
> > understand that I am not after a side-effect but
> > specific-code in my case.
> >
> > Where I can see an example or information about
> > implementing such a mechanism? This is having jexl
> > expression that executes some java code that
> returns
> > boolean and can be used for a condition. I opened
> > another thread and I see I have responses so let
> me
> > check out them ... it is precisely related to the
> > context that I thought I need to use for this
> scenario
> > in order to set up the object that the sate
> machine is
> > supposed to use.
> >
> > Is it something the engine is doing already or
> will
> > do?
> >
> <snap/>
> 
> As you state, JEXL already does that. So Commons
> SCXML does that too
> by transitivity if you use JEXL for expressions. If
> "contextObjectUsingTheEventName" from the above
> snippet is available
> in the Context, then JEXL will take care of the
> method invocation. We
> do have examples of JSF method binding expressions
> in SCXML documents
> in the usecases, but probably none of JEXL method
> invocation. But
> there is nothing more to it than your snippet above.
> 
> -Rahul
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> 
> 


__________________________________________________
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] patterns for bridging

Posted by Rahul Akolkar <ra...@gmail.com>.
Trimming copious amounts to keep message size manageable ...

On 4/20/06, Nestor Urquiza <ne...@yahoo.com> wrote:
> --- Rahul Akolkar <ra...@gmail.com> wrote:
<snip/>
>
> I am implementing state oriented business application
> protocol ("scxml engine" + "bridge") that in fact will
> be used between others by http calls ("system") not
> relevant the way ... it can be GET/POST/REST/SOAP or
> whatever terminology someone can come for the same
> "Receiving calls from a client and answering them via
> HTTP".
>
<snap/>

Thanks for that level set.


>
> Could you think about an option to avoid action
> states?
>
<snip/>

Yes, as you point out below ;-)


> > While you can hack most state machines to fit many
> > topologies (such as
> > by having side-effects in guard conditions), the
>
> Interesting, given the fact that jexl supports method
> invocation ... don't you think this is a way to avoid
> to much descriptive information in the scxml file?
>
<snap/>

It somewhat comes down to a matter of personal taste in readability,
or how it was modeled. I can see the need for both usages, and have
seen (and used) both.


> Consider the jexl expression for example:
> "validVar eq true and
> contextObjectUsingTheEventName.execute()"
>
> Because of the simple and there you could ensure that
> only if the first part is true (pre-cond) you call the
> execute method of an object that is supposed to be in
> the context and you know its name because it maps to
> the state machine event-name and the http-call. The
> result is a boolean that will complete the
> post-condition and therefore you do not need an action
> state.
>
<snip/>

Yup, makes sense, but Commons SCXML cannot make any guarantees about
things such as whether the underlying EL used short-circuits compound
boolean expressions etc.


> In other words this is maybe answering the alternative
> way I am looking for. And it is important to
> understand that I am not after a side-effect but
> specific-code in my case.
>
> Where I can see an example or information about
> implementing such a mechanism? This is having jexl
> expression that executes some java code that returns
> boolean and can be used for a condition. I opened
> another thread and I see I have responses so let me
> check out them ... it is precisely related to the
> context that I thought I need to use for this scenario
> in order to set up the object that the sate machine is
> supposed to use.
>
> Is it something the engine is doing already or will
> do?
>
<snap/>

As you state, JEXL already does that. So Commons SCXML does that too
by transitivity if you use JEXL for expressions. If
"contextObjectUsingTheEventName" from the above snippet is available
in the Context, then JEXL will take care of the method invocation. We
do have examples of JSF method binding expressions in SCXML documents
in the usecases, but probably none of JEXL method invocation. But
there is nothing more to it than your snippet above.

-Rahul

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


Re: [SCXML] patterns for bridging

Posted by Nestor Urquiza <ne...@yahoo.com>.
--- Rahul Akolkar <ra...@gmail.com> wrote:

> On 4/19/06, Nestor Urquiza <ne...@yahoo.com>
> wrote:
> > Hello guys,
> >
> > Recently Rahul gave an excellent list of some
> patterns
> > to handle bridging[1].
> >
> > I am trying to bridge my "system" or "domain"
> layer to
> > my "scxml engine".
> >
> > Could anyone please give advice about which of
> them
> > [1] better fit my usecase:
> >
> > I need to be able to accept an http request,
> analyze
> > if specific business rules (to be configured by
> means
> > of conditions (guards) in an scxml file) apply,
> then
> > execute some internal actions and then move to the
> > proper final state.
> >
> <snip/>
> 
> A couple of usecases [1] are available on the
> website that
> specifically deal with usages in the servlet
> container, the difference
> would be that both are dealing with (view)
> navigation rules. The
> general concept being that an SCXMLExecutor is
> available within a
> session, and each request (potentially) affects the
> state machine for
> its session -- and that concept still holds in your
> case. Both
> usecases map states to activities (first pattern)
> because the
> activities are homogeneous (Ex: In RDC usecase we
> always invoke a
> speech component whose ID matches the state ID, so
> if the state
> machine starts off in state "foo", the component
> with ID "foo" is
> activated). Unclear what the actions and activities
> are in your case.
> 

I am implementing state oriented business application
protocol ("scxml engine" + "bridge") that in fact will
be used between others by http calls ("system") not
relevant the way ... it can be GET/POST/REST/SOAP or
whatever terminology someone can come for the same
"Receiving calls from a client and answering them via
HTTP". 

A given http-call can be executed only if certain
pre-conditions apply within a given state. If
conditions apply and the execution of the
specific-code related to the service requested is
succesful then the system can move to the next step.

The problem is not about matching states to activities
but the way activities are related to states and this
is there is an interdependency between them both.
Below I think you gave the response already ... I will
need to create an action state for each state I
already thought about to implement. 

Mapping then is ensured because my activities are
classes with the same name as the incomming event.

Could you think about an option to avoid action
states? 

> 
> > Let us put an example:
> > -current state is S10 that will go to S12 if event
> > E101 is received and condition C1 is satisfied.
> > -C1 should be true if the request come from a
> valid IP
> > and the proper actions related to E1 were
> succesfully
> > completed.
> >
> > So before starting to execute specific-code for
> E101
> > the first part of C1 (validIP eq true) should be
> > satisfied what makes the execution of
> specific-code
> > dependant on a setting from the scxml file. Later
> when
> > the specific-code finishes, the rest of the
> condition
> > (E101 finished correctly) can be validated and the
> > transition can occur.
> >
> <snap/>
> 
> Without actually dealing with the specifics of any
> example, lets look
> at guard conditions that are not "atomic", meaning
> that the guard
> condition is broken down into:
> 
>  * A pre-condition that is evaluated as soon as the
> event is received
>  * A set of actions that need to performed if the
> pre-condition is satisfied
>  * A post-condition that evaluates the logical
> outcome from the
> actions performed (and hence the transition target
> i.e. the next
> state)
> 
> The reason I'm not taking up your specific example
> is because its
> possible to say that IP-based restriction is really
> more of a
> container provided service, for example, Tomcat
> remote host / address
> valves [2], and that sort of beats the undercurrent
> of the question,
> IMO.
> 

It might be true my example was confusing and still
you got my point which is the important part
(pre-cond, spec-act, post-cond affected by the result
of spec-act and at the end state change) but just fyi
I am using a propietary kind of servlet container and
the IP-based restriction in my app must be done by the
app itself because it is based on several business
rules that simply cannot be inserted in the
configuration file of the servlet. I need an IP/client
filtering engine that should be part of the particular
application and not part of the servlet container.

> While you can hack most state machines to fit many
> topologies (such as
> by having side-effects in guard conditions), the

Interesting, given the fact that jexl supports method
invocation ... don't you think this is a way to avoid
to much descriptive information in the scxml file?

Consider the jexl expression for example: 
"validVar eq true and
contextObjectUsingTheEventName.execute()" 

Because of the simple and there you could ensure that
only if the first part is true (pre-cond) you call the
execute method of an object that is supposed to be in
the context and you know its name because it maps to
the state machine event-name and the http-call. The
result is a boolean that will complete the
post-condition and therefore you do not need an action
state.

In other words this is maybe answering the alternative
way I am looking for. And it is important to
understand that I am not after a side-effect but
specific-code in my case.

Where I can see an example or information about
implementing such a mechanism? This is having jexl
expression that executes some java code that returns
boolean and can be used for a condition. I opened
another thread and I see I have responses so let me
check out them ... it is precisely related to the
context that I thought I need to use for this scenario
in order to set up the object that the sate machine is
supposed to use. 

Is it something the engine is doing already or will
do?

> most widely accepted
> solution to the above scenario is to introduce an
> additional "action
> state", like so:
> 
> <state id="S10">
>  ...
>  <transition event="event.foo"
>   cond="pre-condition" target="S11"/> <!-- waiting
> for event.foo here -->
> </state>
> 
> <state id="S11"> <!-- action state -->
>  <onentry>
>   <!-- Set of actions if pre-condition is satisfied
> -->
>  </onentry>
>  <transition cond="post-condition"
>   target="S12"/> <!-- not waiting for an event here
> -->
>  ...
> </state>
> 
> <state id="S12">
>  ...
> </state>
> 
> -Rahul
> 
> [1]
>
http://jakarta.apache.org/commons/sandbox/scxml/usecases.html
> [2]
>
http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html
> 
> 
> >
> > Thanks,
> > Nestor
> >
> > [1] See thread named [SCXML] SCXMLListener
> Exception
> > Handling Question
> >
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> 
> 


__________________________________________________
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] patterns for bridging

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/19/06, Nestor Urquiza <ne...@yahoo.com> wrote:
> Hello guys,
>
> Recently Rahul gave an excellent list of some patterns
> to handle bridging[1].
>
> I am trying to bridge my "system" or "domain" layer to
> my "scxml engine".
>
> Could anyone please give advice about which of them
> [1] better fit my usecase:
>
> I need to be able to accept an http request, analyze
> if specific business rules (to be configured by means
> of conditions (guards) in an scxml file) apply, then
> execute some internal actions and then move to the
> proper final state.
>
<snip/>

A couple of usecases [1] are available on the website that
specifically deal with usages in the servlet container, the difference
would be that both are dealing with (view) navigation rules. The
general concept being that an SCXMLExecutor is available within a
session, and each request (potentially) affects the state machine for
its session -- and that concept still holds in your case. Both
usecases map states to activities (first pattern) because the
activities are homogeneous (Ex: In RDC usecase we always invoke a
speech component whose ID matches the state ID, so if the state
machine starts off in state "foo", the component with ID "foo" is
activated). Unclear what the actions and activities are in your case.


> Let us put an example:
> -current state is S10 that will go to S12 if event
> E101 is received and condition C1 is satisfied.
> -C1 should be true if the request come from a valid IP
> and the proper actions related to E1 were succesfully
> completed.
>
> So before starting to execute specific-code for E101
> the first part of C1 (validIP eq true) should be
> satisfied what makes the execution of specific-code
> dependant on a setting from the scxml file. Later when
> the specific-code finishes, the rest of the condition
> (E101 finished correctly) can be validated and the
> transition can occur.
>
<snap/>

Without actually dealing with the specifics of any example, lets look
at guard conditions that are not "atomic", meaning that the guard
condition is broken down into:

 * A pre-condition that is evaluated as soon as the event is received
 * A set of actions that need to performed if the pre-condition is satisfied
 * A post-condition that evaluates the logical outcome from the
actions performed (and hence the transition target i.e. the next
state)

The reason I'm not taking up your specific example is because its
possible to say that IP-based restriction is really more of a
container provided service, for example, Tomcat remote host / address
valves [2], and that sort of beats the undercurrent of the question,
IMO.

While you can hack most state machines to fit many topologies (such as
by having side-effects in guard conditions), the most widely accepted
solution to the above scenario is to introduce an additional "action
state", like so:

<state id="S10">
 ...
 <transition event="event.foo"
  cond="pre-condition" target="S11"/> <!-- waiting for event.foo here -->
</state>

<state id="S11"> <!-- action state -->
 <onentry>
  <!-- Set of actions if pre-condition is satisfied -->
 </onentry>
 <transition cond="post-condition"
  target="S12"/> <!-- not waiting for an event here -->
 ...
</state>

<state id="S12">
 ...
</state>

-Rahul

[1] http://jakarta.apache.org/commons/sandbox/scxml/usecases.html
[2] http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html


>
> Thanks,
> Nestor
>
> [1] See thread named [SCXML] SCXMLListener Exception
> Handling Question
>

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