commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ThiƩbault BenoƮt <...@artenum.com>
Subject [scxml] Creating a custom action with children
Date Mon, 20 Sep 2010 13:38:54 GMT
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");
> 
>         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-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message