Re: Question regarding scxmlgui tool
On Wed, Jun 20, 2012 at 4:22 AM, Nir Shemesh nirshe...@gmail.com wrote: Hi Apache Users, I need your help regarding my question below snip/ See inline below. Many thanks Nir -- Forwarded message -- From: Fabrizio Morbini fmorb...@gmail.com Date: Tue, Jun 19, 2012 at 11:48 PM Subject: Re: Question regarding scxmlgui tool To: Nir Shemesh nirshe...@gmail.com Hi, first i have to say that this question is really a question you should ask the Apache SCXML folks given that it's an executor question as opposed to a interface question. Going to the question, transitions are treatment the same, even if they are loops (i.e. source and target nodes are the same). When one takes the transitions you leave the source node and you execute the OnExit. When you enter the same node you execute the OnEntry. Hope it helps, but please ask the Apache SCXML mailing list. best On Tue, Jun 19, 2012 at 1:42 PM, Nir Shemesh nirshe...@gmail.com wrote: Hi Fabrizio, Im using your tool to evaluate scxml concept for my hobby. I made a simple model with two states (inactive and active) wherethere is transition from inactive to active and active has a transition to itself. Now, when statemachine is in active and its self transitin iignite i noticed that execution occure of the transition(has expected) BUT also onExit and OnEntry execution content of active state also occure. My question is why - since we are in self transition (stayes on save state) there is no need to establish onEntry and onExit execution. Opinun? :) snap/ If you want the onexit and onentry to execute, then specify the parent state as the target state to the transition (via the target attribute of the transition element). Such a transition is referred to as a self transition. If you do not want the onexit and onentry to execute, then leave the transition targetless (do not specify a target attribute on the transition element). Such a transition is referred to as a stay transition. -Rahul Thanks Nir - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] JEXL Evaluator's evalCond issue
On Thu, Jun 14, 2012 at 5:23 PM, sgu...@osc.state.ny.us wrote: 1. Problem renaming method in class used for condition evaluation. Class: Test method: boolean method1(integer i) xml snippet: state id=DELETE_STATE transition event=delete target=STATUS_UNKNOWN cond=test.method1(100)/ /state We are trying rename test.method1(integer i) in Test class to test.methodRenamed(integer i) and update xml to: state id=DELETE_STATE transition event=delete target=STATUS_UNKNOWN cond=test.methodRenamed(100)/ /state Executing SCXML after the above change, test.methodRenamed(100) is not invoked and no information in logs are seen nor any exception seen in the trace. Note: Putting back to the old method name (test.method1(100)) works as expected. snip/ It isn't clear how you are testing the changes once you update the Test class. From the description, it doesn't look like the new Test class is loaded. I don't think this is related to Commons SCXML (i.e. the library code). 2. Problem adding a new method (test.methodNew(200)). Class: Test methods: boolean method1(Integer i) boolean methodNew(Integer i) transition event=delete target=STATUS_UNKNOWN cond=test.method1(100) amp;amp; test.methodNew(200)/ Executing SCXML: 1. test.method1(100) was invoked and returned true. 2. test.methodNew(200) was never invoked 3. JexlEvaluator's method evalCond line exp.evaluate(getEffectiveContext(jexlCtx)) returns false. Note: Adding a non existent method or junk string to the xml's cond attribute doesn't yield any failure information and JexlEvaluator simply returns false . snap/ Same comment as above. Additionally, boolean expressions are assumed to be false unless they successfully evaluate to true. Versions used: commons-scxml-0.9.jar, commons-jexl.1.1.jar The issue seems to be a JEXL issue, however upgrading to the latest JEXL 2 version is not feasible due to compilation issues. Is there/will there be a version of SCXML that is compatible with a later version of JEXCL? (ie: JEXL2) snip/ You can try the Evaluator implementation attached here [1] (which is not released code) or provide your own evaluator implementation [2] for this. -Rahul [1] https://issues.apache.org/jira/browse/SCXML-114 [2] http://commons.apache.org/scxml/guide/contexts-evaluators.html Thanks Regards Satish Gutta Notice: This communication, including any attachments, is intended solely for the use of the individual or entity to which it is addressed. This communication may contain information that is protected from disclosure under State and/or Federal law. Please notify the sender immediately if you have received this communication in error and delete this email from your system. If you are not the intended recipient, you are requested not to disclose, copy, distribute or take any action in reliance on the contents of this information. - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] there is a working example?
On Mon, May 21, 2012 at 6:55 PM, Jacob Beard jbea...@cs.mcgill.ca wrote: Regarding project status, see this thread posted last week: http://mail-archives.apache.org/mod_mbox/commons-dev/201205.mbox/browser snip/ Or this link: http://markmail.org/message/wu5rfl25fxjyn7tb -Rahul Jake On Mon, May 21, 2012 at 5:15 PM, Alessandro Scarozza xan.sc...@gmail.com wrote: first of all, THZ last stable release are 0.9 there is also 0.10 and 1.0 whis is the more feature version? second question: this project are alive? there is anyone that commit for commons SCXML? bye snap/ - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml]
On Wed, May 23, 2012 at 2:01 AM, Ronald Hinchley commu...@gmail.com wrote: I notice that none of the examples or cases work. W3C Working Draft 16 February 2012. SCXML seems heavenly to me but is there interest in it? snip/ I believe you're asking about the Commons SCXML project, rather than the W3C SCXML standard itself. See this recent thread: http://markmail.org/message/wu5rfl25fxjyn7tb -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [SCXML] Ignoring raise element
On Mon, Oct 17, 2011 at 8:43 AM, Dark.Rider85 dark.ride...@yahoo.de wrote: Hi! I wanted to use the raise element but when parsing the .xml file the processor says the following warning: Ignoring element raise in namespace http://www.w3.org/2005/07/scxml; at bundleresource:***.xml:9:38 and digester match scxml/state/state/onentry/raise What is the meaning of that warning? And how do I solve the problem? snip/ The raise action wasn't implemented then. You can use send without a target or type for the same effect below. -Rahul Here is an extract of my xml file: ... state id=State1 initial=SubState1_1 state id=SubState1_1 transition event=event.SubState1_2 target=SubState1_2/ onentry my:customSay id=Hello SubState1_2!/ raise event=event.SubState1_2/ /onentry /state state id=SubState1_2 transition event=event.SubState1_3 target=SubState1_3/ onentry my:customSay id=Hello SubState1_3!/ raise event=event.SubState1_3/ /onentry /state /state ... Thanks in advance! Best regards - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] invoking methods on an object
On Mon, Oct 3, 2011 at 7:07 PM, Daniel Luis dos Santos daniel.d...@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 daniel.d...@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-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] invoking methods on an object
On Mon, Oct 3, 2011 at 9:17 AM, Daniel Luis dos Santos daniel.d...@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-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Syntax Question
On Sat, Oct 1, 2011 at 6:18 AM, Yasser Al Masri ysralma...@yahoo.com wrote: what's the best way to check whether a given variable is any of values within a list? For example, I want to say this: cond=myvar In('a','b','c') or cond=mylist.contain(myvar) snip/ Syntax of expressions within the SCXML document depends on the expression language (EL) in use. Please see the documentation for the EL you're using. For example, if you're using JEXL, see (though thats 2.0 syntax, out of the box you'd be on 1.1): http://commons.apache.org/jexl/reference/syntax.html You can also write your own EL functions if the syntax doesn't easily afford what you want to do. For more on method invocation from ELs, see bottom of this page which illustrates that using two of the common ELs: http://commons.apache.org/scxml/guide/contexts-evaluators.html -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Any Feed From Invoked State Machine Back to Invoker?
On Fri, Sep 23, 2011 at 9:27 AM, Yasser Al Masri ysralma...@yahoo.com wrote: Thanks. Is it much of trouble to post a little snippet explaining this? snip/ Perhaps better if you post where you are, so we start with the right assumptions about your usecase. -Rahul From: Rahul Akolkar To: Commons Users List user@commons.apache.org; Yasser Al Masri ysralma...@yahoo.com Sent: Thursday, September 22, 2011 8:36 PM Subject: Re: [scxml] Any Feed From Invoked State Machine Back to Invoker? On Thu, Sep 22, 2011 at 7:20 AM, Yasser Al Masri ysralma...@yahoo.com wrote: Hi, For synchronous communication between invoker and invoked machines we usually need to pass back a variable or some sort of signal to tell it that a result of a particular operation is so and so. Is there a way to accomplish this? snip/ Event correlation using application-specific naming patterns or payload properties is one way. Event payloads are open-ended and their interpretation is upto the application. -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Any Feed From Invoked State Machine Back to Invoker?
On Thu, Sep 22, 2011 at 7:20 AM, Yasser Al Masri ysralma...@yahoo.com wrote: Hi, For synchronous communication between invoker and invoked machines we usually need to pass back a variable or some sort of signal to tell it that a result of a particular operation is so and so. Is there a way to accomplish this? snip/ Event correlation using application-specific naming patterns or payload properties is one way. Event payloads are open-ended and their interpretation is upto the application. -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Setting state through history element or other means
On Wed, Sep 21, 2011 at 5:53 AM, Dario D darac1...@gmail.com wrote: Hello, Is there a way to programatically change history state of a workflow? Our idea is to be able to set freely the next state to be executed. If we set the state like this: Set states = executor.getCurrentStatus().getStates(); TransitionTarget tt = (TransitionTarget) executor.getStateMachine().getTargets().get(stateId); states.clear(); states.add(tt); This will set current state, but onentry will not be executed, only onexit on transition. Perhaps if we could somehow programatically change current status of the executor, so that when we trigger an event that has target=historyElement, the state machine will transition to the wanted state. Is this possible? snip/ There is no straightforward way to programmatically manipulate executor history. This is by design, as the historical record of execution should be what it was. There are some usecases for programmatic manipulation of current states (as can be done via snippet above) such as pooling of executors or persist-resume scenarios. Often, any need to do more programmatic manipulation beyond that may be mitigated by rethinking the state machine and associated events (including their payloads). -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Handling condition errors in transitions
On Mon, Sep 12, 2011 at 5:17 AM, Dario D darac1...@gmail.com wrote: Hello, I have an SCXML workflow as given below. The conditions in the transitions of state2 are invalid because they have an invalid variable name trans-0. The application was made in the way that on each step forward, it triggers an action.next event, followed by any external events inserted by a custom ErrorReporter. This way, the workflow would move to the _error state on every error. The problem is that on parsing of state2 transition conditions, it did not move to _error state. The following sequence ocurred: 1) Workflow follows to state2 2) Current state is state2, application triggers an action.next event 3) ErrorReported inserted two action.error events in the queue 4) However, the workflow is already in _end state (why?) 5) Application reads the external events queue, triggers two action.error events, but nothing happens because workflow is in _end state Why workflow ends up in _end state after parsing error? snip/ When the state machine is in state2, there are three candidate transitions that match event action.next -- two with guards in state2 and one unguarded or condition-less in state _processing. The two in state2 are not followed, but subsequently the unguarded one is selected and followed which leads to state _end. Given state _end is a final state, no further events triggered on the state machine will have any effect. -Rahul *scxml xmlns=**http://www.w3.org/2005/07/scxml*http://www.w3.org/2005/07/scxml * version=1.0 initialstate=_start* * state id=_start transition target=_processing / /state* * state id=_processing* * initial transition target=_actions/ /initial* * history id=_history type=deep* * /history state id=_actions initial=state1 state id=state1 transition event=action.next target=state2 / /state* * state id=state2 transition event=action.next cond=trans-0.parameter.P_InitialBalance == 7 target=state3 / transition event=action.next cond=trans-0.parameter.P_InitialBalance == 0 target=state4 / /state* * state id=state3 transition event=action.next target=state5 / /state* * state id=state4 transition event=action.next target=state5 / /state* * state id=state5 /state /state* * transition event=action.next target=_end /* * transition event=action.end target=_end/* * transition event=error.* target=_error /* * /state* * state id=_error* * onentry log expr='In error'/ /onentry* * transition event=action.next target=_history/* * transition event=action.end target=_end/* * /state* * state id=_end final=true* * /state* */scxml* - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Handling condition errors in transitions
On Tue, Sep 13, 2011 at 1:43 PM, Dario D darac1...@gmail.com wrote: 2011/9/13 Rahul Akolkar rahul.akol...@gmail.com When the state machine is in state2, there are three candidate transitions that match event action.next -- two with guards in state2 and one unguarded or condition-less in state _processing. The two in state2 are not followed, but subsequently the unguarded one is selected and followed which leads to state _end. Given state _end is a final state, no further events triggered on the state machine will have any effect. Thank you Rahul. There is no way to catch the parsing error if it happens in such conditions, and consequently trigger an error event? snip/ If thats what is desired, the state machine can be changed to reflect that. There isn't any inherent limitation precluding those kinds of patterns. There are a number of ways in which the state machine can be changed here, such as: * Fix the root cause that causes ill-formed expressions to appear * Transition to a non-final state that can still process error.* events * Use better ontology for events, rather than one action.next that is shared at different path fragment depths -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [SCXML] Call a Web Service
On Fri, Sep 2, 2011 at 5:09 AM, dark.rider85 dark.ride...@yahoo.de wrote: Hi! I was trying to search for a possibility to call a web service out of SCXML. I assumed the send command would be the action to use for this intention but I was not able to understand how it should work. In the W3C Working Draft there is a description of the Send command. A valid type also can be a HTTP URL using for Web Services. But how do I call a web service using the send command? Is it possible? Or is there any example code which I can consult? snip/ Provide an EventDispatcher [1] implementation that calls the web service keying off the appropriate type on the send. Bit more on that here [2]. -Rahul [1] http://commons.apache.org/scxml/apidocs/org/apache/commons/scxml/EventDispatcher.html [2] http://commons.apache.org/scxml/guide/core-engine.html Thanks in advance for any help! Best regards - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] sendid vs id attribute on send
On Wed, Aug 3, 2011 at 5:47 AM, Nick Hofstede nick.hofst...@inventivegroup.com wrote: I noticed that commons scxml uses the attribute sendid on the send element to specify the id of an event, whereas the scxml specification states that you should use the id attribute (see http://www.w3.org/TR/scxml/#send) I assume this is a bug and you want me to log it in the issue tracker? snip/ The specification has evolved (it was sendid to begin with), the implementation hasn't -- so yes, please do open a ticket in the tracker. If you could attach a patch to fix this, that'd be appreciated as well -- you'll want to change Send.java in the model package. -Rahul With kind regards, Nick Hofstede Inventive Designers' Email Disclaimer: http://www.inventivedesigners.com/email-disclaimer - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] A local transition to a parallel sub-state affects all its parent's siblings
On Wed, Jul 27, 2011 at 2:42 AM, Hynek Cihlar hynek.cih...@gmail.com wrote: Rahul, thank you for your clear explanation. The internal transitions would be the best solution for my use case (and also the default behavior I would personally expect). snip/ Agree it would work well for the use case below. In terms of implementing internal transitions, I came across a thread from James Barnett who claims to have them (and other standard features) implemented. Here's the link, http://apache-commons.680414.n4.nabble.com/scxml-removing-superstep-etc-td690740.html. Would you know if there was any subsequent progress? snap/ IIRC, there wasn't much beyond that thread. Also, worth noting that in that post he is talking about internal events, not internal transitions. -Rahul Thanks, Hynek On Tue, Jul 26, 2011 at 9:14 PM, Rahul Akolkar rahul.akol...@gmail.comwrote: On Mon, Jul 25, 2011 at 6:31 AM, Hynek Cihlar hynek.cih...@gmail.com wrote: I have come across the following case, where I believe the Commons SCXML behaves incorrectly. Assuming the following state machine configuration: scxml xmlns=http://www.w3.org/2005/07/scxml; xmlns:cs=http://commons.apache.org/scxml; version=1.0 initialstate=parallel parallel id=parallel state id=A initial transition target=A.1/ /initial transition event=anEvent target=A.2/ transition event=anAEvent target=A.3/ state id=A.1/ state id=A.2/ state id=A.3/ /state state id=B initial transition target=B.1/ /initial transition event=anEvent target=B.2/ state id=B.1/ state id=B.2/ /state /parallel /scxml First the event anEvent is triggered to bring the parallel states A and B from their initial states. Now, after triggering the event anAEvent I would expect only the state of A to be changed. Surprisingly the event has also effect on the B state, when it is brought to its initial state. snip/ I understand why this could be slightly surprising, but this is expected behavior. There are two rules of execution that combine here: (a) When a state machine follows a transition, it must leave the source state (and enter the target) (b) A state machine must be in all or none of the orthogonal siblings (or regions of a parallel) at any given time Now, with the above in mind, while processing anAEvent the state machine must leave its source state A which happens to be a region of the parallel, thereby the other region B must also be exited. On reentry into these regions, the rest states are A2 (explicit target of transition) and B1 (initial in absence of any explicit target). Clearly, this behavior may not be what you desire. Couple of ways to correct this and obtain the behavior you are after: (1) Avoid having transitions that are placed in direct child states of parallel, this may be done by having an intermediate wrapper state. (2) Define the transition as internal so source state is not exited in this case -- this is easier in theory but not supported by Commons SCXML at the moment (patches to add support welcome). -Rahul Tested on the svn revision 1143657, last changed date 2011-06-07 01:13:06 +0200 (Tue, 07 Jun 2011). I am attaching the output log from the engine execution. 2011-07-25 12:26:56,419 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel 2011-07-25 12:26:56,420 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/A 2011-07-25 12:26:56,421 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/B 2011-07-25 12:26:56,421 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/A/A.1 2011-07-25 12:26:56,421 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/B/B.1 2011-07-25 12:26:56,425 DEBUG [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null 2011-07-25 12:26:56,426 DEBUG [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap = {B.entry=null, parallel.entry=null, A.1.entry=null, B.1.entry=null, A.entry=null} 2011-07-25 12:26:56,451 DEBUG [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null 2011-07-25 12:26:56,451 DEBUG [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap = {B.entry=null, parallel.entry=null, A.1.entry=null, B.1.entry=null, A.entry=null} 2011-07-25 12:26:56,452 DEBUG [org.apache.commons.scxml.SCXMLExecutor:538] : Current States: [A.1, B.1] 2011-07-25 12:26:56,452 DEBUG [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null 2011-07-25 12:26:56,452 DEBUG [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap = {anEvent=null} 2011-07-25 12:26:56,459 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:53] : /parallel/B/B.1 2011-07-25 12:26:56,459 INFO
Re: [scxml] A local transition to a parallel sub-state affects all its parent's siblings
On Mon, Jul 25, 2011 at 6:31 AM, Hynek Cihlar hynek.cih...@gmail.com wrote: I have come across the following case, where I believe the Commons SCXML behaves incorrectly. Assuming the following state machine configuration: scxml xmlns=http://www.w3.org/2005/07/scxml; xmlns:cs=http://commons.apache.org/scxml; version=1.0 initialstate=parallel parallel id=parallel state id=A initial transition target=A.1/ /initial transition event=anEvent target=A.2/ transition event=anAEvent target=A.3/ state id=A.1/ state id=A.2/ state id=A.3/ /state state id=B initial transition target=B.1/ /initial transition event=anEvent target=B.2/ state id=B.1/ state id=B.2/ /state /parallel /scxml First the event anEvent is triggered to bring the parallel states A and B from their initial states. Now, after triggering the event anAEvent I would expect only the state of A to be changed. Surprisingly the event has also effect on the B state, when it is brought to its initial state. snip/ I understand why this could be slightly surprising, but this is expected behavior. There are two rules of execution that combine here: (a) When a state machine follows a transition, it must leave the source state (and enter the target) (b) A state machine must be in all or none of the orthogonal siblings (or regions of a parallel) at any given time Now, with the above in mind, while processing anAEvent the state machine must leave its source state A which happens to be a region of the parallel, thereby the other region B must also be exited. On reentry into these regions, the rest states are A2 (explicit target of transition) and B1 (initial in absence of any explicit target). Clearly, this behavior may not be what you desire. Couple of ways to correct this and obtain the behavior you are after: (1) Avoid having transitions that are placed in direct child states of parallel, this may be done by having an intermediate wrapper state. (2) Define the transition as internal so source state is not exited in this case -- this is easier in theory but not supported by Commons SCXML at the moment (patches to add support welcome). -Rahul Tested on the svn revision 1143657, last changed date 2011-06-07 01:13:06 +0200 (Tue, 07 Jun 2011). I am attaching the output log from the engine execution. 2011-07-25 12:26:56,419 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel 2011-07-25 12:26:56,420 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/A 2011-07-25 12:26:56,421 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/B 2011-07-25 12:26:56,421 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/A/A.1 2011-07-25 12:26:56,421 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/B/B.1 2011-07-25 12:26:56,425 DEBUG [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null 2011-07-25 12:26:56,426 DEBUG [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap = {B.entry=null, parallel.entry=null, A.1.entry=null, B.1.entry=null, A.entry=null} 2011-07-25 12:26:56,451 DEBUG [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null 2011-07-25 12:26:56,451 DEBUG [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap = {B.entry=null, parallel.entry=null, A.1.entry=null, B.1.entry=null, A.entry=null} 2011-07-25 12:26:56,452 DEBUG [org.apache.commons.scxml.SCXMLExecutor:538] : Current States: [A.1, B.1] 2011-07-25 12:26:56,452 DEBUG [org.apache.commons.scxml.env.SimpleContext:165] : _eventdata = null 2011-07-25 12:26:56,452 DEBUG [org.apache.commons.scxml.env.SimpleContext:165] : _eventdatamap = {anEvent=null} 2011-07-25 12:26:56,459 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:53] : /parallel/B/B.1 2011-07-25 12:26:56,459 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:53] : /parallel/A/A.1 2011-07-25 12:26:56,459 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:53] : /parallel/B 2011-07-25 12:26:56,459 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:53] : /parallel/A 2011-07-25 12:26:56,459 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:63] : transition (event = anEvent, cond = null, from = /parallel/A, to = /parallel/A/A.2) 2011-07-25 12:26:56,459 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:63] : transition (event = anEvent, cond = null, from = /parallel/B, to = /parallel/B/B.2) 2011-07-25 12:26:56,460 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/A 2011-07-25 12:26:56,460 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/B 2011-07-25 12:26:56,460 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] : /parallel/A/A.2 2011-07-25 12:26:56,460 INFO [org.apache.commons.scxml.env.SimpleSCXMLListener:44] :
Re: [scxml] SCXML model thread-safe?
On Wed, Jul 6, 2011 at 12:48 AM, Dario D darac1...@gmail.com wrote: Thank you Rahul. In regards to custom actions in such usage case, from what we've seen, a new instance of the custom action class is created on each execution of the action. This makes it impossible for two threads to access the same custom action object simultaneously. Am I correct? snip/ There is a new instance in the model for each instance of the custom action in the document i.e. the following: onentry custom:foo ... / custom:foo ... / /onentry will create two instances of the custom action foo class as children of the onentry. Either of these instances may be accessed by multiple threads if the same model is shared across many executors. Custom actions implementations should be stateless beyond things like fields that store attribute values which are identical across invocations and not meant to be mutable. Other state should be derived within the execute() method by introspecting the state or root context and persisting changes to said context (which is specific to the executor). -Rahul 2011/7/5 Rahul Akolkar rahul.akol...@gmail.com On Tue, Jul 5, 2011 at 3:37 AM, Dario D darac1...@gmail.com wrote: Is the SCXML model thread-safe? We're considering to parse the SCXML files on application startup and then store the resulting SCXML models in a cache where multiple threads will access them. Should we expect any inconsistencies? Note that executors will not be cached, and a new executor will be created per request. snip/ The above usage pattern is fine. We have a test or two running in the nightlies that does the above (one model, many executors). Ofcourse, I'd recommend authoring tests that closely match your scenario as well. -Rahul Thank you! - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] SCXML model thread-safe?
On Tue, Jul 5, 2011 at 3:37 AM, Dario D darac1...@gmail.com wrote: Is the SCXML model thread-safe? We're considering to parse the SCXML files on application startup and then store the resulting SCXML models in a cache where multiple threads will access them. Should we expect any inconsistencies? Note that executors will not be cached, and a new executor will be created per request. snip/ The above usage pattern is fine. We have a test or two running in the nightlies that does the above (one model, many executors). Ofcourse, I'd recommend authoring tests that closely match your scenario as well. -Rahul Thank you! - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Target of transition as variable?
On Tue, Jun 21, 2011 at 3:42 PM, Artem Vovk vovk.ar...@googlemail.com wrote: Can I use dynamic transition targets? Something like this? datamodel data id=dyn_state expr=State1 /datamodel ... transition ... target=dyn_state/ If I use it on this way, I receive an exception: Transition target with ID dyn_state not found - Interpreter thinks that it is a name of the state, but not the variable... Is there a way to define such transitions? snip/ Not directly as you are illustrating above. Most state machines in general, and SCXML in particular, requires you specify fixed target(s) for each transition. This is actually quite useful because it allows static analysis to determine whether all transition targets are legal even before the state machine is executed. It is also not as limiting as it may seem at first, because of the existence of things like guard conditions on transitions and history states. For the above, a literal translation may appear to be as follows (replacing dynamic target with static ones): transition cond=dyn_state eq 'State1' target=State1/ transition cond=dyn_state eq 'State2' target=State2/ ... The above pattern can certainly be used, and may seem more verbose. But note that there are usually two assign or similar statements elsewhere that are updating the data 'dyn_state'. Often, these can instead be replaced as appropriate guard conditions on the two transitions above so the net effect is no change in verbosity. -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Target of transition as variable?
On Thu, Jun 23, 2011 at 6:46 PM, Artem Vovk vovk.ar...@googlemail.com wrote: Thanks for the answer! I have also implemented on this way, but I think it makes all complicated and I see no benefits from static states I give an example where dyn states are useful and much less verbose: I have 10 basic_states that under some condition(internet is not available) can be transitioned to another special_state(NoInternetConnection), but this state must know the basic_state from which it receives the event, to go back under another condition(internet is available). With dynamic states it takes only one assign per basic_state and one transition in special_state and I does not need to change special_state each time when I want to add a new basic_state snip/ Use history states (see mention in previous email). -Rahul On Jun 23, 2011, at 11:54 PM, Rahul Akolkar wrote: On Tue, Jun 21, 2011 at 3:42 PM, Artem Vovk vovk.ar...@googlemail.com wrote: Can I use dynamic transition targets? Something like this? datamodel data id=dyn_state expr=State1 /datamodel ... transition ... target=dyn_state/ If I use it on this way, I receive an exception: Transition target with ID dyn_state not found - Interpreter thinks that it is a name of the state, but not the variable... Is there a way to define such transitions? snip/ Not directly as you are illustrating above. Most state machines in general, and SCXML in particular, requires you specify fixed target(s) for each transition. This is actually quite useful because it allows static analysis to determine whether all transition targets are legal even before the state machine is executed. It is also not as limiting as it may seem at first, because of the existence of things like guard conditions on transitions and history states. For the above, a literal translation may appear to be as follows (replacing dynamic target with static ones): transition cond=dyn_state eq 'State1' target=State1/ transition cond=dyn_state eq 'State2' target=State2/ ... The above pattern can certainly be used, and may seem more verbose. But note that there are usually two assign or similar statements elsewhere that are updating the data 'dyn_state'. Often, these can instead be replaced as appropriate guard conditions on the two transitions above so the net effect is no change in verbosity. -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Transition without changing a state
On Sat, Jun 18, 2011 at 9:39 AM, Artem Vovk vovk.ar...@googlemail.com wrote: Hi, Is it a valid scxml expression in apache commons? snip/ If you mean transition, yes, target-less transitions are valid (a.k.a. stay transitions). transition event=internal cond=_eventdata['name'] eq 'cancelclick' send event='send_event' targettype='outside' namelist=cancel / /transition Because I trigger this event, but send does not works. snap/ You should see the EventDispatcher#send() call if the transition is indeed followed (event triggered and guard condition is true). -Rahul Cheers Artem - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [jexl][scxml] Change values of map in scxml
On Wed, Jun 15, 2011 at 12:25 PM, Artem Vovk vovk.ar...@googlemail.com wrote: Second method works pretty good, Thanks! One more question, is there in scxml version using in apache commons a time out functionality? I need something like: state id=Awaiting onentry Wait 5 sec than go to state end /onentry /state snip/ Sure, use send with delay attribute and use the SimpleScheduler [1] as the EventDispatcher implementation (or write similar if you want something other than java.util.Timer). -Rahul [1] http://commons.apache.org/scxml/0.9/apidocs/org/apache/commons/scxml/env/SimpleScheduler.html On Jun 14, 2011, at 12:45 AM, Rahul Akolkar wrote: On Mon, Jun 13, 2011 at 10:50 AM, Artem Vovk vovk.ar...@googlemail.com wrote: Hi, I have a data model in my scxml file, that defined as map: datamodel data id=event expr={'key1' : 'value1', 'key2', 'value2'} /datamodel I want to use this data as a constructor for sending data, but I need to change values in this data: something like that data id=event_new expr=event_new = event, but change event[key1] to new_value Is this possible within scxml using jexl? snip/ Either using a script tag (unreleased, see J6 branch in SVN) or a custom function as you mention below. Another question, that may replace this functionality, is using functions: can I define function in scxml using jexl? snap/ Yes, see bottom of this page, section on Method invocation in expressions: http://commons.apache.org/scxml/guide/contexts-evaluators.html -Rahul Cheers Artem - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [jexl][scxml] Change values of map in scxml
On Mon, Jun 13, 2011 at 10:50 AM, Artem Vovk vovk.ar...@googlemail.com wrote: Hi, I have a data model in my scxml file, that defined as map: datamodel data id=event expr={'key1' : 'value1', 'key2', 'value2'} /datamodel I want to use this data as a constructor for sending data, but I need to change values in this data: something like that data id=event_new expr=event_new = event, but change event[key1] to new_value Is this possible within scxml using jexl? snip/ Either using a script tag (unreleased, see J6 branch in SVN) or a custom function as you mention below. Another question, that may replace this functionality, is using functions: can I define function in scxml using jexl? snap/ Yes, see bottom of this page, section on Method invocation in expressions: http://commons.apache.org/scxml/guide/contexts-evaluators.html -Rahul Cheers Artem - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: Terminate SCXML-Executor
On Fri, Jun 10, 2011 at 12:33 PM, Oksana Kolach bo...@gmx.de wrote: Hello everybody, which possibilities exists to terminate an SCXML-Executor, that is running in an infinit loop? snip/ SCXML does not provide any in-built safeguards against infinite loops. Like most languages, its possible to write such loops (in this case, as back and forth state transitions). Background: My SCXML-state machine contains a loop. If the SCXML-state machine is loaded by the executor and the executor is set to go(), then the executor is never ending. To terminate this infinite loop after a certain time, I could start the executor into another java-thread and kill this thread after the time-limit is reached. But this solution is not the best one I think. snap/ Right, I'd say the state machine is defective i.e. it raises the question why it contains an infinite loop in the first place -- I'd recommend analyzing that at a modeling level using the knowledge of the domain and usecase to remove such loops in favor of any number of alternatives (custom actions, facets of the external communications module - send, invoke etc.). Has anyone a better idea? Exists there something like a watchdog-timer-method (http://en.wikipedia.org/wiki/Watchdog_timer)? snip/ You could easily implement such in SCXML itself using delayed send coupled with a near-root level transition that kicks the state machine out of the loopy bits :-) -Rahul Thanks in advance. O.K. - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] JEXL map in scxml
On Wed, Jun 8, 2011 at 4:31 AM, Artem Vovk vovk.ar...@googlemail.com wrote: Hi, I'm trying to create and send JEXL map, I wrote: cs:var name=one expr={ 'test' : 2}/ send event='event1' target=receiver targetType=x-ajax namelist=one/ But SCXML interpreter shows an exception : WARNUNG: EXPRESSION_ERROR (eval('{ 'test' : 2}'):Lexical error at line 1, column 10. Encountered: : (58), after : ): What is wrong with this syntax? snip/ Its not JEXL 1.x syntax, which is default. JEXL 2.x syntax will require a suitable Evaluator/Context implementation. You can either provide one yourself or try the one attached to this ticket [1]. -Rahul [1] https://issues.apache.org/jira/browse/SCXML-114 Cheers Artem - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] src element as a pointer to memory content
On Mon, Jun 6, 2011 at 5:35 PM, Dario D darac1...@gmail.com wrote: Hello, Would it be possible to have a PathResolver implementation which treats the src element as a pointer to a database entry where content is stored, or an in-memory object? Of course, I could make a PathResolver implementation which will parse the value of src make a query to the database, download the content to a file, and then return file path as the result of the resolvePath() method. However, I would like to skip the step of making a file on the disk just for the purpose of loading the src content. Ideally, this PathResolver implementation would be able to read content directly from a memory object (perhaps a cache of some sort), without the need of creating a file. I'm planning to use SCXML in a high-throughtput environment and I feel that writing files on the disk and then reading them back will slow the process down a bit. One of the requirements for the application is to be able to split SCXML files into many reusable modules, thus the need to use the src element. Any thoughts? snip/ Requirement is reasonable, my suggestion would be to investigate using your own scheme for the resolved URLs and providing a custom stream protocol handler that reads from memory or cache as desired. For more on how to do this, see the java.net.URL class docs, in particular, the portion here: http://download.oracle.com/javase/1.4.2/docs/api/java/net/URL.html#URL(java.lang.String,%20java.lang.String,%20int,%20java.lang.String) Separately, you should be aware that the src attribute has been removed from the SCXML spec in favor of standard techniques like XInclude, though Commons SCXML will continue to support it till the next major release. -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] trasition tag with type=internal in compound state issue
On Mon, Jun 6, 2011 at 7:11 PM, Vance huang vancehu...@yahoo.com wrote: Hi, According to the SCXML spec, the following was stated: The behavior of transitions with 'type' of internal is identical, except in the case of a transition whose source state is a compound state and whose target(s) is a descendant of the source. In such a case, an internal transition will not exit and re-enter its source state, while an external one will, as shown in the example below. I am trying to do something similar like the following: state id=s1 initial=s11 onentry log expr=entering S1/ /onentry onexit log expr='leaving s1'/ /onexit state id=s11 onentry log expr=entering s11/ /onentry onexit log expr='leaving s11'/ /onexit /state state id=s12 onentry log expr=entering s12/ /onentry onexit log expr='leaving s12'/ /onexit /state transition event=e target=s12 type=internal log expr='executing transition'/ /transition /state Assuming I am in s11 when event e fired. But it always log leaving s1 before log executing transition which means going out of S1 even if the internal type was set. Am I missing something in the spec? snip/ No, though internal transitions are a recent addition and are not yet implemented in Commons SCXML. You may open an enhancement request to track this in JIRA [1]. Patches with suggested fixes are welcome as well. Also, I am not sure how can I search in the archive to see if this question has been asked before. Can you let me know? Thanks! snap/ You can use a number of archives for searching, markmail [2] is one example. More information on the project mailing lists page [3], see two columns on far right in table on page. -Rahul [1] http://commons.apache.org/scxml/issue-tracking.html [2] http://commons.markmail.org/ [3] http://commons.apache.org/scxml/mail-lists.html Vance - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] src element as a pointer to memory content
On Tue, Jun 7, 2011 at 12:44 AM, Dario D darac1...@gmail.com wrote: Thank you Rahul. In fact we were investigating the possibility of having our own protocol handlers, but we noticed that the resolve() method of PathResolver returned a string, not an URL. What did you have in mind? snip/ ISTR that the String value is simply treated as a URL spec by the parser so it'd be effectively the same. Suggest doing a little test of your own to verify. -Rahul 2011/6/7 Rahul Akolkar rahul.akol...@gmail.com On Mon, Jun 6, 2011 at 5:35 PM, Dario D darac1...@gmail.com wrote: Hello, Would it be possible to have a PathResolver implementation which treats the src element as a pointer to a database entry where content is stored, or an in-memory object? Of course, I could make a PathResolver implementation which will parse the value of src make a query to the database, download the content to a file, and then return file path as the result of the resolvePath() method. However, I would like to skip the step of making a file on the disk just for the purpose of loading the src content. Ideally, this PathResolver implementation would be able to read content directly from a memory object (perhaps a cache of some sort), without the need of creating a file. I'm planning to use SCXML in a high-throughtput environment and I feel that writing files on the disk and then reading them back will slow the process down a bit. One of the requirements for the application is to be able to split SCXML files into many reusable modules, thus the need to use the src element. Any thoughts? snip/ Requirement is reasonable, my suggestion would be to investigate using your own scheme for the resolved URLs and providing a custom stream protocol handler that reads from memory or cache as desired. For more on how to do this, see the java.net.URL class docs, in particular, the portion here: http://download.oracle.com/javase/1.4.2/docs/api/java/net/URL.html#URL(java.lang.String,%20java.lang.String,%20int,%20java.lang.String) Separately, you should be aware that the src attribute has been removed from the SCXML spec in favor of standard techniques like XInclude, though Commons SCXML will continue to support it till the next major release. -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] transition leaving a child state of parallel
On Fri, Jun 3, 2011 at 3:20 AM, Enrico Nardelli narde...@mat.uniroma2.it wrote: I have the following SCXML ?xml version=1.0 encoding=UTF-8? scxml xmlns=http://www.w3.org/2005/07/scxml; version=1.0 exmode=lax initialstate=initialstate state id=initialstate transition event=start target=onetwo / /state parallel id=onetwo transition event=onetwo_three target=three / state id=one /state state id=two transition event=two_four target=four / /state /parallel state id=three transition event=three_one target=one / transition event=three_four target=four / /state state id=four transition event=four_onetwo target=onetwo / transition event=four_three target=three / /state /scxml Issuing event onetwo_three while in the parallel correctly brings the state machine in three. Issuing event two_four while in the parallel raises an ILLEGAL_CONFIG error. snip/ I can't see why it should error out either. Please open a defect in JIRA [1] with above SCXML document and I'll take a look. If you're so inclined, a patch with a (failing) JUnit test -- see existing test suite [2] for inspiration -- would make it even easier. -Rahul [1] http://commons.apache.org/scxml/issue-tracking.html [2] http://svn.apache.org/repos/asf/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/ Here is the detailed log transcription 3-giu-2011 3.30.35 org.apache.commons.scxml.model.Log execute INFO: null: entering initialstate event: start 3-giu-2011 3.30.46 org.apache.commons.scxml.model.Log execute INFO: null: leaving initialstate 3-giu-2011 3.30.46 org.apache.commons.scxml.model.Log execute INFO: null: entering onetwo 3-giu-2011 3.30.46 org.apache.commons.scxml.model.Log execute INFO: null: entering one 3-giu-2011 3.30.46 org.apache.commons.scxml.model.Log execute INFO: null: entering two event: onetwo_three 3-giu-2011 3.30.53 org.apache.commons.scxml.model.Log execute INFO: null: leaving two 3-giu-2011 3.30.53 org.apache.commons.scxml.model.Log execute INFO: null: leaving one 3-giu-2011 3.30.53 org.apache.commons.scxml.model.Log execute INFO: null: leaving onetwo 3-giu-2011 3.30.53 org.apache.commons.scxml.model.Log execute INFO: null: entering three event: three_four 3-giu-2011 3.31.04 org.apache.commons.scxml.model.Log execute INFO: null: leaving three 3-giu-2011 3.31.04 org.apache.commons.scxml.model.Log execute INFO: null: entering four event: four_onetwo 3-giu-2011 3.31.08 org.apache.commons.scxml.model.Log execute INFO: null: leaving four 3-giu-2011 3.31.08 org.apache.commons.scxml.model.Log execute INFO: null: entering onetwo 3-giu-2011 3.31.08 org.apache.commons.scxml.model.Log execute INFO: null: entering one 3-giu-2011 3.31.08 org.apache.commons.scxml.model.Log execute INFO: null: entering two event: two_four 3-giu-2011 3.31.15 org.apache.commons.scxml.env.SimpleErrorReporter onError AVVERTENZA: ILLEGAL_CONFIG (Not all AND states active for parallel onetwo): /onetwo : [/onetwo/one] Illegal state machine configuration! 3-giu-2011 3.31.15 org.apache.commons.scxml.env.SimpleErrorReporter onError AVVERTENZA: ILLEGAL_CONFIG (Multiple top-level OR states active!): SCXML : [/four, /onetwo] Any hints ? Best...Enrico - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Problem raising event in scxml
On Tue, May 31, 2011 at 6:21 AM, J J jesfa...@yahoo.es wrote: Thanks Rahul, I've changed the in the way you told me and the warning disappeared, but it didn't work in the way I needed, so I've changed the implementation to do it in a custom action in the onentry tag. snip/ OK, though there isn't enough information above. The custom Action does the work fine, but at the end I need to raise a next event to the queue but it's not working. I try to raise the event with eventDispatcher.send method but it's not lauching that event. I know it's not launchiung because I have a SCXMLListener with a onentry method wich is executed after the custom action and I can see in debug mode the states where the the flow goes. Here is the code I'm using. I've tried also to set target and type to null, but it happens the same. any idea? snap/ Depends on the EventDispatcher implementation (the simple/dummy one in the distro doesn't do much). thanks. public class Skip extends Action { @Override public void execute(EventDispatcher eventDispatcher, ErrorReporter errorReporter, SCInstance scInstance, Log log, Collection derivedEvents) throws ModelException, SCXMLExpressionException { //some checks and if I want to skip this state I add in the String event //variable the name of the event ... snip/ If you want a derived event, add it to derivedEvents like so: TriggerEvent te = ... // create the derived event after same checks as above derivedEvents.add(te); // add to internal event queue Thats about it. -Rahul if(event != null){ //I want to raise the event String sendId = null; String target = #_internal; String type = scxml; Map params = null; Object hints = null; long delay = 0; List externalNodes = null; eventDispatcher.send(sendId , target, type, event, params, hints, delay, externalNodes); } } } De: Rahul Akolkar rahul.akol...@gmail.com Para: Commons Users List user@commons.apache.org Enviado: jue,26 mayo, 2011 15:31 Asunto: Re: [scxml] Problem raising event in scxml On Thu, May 26, 2011 at 7:55 AM, J J jesfa...@yahoo.es wrote: Hello, I'm having an issue with the raise tag inside an if element in the onentry content. The problem is explained more in this Stackoverflow question: http://stackoverflow.com/questions/6044370/problem-raising-event-in-scxml Can anyone tell me what may be the problem? snip/ As the warning message indicates, raise is not implemented yet, neither is _event (previously, a subset was _eventdata, which is implemented). You can use send with no target or type to achieve the same (basically change the element name in that snippet to be send). You may open enhancement requests for anything that isn't implemented yet from the latest draft [1]. -Rahul [1] http://commons.apache.org/scxml/issue-tracking.html - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Problem raising event in scxml
On Thu, May 26, 2011 at 7:55 AM, J J jesfa...@yahoo.es wrote: Hello, I'm having an issue with the raise tag inside an if element in the onentry content. The problem is explained more in this Stackoverflow question: http://stackoverflow.com/questions/6044370/problem-raising-event-in-scxml Can anyone tell me what may be the problem? snip/ As the warning message indicates, raise is not implemented yet, neither is _event (previously, a subset was _eventdata, which is implemented). You can use send with no target or type to achieve the same (basically change the element name in that snippet to be send). You may open enhancement requests for anything that isn't implemented yet from the latest draft [1]. -Rahul [1] http://commons.apache.org/scxml/issue-tracking.html - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] release date of new version
On Mon, May 23, 2011 at 5:50 PM, Uli Biberger ubiber...@yahoo.de wrote: Hello, I wonder if there's any plan for another official release. The 0.9 version is over two years old - and I am curious wether there's active development or just maintainance. snip/ There isn't any official date and its unlikely to be over the next few months, unless others jump in and help with the development and release. There isn't any active development at the moment. The underlying reasons for the above are: * v0.9 still works well for many usecases (and ofcourse, will continue to be available, as do all releases) * I don't have the cycles to work towards a release at the moment * The Working Group is expecting to produce a Last Call Working Draft in a few months -- it makes sense to save any cycles for an update then (when most moving parts will have reasonably settled in the spec) -Rahul Thanks for any response in advance, Uli - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Trigger complicated events
On Sat, May 21, 2011 at 4:41 PM, Artem Vovk vovk.ar...@googlemail.com wrote: Hi, In the document about Authoring Applications for the Multimodal Architecture(http://www.w3.org/TR/mmi-auth/), I have noticed an interesting transition tag : !-- handle GUI input -- transition event=mmi:extension cond=_event.data..@source.toString() == 'GUI' _event.data..@status.toString() == 'success' target=echoColor/ !-- save color to data model -- assign location=_data.color expr=_event.data..color.toString()/ /transition It looks that a data was send with the event and one can access this data with _event.data... . How can I send such events from commons scxml to scxml document?(with method fireEvent(String event) I can fire only the event name, without data) snip/ When you instantiate the TriggerEvent, use the three argument constructor to add event payload: http://commons.apache.org/scxml/0.9/apidocs/org/apache/commons/scxml/TriggerEvent.html#TriggerEvent(java.lang.String, int, java.lang.Object) Then, you may refer to the payload Object as _eventdata (in v0.9, in next release it will change to _event.data as the spec now requires). Here is an example from the test suite that uses event payload to determine transitions to follow; so you can look up syntax (see parent directory for more samples, syntax depends on EL in use): http://svn.apache.org/repos/asf/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/eventdata-02.xml -Rahul Cheers, Artem - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Trigger complicated events
On Sat, May 21, 2011 at 6:48 PM, Rahul Akolkar rahul.akol...@gmail.com wrote: On Sat, May 21, 2011 at 4:41 PM, Artem Vovk vovk.ar...@googlemail.com wrote: Hi, In the document about Authoring Applications for the Multimodal Architecture(http://www.w3.org/TR/mmi-auth/), I have noticed an interesting transition tag : !-- handle GUI input -- transition event=mmi:extension cond=_event.data..@source.toString() == 'GUI' _event.data..@status.toString() == 'success' target=echoColor/ !-- save color to data model -- assign location=_data.color expr=_event.data..color.toString()/ /transition It looks that a data was send with the event and one can access this data with _event.data... . How can I send such events from commons scxml to scxml document?(with method fireEvent(String event) I can fire only the event name, without data) snip/ When you instantiate the TriggerEvent, use the three argument constructor to add event payload: http://commons.apache.org/scxml/0.9/apidocs/org/apache/commons/scxml/TriggerEvent.html#TriggerEvent(java.lang.String, int, java.lang.Object) snip/ Encoding above to increase chances of a good hyperlink in mail readers: http://commons.apache.org/scxml/0.9/apidocs/org/apache/commons/scxml/TriggerEvent.html#TriggerEvent(java.lang.String%2C%20int%2C%20java.lang.Object) -Rahul Then, you may refer to the payload Object as _eventdata (in v0.9, in next release it will change to _event.data as the spec now requires). Here is an example from the test suite that uses event payload to determine transitions to follow; so you can look up syntax (see parent directory for more samples, syntax depends on EL in use): http://svn.apache.org/repos/asf/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/jexl/eventdata-02.xml -Rahul Cheers, Artem - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: Re: [scxml]
On Tue, May 17, 2011 at 3:44 PM, Vance huang vancehu...@yahoo.com wrote: Hi, Rahul: Thanks for taking a look. In further testing, I found the probable cause of this issue is that when the custom action in test2 is executing, sometimes it injects the actionComplete event right back to the scxml engine (in the same thread). When that occurs, the state transition is messed up and stayed in test2-init state though in the log it went into active state. If the custom action is not doing that, and later another thread sends the actionComplete to the engine, then it transitions fine. Is this a bug or something should not be done based on the spec? Thanks. snip/ You should inject events from within a custom action by adding to the set of derived events (param of execute method) which will be processed in a subsequent microstep, rather than triggering another event on the executor (if thats what you're doing). -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] events triggered in onentry
On Tue, May 17, 2011 at 8:37 PM, Ryan rnidef...@gmail.com wrote: Looks like I signed up for this mailing list about 5 hours too late. Reading today's reply from Rahul, he notes: You should inject events from within a custom action by adding to the set of derived events (param of execute method) which will be processed in a subsequent microstep, rather than triggering another event on the executor (if thats what you're doing). Once I added the TriggerEvent to the Collection of derived events, the transition condition evaluated to 'true' as expected. Is this explained in the documentation and I just missed it? I'm curious as to when it would be desirable to trigger an event on the SCXMLExecutor instance itself versus adding it to the derived events collection. snip/ Synchronous cases like custom actions (pretty much the only case) should produce derived events (rather than attempting re-entrant triggers). Asynchronous cases like invoke or delayed sends should trigger events on the executor. If expected frequency of external triggers on a state machine is high (many per sec), its a good idea to maintain a separate synchronized event queue. Finally, there is always room for better docs, FAQ etc. -- happy to look at any suggested patches [1] for improvement. Site source is here [2]. -Rahul [1] http://commons.apache.org/scxml/issue-tracking.html [2] http://svn.apache.org/repos/asf/commons/proper/scxml/trunk/src/site/ Ryan On Tue, May 17, 2011 at 5:22 PM, Ryan rnidef...@gmail.com wrote: I have the following simple SCXML document: scxml xmlns=http://www.w3.org/2005/07/scxml; xmlns:my=http://www.my.com; version=1.0 initialstate=welcome state id=welcome onentry my:play filename=welcome/ /onentry transition cond=${_eventdata eq 'blah'} target=end/ /state state id=end final=true onentry/ /state /scxml My approach is to generate events from custom actions, then act on those events in my transitions. To test this approach, I hardcoded the generation of an event in my Play.class action: TriggerEvent evt = new TriggerEvent(agi.keypress, TriggerEvent.SIGNAL_EVENT, blah); scInstance.getExecutor().triggerEvent(evt); However, I can't seem to get the transition/ to recognize this event. Here is log output as the state machine runs: [org.apache.commons.scxml.Context] (Asterisk-Java DaemonPool-1-thread-1) _eventdata = blah [org.apache.commons.scxml.Context] (Asterisk-Java DaemonPool-1-thread-1) _eventdatamap = {agi.keypress=blah} [org.apache.commons.scxml.Context] (Asterisk-Java DaemonPool-1-thread-1) _eventdata = null [org.apache.commons.scxml.Context] (Asterisk-Java DaemonPool-1-thread-1) _eventdatamap = null [org.apache.commons.scxml.SCXMLExecutor] (Asterisk-Java DaemonPool-1-thread-1) Current States: [] [org.apache.commons.scxml.Context] (Asterisk-Java DaemonPool-1-thread-1) _eventdata = null [org.apache.commons.scxml.Context] (Asterisk-Java DaemonPool-1-thread-1) _eventdatamap = {welcome.entry=null} [org.apache.commons.scxml.Evaluator] (Asterisk-Java DaemonPool-1-thread-1) ${_eventdata eq 'blah'} = false [org.apache.commons.scxml.Context] (Asterisk-Java DaemonPool-1-thread-1) _ALL_NAMESPACES = null [org.apache.commons.scxml.Context] (Asterisk-Java DaemonPool-1-thread-1) _eventdata = null [org.apache.commons.scxml.Context] (Asterisk-Java DaemonPool-1-thread-1) _eventdatamap = {welcome.entry=null} [org.apache.commons.scxml.SCXMLExecutor] (Asterisk-Java DaemonPool-1-thread-1) Current States: [welcome] Why is the _eventdata/_eventdatamap pair being printed twice to start? The first time it has the event I've triggered, the second time its empty. Then after this, you see that the welcome.entry event triggered, then the JSP EL condition evaluates to false. My initial guess is that I've misunderstood the state machine algorithm, and my attempt to trigger an event from the onentry/ is flawed. How should I go about this? Thanks, Ryan - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: Re: [scxml]
On Mon, May 16, 2011 at 12:26 PM, Vance huang vancehu...@yahoo.com wrote: Hi, Rahul: Here is the trimmed down snippet: snip/ I reduced it even further: state id=active transition event=test2 target=test2/ /state state id=test2 initial=test2-init state id=test2-init onentry assign name=keepGoing expr=true/ /onentry transition cond=keepGoing == true custom:action/ !-- above presumably adds actionComplete derived event -- /transition transition event=actionComplete target=test2-final/ /state state id=test2-final transition target=active/ /state /state Is the above still a representative test case where you're seeing the behavior (using the same custom action you have below)? If so, the issue is still unclear. If you're repeatedly firing test2 events, you may want to throttle them (with short delays) to ensure the executor is done processing the previous event. If after that something still seems amiss, next step would then be to provide a simplest JUnit test case that can reproduce the problem (see src/test directory in SVN or source distro for numerous examples of test cases). -Rahul state id=active onentry log expr='active State. / /onentrytransition event=test2 target=test2/ transition event=* log expr='active State handling unexpected event' / custom action here/ /transition /state state id=test2 initial=test2-init state id=test2-init onentry log expr='test2-init State. / assign name=keepGoing expr=true/ /onentry transition cond=keepGoing == true log expr='test2-keepGoing' / calling a custom action here/ /transition transition event=actionComplete target=test2-final log expr='test2-actionComplete.' / /transition transition event=* log expr='test2 State handling unexpected event' / custom action here/ /transition /state state id=test2-final onentry log expr='test2-final State' / /onentry transition target=active log expr='test2-final State exiting' / /transition /state onexit custom action here/ /onexit /state What happen was that sometimes going from active to test2 and back to active works fine. But other times though it seems to coming back from test2 to active state is fine (based on the onentry logging) but when test2 event fired, it was caught in test2 state not active state. I am not sure what else can I do to provide more information on this. Thanks. Vance From: Vance huang vancehu...@yahoo.com To: user@commons.apache.org Sent: Fri, May 13, 2011 5:54:44 PM Subject: [scxml] Hi, I am using scxml 0.9 release and encountered a weird issue. When I am transitioning between 2 states, it worked fine sometimes but in other times, it failed to transition to the next state. I put logging in onexit and onentry and here is what happened: State 1 transition to State 2. State 2 processes some events and transition back to State 1 I put logging in onexit of State 1 and onentry of State 2. I saw both logs. Then after few seconds an event fired but caught in State 2!! Is it a known issue in 0.9 release? Any workaround? Thanks. Vance - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Questions about error events and setting workflow state
On Fri, May 13, 2011 at 4:07 AM, Dario D darac1...@gmail.com wrote: 2011/5/12 Rahul Akolkar rahul.akol...@gmail.com On Thu, May 12, 2011 at 6:56 AM, Dario D darac1...@gmail.com wrote: 2) One requirement for the application is to allow setting an arbitrary state in a workflow. For example, if we have the following workflow: A-B-C-D-E and the workflow is currently in state D, a user should be able to move the workflow back to state B (or any other state). We were considering to use the following way (from the mailing list archives): public void setState(String state) { Set states = getCurrentStatus().getStates(); TransitionTarget tt = getStateMachine().getTargets().get(state); states.clear(); states.add(tt); } Would you recommend doing it this way and how would this affect on any context which was previously set? snap/ It'd likely be OK with the drawback that it hides these transitions from the SCXML document (so anyone staring at the document doesn't see the whole picture). The above doesn't have any effect on the set context(s). Thank you for your feedback, as always. In regards to the question and the workflow example, let's suppose that a user has set the current state to B after being in state D. Any local context which may have been created in states C and D will remain associated to those states, until it gets overwritten when the workflow transitions again to C and D, am I right? snip/ Yes, you can verify with tests for your likely scenarios. Note that when the current state is changed procedurally as above, the corresponding onexit (state D) and onentry (state B) handlers will not be executed which is different from an in-document transition. To continue on the same workflow example, let's supposed that the worklow is in state B. A bug in the workflow has been found at some later stage (states C, D, E) and the user would like to correct this bug before continuing execution of the workflow. Restarting the workflow is not a good idea because actions executed in states A and B are too expensive to be repeated. He corrects this bug and creates a new version of the worfklow model. The application will then call the following method on the existing executor: exec.setStateMachine(newWorkflowModel); This effectively means that the above method would would've been called twice on the executor (when the executor was first created before exec.go(), and after the workflow has been corrected). Is this the right thing to do and again, how would it affect the context which was made during initialization of the worklow and in states A and B? If this is not a good idea, can you suggest any alternatives? snap/ SCXML is not really designed for dynamic workflows and thereby, neither is Commons SCXML. The model / state machine is assumed to be immutable once the executor is set in motion. Having said that, doing something like the above is possible with a good understanding of the internals of Commons SCXML. I'd start by augmenting the existing state machine (SCXML class instance) rather than creating a new one since the references to states are maintained in internal book-keeping for contexts etc. and passing an altogether new object once the executor is in motion (like newWorkflowModel above) would disrupt all that. Something like: SCXML machine = exec.getStateMachine(); // manipulate machine, read SCXMLParser and ModelUpdater classes // in scxml.io package to understand all necessary changes To sum it up -- above be dragons. As an alternative, I'd suggest the following: (1) Use a flat context for entire state machine (use custom evaluator, override newContext() in existing evaluator impl always return same context instance, set same as root context) -- flat is actually what the spec recommends now (2) When the workflow needs to be remedied, create a brand new executor with remedied workflow/machine and set it in motion (3) Update the current state programmatically as code snippet in your note above to current state of old exec (4) Transfer root context from old exec to new and use same evaluator instance as before (5) Optionally, old exec instance may now be destroyed -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [digester] Grabbing data from sub-element attributes
On Fri, May 13, 2011 at 5:45 PM, Christopher Schultz ch...@christopherschultz.net wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 All, Wouldn't you know it, just after I posted, I had an epiphany: On 5/13/2011 5:33 PM, Christopher Schultz wrote: entities entity foosome value/foo barsome other value/bar baz id=123 / /entity /entities The solution is: digester.addObjectCreate(entities/entity, Entity.class); digester.addSetNestedProperties(entities/entity, { foo, bar, baz }, { foo, bar, null }); // ignore baz // go back and get baz digester.addSetProperties(entities/entity/baz, id, baz); snip/ Yeah, and probably more than one way even with out of the box rules: d.addObjectCreate(entities/entity, Entity.class); d.addCallMethod(entities/entity/foo, setFoo, 0); d.addCallMethod(entities/entity/bar, setBar, 0); d.addCallMethod(entities/entity/baz, setBaz, 1); d.addCallParam(entities/entity/baz, 0, id); -Rahul Sorry for the noise. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk3Npo0ACgkQ9CaO5/Lv0PDG0ACgpYqGZOM054nO/bLNypyfrKPx iysAnjqdjkrsQT4l3qlj1OLJp4vG4sbT =n7/z -END PGP SIGNATURE- - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml]
On Fri, May 13, 2011 at 6:54 PM, Vance huang vancehu...@yahoo.com wrote: Hi, I am using scxml 0.9 release and encountered a weird issue. When I am transitioning between 2 states, it worked fine sometimes but in other times, it failed to transition to the next state. I put logging in onexit and onentry and here is what happened: State 1 transition to State 2. State 2 processes some events and transition back to State 1 I put logging in onexit of State 1 and onentry of State 2. I saw both logs. Then after few seconds an event fired but caught in State 2!! Is it a known issue in 0.9 release? Any workaround? snip/ Doesn't ring a bell. We'll need a concrete test case. Post the smallest possible SCXML snippet exhibiting the behavior you think is unexpected with a reason why you think its unexpected (if not obvious). -Rahul Thanks. Vance - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Questions about error events and setting workflow state
On Thu, May 12, 2011 at 6:56 AM, Dario D darac1...@gmail.com wrote: We're developing an application which will use SCXML for its workflow and I would ask you for advice on a couple of topics: 1) All workflows will have a single state which is called error. Whenever a custom action catches an error, it will fire a derived event and this will cause the workflow go to the error state. Is it possible to expand this functionality to other execution errors? For example when an assignment is made to an undefined variable, or when an expression error happens, to fire an error event. I've tried making transitions that listen to error.* ( http://www.w3.org/TR/scxml/#ErrorEvents) but they are not being used. I was also hoping to raise this event from ErrorReporter but we don't have a mechanism to raise events from there. snip/ Your observations are correct, Commons SCXML v0.9 is not upto date with respect to the latest spec changes. You may open an issue for this, a patch will ensure its attended to sooner if you're so inclined -- need to add the error event to the set of derived ones on catching ExpressionException in SCXMLSemanticsImpl. WRT approaches: * An ErrorReporter implementation could be used, one that maintains a reference to the SCXMLExecutor instance its attached to and fires events asynchronously after a short delay * Better yet, one could maintain an external event queue where various components can add events (ErrorReporter being one) and these get triggered in the order added * Best fix is the semantics impl change along above lines 2) One requirement for the application is to allow setting an arbitrary state in a workflow. For example, if we have the following workflow: A-B-C-D-E and the workflow is currently in state D, a user should be able to move the workflow back to state B (or any other state). We were considering to use the following way (from the mailing list archives): public void setState(String state) { Set states = getCurrentStatus().getStates(); TransitionTarget tt = getStateMachine().getTargets().get(state); states.clear(); states.add(tt); } Would you recommend doing it this way and how would this affect on any context which was previously set? snap/ It'd likely be OK with the drawback that it hides these transitions from the SCXML document (so anyone staring at the document doesn't see the whole picture). The above doesn't have any effect on the set context(s). -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Usage of send tag
On Wed, May 11, 2011 at 2:36 PM, Artem Vovk vovk.ar...@googlemail.com wrote: Hi, i have a simple send tag: send event=response target=VUI targettype=basichttp / On Apache Commons side i have used JEXL as Evaluator, if I start my machine and execute this tag i receive WARNING: send target expression VUI evaluated to null or empty String. Why does it happens? Should I register each target which I use somewhere in scxml? snip/ You'll need single quotes around the event name like so (its treated as an expression - spaces added below for readability): send event= 'response' ... / Another quesiotion: can I send something like JSON Object from scxml? snap/ What you can send is only limited by what you make available in the state machine's context. You could: (a) Make such an Object available in the state machine's context (b) Make a JEXL function available in the context that returns a JSON object/string representation -Rahul Best regards - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Creating ad-hoc arrays in JEXL expressions
On Mon, May 9, 2011 at 4:19 PM, Dario D darac1...@gmail.com wrote: Hello, I am trying to create an ad-hoc array in my workflow and provide it to a custom action: state id=fetchCustomerData onentry log expr='Customer - Fetching data'/ al:fetchTableData select=['col1', 'col2'] / /onentry /state In the custom action, I am evaluating this string through JEXL Evaluator: public void execute(EventDispatcher eventDispatcher, ErrorReporter errorReporter, SCInstance scInstance, Log log, Collection collection) throws ModelException, SCXMLExpressionException { log.info(scInstance.getEvaluator().eval(scInstance.getRootContext(), this.getSelect())); } This throws an error: WARNING: EXPRESSION_ERROR (eval('['col1', 'col2']'):Encountered [ at line 1, column 1. Was expecting one of: EOF INTEGER_LITERAL ... FLOAT_LITERAL ... { ... empty ... ( ... size ... - ... ~ ... ! ... not ... null ... true ... false ... ; ... if ... while ... foreach ... IDENTIFIER ... STRING_LITERAL ... ): Is creating arrays (or HashMaps, for that matter) even possible like this in SCXML? I was following the guide at: http://commons.apache.org/jexl/reference/syntax.html The executor was created like this: SCXMLExecutor exec = null; exec = new SCXMLExecutor(new JexlEvaluator(), new SimpleDispatcher(), new SimpleErrorReporter()); Context ctx = new JexlContext(); exec.setRootContext(ctx); exec.setStateMachine(scxml); exec.setSuperStep(true); Thank you! snip/ JEXL 2.x syntax will require a suitable Evaluator/Context implementation (the default in v0.9 supports JEXL 1.x). You can either provide one yourself or try the one attached to this ticket [1]. -Rahul [1] https://issues.apache.org/jira/browse/SCXML-114 - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Calling go() twice
On Tue, May 3, 2011 at 10:13 AM, Dario D darac1...@gmail.com wrote: Thanks Jocke. How would you suggest to resume the the last state before the condition was not met? Let's say that the condition was made valid somehow. How to resume from the last state? To continue the previous example: try { exec.go(); // Execution stops at state2, condition is not met // Condition is made valid through some means // How to resume? } catch (ModelException e) { e.printStackTrace(); } snip/ Triggering events is here: http://commons.apache.org/scxml/guide/core-events.html The main page for the user guide, which has more, is here: http://commons.apache.org/scxml/guide.html If you're using EL, you've have to use the EL syntax for expressions, so rather than the following from your example ... transition target=state3 cond=1 = 2 / ... the syntax will be like below: transition target=state3 cond=${1 eq 2} / -Rahul 2011/5/3 jocke eriksson joakim.eriks...@albatross.com exec.go(); should only be called once. It will start the state machine and it will go through all steps that meets the criteria (event cond). Regards Jocke. 2011/5/3 Dario D darac1...@gmail.com: Hello all, I've just started using SCXML and it's great. However, I've hit a brick wall and I can't seem to figure out something. I have the following XML file: scxml xmlns=http://www.w3.org/2005/07/scxml; version=1.0 initialstate=state1 state id=state1 onentry log expr=State 1/ /onentry transition target=state2 / /state state id=state2 onentry log expr=State 2/ /onentry transition target=state3 cond=1 = 2 / /state state id=state3 final=true onentry log expr=State 3/ /onentry /state /scxml Now, I execute the state machine like this: SCXMLExecutor exec = null; exec = new SCXMLExecutor(new ELEvaluator(), new SimpleDispatcher(), new SimpleErrorReporter()); Context ctx = new ELContext(); exec.setRootContext(ctx); exec.setStateMachine(scxml); exec.setSuperStep(true); // Start execution try { exec.go(); exec.go(); } catch (ModelException e) { e.printStackTrace(); } As you can see I call exec.go() two times. I would expect that in the first time, the state machine will stop in the state2 state and remain there, because condition is not satisfied for going into state3. However, when exec.go() is called the second time, it goes from the start. Effectively, it acts as exec.reset()? Following output is provided: 03.05.2011. 14:01:32 org.apache.commons.scxml.model.Log execute INFO: null: State 1 03.05.2011. 14:01:32 org.apache.commons.scxml.model.Log execute INFO: null: State 2 03.05.2011. 14:01:32 org.apache.commons.scxml.model.Log execute INFO: null: State 1 03.05.2011. 14:01:32 org.apache.commons.scxml.model.Log execute INFO: null: State 2 Could you explain this behavior? - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [digester] The element type ... must be terminated by the matching end-tag
On Tue, May 3, 2011 at 12:48 PM, Patrick Diviacco patrick.divia...@gmail.com wrote: I get the following error: May 3, 2011 6:41:25 PM org.apache.commons.digester.Digester fatalError SEVERE: Parse Fatal Error at line 2336608 column 3: The element type user must be terminated by the matching end-tag /user. org.xml.sax.SAXParseException: The element type user must be terminated by the matching end-tag /user. However 2336608 is the last line of my text file. I guess I'm opening a tag /user and I never close it. Do you know how can I find it and fix it, in big text files ? thanks snip/ I'm assuming there are far too many user tags to do simple text searches -- most editors or even web browsers (when instructed to treat as XML) provide some help in matching start and end tags by collapsing element bodies etc., you'd have to inspect by opening in one of those. -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [SCXML] Count event support
On Sun, Apr 10, 2011 at 11:14 AM, jocke eriksson jock...@gmail.com wrote: Hello SCXML users. I'm the project owner of freeswitch-scxml at google code. I have been waning to add a feature and I'm not quite sure how to implement it. I want to be able to add a count object, when evaluated in a transition, it should return the number of times that event has happened in a state. ex transition event=nomatch target=exit cond=count gt 3 / The problem I have is that when the guarded block is evaluated I have no way to find out in which transition it currently is located in. Is my only option to override SCXMLSemanticsImpl#filterTransitionsSet and set the current transition in the context before evaluation. snip/ Implicit variables can be fun :-) Yes, filterTransitionsSet() would likely be the easiest way -- this is a good example of the semantics interface used for extensibility. BTW, if you want freeswitch-scxml to be listed on the Commons SCXML home page (see Who is using it? section [1] at the bottom of home page), send us a one-liner description you'd want to see and we can add it to that section. -Rahul [1] http://commons.apache.org/scxml/#Related_Projects Regards Jocke Eriksson - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: SCXML and EventDispatcher:send(String sendId, String targe, String type, String event, Map params, Object hints, long delay, List externalNodes)
On Sat, Feb 26, 2011 at 5:57 PM, Micka mickamus...@gmail.com wrote: Hi, I would like to understand how to use the send balise with the function send in the EventDispatcher class. send(String sendId, String targe, String type, String event, Map params, Object hints, long delay, List externalNodes){ } I've some difficulty to get some data in the params by example. I can only get one data in params when i do that : assign name=test expr=toto='test'+' hey\r\n' / send namelist=test type='foo' targettype='x-csta' / But how can i manage to have more than one value in params ? it is a Map type, so It should be possible, right ? snip/ Right, namelist is a space separated list. To build on your example above, the following send will have 3 entries in the params map (with keys foo, bar and test): assign name=foo expr=...some expr.../ assign name=bar expr=...some other expr.../ assign name=test expr=toto='test'+' hey\r\n' / send namelist=foo bar test type='foo' targettype='x-csta' / -Rahul Thx, - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [vfs] Where is version 1.1?
On Mon, Feb 7, 2011 at 4:38 PM, Gary Gregory ggreg...@seagullsoftware.com wrote: All: Should we include a SVN revision number in the manifest.mf file to help out in cases like this? snip/ Don't think we can do much -- there is never any confusion for official releases and there is always potential for confusion for home brew jars (unless proper care is taken by those creating them). -Rahul Gary Gregory Senior Software Engineer Rocket Software 3340 Peachtree Road, Suite 820 . Atlanta, GA 30326 . USA Tel: +1.404.760.1560 Email: ggreg...@seagullsoftware.com Web: seagull.rocketsoftware.com -Original Message- From: Rogelio Flores [mailto:rogelio.flo...@gmail.com] Sent: Monday, February 07, 2011 16:35 To: Commons Users List Subject: Re: [vfs] Where is version 1.1? Thanks. And I suppose there's no archive of these snapshots, is there? -- Rogelio On Mon, Feb 7, 2011 at 4:10 PM, Gary Gregory ggreg...@seagullsoftware.com wrote: -Original Message- From: Rogelio Flores [mailto:rogelio.flo...@gmail.com] Sent: Monday, February 07, 2011 15:58 To: user@commons.apache.org Subject: [vfs] Where is version 1.1? VFS version 1.1 was not released AFAIK. This is probably a 1.1-SNAPSHOT build. There is a version 2.0 in the works ATM. Gary I have an app where a previous developer--no longer here--added commons-vfs-1.1.jar to our dependencies. I'd like to get the source code for this but the download site lists 1.0 as the latest official download (http://commons.apache.org/vfs/download_vfs.cgi) So my question is, where did he get this 1.1 JAR file? (in case it helps, the timestamp of the files within it is 11/8/2008 9:53 - 9:54 AM and this jar file weights 362,465 bytes) Contents of Manifest.mf: Manifest-Version: 1.0 Ant-Version: Apache Ant 1.7.0 Created-By: 11.0-b15 (Sun Microsystems Inc.) I just want to get the source code for the version we're using. Thanks in advance for your help, -- Rogelio - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: SCXML : SEND vs JEXL FUNCTION
On Thu, Jan 27, 2011 at 3:25 PM, Micka mickamus...@gmail.com wrote: Hi, I'm always amazing about the SCXML. I'm using JEXL in my SCXML project and when i discovered all the thing that JEXL can bring ( like custom function ) , I was wondering what is the purpose to use send or invoke tag in the scxml file. Is it possible that someone explain me ? By the way, thank you for this amazing project ! -- if my english is not good enough for you to understand. Why should I use : org.apache.commons.scxml.EventDispatcher class with the : public void send(String sendId, String targe, String type, String event, Map params, Object hints, long delay, List externalNodes) ; instead of : JEXL.setFunctions(funcs); ? snip/ Custom functions in JEXL should be used to make the expression language more effective for the SCXML document -- so utility functions for quick, local calculations and transforms. The use of send is a standard feature in SCXML, and its purpose is to initiate and maintain communication with other processes (local or remote). Anything to do with such external communications should be modeled as send and thereby implemented using the EventDispatcher. -Rahul Thanks you, - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] serializer
On Sun, Jan 16, 2011 at 4:25 AM, jocke eriksson jock...@gmail.com wrote: I am trying to use the SCXMLSerializer and I have a couple of questions. 1. Did not state have an attribute called src I could have swear that it was there before. I even have documents utilizing it. snip/ The src attribute was removed from the newer Working Drafts in favor of standard techniques for XML inclusion (such as XInclude). Commons SCXML will continue to support the src attribute for backwards compatibility, until atleast the next major release. 2. Why does the log element loses it's label when serializing. else if (a instanceof Log) { Log lg = (Log) a; b.append(indent).append(log expr=\). append(SCXMLHelper.escapeXML(lg.getExpr())). append(\/\n); } snap/ Looks like it was simply missed when the label attribute support was added. Open an issue [1] (patch optional) as a reminder, will try to get to it next week. -Rahul [1] http://commons.apache.org/scxml/issue-tracking.html - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] What version of SCXML Commons is supported?
On Thu, Jan 13, 2011 at 8:46 AM, Libor Jelinek ljeli...@virtage.com wrote: Hi all! I am very new to Commons SCXML. First and basic my question is *** What version of W3C SCXML is supported by actual version of Commons SCXML? *** From the few examples and code excerpts I suppose it's some older (2006-01-24?) version? snip/ I'll link to a previous response from the archives: http://markmail.org/message/rhohe7uzsoj6gonw -Rahul Thanks for all replies! Libor - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [digester] Need help with simple digester usage
On Thu, Jan 13, 2011 at 12:39 PM, KARR, DAVID (ATTSI) dk0...@att.com wrote: -Original Message- From: Rahul Akolkar Sent: Monday, December 20, 2010 10:18 PM To: Commons Users List Subject: Re: [digester] Need help with simple digester usage On Mon, Dec 20, 2010 at 11:08 PM, KARR, DAVID (ATTSI) dk0...@att.com wrote: -Original Message- From: KARR, DAVID (ATTSI) Sent: Monday, December 20, 2010 7:54 PM To: user@commons.apache.org Subject: [digester] Need help with simple digester usage I'm trying to use Digester for a simple application. I want to define the structure of a binary tree in XML, and then construct that node tree using Digester. The trivial Node class is just this: public static class Node { private Node left; private Node right; private String value; public Node getLeft() { return left; } public Node getRight() { return right; } public String getValue() { return value; } public void setLeft(Node left) { this.left = left; } public void setRight(Node right) { this.right = right; } public void setValue(String value) { this.value = value; } } The XML is composed of nested node elements. The first node child gets set as the left property of the root, and the second gets set as the right property. For instance: node value=abc node value=def/ /node Should result in a root Node with a left property referring to the second node. So, going through the Digester documentation, which I haven't looked at in many years, I figured it would be something like this: digester.addRule(*/node, new ObjectCreateRule(AugmentedNode.class)); digester.addRule(*/node, new SetPropertiesRule()); digester.addRule(*/node, new SetNextRule(addChild, AugmentedNode.class.getName())); Where AugmentedNode extends Node, adding: public void addChild(Node node) { if (getLeft() == null) setLeft(node); else setRight(node); } For those well steeped in Digester lore, I imagine you can immediately tell this won't work. You're right, of course. This dies with an NPE in MethodUtils.invokeMethod() (object is null). I have no clue what's wrong with this, or what I should be doing instead. Oh, ok. I figured out one thing. I have to push an AugmentedNode on the stack before I start parsing, and then I take the result as the left property of that top node. Is that all I should have figured out? Is there a better way to do this in the first place? snip/ Add this as the first rule, then the parse method will get you the actual (root) node: digester.addRule(node, new ObjectCreateRule(AugmentedNode.class)); This calls out the root as different from other nodes -- the root doesn't need a SetNextRule (thats the one causing the NPE since it has no parent). I'm still not quite sure how to transform my existing code so I can use the top node, not the left of the top node. My existing code is this: digester.push(new AugmentedNode()); digester.addRule(*/node, new ObjectCreateRule(AugmentedNode.class)); digester.addRule(*/node, new SetPropertiesRule()); digester.addRule(*/node, new SetNextRule(addChild, AugmentedNode.class.getName())); return ((Node) digester.parse(new StringReader(xml))).getLeft(); I've tried several variations with adding that line you suggest, but I can't get it to work, and I'm not sure exactly what it's trying to accomplish. snip/ Try this, per previous email: digester.addRule(node, new ObjectCreateRule(AugmentedNode.class)); // above line is better match for root (not using push) digester.addRule(*/node, new ObjectCreateRule(AugmentedNode.class)); digester.addRule(*/node, new SetPropertiesRule()); digester.addRule(*/node, new SetNextRule(addChild, AugmentedNode.class.getName())); return ((Node) digester.parse(new StringReader(xml))); // above line is without getLeft() -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [digester] Need help with simple digester usage
On Thu, Jan 13, 2011 at 7:40 PM, KARR, DAVID (ATTSI) dk0...@att.com wrote: -Original Message- From: Rahul Akolkar Sent: Thursday, January 13, 2011 2:07 PM To: Commons Users List Subject: Re: [digester] Need help with simple digester usage On Thu, Jan 13, 2011 at 12:39 PM, KARR, DAVID (ATTSI) dk0...@att.com wrote: -Original Message- From: Rahul Akolkar Sent: Monday, December 20, 2010 10:18 PM To: Commons Users List Subject: Re: [digester] Need help with simple digester usage On Mon, Dec 20, 2010 at 11:08 PM, KARR, DAVID (ATTSI) dk0...@att.com wrote: -Original Message- From: KARR, DAVID (ATTSI) Sent: Monday, December 20, 2010 7:54 PM To: user@commons.apache.org Subject: [digester] Need help with simple digester usage I'm trying to use Digester for a simple application. I want to define the structure of a binary tree in XML, and then construct that node tree using Digester. The trivial Node class is just this: public static class Node { private Node left; private Node right; private String value; public Node getLeft() { return left; } public Node getRight() { return right; } public String getValue() { return value; } public void setLeft(Node left) { this.left = left; } public void setRight(Node right) { this.right = right; } public void setValue(String value) { this.value = value; } } The XML is composed of nested node elements. The first node child gets set as the left property of the root, and the second gets set as the right property. For instance: node value=abc node value=def/ /node Should result in a root Node with a left property referring to the second node. So, going through the Digester documentation, which I haven't looked at in many years, I figured it would be something like this: digester.addRule(*/node, new ObjectCreateRule(AugmentedNode.class)); digester.addRule(*/node, new SetPropertiesRule()); digester.addRule(*/node, new SetNextRule(addChild, AugmentedNode.class.getName())); Where AugmentedNode extends Node, adding: public void addChild(Node node) { if (getLeft() == null) setLeft(node); else setRight(node); } For those well steeped in Digester lore, I imagine you can immediately tell this won't work. You're right, of course. This dies with an NPE in MethodUtils.invokeMethod() (object is null). I have no clue what's wrong with this, or what I should be doing instead. Oh, ok. I figured out one thing. I have to push an AugmentedNode on the stack before I start parsing, and then I take the result as the left property of that top node. Is that all I should have figured out? Is there a better way to do this in the first place? snip/ Add this as the first rule, then the parse method will get you the actual (root) node: digester.addRule(node, new ObjectCreateRule(AugmentedNode.class)); This calls out the root as different from other nodes -- the root doesn't need a SetNextRule (thats the one causing the NPE since it has no parent). I'm still not quite sure how to transform my existing code so I can use the top node, not the left of the top node. My existing code is this: digester.push(new AugmentedNode()); digester.addRule(*/node, new ObjectCreateRule(AugmentedNode.class)); digester.addRule(*/node, new SetPropertiesRule()); digester.addRule(*/node, new SetNextRule(addChild, AugmentedNode.class.getName())); return ((Node) digester.parse(new StringReader(xml))).getLeft(); I've tried several variations with adding that line you suggest, but I can't get it to work, and I'm not sure exactly what it's trying to accomplish. snip/ Try this, per previous email: digester.addRule(node, new ObjectCreateRule(AugmentedNode.class)); // above line is better match for root (not using push) snip/ Given the root node can also have a value attribute, need this (insert after the line above): digester.addRule(node, new SetPropertiesRule()); -Rahul digester.addRule(*/node, new ObjectCreateRule(AugmentedNode.class)); digester.addRule(*/node, new SetPropertiesRule()); digester.addRule(*/node, new SetNextRule(addChild, AugmentedNode.class.getName())); return ((Node) digester.parse(new StringReader(xml))); // above line is without getLeft() That causes my tests to fail. It appears as if it's not returning the root node, but some other node. How about if I include my CUT and test class here? --- package binarytree; import java.util.HashSet; import
Re: SCXML : getCurrentStateS
On Sat, Dec 11, 2010 at 6:26 AM, Micka mickamus...@gmail.com wrote: Hi, I'm trying to get the currentStates in case we have multiple states. by example : ?xml version=1.0 encoding=UTF-8? scxml xmlns=http://www.w3.org/2005/07/scxml; version=1.0 initialstate=start parallel id=start state id=simulatedUser datamodel data name=one expr=1 / data name=two expr=2 / /datamodel onentry send event='event.bar' namelist=one two delay='100ms'/ /onentry transition event=event.bar log label='simulatedUser' expr=_eventdatamap['event.bar'].one + ', ' + _eventdatamap['event.bar'].two/ /transition /state state id=counter initial transition target=twenty/ /initial state id=twenty transition event=event.bar cond=_eventdatamap['event.bar'].one + _eventdatamap['event.bar'].two eq 3 target=thirty/ transition event=event.bar log label='event.bar in twenty state' expr=_eventdatamap['event.bar'].one + ', ' + _eventdatamap['event.bar'].two/ /transition /state state id=thirty final=true/ /state /parallel /scxml theoretically , the current states is : *simulatedUser *and *twenty* snip/ Correct. I tried to code something but i'm getting : twenty+thirty#simulatedUser I should have twenty#simulatedUser !! instead i get all the state inside counter . :( do you have an answer and a solution for that ? snap/ Nothing stood out in the code so I actually pasted it into a test and ran it -- I get simulatedUser#twenty which is effectively the same thing. If you aren't seeing the expected result there is some other relevant piece of information that you haven't yet posted here. -Rahul public String getCurrentStates() { Set states = exec.getCurrentStatus().getStates(); IteratorState it = states.iterator(); State state; String sid=; while(it.hasNext()){ state = it.next(); sid+=stateToString(state,+-*(){}/); if(it.hasNext())sid+=#; } return ((State) exec.getCurrentStatus().getStates().iterator().next()) .getId(); } public String stateToString(State state,String separators){ String sid=; boolean test= state.isComposite(); if( test separators.length()0){ char separator=separators.charAt(0); separators=separators.substring(1); Map states = state.getChildren(); IteratorState it = states.values().iterator(); while(it.hasNext()){ state = it.next(); sid+=stateToString(state,separators); if(it.hasNext())sid+=separator; } return sid; }else{ return state.getId(); } } It will be helpfull to have a solution for that, because it is the same problem for the checkIfAbleToChangeState() function. Thank you !! ( And thanks for this amazing work ) - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [digester] Class loading issue using commons-digester in OSGi setup
On Tue, Nov 30, 2010 at 1:22 PM, niklas modin niklas.mo...@oracle.com wrote: Hi all, I'm trying to use commons-scxml in an OSGi environment (Equinox) and scxml has a dependency on digester, which causes some class loading issues. Digester gets it's own class loader being a separate bundle, however it looks like when ObjectCreateRule.begin() instantiates the SCXML object when I try to parse a scxml document this is done using this snippet: /Class clazz = digester.getClassLoader().loadClass(realClassName);/ Since SCXML isn't in the digesters class loader, this will never work. Any ideas on how this should work in an OSGi deployment ? Any one else with some experience of using scxml/digester in this manner ? snip/ There is atleast one Eclipse-based plugin that use Commons SCXML; more below. Do I need to skip installing all the bundles separately, and just pack them all together into a big jar ? Feels like that contradicts the whole modularization goal of OSGi/bundles. snip/ Right, this can be done without packing everything into one jar. Such situations are usually handled using OSGi buddy policies and buddy class loading mechanisms. From the archives, see my reply to a similar query: http://markmail.org/message/hoyi3r7cvbxqrk5x -Rahul Cheers, Niklas - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: SCXML : send transition doesn't work when they are in the same state.
On Sun, Nov 28, 2010 at 7:51 AM, Micka mickamus...@gmail.com wrote: Hi, The problem is happening when I initalize manually the state of my machine, and I trigger the event. do you think that initializing the state manullay is causing the problem ? snip/ Initializing to the state manually as below seems fine. What such initialization will not do, however, is cause the execution of the onentry of said state, as the state machine is already considered to be in that state. So, in the original example below, if STATE_START is that persisted state which is restored the oentry and thereby the contained send will not be executed. I don't see anything unexpected in the EventDispatcher implementation. -Rahul public class NEventDispatcher implements EventDispatcher { public NEventDispatcher() { } @Override public void cancel(String arg0) { } @SuppressWarnings(unused) @Override public void send(String sendId, String targe, String type, String event, Map params, Object hints, long delay, List externalNodes) { if (externalNodes == null || externalNodes.size() = 0) return; // some stupid code here, i'm just inserting the information in my database } } The implementation of the machine that i use : tracer = new NTracer(); nEventDispatcher=new NEventDispatcher(); exec = new SCXMLExecutor(new JexlEvaluator(), nEventDispatcher, tracer); exec.setStateMachine(config); exec.addListener(config, tracer); map=new HashMap(); jExlCtx = new JexlContext(map); exec.setRootContext(jExlCtx); exec.setErrorReporter(tracer); and how i'm initializing the state : @SuppressWarnings(unchecked) public void setInitialState(String idOfPersistedState)throws Exception { if (idOfPersistedState != null) { MapString, State allStates = exec.getStateMachine().getTargets(); State state = allStates.get(idOfPersistedState); if (state == null) { throw new Exception(Unknown state + idOfPersistedState); } // got the state, now set it @SuppressWarnings(rawtypes) Set states = exec.getCurrentStatus().getStates(); states.clear(); states.add(state); } } On Fri, Nov 26, 2010 at 7:14 PM, Rahul Akolkar rahul.akol...@gmail.com wrote: This is a post for the user list, but please see below first ... On Fri, Nov 26, 2010 at 1:03 PM, Michael musset mickamus...@gmail.com wrote: Hi, I'm having a problem in my scxml project : state id=STATE_START onentry send target=test targettype='x-csta' xmlns:csta= http://www.ecma.ch/standards/ecma-323/csta; EVENT TARGET=test TAG=EVENT_HELLO ![CDATA[ my data ]] /EVENT /send /onentry transition event=EVENT_TEST target=STATE_1 cond=_eventdata.DATA1 eq 'ok'/ transition event=EVENT_START target=STATE_START / /state the send tag is recuperate properly by the the eventdispatcher ( I need what is inside the send tag) , but I can't manage to change state into the STATE_1. And If I remove the all send ... /send tag , the transition is working, I manage to change state into the STATE_1. So what is wrong? I'm using JexlEvaluator and JexlContext for my engine. snip/ We'll need to know what your EventDispatcher implementation is doing that might disrupt processing the original event, which is why the payload guard condition may no longer hold for the transition you expect to be taken. Lets continue on the Commons User list, see: http://commons.apache.org/mail-lists.html -Rahul Thanks in advance for the help !!! -- Michael Musset, Tel: 06 26 06 29 89 - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml]SCXML Executor Priority?
On Tue, Nov 23, 2010 at 4:47 PM, Lee, Cheryl - ES cheryl@itt.com wrote: Hi, I'm still a bit new to SCXML, and I have a single java SCXMLExecutor running on Fedora 11 on a large state machine (about 5000 states). I am at the point of tuning my system, and I was hoping to be able to increase the priority of the SCXMLExecutor. Is there a way to increase the thread priority of the state machine engine? I didn't see a way to do it using the API provided for SCXMLExecutor. snip/ The SCXMLExecutor API is synchronous. The executor doesn't spawn any threads by itself. Therefore, any tuning of the above nature relates to the calling application thread. The size of the state machine mostly matters at parse time and parsing should ideally be done before response time is a critical consideration, such as at application startup. -Rahul Thanks! This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail. - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Need for JSF
On Wed, Nov 17, 2010 at 12:46 PM, niklas modin niklas.mo...@oracle.com wrote: Hi, Looking at the manifest for scxml, it seems like all optional maven dependencies along with the required ones, all gets translated into an entry under the Import-Package: part. AFAIK, I don't think there is a notion for optional dependency injection in OSGi, so I guess that means that all dependencies are in fact required for an OSGi deployment. Not sure how to proceed here, but seems that also deploying JSF and all transitive dependencies is what I need to do. snip/ WRT above, will reply to your next post in this thread in a few. WRT another release: Another quick Q: Are there any plans for a 0.10 release ? snap/ My current focus is on completing a few tasks assigned to me to get the next W3C Working Draft out the door. Once that is done, I intend to take a look at updating Commons SCXML and performing the v0.10 release. Time frame would be atleast a couple of months. -Rahul Thanks, Niklas On 11/16/2010 2:23 PM, Rahul Akolkar wrote: On Tue, Nov 16, 2010 at 4:53 PM, niklas modinniklas.mo...@oracle.com wrote: Hi, I'm trying to get SC XML up and running in an equinox OSGi environment, and I'm having some dependencies issues. What's the reason for having a dependency to myfaces-api ? This isn't a big issue per say I guess, but it just seems like that drag's in a lot of dependencies, and can't really see what JSF is used for. snip/ You are indeed correct that most applications that use Commons SCXML may be unrelated to JSF (and some of the other optional dependencies as well). Commons SCXML has three required dependencies, which are listed at the top of this page: http://commons.apache.org/scxml/dependencies.html Note that the others are optional. In addition, the JSF API is meant to be provided (by the environment). If the OSGi related headers in the release jar file don't reflect this correctly, then they should. -Rahul Cheers, Niklas - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Need for JSF
On Wed, Nov 17, 2010 at 7:45 PM, niklas modin niklas.mo...@oracle.com wrote: Hi again, Looked into it a little bit more, and there is indeed a way to note import packages as optional, but it seems like this isn't set properly in the manifest file. Not sure if there is an issue with the maven assembly plugin, or if there is a way to instruct it to include the resolution:=optional parameter in the manifest file. snip/ The manifest entries are generated by the maven bundle plugin [1]. I haven't checked, but it would be worthwhile to see if the plugin has more intelligence about optional dependencies today than it did when the last Commons SCXML release was cut. If not, we can also look at hard-coding the appropriate OSGi related manifest entries via following properties defined in the parent pom [2]: Export-Package${commons.osgi.export}/Export-Package Private-Package${commons.osgi.private}/Private-Package Import-Package${commons.osgi.import}/Import-Package DynamicImport-Package${commons.osgi.dynamicImport}/DynamicImport-Package I'll take a look when I get a chance. If you'd like to suggest improvements (or want to track this), feel free to open an issue (with an appropriate patch, if available) to JIRA [3]. -Rahul [1] http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html [2] http://svn.apache.org/repos/asf/commons/proper/commons-parent/trunk/pom.xml [3] http://commons.apache.org/scxml/issue-tracking.html /Niklas On 11/17/2010 9:46 AM, niklas modin wrote: Hi, Looking at the manifest for scxml, it seems like all optional maven dependencies along with the required ones, all gets translated into an entry under the Import-Package: part. AFAIK, I don't think there is a notion for optional dependency injection in OSGi, so I guess that means that all dependencies are in fact required for an OSGi deployment. Not sure how to proceed here, but seems that also deploying JSF and all transitive dependencies is what I need to do. Another quick Q: Are there any plans for a 0.10 release ? Thanks, Niklas On 11/16/2010 2:23 PM, Rahul Akolkar wrote: On Tue, Nov 16, 2010 at 4:53 PM, niklas modinniklas.mo...@oracle.com wrote: Hi, I'm trying to get SC XML up and running in an equinox OSGi environment, and I'm having some dependencies issues. What's the reason for having a dependency to myfaces-api ? This isn't a big issue per say I guess, but it just seems like that drag's in a lot of dependencies, and can't really see what JSF is used for. snip/ You are indeed correct that most applications that use Commons SCXML may be unrelated to JSF (and some of the other optional dependencies as well). Commons SCXML has three required dependencies, which are listed at the top of this page: http://commons.apache.org/scxml/dependencies.html Note that the others are optional. In addition, the JSF API is meant to be provided (by the environment). If the OSGi related headers in the release jar file don't reflect this correctly, then they should. -Rahul Cheers, Niklas - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Need for JSF
On Tue, Nov 16, 2010 at 4:53 PM, niklas modin niklas.mo...@oracle.com wrote: Hi, I'm trying to get SC XML up and running in an equinox OSGi environment, and I'm having some dependencies issues. What's the reason for having a dependency to myfaces-api ? This isn't a big issue per say I guess, but it just seems like that drag's in a lot of dependencies, and can't really see what JSF is used for. snip/ You are indeed correct that most applications that use Commons SCXML may be unrelated to JSF (and some of the other optional dependencies as well). Commons SCXML has three required dependencies, which are listed at the top of this page: http://commons.apache.org/scxml/dependencies.html Note that the others are optional. In addition, the JSF API is meant to be provided (by the environment). If the OSGi related headers in the release jar file don't reflect this correctly, then they should. -Rahul Cheers, Niklas - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: SCXML Plugin
On Sat, Nov 6, 2010 at 9:26 AM, Bilel Messaoud bilelmessa...@gmail.com wrote: Hi to all i really couldnt download the source of scxml plugin [scxml] and i used every link i use eclipse helios 3.6 and please can you help me how i can download the project and how can i be part of this project thanks and good luck Check out projects from trunk in workspace: http://commons.apache.org/sandbox/gsoc/2010/scxml-eclipse/source-repository.html Again, see (you'll likely save yourself some trouble if you get Ganymede as suggested): http://commons.apache.org/sandbox/gsoc/2010/scxml-eclipse/guide/run-source-code.html -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Questions on Multiple Instances
On Mon, Oct 25, 2010 at 12:19 PM, Christopher Dragert chris.drag...@mail.mcgill.ca wrote: The scenario: I have many different classes (call them type A) each with their own unique SCXML state chart. Though designed to work together, type A classes are necessarily separate because we need them to be used modularly. Another set of classes (call these type B), each instantiate a subset of the available type A classes. Inside a type B class, events are manually passed between the state charts in a broadcast arrangement. Thus, there are many different type B classes, each containing their own instances of several type A classes that essentially operate as parallel state charts. I am having problems with the efficiency of this arrangement. I have two questions: 1) When a state chart is parsed and loaded, one of the steps is to create an SCXML engine. Is it possible to clone the engine? In my scenario, each type A class may be instantiated many times. This means that the associated SCXML file is parsed and loaded many times, causing a significant slow down at load time. Cloning an engine seems to offer a way around this. snip/ As already mentioned, Commons SCXML uses a parse to model once, instantiate any number of executors approach. This will require not using the AbstractStateMachine helper class, which is a very simple pattern (that re-parses). 2) Is it possible to create an engine, then add a new state chart to the engine, treated as though it was part of the first state chart but enclosed in parallel tags? In my scenario, this would allow my type B classes to only have one execution environment for all of its instantiated type A classes. Since we don't know what type As will be contained in a type B, it seems hard to do this by prebuilding scxml files that actually contain the parallel sections. All this could be done before the state chart begins execution. snap/ Type B could generate the SCXML just before executor instantiation, including the type As as needed either via XML includes or via the now deprecated src attribute of the state element. -Rahul Any other advice regarding running large number of SCXML files would be appreciated! Thanks for any help. Regards, Chris Dragert - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [SCXML] Which XSD file can I use to validate my SCXML before I try to use it?
On Wed, Nov 3, 2010 at 11:09 AM, Lee Breisacher lbreisac...@seagullsoftware.com wrote: Did anything ever happen with this? I would like to have a set of SCXML xsd files that match commons-scxml. snip/ I don't think the files were posted to this list or the issue tracker. -Rahul Thanks, Lee On Thu, Feb 4, 2010 at 10:01 PM, Michael McCarthy mmccar...@touchcommerce.com wrote: I have a need to validate my XML file prior to trying to create an instance of it. So, I took the latest schema files provided by w3c and make some tweaks so that it would accept syntax supported by Commons SCXML. It currently passes validation for XML supported by Commons SCXML, but it may not be strict enough and may still pass validation for unsupported elements syntax. I would be happy to post it to this mailing list if there are folks who could review and perhaps refine it. snip/ Cool :-) Please attach it to a new JIRA [1] ticket and I'll take a look within a few days. This will be a good fit for the Commons SCXML extras [2] and we can post it there once ready. -Rahul [1] http://commons.apache.org/scxml/issue-tracking.html [2] http://svn.apache.org/repos/asf/commons/proper/scxml/branches/J6/extras/ -Mike -Original Message- From: Rahul Akolkar Sent: Thursday, February 04, 2010 3:30 PM To: Commons Users List Subject: Re: Which XSD file can I use to validate my SCXML before I try to use it? On Thu, Feb 4, 2010 at 6:15 PM, Michael McCarthy mmccar...@touchcommerce.com wrote: Hello, I am looking for a way to validate my SCXML document before I try to instantiate a state machine from it using Commons SCXML. I have tried to use various versions of the XSD provided in the W3C SCXML spec (including the latest version at: http://www.w3.org/TR/scxml/) but I am finding discrepancies in that schema as compared to what Commons SCXML supports. Could someone please point me to the definitive SCXML XSD profile that I should be using to validate Commons SCXML documents? snip/ We don't have such an XSD ATM. It'd be good to have one ofcourse -- an interesting exercise if someone wants to come up with the XSD for the subset we support then I imagine it'd be easy to maintain going forward. -Rahul Thank you for any help you can provide. - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Which W3C draft version is supported?
On Wed, Oct 20, 2010 at 5:23 AM, henrik.le...@tieto.com wrote: Hi Which W3C draft version is supported by Apache Commons SCXML v0.9 snip/ Commons SCXML v0.9 is closest (there are some missing pieces -- especially optional ones like anchor which were later removed) to this Working Draft: http://www.w3.org/TR/2008/WD-scxml-20080516/ (and what is 0.10 aiming at?) snap/ That'd be the latest. Could compliance information be stated in the release notes perhaps? snip/ Yes, we should do that for future releases. -Rahul Best regards, Henrik - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [digester] Trouble adding a list to a hash map
On Fri, Oct 1, 2010 at 3:12 PM, Philip A Grim II pg...@data-tactics.com wrote: I'm having difficulty with the Digester when trying to add a list to a hash map. The following is a portion of the XML I'm digesting: ?xml version=\1.0\ encoding=\utf-8\? Envelope Person Locations Location Id3eca4cd1-a07a-4013-b4a3-1d6a6530f7e3/Id DateAsOf201007132112/DateAsOf DateLastModified20100803203509203/DateLastModified NameMost Recent Location/Name WKTPOINT (69.568583399873617 33.86775960347174 0)/WKT /Location Location Id3e2462d1-a0c7-4013-4523-1345a3b8f7e3/Id DateAsOf201007100814/DateAsOf DateLastModified20100803203509203/DateLastModified NamePrevious Location/Name WKTPOINT (66.53455434533617 32.863453455537174 0)/WKT /Location /Locations /Person /Envelope The top level object is a HashMap that contains properties of the Person tag. Simple properties work fine, but nested properties such as Locations are what are giving me trouble. I am trying to create an ArrayList of the Location tags which contains a HashMap of the properties nested inside each Location tag, and that part works, but when I try to add that ArrayList to the HashMap of person properties, I get an empty list. Please note that I have no control over the format of the XML itself...it is created by a third-party application, and I have to read what's there. Attached is a simple code example that shows what I've tried to do. Either I'm doing it wrong or something isn't happening the way it should in the Digester. I'd appreciate any help you could offer. snip/ Attachment did not come through on the list. Best to inline the smallest piece of code that fully captures the issue. -Rahul Thanks, Phil Philip A Grim II Chief Engineer Data Tactics Corporation 7901 Jones Branch Dr. Suite 240 McLean, VA 22102 Cell: (717) 880-1714 The information contained in this message may be privileged and/or confidential and protected from disclosure. If the reader of this message is not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting the material from any computer. - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [digester] Trouble adding a list to a hash map
Please note that its important to post the smallest piece of code that fully demonstrates the problem at hand -- vast majority of the code below is quite unrelated and it takes time to read through each line that you add to your post. In any case, I did find atleast a couple of needles in the haystack. Given the length of the email, I've added markers to my inline comments, search for the string RA: in this email to get to my comments below. On Fri, Oct 1, 2010 at 4:37 PM, Philip A Grim II pg...@data-tactics.com wrote: Apologies...wasn't thinking straight. Here's the code. import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import org.apache.commons.digester.Digester; import org.apache.commons.digester.xmlrules.DigesterLoader; import org.xml.sax.InputSource; import org.xml.sax.SAXException; public class DigestTester { private static String xml = ?xml version=\1.0\ encoding=\utf-8\? + Envelope + Person + Locations + Location + Id3eca4cd1-a07a-4013-b4a3-1d6a6530f7e3/Id + DateAsOf201007132112/DateAsOf + DateLastModified20100803203509203/DateLastModified + NameMost Recent Location/Name + WKTPOINT (69.568583399873617 33.86775960347174 0)/WKT + /Location + Location + Id3e2462d1-a0c7-4013-4523-1345a3b8f7e3/Id + DateAsOf201007100814/DateAsOf + DateLastModified20100803203509203/DateLastModified + NamePrevious Location/Name + WKTPOINT (66.53455434533617 32.863453455537174 0)/WKT + /Location + /Locations + /Person + /Envelope; private static String test2 = ?xml version=\1.0\? + digester-rules + snip/ RA: Meta point is that when using XML rules its best to use an XML editor, reference the DTD and inspect / validate the rules before trying to use them. When used as a Java string such as above, it can hide problems as I'll point out below. pattern value=\Envelope/Person\ + object-create-rule pattern=\Locations\ classname=\java.util.ArrayList\/ + object-create-rule pattern=\Locations/Location\ classname=\java.util.HashMap\/ + call-method-rule pattern=\Locations/Location/Id\ targetoffset=\0\ methodname=\put\ paramcount=\2\ + paramtypes=\java.lang.Object,java.lang.Object\/ + object-param-rule pattern=\Locations/Location/Id\ paramnumber=\0\ type=\java.lang.String\ value=\id\/ + call-param-rule pattern=\Locations/Location/Id\ paramnumber=\1\/ + call-method-rule pattern=\Locations/Location/DateAsOf\ targetoffset=\0\ methodname=\put\ paramcount=\2\ + paramtypes=\java.lang.Object,java.lang.Object\/ + object-param-rule pattern=\Locations/Location/DateAsOf\ paramnumber=\0\ type=\java.lang.String\ value=\date_as_of\/ + call-param-rule pattern=\Locations/Location/DateAsOf\ paramnumber=\1\/ + call-method-rule pattern=\Locations/Location/DateLastModified\ targetoffset=\0\ methodname=\put\ paramcount=\2\ + paramtypes=\java.lang.Object,java.lang.Object\/ + object-param-rule pattern=\Locations/Location/DateLastModified\ paramnumber=\0\ type=\java.lang.String\ value=\date_last_modified\/ + call-param-rule pattern=\Locations/Location/DateLastModified\ paramnumber=\1\/ + call-method-rule pattern=\Locations/Location/Name\ targetoffset=\0\ methodname=\put\ paramcount=\2\ + paramtypes=\java.lang.Object,java.lang.Object\/ + object-param-rule pattern=\Locations/Location/Name\ paramnumber=\0\ type=\java.lang.String\ value=\name\/ + call-param-rule pattern=\Locations/Location/Name\ paramnumber=\1\/ + call-method-rule pattern=\Locations/Location/WKT\ targetoffset=\0\ methodname=\put\ paramcount=\2\
Re: [scxml] Too many state navigation causes StackOverflowException
On Mon, Sep 27, 2010 at 6:40 AM, Lorenz Schumann | Sysvision GmbH lorenz.schum...@sysvision.de wrote: Hi Rahul, i took over a project in development and took the implementation as the correct way to do it. But after i read your response (thank you very much by the way!) i re-read everything in the documentation. I want to control a phone application with what scxml can offer me. But when i look at the stopwatch example i see a huge difference to our approach: When controlling a stopwatch the states change on user action (mostly). The user interface sends the events to the statemachine. But in our phone application the states change depending on what happens inside the invoked code. So we trigger the events inside the invoked code. I know there is some fraction of the puzzle i am missing and i cannot see how to fire the events from outside to control the statemachine. snip/ I think part of it is that you have started with one of the most flexible and thereby, harder constructs i.e. invoke to work with. If the code that you are invoking isn't long running, then you are better off using constructs that allow for easier synchronous usage for triggering events. I also couldn't find any helpful examples. Anything that helps is appreciated! snap/ There is an example (related to mobile apps) linked from the home page, see Who is using it? section: http://commons.apache.org/scxml/ Some details here, code is invoked using custom actions (not using invoke): http://mymobileweb.morfeo-project.org/mymobileweb/mymw-tech/scxml I pointed to the guide in the previous email, which has more on custom actions. Thanks in advance! Lorenz P.S.: I decided to create a minimal example of how i use it right now. Maybe it helps... ?xml version=1.0 encoding=UTF-8? scxml xmlns=http://www.w3.org/2005/07/scxml; version=1.0 initial=enter_pin state id=enter_pin invoke targettype=java src=EnterPin / transition event=fail target=pin_failed / transition event=succ target=pin_succeeded / /state state id=pin_failed invoke targettype=java src=HandlePinFailed / transition event=finish target=end / transition event=retry target=enter_pin / /state state id=pin_succeeded invoke targettype=java src=HandlePinSucceeded / transition event=finish target=end / /state state id=end final=true / /scxml - SCXML scxml = SCXMLParser.parse(ClassLoader.getSystemResource(sc.xml), new SimpleErrorHandler()); SCXMLExecutor executor = new SCXMLExecutor(new JexlEvaluator(), new SimpleDispatcher(), new SimpleErrorReporter()); executor.setRootContext(new JexlContext(new HashMap())); executor.setStateMachine(scxml); // ReflectiveInvoker calls EnterPin, HandlePinFailed, etc. by reflection executor.registerInvokerClass(java, ReflectiveInvoker.class); executor.go(); - Now the most likely completely wrong usage: snip/ Likely, yes. See note at bottom of interface Javadocs: http://commons.apache.org/scxml/0.9/apidocs/org/apache/commons/scxml/invoke/Invoker.html -Rahul public class EnterPin { public void handle(SCInstance sc) { ... if (success) { sc.getExecutor().triggerEvent(new TriggerEvent(succ, TriggerEvent.SIGNAL_EVENT)); } else { sc.getExecutor().triggerEvent(new TriggerEvent(fail, TriggerEvent.SIGNAL_EVENT)); } } } On Fri, Sep 24, 2010 at 11:34 AM, Lorenz Schumann | Sysvision GmbH lorenz.schum...@sysvision.de wrote: Hi, i am using Commons SCXML for the first time and am overall new to the Statechart paradigm. But i am working on a software where a statemachine is needed and the first choice fell on commons. So much for the introduction. Now what we discovered is that when you navigate from state to state via triggering events there is a recursion that makes the method-stack higher and higher and will at some point throw an StackOverflowError. This is what the important part of a stacktrace looks like: at org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.initiateInvokes(SCXMLSemanticsImpl.java:847) at org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:142) at org.apache.commons.scxml.SCXMLExecutor.triggerEvent(SCXMLExecutor.java:160) at MyInvoker.invoke(MyInvoker.java:23) at org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.initiateInvokes(SCXMLSemanticsImpl.java:847) at org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:142) at org.apache.commons.scxml.SCXMLExecutor.triggerEvent(SCXMLExecutor.java:160) at MyInvoker.invoke(MyInvoker.java:23) at org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.initiateInvokes(SCXMLSemanticsImpl.java:847) at org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:142) at org.apache.commons.scxml.SCXMLExecutor.triggerEvent(SCXMLExecutor.java:160)
Re: [scxml] Too many state navigation causes StackOverflowException
On Tue, Sep 28, 2010 at 10:29 AM, Rahul Akolkar rahul.akol...@gmail.com wrote: On Mon, Sep 27, 2010 at 6:40 AM, Lorenz Schumann | Sysvision GmbH lorenz.schum...@sysvision.de wrote: Hi Rahul, i took over a project in development and took the implementation as the correct way to do it. But after i read your response (thank you very much by the way!) i re-read everything in the documentation. I want to control a phone application with what scxml can offer me. But when i look at the stopwatch example i see a huge difference to our approach: When controlling a stopwatch the states change on user action (mostly). The user interface sends the events to the statemachine. But in our phone application the states change depending on what happens inside the invoked code. So we trigger the events inside the invoked code. I know there is some fraction of the puzzle i am missing and i cannot see how to fire the events from outside to control the statemachine. snip/ I think part of it is that you have started with one of the most flexible and thereby, harder constructs i.e. invoke to work with. If the code that you are invoking isn't long running, then you are better off using constructs that allow for easier synchronous usage for triggering events. I also couldn't find any helpful examples. Anything that helps is appreciated! snap/ There is an example (related to mobile apps) linked from the home page, see Who is using it? section: http://commons.apache.org/scxml/ Some details here, code is invoked using custom actions (not using invoke): http://mymobileweb.morfeo-project.org/mymobileweb/mymw-tech/scxml snip/ Or this instead: http://forge.morfeo-project.org/wiki_en/index.php/SCXML_Getting_Started -Rahul I pointed to the guide in the previous email, which has more on custom actions. Thanks in advance! Lorenz P.S.: I decided to create a minimal example of how i use it right now. Maybe it helps... ?xml version=1.0 encoding=UTF-8? scxml xmlns=http://www.w3.org/2005/07/scxml; version=1.0 initial=enter_pin state id=enter_pin invoke targettype=java src=EnterPin / transition event=fail target=pin_failed / transition event=succ target=pin_succeeded / /state state id=pin_failed invoke targettype=java src=HandlePinFailed / transition event=finish target=end / transition event=retry target=enter_pin / /state state id=pin_succeeded invoke targettype=java src=HandlePinSucceeded / transition event=finish target=end / /state state id=end final=true / /scxml - SCXML scxml = SCXMLParser.parse(ClassLoader.getSystemResource(sc.xml), new SimpleErrorHandler()); SCXMLExecutor executor = new SCXMLExecutor(new JexlEvaluator(), new SimpleDispatcher(), new SimpleErrorReporter()); executor.setRootContext(new JexlContext(new HashMap())); executor.setStateMachine(scxml); // ReflectiveInvoker calls EnterPin, HandlePinFailed, etc. by reflection executor.registerInvokerClass(java, ReflectiveInvoker.class); executor.go(); - Now the most likely completely wrong usage: snip/ Likely, yes. See note at bottom of interface Javadocs: http://commons.apache.org/scxml/0.9/apidocs/org/apache/commons/scxml/invoke/Invoker.html -Rahul public class EnterPin { public void handle(SCInstance sc) { ... if (success) { sc.getExecutor().triggerEvent(new TriggerEvent(succ, TriggerEvent.SIGNAL_EVENT)); } else { sc.getExecutor().triggerEvent(new TriggerEvent(fail, TriggerEvent.SIGNAL_EVENT)); } } } On Fri, Sep 24, 2010 at 11:34 AM, Lorenz Schumann | Sysvision GmbH lorenz.schum...@sysvision.de wrote: Hi, i am using Commons SCXML for the first time and am overall new to the Statechart paradigm. But i am working on a software where a statemachine is needed and the first choice fell on commons. So much for the introduction. Now what we discovered is that when you navigate from state to state via triggering events there is a recursion that makes the method-stack higher and higher and will at some point throw an StackOverflowError. This is what the important part of a stacktrace looks like: at org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.initiateInvokes(SCXMLSemanticsImpl.java:847) at org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:142) at org.apache.commons.scxml.SCXMLExecutor.triggerEvent(SCXMLExecutor.java:160) at MyInvoker.invoke(MyInvoker.java:23) at org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.initiateInvokes(SCXMLSemanticsImpl.java:847) at org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:142) at org.apache.commons.scxml.SCXMLExecutor.triggerEvent(SCXMLExecutor.java:160) at MyInvoker.invoke(MyInvoker.java:23
Re: [scxml] Too many state navigation causes StackOverflowException
On Fri, Sep 24, 2010 at 11:34 AM, Lorenz Schumann | Sysvision GmbH lorenz.schum...@sysvision.de wrote: Hi, i am using Commons SCXML for the first time and am overall new to the Statechart paradigm. But i am working on a software where a statemachine is needed and the first choice fell on commons. So much for the introduction. Now what we discovered is that when you navigate from state to state via triggering events there is a recursion that makes the method-stack higher and higher and will at some point throw an StackOverflowError. This is what the important part of a stacktrace looks like: at org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.initiateInvokes(SCXMLSemanticsImpl.java:847) at org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:142) at org.apache.commons.scxml.SCXMLExecutor.triggerEvent(SCXMLExecutor.java:160) at MyInvoker.invoke(MyInvoker.java:23) at org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.initiateInvokes(SCXMLSemanticsImpl.java:847) at org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:142) at org.apache.commons.scxml.SCXMLExecutor.triggerEvent(SCXMLExecutor.java:160) at MyInvoker.invoke(MyInvoker.java:23) at org.apache.commons.scxml.semantics.SCXMLSemanticsImpl.initiateInvokes(SCXMLSemanticsImpl.java:847) at org.apache.commons.scxml.SCXMLExecutor.triggerEvents(SCXMLExecutor.java:142) at org.apache.commons.scxml.SCXMLExecutor.triggerEvent(SCXMLExecutor.java:160) at MyInvoker.invoke(MyInvoker.java:23) Are we using it as it is meant to be? Is there a way that the execution of states is not beeing stacked? snip/ The invoke paradigm is broadly about asynchronously initiating and interacting with external processes. From the trace it looks like your invoker may be synchronously triggering an event on the state machine (which may be initiating the invoke again and so on ad infinitum). Instead, invoke should simply initiate external processing asynchronously and then trigger an event back when the processing is done (or when it fails). Some background on usage is here [1]. If what you are trying to do can be modeled as sending events to existing external processes, you can take a look at send and the EventDispatcher instead. If what you are trying to do can be modeled as inherently synchronous executable content within the state machine's onentry, onexit or transitions, then you can have a look a custom actions [2] instead. -Rahul [1] http://commons.apache.org/scxml/guide/using-commons-scxml.html [2] http://commons.apache.org/scxml/guide/custom-actions.html Help is much appreciated. Lorenz - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Transitions without targets compete for enablement
On Tue, Sep 21, 2010 at 4:35 AM, Hallvard Trætteberg h...@idi.ntnu.no wrote: Thanks Rahul for the answer. Comments below: You're correct that in this case both (or more than two) transitions could be selected. The selection process in v0.9 picks the first transition in document order (from each orthogonal region, if there are such regions) without inspecting the transition targets, and that could be changed to pick more if there are no conflicts. Yes, I read the code and noticed that a null target (stay) isn't considered as a special case. However, the correct solution for Commons SCXML is to port the SCXMLSemantics impl in use to match more closely the current algorithm specified in an appendix of the latest SCXML WD which always ensures that only one event is processed at a time (even internal events are queued). This change is slated for v1.0, and needs a JIRA ticket opened against it so it can be tracked -- you can open the ticket if you want, or I'll open it when I get a chance. Unless a patch becomes available, I don't expect to be able to update the impl for at least another month. I read the specification, but didn't find special mention of the null target case. They do explain why one transition overrules (preempts?) another, when they lead out of a region. However, think the issue of queueing is orthogonal to the issue of selecting more than one target-less transition. You are right that the way I described my case, handling one event at time would solve the issue. But there's no guarantee that an event isn't used several times, so being able to select multiple target-less transitions is best. snip/ Agreed. One interim solution may be to design a slightly smarter custom action for a wildcarded transition that initiates appropriate processing based on the event(s) being processed. My interim solution is to wrap each transition in a state, so they don't compete. It clutters the model, but since it is generated from a DSL, that's not a big issue. Still, I would like SCXML's implementation to be more reasonable :-). A final (and hopefully positive and constructive) comment: SCXML's code is tidy and easy to read, so implementing a custom Semantics isn't really that difficult either. What could help, is if some of the methods were split into parts/stages implemented by overridable (protected) methods, so that variations on the official semantics could be implemented in a subclass, without much copying of code. snap/ Indeed, thats a valid comment. The ability to provide custom semantics was provided to allow for any changes in executor behavior, but it wasn't anticipated to be widely used (and hence, isn't very modular). Indeed, it is probably the least used feature of the library and we don't get much feedback on it. The default semantics impl could be made more modular and easier to subclass, bearing in mind that it may have implications on backward compatibility -- though since we are at 0.x releases we can certainly make such changes if needed. If you have specific suggestions on making subclassing easier, please submit a patch for consideration through JIRA [1]. -Rahul [1] http://commons.apache.org/scxml/issue-tracking.html Hallvard - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Transitions without targets compete for enablement
On Mon, Sep 20, 2010 at 5:25 AM, Hallvard Trætteberg h...@idi.ntnu.no wrote: Hi, I'm trying to implement a state such that whenever some event (in a predetermined set) occurs a corresponding actions should be performed, e.g. whenever event eA occurs, action aA should be performed, whenever event eB occurs, action aB should be performed etc. I've implemented this using one targetless transition for each event/action pair, so that the appropriate action is performed without leaving the state. Now I've discovered that only the first transition (in document order) is enabled, if several events are triggered at the same time. I understand that if there are several transitions out of a state, only one can be enabled. However, none of my transitions have a target so I thought they could all be enabled at the same time. What's the reason for not allowing this? snip/ You're correct that in this case both (or more than two) transitions could be selected. The selection process in v0.9 picks the first transition in document order (from each orthogonal region, if there are such regions) without inspecting the transition targets, and that could be changed to pick more if there are no conflicts. However, the correct solution for Commons SCXML is to port the SCXMLSemantics impl in use to match more closely the current algorithm specified in an appendix of the latest SCXML WD which always ensures that only one event is processed at a time (even internal events are queued). This change is slated for v1.0, and needs a JIRA ticket opened against it so it can be tracked -- you can open the ticket if you want, or I'll open it when I get a chance. Unless a patch becomes available, I don't expect to be able to update the impl for atleast another month. One interim solution may be to design a slightly smarter custom action for a wildcarded transition that initiates appropriate processing based on the event(s) being processed. -Rahul Hallvard - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] How to retrieve the transition target in a custom action
2010/9/20 Thiébault Benoît d...@artenum.com: Hi everyone, I would like to retrieve the transition target (if there is one) in my custom action. How can I do this? My need is more to know if there is a transition than to know what the target is. snip/ I believe you mean a transition thats not a stay nor self transition, since the only way a custom action will ever execute is if some transiton is being followed (in order for SCXML executable content to execute). There isn't a direct way to access information about the transition target. I imagine your custom action is within a transition element. If so, you could walk up the SCXML object model and check whether the parent transition has a target attribute and whether it is the parent state id itself. It may also be possible to infer whether a (non-stay) transition is being followed and what the target is, by using a suitable SCXMLListener impl. For long computations, you should consider using the external communications module (either send or invoke) to send an event to (or invoke) some external process which manages the computation and fires a completion event on the state machine when done. -Rahul I need this info to know if it is possible to launch a long computation in a different thread: - if there is a transition target, the state machine will go to the new state and my computation will be started in one state and continue in another one, which I want to avoid. - if there is no transition target, it means that my computation is performed within the original state (internal transition) and I can use my computation without fearing an undetermined state machine. Kind regards, Ben - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Creating a custom action with children
2010/9/20 Thiébault Benoît d...@artenum.com: My mistake, read: MyCustomAction class implements org.apache.commons.scxml.model.Action instead of: MyCustomAction class implements CustomAction Le 20 sept. 2010 à 15:38, Thiébault Benoît a écrit : Hello everyone, I'm trying to configure SCXML to read custom actions like this: my:custom my:command name=foo/ my:command name=bar/ /my:custom I've read the custom actions tutorial (http://commons.apache.org/scxml/guide/custom-actions.html), which sends back to Digester API for custom action with nested children and I end up with the following code: Digester digester = SCXMLParser.newInstance(null, new URLResolver(scxmlDocument), null); digester.setNamespaceAware(true); digester.setRuleNamespaceURI(http://www.my.org/SCXML;); digester.addObjectCreate(*/custom, MyCustomAction.class); digester.addSetProperties(*/custom); digester.addObjectCreate(*/custom/command, MyCustomAction.class); digester.addSetNext(*/custom/command, addCommand, my.package.CommandCustomAction); snip/ Need to add the custom action to the parent actions holder (such as onentry, onexit or transition). So, minimally, you'll have to add the SetNextRule (and maybe others, as per your action needs): digester.addSetNext(*/custom/command, addAction); As an aside, best to add custom actions to these three paths (where ACTION_NAME is name of the custom action element): !*/onentry/ + ACTION_NAME !*/transition/ + ACTION_NAME !*/onexit/ + ACTION_NAME -Rahul digester.setErrorHandler(errHandler); try { stateMachine = (SCXML) digester.parse(scxmlDocument.toString()); if (stateMachine != null) { SCXMLParser.updateSCXML(stateMachine); } } catch (RuntimeException rte) { logError(rte); } catch (IOException ioe) { logError(ioe); } catch (SAXException sae) { logError(sae); } catch (ModelException me) { logError(me); } MyCustomAction class implements CustomAction and stores an ArrayList of CommandCustomAction and has a addCommand method. The CommandCustomAction defines the setName() and getName() methods. This code seems to work (I mean no crash nor warning)... but does nothing. I guess I just read successfully the XML file, but didn't tell SCXML that it has to call the execute method in MyCustomeAction class. How to do it ? Is there an example somewhere of the use of such custom actions with children elements ? Kind regards, Ben - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] How to retrieve the triggering event in a custom action
2010/9/16 Thiébault Benoît d...@artenum.com: Hi everyone, I'm using SCML with custom actions. I followed the Custom Actions tutorial successfully (http://commons.apache.org/scxml/guide/custom-actions.html), but the Hello action only uses parameters provided in the SCXML file. What I want to do is to provide a payload to the triggering event and retrieve it in my custom action. Is this possible ? // In the method firing the event TriggerEvent[] evts = {new TriggerEvent(event.getId(), TriggerEvent.SIGNAL_EVENT, myPayload)}; try { engine.triggerEvents(evts); } catch (ModelException me) { logError(me); } // In the custom action class public void execute(EventDispatcher evtDispatcher, ErrorReporter errRep, SCInstance scInstance, Log appLog, Collection derivedEvents) throws ModelException, SCXMLExpressionException { // Here I want to retrieve myPayload snip/ When using v0.9, for the above external trigger: Object payload = scInstance.getRootContext().get(_eventdata); When processing internal / derived events, the following: Object payload = scInstance.getRootContext().get(_eventdatamap).get(my.event.name); For examples which may illustrate where the payload resides in the root context, see the eventdata-*.xml files here (this may help to see how the values may be retrieved programmatically within a custom action): http://svn.apache.org/repos/asf/commons/proper/scxml/tags/SCXML_0_9/src/test/java/org/apache/commons/scxml/env/jexl/ -Rahul } Kind regards Ben - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] How to retrieve the triggering event in a custom action
2010/9/16 Thiébault Benoît d...@artenum.com: Thank you, it works very well (the first option, because I don't know a priori the event name so it is hard to use the second). When you say When using v0.9, is this API planned to change in future version or is it just to say it works in 0.9 but might not work forever snip/ The latest draft includes more meta-data for events (in addition to payload). Though the change hasn't been implemented yet, there will be an _event variable and the payload will be at _event.data in subsequent releases. -Rahul Kind regards Ben Le 16 sept. 2010 à 16:38, Rahul Akolkar a écrit : 2010/9/16 Thiébault Benoît d...@artenum.com: Hi everyone, I'm using SCML with custom actions. I followed the Custom Actions tutorial successfully (http://commons.apache.org/scxml/guide/custom-actions.html), but the Hello action only uses parameters provided in the SCXML file. What I want to do is to provide a payload to the triggering event and retrieve it in my custom action. Is this possible ? // In the method firing the event TriggerEvent[] evts = {new TriggerEvent(event.getId(), TriggerEvent.SIGNAL_EVENT, myPayload)}; try { engine.triggerEvents(evts); } catch (ModelException me) { logError(me); } // In the custom action class public void execute(EventDispatcher evtDispatcher, ErrorReporter errRep, SCInstance scInstance, Log appLog, Collection derivedEvents) throws ModelException, SCXMLExpressionException { // Here I want to retrieve myPayload snip/ When using v0.9, for the above external trigger: Object payload = scInstance.getRootContext().get(_eventdata); When processing internal / derived events, the following: Object payload = scInstance.getRootContext().get(_eventdatamap).get(my.event.name); For examples which may illustrate where the payload resides in the root context, see the eventdata-*.xml files here (this may help to see how the values may be retrieved programmatically within a custom action): http://svn.apache.org/repos/asf/commons/proper/scxml/tags/SCXML_0_9/src/test/java/org/apache/commons/scxml/env/jexl/ -Rahul } Kind regards Ben - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] update datamodel from java
On Sat, Sep 4, 2010 at 12:55 PM, Azraiyl azra...@gmail.com wrote: Hello, I've a simple state machine ?xml version=1.0 encoding=UTF-8? scxml xmlns=http://www.w3.org/2005/07/scxml; version=1.0 name=Fan2 initial=Off exmode=strict datamodel data id=T expr=10/ /datamodel state id=Off onentry log expr='OnEntry Off'/ /onentry transition cond=T gt; 30 target=On/ onexit log expr='OnExit Off'/ /onexit /state state id=On onentry log expr='OnEntry On'/ /onentry transition cond=T lt; 20 target=Off/ onexit log expr='OnExit On'/ /onexit /state /scxml and like to update T through Java. I tried this: fan2.getEngine().getRootContext().set(T, 40); but somehow the engine does not switch into the new state. Do I have to manually trigger the engine to reevaluate all conditions or what I'am missing? snip/ Yes, once in steady state, the conditions will be evaluated again only during the next event processing. Couple of options: * Send the new value of T through the payload of an event * Trigger an event after the set value of T above -Rahul Thanks in advance for any hint - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] update datamodel
On Sat, Sep 4, 2010 at 12:40 PM, Azraiyl azra...@gmail.com wrote: Hello, I've a simple state machine ?xml version=1.0 encoding=UTF-8? scxml xmlns=http://www.w3.org/2005/07/scxml; version=1.0 name=Fan2 initial=Off exmode=strict datamodel data id=T expr=10/ /datamodel state id=Off onentry log expr='OnEntry Off'/ /onentry transition cond=T gt; 30 target=On/ onexit log expr='OnExit Off'/ /onexit /state state id=On onentry log expr='OnEntry On'/ /onentry transition cond=T lt; 20 target=Off/ onexit log expr='OnExit On'/ /onexit /state /scxml and like to update T through Java. I tried this: fan2.getEngine().getRootContext().set(T, 40); but somehow the engine does not switch into the new state. Do I have to manually trigger the engine to reevaluate all expression or what I'am missing? snip/ Yes (this looks like a duplicate post, more in previous reponse linked below): http://markmail.org/message/purvcoyinluuwubo -Rahul Thanks in advance for any hint - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] update datamodel from java
On Sat, Sep 4, 2010 at 1:19 PM, Azraiyl azra...@gmail.com wrote: Thanks for your response. Just out of curiousity: Is this the intended behaviour of SCXML? Chapter 3.3.3: If the event clause is missing, the transition is taken whenever the cond evaluates to true. snip/ At a high level, the only way for the environment to communicate with a state machine is through events. Data model changes are best made via native mechanisms described in state machine theory (such as event payloads). Doing so will cause the cond to be evaluated in the process and has the additional benefit of being more declarative (i.e. it will be modeled with the rest of the state machine, rather than behavior that can't be noticed just by reading the SCXML document). Programmatic access to the data model (only root context is accessible) is provided as this is often convenient in certain environments. However, such access clearly isn't portable across implementations and has the downsides of not being tied into the event processing loop. If such a choice is made by the developer, there is an additional onus on the developer -- this includes, firing an event if need be and synchronizing access if needed etc. IMO, the section 3.3.3 quote probably needs some sort of disclaimer for programmatic access. There are cases where the application may deem it unnecessary for every programmatic update to the root context to result in evaluating all conds. Commons SCXML provides the developer that level of control. -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] update datamodel from java
On Sat, Sep 4, 2010 at 2:03 PM, Azraiyl azra...@gmail.com wrote: changing the datamodel is IMHO an event which could be triggered through getRootContext().set(...). snip/ If this is to be done, then yes, that'd be a good hook. A simple implementation would reevalute all events without and event attribute, a better implemention may ask the script engine which expression depends on what. snap/ Indeed. We cater to a number of expression languages and if some provide an ability to conveniently build such expression dependency graphs, we can incorporate them on a case-by-case basis. Much of the work to come up with such graphs would best be done outside Commons SCXML as this work is currently incidental to SCXML. However this is a personal opinion, but it would be nice if the perhaps the Commons SCXML documents that behaviour (if it isn't already and I was to dumb) or add an option (or even function call that I need to call manually) to reevalute all conditions. snip/ Yes, we can always improve (many aspects of documentation and code). I don't intend to spend any time on adding this particular option, but if others are interested, feel free to post tickets in JIRA with patches for consideration. -Rahul [1] http://commons.apache.org/scxml/issue-tracking.html Thanks for your explanation - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] StopWatch usecase and State pattern
2010/8/22 Thiébault Benoît d...@artenum.com: Thank you Rahul for your quick answer, I will have a look at the link you provided and at the AbstractStateMachine class implementation. Another question, not really related to the first one : is there a roadmap for the W3C standard ? I mean is there a planned date for the release of the final version of the specification ? snip/ With the disclaimer that I certainly do not speak for the Working Group, there seems to be a sense that the Working Draft after the next one will be Last Call. The WG is in the process of writing spec assertions (and tests), which generally implies most of the original spec content is done. -Rahul Kind regards, Ben Le 21 août 2010 à 19:47, Rahul Akolkar a écrit : 2010/8/21 Thiébault Benoît d...@artenum.com: Hi everyone, I'm starting using SCXML and there is something that I am not sure to understand very well. In the previous applications I developed, I used an event-driven architecture : my user interface (for instance) was triggering Events that an EventDispatcher converted into (a) Action call(s). The mapping Event/Action(s) was declared in a separate XML file. When I discovered SCXML I thought I could improve this architecture by declaring the Event/Action(s) mapping in the SCXML file. There are however some points that are not very clear yet for me. In the State design pattern (http://en.wikipedia.org/wiki/State_pattern), a state is represented by a class while the actions are mapped with the methods (roughly). I though I could thus map my events with a method of a given object. But when I look at the StopWatch use case, and especially the StopWatch class (http://commons.apache.org/scxml/xref-test/org/apache/commons/scxml/env/StopWatch.html), the whole state machine is represented by the class and each state is mapped by the methods... In this use case, I don't see how actions are handled. I mean if I have two events triggered targeting the same state, how can I handle both events differently ? There could be two ways to go from a state A to a state B, for instance in an application where you want to edit a text file, from the ready state (when the application is ready to start) you could go to the edit state by opening an existing file or by creating a new one. The targeted state is then the same, even though the way to reach it is different. I don't know how to model this in SCXML. Can someone help ? snip/ The AbstractStateMachine class is one simple pattern among many that may be employed to use Commons SCXML [1], and is certainly very basic. It does not implement the State pattern as described in the document you point to. The State pattern itself has limitations (requiring a flattened state machine), so even implementing that isn't a silver bullet. As someone who wants to use the State pattern, please take a look at the AbstractStateMachine class implementation and perform the changes necessary to rather implement the State pattern instead. The higher order bit is that SCXML as a language is more powerful that any of these individual patterns. -Rahul [1] http://commons.apache.org/scxml/guide/using-commons-scxml.html Thank you Ben - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] condition checking
On Fri, Aug 20, 2010 at 3:06 PM, Christopher Dragert chris.drag...@mail.mcgill.ca wrote: My SCXML is crashing when I try to run it and my debugging efforts have gone for naught. The observable behaviour is as follows -- from the state stationary, the state machine checks the guard on a transitions several times, and then stops functioning. The cond is a method call using JEXL that returns a boolean (I've tested this and found that the method does return on a call leading to the crash, so the problem is not here). If the move transition is followed, then on eventual return to the stationary state, the state machine will become unresponsive after a few checks of the guard. With a listener I've determined that there is no state change, so if the machine is running, the cond should be evaluated. My hunch is that the state machine is silently failing -- how can i determine if this is the case? snip/ Not sure what crash means since I take it you are not observing any stack traces or ErrorReporter callbacks. It also seems that the state machine makes progress in some cases (as the move transition you mention above). Eventless transitions are only evaluated when an event is processed by Commons SCXML (be it external or internal). The cond method getting called number of times is a result of the processing of the external event followed by one or more internal events. Then the state machine may just be at rest between processing events (and therefore silent). Are there any obvious mistakes that I'm making in my SCXML file? snap/ The indentation makes it slightly harder to read, but apart from the fact that some non-final states seem to be declared as final, I don't see much else (it would be good to remove all final=true instances). Ofcourse, there are a number of eventless transitions (see above). Best if you could describe the expected behavior you are looking on (for a given scenario of current state, event fired etc.) -- what you are observing is clearer in your note. -Rahul Any help would be appreciated, Chris Dragert -- SCXML file: ?xml version=1.0 encoding=ASCII? scxml xmlns=http://www.w3.org/2005/07/scxml; version=1.0 initialstate=stationary datamodel data id=threatener / data id=move expr=move / /datamodel state id=tracking final=true initial transition target=safe / /initial transition event=i_see_player log expr=this.addPlayer(_eventdata) / /transition transition event=i_dont_see_player log expr=this.removePlayer(_eventdata) / /transition state id=safe final=true initial transition target=history / /initial history type=deep id=history transition target=stationary/ /history state id=stationary final=true transition cond=this.tooClose(this.getTheyApproachBuffer()) target=threatened / transition event=move target=moving / /state state id=moving final=true transition cond=this.tooClose(this.getWeApproachBuffer()) target=threatened raise event=destination_unreachable / /transition transition event=destination_reached target=stationary / transition event=destination_unreachable target=stationary / /state /state state id=threatened onentry log expr=this.fleeTarget(threatener) / log expr=this.createEvent('move', destination) / /onentry transition event=destination_reached target=history / transition event=destination_unreachable target=history / /state /state /scxml - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] StopWatch usecase and State pattern
2010/8/21 Thiébault Benoît d...@artenum.com: Hi everyone, I'm starting using SCXML and there is something that I am not sure to understand very well. In the previous applications I developed, I used an event-driven architecture : my user interface (for instance) was triggering Events that an EventDispatcher converted into (a) Action call(s). The mapping Event/Action(s) was declared in a separate XML file. When I discovered SCXML I thought I could improve this architecture by declaring the Event/Action(s) mapping in the SCXML file. There are however some points that are not very clear yet for me. In the State design pattern (http://en.wikipedia.org/wiki/State_pattern), a state is represented by a class while the actions are mapped with the methods (roughly). I though I could thus map my events with a method of a given object. But when I look at the StopWatch use case, and especially the StopWatch class (http://commons.apache.org/scxml/xref-test/org/apache/commons/scxml/env/StopWatch.html), the whole state machine is represented by the class and each state is mapped by the methods... In this use case, I don't see how actions are handled. I mean if I have two events triggered targeting the same state, how can I handle both events differently ? There could be two ways to go from a state A to a state B, for instance in an application where you want to edit a text file, from the ready state (when the application is ready to start) you could go to the edit state by opening an existing file or by creating a new one. The targeted state is then the same, even though the way to reach it is different. I don't know how to model this in SCXML. Can someone help ? snip/ The AbstractStateMachine class is one simple pattern among many that may be employed to use Commons SCXML [1], and is certainly very basic. It does not implement the State pattern as described in the document you point to. The State pattern itself has limitations (requiring a flattened state machine), so even implementing that isn't a silver bullet. As someone who wants to use the State pattern, please take a look at the AbstractStateMachine class implementation and perform the changes necessary to rather implement the State pattern instead. The higher order bit is that SCXML as a language is more powerful that any of these individual patterns. -Rahul [1] http://commons.apache.org/scxml/guide/using-commons-scxml.html Thank you Ben - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] double evaluation of expr in assignments
On Thu, Aug 12, 2010 at 2:51 PM, Fabrizio Morbini fmorb...@gmail.com wrote: Hi, problem: i would like to assign to a variable, v1, the value of another variable, v2, but the name v2 is the result of an expression. For example, assume you have an inspect event that should assign to a predetermined variable the value of the variable whose name is passed as payload to the inspect event. attempted solution: add a new parameter to the scxml assign action. The new parameter is a boolean that if true allows to evaluate the result of the first evaluation of the expr field of the assign action. In the example above, if the expr is _eventdatamap.get('inspect').get('varName') the first evaluation will return v2 the second evaluation will return the value of v2 in the datamodel. question: this seems a common situation and i wonder if there is already a solution. snip/ The above is like a gensym operation (generate symbol) and there isn't a standard solution. As you point out, its possible to do this with a variant of the assign action. Depending on the expression language and data structures, you can get some pseudo-gensym behavior (for example, when using JEXL you may generate the key for a map using an expression within the [ ] operator). In SCXML, the underlying datamodel context is itself like a map, but it isn't exposed directly to the expressions as such. -Rahul thanks - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] datamodel, custom actions and digester
On Wed, Aug 11, 2010 at 2:19 PM, Abigail Gertner gert...@mitre.org wrote: On 8/11/2010 12:29 AM, Rahul Akolkar wrote: snip/ The way to obtain the live values of the datamodel is to use the expression evaluator, see interfaces mentioned here: http://commons.apache.org/scxml/guide/contexts-evaluators.html Is it possible to call a method using the expression evaluator with an argument that is a node in the XML tree, rather than just a string value? snip/ Executable content is open ended in SCXML, as largely speaking most things are possible with custom actions. I'm afraid I've lost the bigger picture of your scenario in the pin-pointed question above. To obtain a node using the expression evaluator, use Evaluator#evalLocation(...) which returns a Node. Might be worthwhile revisiting the need for using SCXMLParser#newInstance() rather than the static parse methods. The reason I am doing this is that I am using xinclude to include a separate xml file and I found that I needed to call setXIncludeAware() on the parser to make it do the include. Is there some way to do this using the static parse methods? snap/ Not in the latest release (v0.9) so thats one of the cases where you may indeed not be able to use the static parse methods. Based on what I've read so far, it seems your best bet may be to register the digester rules for your custom actions by hand after you obtain the new instance and let the custom action do the appropriate expression evaluation and datamodel / context processing. -Rahul Thanks again, -Abigail - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] datamodel, custom actions and digester
On Wed, Aug 11, 2010 at 3:51 PM, Abigail Gertner gert...@mitre.org wrote: On 8/11/2010 3:36 PM, Rahul Akolkar wrote: On Wed, Aug 11, 2010 at 2:19 PM, Abigail Gertner gert...@mitre.org wrote: On 8/11/2010 12:29 AM, Rahul Akolkar wrote: snip/ The way to obtain the live values of the datamodel is to use the expression evaluator, see interfaces mentioned here: http://commons.apache.org/scxml/guide/contexts-evaluators.html Is it possible to call a method using the expression evaluator with an argument that is a node in the XML tree, rather than just a string value? snip/ Executable content is open ended in SCXML, as largely speaking most things are possible with custom actions. I'm afraid I've lost the bigger picture of your scenario in the pin-pointed question above. To obtain a node using the expression evaluator, use Evaluator#evalLocation(...) which returns a Node. What I mean is, if I want to do something like: onentry cs:var name=result expr=foo.bar(...)/ /onentry Where the argument to foo.bar() is a Node from the datamodel, but with the current context values included, how can I get that from the expression evaluator. I tried using the Data('var','path') expression but it doesn't seem to work for nodes. snip/ Here are some ways to tackle this: * Break the above into smaller operations: (1) obtain a node, (2) invoke the method. For example: onentry my:node name=arg expr=.../ cs:var name=result expr=foo.bar(arg)/ /onentry where my:node uses Evaluator#evalLocation(...) and creates a var matching the name argument. * Use XPath as the expression language as its better equipped to deal with XML nodes. The above would then become: onentry cs:var name=result expr=foo:bar($dataid/xpath/to/node)/ /onentry However, the XPath evaluator isn't available in the latest release however, but rather in a branch: http://svn.apache.org/repos/asf/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/env/xpath/ * A bit of background - The Data() function is mostly limited to values of leaf nodes (strings, integers) and is designed to satisfy the rvalue of most assignment expressions. There is a corresponding LData() -- I presume you're using JEXL -- that is meant to satisfy the lvalue (and will return nodes) but these are implementation details so resorting to using LData isn't recommended. Might be worthwhile revisiting the need for using SCXMLParser#newInstance() rather than the static parse methods. The reason I am doing this is that I am using xinclude to include a separate xml file and I found that I needed to call setXIncludeAware() on the parser to make it do the include. Is there some way to do this using the static parse methods? snap/ Not in the latest release (v0.9) so thats one of the cases where you may indeed not be able to use the static parse methods. Based on what I've read so far, it seems your best bet may be to register the digester rules for your custom actions by hand after you obtain the new instance and let the custom action do the appropriate expression evaluation and datamodel / context processing. I'm trying to do it this way now and having trouble getting the custom action to fire. I am using dig.addObjectCreate(!*/onentry/sendMessage, SendMessage.class); Where my custom action is called SendMessage. Then in my scxml file I have onentry sendMessage/ /onentry The SendMessage object is being created when the file is parsed, but the execute() method is not being called when the state is entered. Do I have to do something else to get it to call execute()? snap/ Minimally, you'll have to add the SetNextRule (and maybe others, as per your action needs), so this: dig.addSetNext(!*/onentry/sendMessage, addAction); Also, best to use a different XML namespace for custom actions. See Digester#setRuleNamespaceURI(...) for this purpose. -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] datamodel, custom actions and digester
On Tue, Aug 10, 2010 at 7:11 PM, Abigail Gertner gert...@mitre.org wrote: Hi -- I have a couple of questions about using commons SCXML. I am trying to use the datamodel within a state as a kind of template, so when I enter the state, I will set some values within the datamodel and then execute some code with the resulting data. I was trying to use an assign statement within the state's onentry tag and then use the onEntry() method of a Listener to do the additional processing of the data, but I found that the listener did not get the values that had been set by the assign statement as part of the datamodel associated with its target node. It only gets the original datamodel when I call target.getDatamodel() - not the version with the updated values. Is this correct? snip/ The getDatamodel() call returns an oacs.model.Datamodel object (anything belonging to the model package is not part of an executing state machine, rather its part of the state machine description itself i.e. the model on which the executor operates). So yes, the above behavior you note is certainly as expected. Note that the above is useful in some scenarios, such as reset type scenarios where one may want to restore the datamodel to its original values. The way to obtain the live values of the datamodel is to use the expression evaluator, see interfaces mentioned here: http://commons.apache.org/scxml/guide/contexts-evaluators.html So, I think I need to use a custom action to do this. I think I have figured out how to implement the custom action. My problem now is that (for unrelated reasons) I am using a dispatcher obtained from SCXMLParser.newInstance() to parse the scxml document and I don't know how to include the custom action when I am doing it this way. In the documentation for custom actions, it says that the digester rules can be added by directly by obtaining a Digester instance with the default SCXML rules using the newInstance() methods and further directly adding the necessary rules using the digester API. Can someone give me a bit more information or an example on how to accomplish this? snap/ You'll need to be familiar with Digester, which is what the above method returns (an instance thereof): http://commons.apache.org/digester/ The idea is to register the custom action related digester rule(s) that inject the backing action classes in the SCXML object model (for example, the digester paths will likely be !*/onentry/foo, !*/onexit/foo, !*/transition/foo, !*/if/foo where foo is the custom action). Might be worthwhile revisiting the need for using SCXMLParser#newInstance() rather than the static parse methods. Alternatively, if there is a way to do what I am trying to do (assign some values to the data and then pass that data to a listener) without a custom action I would like to know that too. snip/ Some data, such as that available in the root context, may be accessed directly if the listener has a handle to the root context. -Rahul Thanks for your help - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Regarding usage of fireEvent method
On Mon, Aug 2, 2010 at 1:40 AM, Prem Chand Majeti prem.maj...@aricent.com wrote: Hi, I'm trying to implement simple FSM in java. Here is my scxml :- scxml xmlns=http://www.w3.org/2005/07/scxml; version=1.0 initialstate=first state id=first transition event=event1 target=second / transition event=event2 target=last / /state state id=second transition event=event3 target=last / /state state id=last final=true / /scxml Java Implemetation:- public class FsmTest extends AbstractStateMachine { public FsmTest(URL scxmlDocument) { super(scxmlDocument); } public void first() { //Some process... if(..) fireEvent(event1); else fireEvent(event2); } snip/ The above is a bit of an anti-pattern for the simple AbstractStateMachine class. The mapped methods (such as first above) are executed synchronously as part of the onentry processing for the corresponding states. Firing a new event synchronously while still processing a previous one isn't recommended. Many possible solutions. To name a few: * Override the fireEvent() method to be asynchronous (in a new thread, perhaps with some wait time) * Add a first-class event queue to an AbstractStateMachine subclass and add events to the queue from where they get processed in sequence * Use one of the more sophisticated patterns (see [1]) than the simple AbstractStateMachine class -Rahul [1] http://commons.apache.org/scxml/guide/using-commons-scxml.html public void second() { // Some Process fireEvent(event3); } public void last() { } } When I try to run this, it was entering into the state first. But from there no event was fired and it was not moving to other states. Please let me know if I was doing something wrong. Thanks Regards Prem - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Calling methods through scxml
On Fri, Jul 30, 2010 at 8:57 PM, Fabrizio Morbini fmorb...@gmail.com wrote: other two alternatives may be: 1) use the expr attribute of the log element. 2) create a custom action, e.g. eval that does just what you are asking. snip/ More about custom actions here: http://commons.apache.org/scxml/guide/custom-actions.html -Rahul On Fri, Jul 30, 2010 at 15:08, Christopher Dragert chris.drag...@mail.mcgill.ca wrote: Hello, I'm trying to find an elegant way to call a method from an object using scxml. I start by placing my object (foo) in the context, then starting execution. My goal would be to have something like: onentry expr=foo.bar()/ /onentry but this does not work since expr is not a tag. Instead, the best method I've found is to create a dummy variable in my data model and then fake assignments to it: datamodel data id=scratch / /datamodel state id=hello final=true onentry assign location=scratch expr=foo.bar()/ /onentry /state While this works, it seems unneccesary and contrived. Is there a more elegant way to do this? Thanks, Chris Dragert - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [math] questions regarding bibliographic citations?
On Mon, Jul 26, 2010 at 5:52 PM, Tanim Islam tanim.is...@gmail.com wrote: Hello: I am employing apache commons math 2.2 in the course of my research, and I wonder if there is a format to cite my use of apache commons math? If anyone has a bibtex entry for citing apache commons projects, that would be most helpful. snip/ There isn't a standard template obviously (as you've noticed) and I've seen a number of ways in which this has been done. I'd use something along the lines below using Commons Math v2.1 as an example: @misc{CMath21, title = {Apache Commons Math, Release 2.1}, author = {Commons Math Developers}, year = 2010, month = apr, organization = {The Apache Software Foundation}, URL = {http://commons.apache.org/math}, howpublished = {Available from \url{http://commons.apache.org/math/download_math.cgi}} } Adjust per taste. -Rahul Tanim Islam - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Query on usage of datamodel
On Fri, Jul 23, 2010 at 9:16 AM, Prem Chand Majeti prem.maj...@aricent.com wrote: Hi, I'm new to SCXML. I had a query on usage of datamodel and data. E.g.:- data name=foo / 1) Is it possible to set data values from Java program dynamically? 2) Can I declare this data at document level and use it in all the states for further processing? snip/ Yes, and in fact, if you declare a document level datamodel, it is quite trivial to set data values programmatically using SCXMLExecutor#getRootContext() followed by a set on the root context. If it is possible, can you give some pointers where I can find an example or tutorial for this? snap/ The following resources may be useful (let us know if you have more questions beyond that): http://commons.apache.org/scxml/guide/datamodel.html http://commons.apache.org/scxml/guide/contexts-evaluators.html -Rahul Thanks Regards Prem DISCLAIMER: This message is proprietary to Aricent and is intended solely for the use of the individual to whom it is addressed. It may contain privileged or confidential information and should not be circulated or used for any purpose other than for what it is intended. If you have received this message in error, please notify the originator immediately. If you are not the intended recipient, you are notified that you are strictly prohibited from using, copying, altering, or disclosing the contents of this message. Aricent accepts no responsibility for loss or damage arising from the use of the information transmitted by this email including damage from virus. - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] passing data to the state
On Mon, Jul 12, 2010 at 12:49 PM, qin ding qindi...@yahoo.com wrote: I am learning commons scxml. I am experimenting writing a poker game using activemq and scxml. So, I have my config xml defined as follows: ?xml version=1.0? scxml xmlns=http://www.w3.org/2005/07/scxml; version=1.0 initialstate=waitingRound datamodel data name=inputPlayer !-- Note namespace declaration in line below -- player xmlns=com.mgt.lottery.poker.domain id/ name/ chips/ sitin/ winner/ betOption/ gainedChips/ popocketCards/ description/ bestHand/ /player /data /datamodel state id=waitingRound !-- shuffle deck and check players and empty pot -- transition event=game.start target=preflopRound/ /state state id=preflopRound !-- place small/big blinds in pot and deal each player two hole cards -- transition target=firstBettingRound/ /state state id=firstBettingRound transition event=game.flop target=flopRound/ transition event=game.showdown target=showdownRound/ /state state id=flopRound !-- deal three cards in the community -- transition target=secondBettingRound/ /state state id=secondBettingRound onentry var name=inputPlayer expr=#{request$player} / /onentry transition event=game.turn target=turnRound/ transition event=game.showdown target=showdownRound/ /state state id=turnRound !-- deal a 4th card in the community -- transition target=thirdBettingRound/ /state state id=thirdBettingRound !-- deal a 4th card in the community -- onentry var name=inputPlayer expr=#{request$player} / /onentry transition event=game.final target=finalRound/ transition event=game.showdown target=showdownRound/ /state state id=finalRound !-- deal a 5th card in the community -- transition target=finalBettingRound/ /state state id=finalBettingRound !-- bet, check, call, raise, or fold -- onentry var name=inputPlayer expr=#{request$player} / /onentry transition event=game.showdown target=showdownRound/ /state state id=showdownRound transition event=game.reset target=waitingRound/ /state /scxml My questions: How can I pass my pojo Player to the firstBettingRound, secondBettingRound and etc? This player object is coming from game client with betting information. snip/ Data (including POJOs) can be passed into an executor either via an external event's payload or via procedural injection to the executor's root context. So, as an example of the latter, the following will create a variable player in the executor's root context and bind the POJO to it: Player p = ... // POJO from game client getEngine().getRootContext().set(player, p); Subsequently, the variable player may be used in expressions in the state machine. In the above state machine, the variable inputPlayer doesn't seem to be accessed anywhere, so unless the player information is needed for the state machine logic, it can perhaps stay out of the state machine's root context altogether (given the pattern of use you mention below). After the activemq delivers it to the server end, how can I know which method to call? I think scxml handles the the state of game, so I have to say Set states = getEngine().getCurrentStatus().getStates(); return ((org.apache.commons.scxml.model.State) states.iterator(). next()).getId(); if the current state is firstBettingRound, I do game.firstBettingRound(player); Is it correct snap/ If you wanted to map states to activities that way. There are a few patterns that are commonly used, see: http://commons.apache.org/scxml/guide/using-commons-scxml.html -Rahul I seem unable to find the example to show me how to pass pojo to the state correcponded method. If I am completely wrong with my approach, Please advise. Thank you very much. QD - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] passing data to the state
On Mon, Jul 12, 2010 at 3:18 PM, qin ding qindi...@yahoo.com wrote: Thank you, Rahaul, for your quick response. If I do the following: Player p = ... // POJO from game client getEngine().getRootContext().set(player, p); then in the states, I should do this to get it out, right? Player p = (Player) getEngine().getRootContext().get(player); Somehow, when I do this, I get null out of the RootContext(). Any idea? snip/ You should certainly get back what you've last set it to. I assume its not null before the set, in which case its being modified elsewhere, so we'll need more details. -Rahul I will study the link you sent to me. - Original Message From: Rahul Akolkar rahul.akol...@gmail.com To: Commons Users List user@commons.apache.org Sent: Mon, July 12, 2010 1:02:04 PM Subject: Re: [scxml] passing data to the state On Mon, Jul 12, 2010 at 12:49 PM, qin ding qindi...@yahoo.com wrote: I am learning commons scxml. I am experimenting writing a poker game using activemq and scxml. So, I have my config xml defined as follows: ?xml version=1.0? scxml xmlns=http://www.w3.org/2005/07/scxml; version=1.0 initialstate=waitingRound datamodel data name=inputPlayer !-- Note namespace declaration in line below -- player xmlns=com.mgt.lottery.poker.domain id/ name/ chips/ sitin/ winner/ betOption/ gainedChips/ popocketCards/ description/ bestHand/ /player /data /datamodel state id=waitingRound !-- shuffle deck and check players and empty pot -- transition event=game.start target=preflopRound/ /state state id=preflopRound !-- place small/big blinds in pot and deal each player two hole cards -- transition target=firstBettingRound/ /state state id=firstBettingRound transition event=game.flop target=flopRound/ transition event=game.showdown target=showdownRound/ /state state id=flopRound !-- deal three cards in the community -- transition target=secondBettingRound/ /state state id=secondBettingRound onentry var name=inputPlayer expr=#{request$player} / /onentry transition event=game.turn target=turnRound/ transition event=game.showdown target=showdownRound/ /state state id=turnRound !-- deal a 4th card in the community -- transition target=thirdBettingRound/ /state state id=thirdBettingRound !-- deal a 4th card in the community -- onentry var name=inputPlayer expr=#{request$player} / /onentry transition event=game.final target=finalRound/ transition event=game.showdown target=showdownRound/ /state state id=finalRound !-- deal a 5th card in the community -- transition target=finalBettingRound/ /state state id=finalBettingRound !-- bet, check, call, raise, or fold -- onentry var name=inputPlayer expr=#{request$player} / /onentry transition event=game.showdown target=showdownRound/ /state state id=showdownRound transition event=game.reset target=waitingRound/ /state /scxml My questions: How can I pass my pojo Player to the firstBettingRound, secondBettingRound and etc? This player object is coming from game client with betting information. snip/ Data (including POJOs) can be passed into an executor either via an external event's payload or via procedural injection to the executor's root context. So, as an example of the latter, the following will create a variable player in the executor's root context and bind the POJO to it: Player p = ... // POJO from game client getEngine().getRootContext().set(player, p); Subsequently, the variable player may be used in expressions in the state machine. In the above state machine, the variable inputPlayer doesn't seem to be accessed anywhere, so unless the player information is needed for the state machine logic, it can perhaps stay out of the state machine's root context altogether (given the pattern of use you mention below). After the activemq delivers it to the server end, how can I know which method to call? I think scxml handles the the state of game, so I have to say Set states = getEngine().getCurrentStatus().getStates(); return ((org.apache.commons.scxml.model.State) states.iterator(). next()).getId(); if the current state is firstBettingRound, I do game.firstBettingRound(player); Is it correct snap/ If you wanted to map states to activities that way. There are a few patterns that are commonly used, see: http://commons.apache.org/scxml/guide/using-commons-scxml.html -Rahul I seem
Re: [scxml] stop and resume by serializing the executor does not work
On Fri, Jul 2, 2010 at 7:04 PM, RT aara...@gmail.com wrote: I tried your suggestion - executor.getCurrentStatus().getStates() - in a few places and I noticed something interesting. snip/ OK, reading the content below, this isn't a serialization round trip issue then (that would've been unexpected). OTOH, the behavior you note below is expected, and hence my suggestion was to introspect executor's active state in the fireEvent method from your previous email (and not in onEntry or custom actions). So, using the context explained in my prev email, (without the serialization/deserialization): 1. state machine starts 2. onEntry() gets called for stateA - here I call the executable content for this state - something similar to what AbstractStateMachine does 3. Executable content for StateA completes 4. After a few mins - trigger event gotoB 5. onEntry() gets called for stateB - before calling the executable content, I inspect executor.getCurrentStatus().getStates(). Surprisingly, the only active state here is stateA. How is that possible? Does the executor.currentStatus object get updated after the listeners kick-in? snap/ Thats the original behavior from Commons SCXML's first release, where the active state(s) were changed after considering all event processing steps to be atomic, and only after all steps were completed the active state(s) within the executor would be updated. Therefore, its best to check the executor's active state(s) in your fireEvent method after (or replacing) the System.out.println line. The current expectation from the SCXML spec is that the active state(s) would be updated before the onEntry custom actions and listeners. The behavior of the library will be updated to match in a subsequent release. My stopresume logic with the serialized executor kind of depends on the agreement that stateB would be in the list of activeStates while queried in in the onEntry of a listener. Here's how: a. onEntry() called for stateA b. store stateA as the last known state of the state machine c. save a serialized version of the executor to the database d. invokeExecutableContentForA() e. exit onEntry() handler If the app crashed while in step c and we try to resume again f. check the last known state in the database - in this case stateA g. here I have a map that tells me what event I need to trigger - in this case gotoB h. deserialize the executor from the database i. executor.triggerEvent(gotoB) snip/ Correct, and you can still do all this, with the change that step (b) -- and perhaps (c) -- above would be performed in fireEvent and not onEntry. -Rahul While debugging the flow of control in the executor after this triggerEvent is called, I see that we try to find a match for a transition with this event from the parent of stateA - not from stateA and thats why I never saw any transitions happening. - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] stop and resume by serializing the executor does not work
On Thu, Jul 1, 2010 at 8:56 PM, RT aara...@gmail.com wrote: My scxml is defined like this: state id=stateA onentry log expr='Inside stateA'/ /onentry onexit log expr='Leaving stateA'/ /onexit transition event=gotoB target=stateB/ /state final id=stateB onentry log expr='Inside stateB'/ /onentry onexit log expr='Leaving stateB'/ /onexit /final So, I initiate an SCXMLExecutor object, set all the requisites and call go() , like this: SCXMLExecutor engine = new SCXMLExecutor(getEvaluator(), new SimpleDispatcher(), new SimpleErrorReporter()); engine.setStateMachine(getSCXML()); engine.setSuperStep(true); engine.setRootContext(getContext()); engine.addListener(getSCXML(), getListener()); try { engine.go(); } catch (ModelException me) { me.printStackTrace(); } In the listener, I override the onEntry like this: public void onEntry(TransitionTarget state) { System.out.println(Entering state + state.getId()); } After I call go() on my executor, I see the stateA being entered and then the state machine stops as its waiting for the gotoB event to transition to the next state. Now, I serialize this executor object to a file.Wait for a few seconds, then deserialize it and then call fireEvent(gotoB) which is defined as: public void fireEvent(String eventName) { try { executor.triggerEvent(new TriggerEvent(eventName, TriggerEvent.SIGNAL_EVENT)); System.out.println(fired eventsuccessfully:+eventName); } catch (ModelException e) { e.printStackTrace(); } } I see in the log that my event was fired on the executor, but I do not see the stateB being entered. snip/ To confirm, rather than rely on any listener output, introspect the executor directly. So, after the System.out.println line above, check the active state(s) via executor.getCurrentStatus().getStates() -- one would expect stateB as the ID of the active state in this case. So obviously during serialization/deserialization some entities were lost on the executor object. Any idea what I should be looking for? snap/ We do serialization round trips and have tests for it as well. Assumption is that all application provided listeners, data, dispatchers, invokers etc. are serializable (check that is the case here). Another thing to do would be to create a unit test for the Commons SCXML test suite that demonstrates what you are observing and then we can look at it. -Rahul - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] Rational Software Architect to SCXML plugin
On Wed, Jun 16, 2010 at 3:33 PM, Christopher Dragert chris.drag...@mail.mcgill.ca wrote: I'm wondering if anyone on the mailing list has experience with the RSA plug-in. I want to design my state-charts in RSA, export them as SCXML documents, them use them in a project built on commons SCXML. Unfortunately, the RSA plugin is to be out-of-date (built on 2005 SCXML working draft), has trouble with executable content, and cannot handle custom actions. Has anyone managed to get this working in a useful way for a commons SCXML project? Is there anyone out there who can offer advice on how to use it? If necessary, I would be willing to work on the plugin, but the source is not available. snip/ The RSA plugin is not maintained. There is currently work being done to develop an updated Eclipse plugin (doesn't require RSA) that covers executable content and some additional features. If you are interested in trying it out, please email the dev list since this is ongoing work. -Rahul Regards, Chris Dragert Ph.D. Candidate McGill University Montreal, Canada - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] src and parser invocation
On Wed, Jun 2, 2010 at 8:08 PM, Fabrizio Morbini fmorb...@gmail.com wrote: Hi, if we have the following case: 2 scxml files: a.scxml and b.scxml in a.scxml, 2 different nodes use the src attribute to source the content from other 2 different nodes defined in b.scxml (using the syntax src=b.scxml#node_i). is the file b.scxml completely parsed for every instance of src attribute found while parsing a.scxml? Or is b.scxml parsed only once and the result reused? snip/ It will be parsed twice, completely (any time the src attribute is used, the entire document at the mentioned URL is parsed). Therefore, where possible, its better to separate content that gets sourced in, into smaller independent files. -Rahul thanks, fabrizio. - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] src and parser invocation
On Wed, Jun 2, 2010 at 8:39 PM, Fabrizio Morbini fmorb...@gmail.com wrote: Hi Rahul, (btw, thanks for your quick and precise answers.) is there anything wrong in modifying the methog: DigestSrcAttributeRule in SCXMLParser.java to add an HashMapString,SCXML that stores the result of the call externalSrcDigester.parse(location); for a given location? If the same location is encountered again, the previous result is reused. snip/ That assumes the resource at the URL is a static one, whereas there is no such limitation so it isn't cached by default. Obviously, if all src'ed URLs are static in your case, that would certainly help to not retrieve and parse them multiple times as you indicate above. i tried this and it works fine (no parse errors) and reduces the parse time from 90 seconds to less than a second. But i didn't try to execute the network and i'm afraid the produced network may have some subtle problems caused by reusing the result of the parser. snap/ You may want to try executing it. There generally shouldn't be issues unless you are src'ing in the same state (or entire state machine) from the same external document multiple times in which case you can run into ID clashes. There is a wiki page [1] that describes one pattern to work around such clashes, but it involves dynamic resources (so caching won't be a good option there). -Rahul [1] http://wiki.apache.org/commons/SCXML/Tutorials/Templating thanks, fabrizio. On Wed, Jun 2, 2010 at 17:18, Rahul Akolkar rahul.akol...@gmail.com wrote: On Wed, Jun 2, 2010 at 8:08 PM, Fabrizio Morbini fmorb...@gmail.com wrote: Hi, if we have the following case: 2 scxml files: a.scxml and b.scxml in a.scxml, 2 different nodes use the src attribute to source the content from other 2 different nodes defined in b.scxml (using the syntax src=b.scxml#node_i). is the file b.scxml completely parsed for every instance of src attribute found while parsing a.scxml? Or is b.scxml parsed only once and the result reused? snip/ It will be parsed twice, completely (any time the src attribute is used, the entire document at the mentioned URL is parsed). Therefore, where possible, its better to separate content that gets sourced in, into smaller independent files. -Rahul thanks, fabrizio. - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [scxml] src and relative url
On Tue, Jun 1, 2010 at 2:26 PM, Fabrizio Morbini fmorb...@gmail.com wrote: Hi, i'm using the src attribute to include external content (i haven't yet spent time in figuring our how to use xinclude). snip/ OK, as long as you're aware its deprecated usage. I load the initial scxml file using a url like file:C:/path/file.scxml. Inside file.scxml some node uses the src attribute set to (for example) src=include1.scxml#node34. When it gets parsed the urlResolver.resolvePath has as baseURL the complete file:C:/path/file.scxml and as ctxPath the string include1.scxml, the merging results in an absolute url: file:/include1.scxml instead of the desired file:C:/path/include1.scxml. is there a better alternative than modify the urlResolver (by removing the file.scxml part from the baseURL) to get the desired merged path when using the method resolvePath? snap/ The portable way is to put the SCXML files as resources on application classpath and use the getResource() method of the appropriate ClassLoader to get the URL (this will also resolve src attributes correctly). -Rahul thanks, fabrizio. - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [SCXML] - Conditional Loops
On Mon, May 24, 2010 at 5:23 AM, Andrew Mansfield amans...@globeop.com wrote: Hi, Is there any way we can model conditional loops in an scxml document ? Preferably I would like to be able to use the next object iteration from the super state as a var of a sub state nested loop. snip/ The W3C Working Group is considering the addition of an iterative construct in the next draft, scxml:foreach, for similar requirements. ATM, one option would be to write a custom action [1] for this. See implementation of standard action scxml:if to get started on such an implementation. -Rahul [1] http://commons.apache.org/scxml/guide/custom-actions.html Regards, Andy - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org