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

Reply via email to