rulesList = findExactAncesterMatch(pattern); if (rulesList != null) { if (parentMatchEnd) { parentMatched = parentMatch(key, pattern, parentPattern); basicMatched = basicMatch(key, pattern);
final PathResolver pr, final List customActions) { ExtendedBaseRules scxmlRules = new ExtendedBaseRules(); scxmlRules.setNamespaceURI(NAMESPACE_SCXML); scxmlRules.add(XP_SM, new ObjectCreateRule(SCXML.class)); scxmlRules.add(XP_SM, new SetPropertiesRule()); scxmlRules.add(XP_SM_ST, new SetNextRule("addState")); scxmlRules.add(XPU_ST_ST, new SetNextRule("addChild")); scxmlRules.add(XPU_PAR_ST, new SetNextRule("addState")); scxmlRules.add(XPU_TR_TAR_ST, new SetNextRule("setTarget"));
/** * Add Digester rule for all setting parent state. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param parent The distance between this state and its parent * state on the Digester stack */ private static void addParentRule(final String xp, final ExtendedBaseRules scxmlRules, final int parent) { if (parent < 1) { return; } scxmlRules.add(xp, new Rule() { // A generic version of setTopRule public void body(final String namespace, final String name, final String text) throws Exception { TransitionTarget t = (TransitionTarget) getDigester().peek(); TransitionTarget p = (TransitionTarget) getDigester().peek( parent); // CHANGE - Moved parent property to TransitionTarget t.setParent(p); } }); }
final ExtendedBaseRules scxmlRules, final String setNextMethod, final PathResolver pr, final List customActions) { scxmlRules.add(xp, new ObjectCreateRule(Transition.class)); scxmlRules.add(xp, new SetPropertiesRule( new String[] {"event", "cond", "target"}, new String[] {"event", "cond", "next"})); scxmlRules.add(xp, new SetCurrentNamespacesRule()); addActionRules(xp, scxmlRules, pr, customActions); scxmlRules.setNamespaceURI(NAMESPACE_COMMONS_SCXML); scxmlRules.add(xp + XPF_EXT, new Rule() { public void end(final String namespace, final String name) { Transition t = (Transition) getDigester().peek(1); scxmlRules.setNamespaceURI(NAMESPACE_SCXML); scxmlRules.add(xp, new SetNextRule(setNextMethod));
private void configure() { // configure from config file try { Digester digester = newDigester(); digester.push(this); digester.setRules(new ExtendedBaseRules()); // load pop servers digester.addObjectCreate("mail-servers/pop-server", getPopMailServerClass()); digester.addSetProperties("mail-servers/pop-server"); digester.addBeanPropertySetter("mail-servers/pop-server/?"); digester.addSetRoot("mail-servers/pop-server", "create"); // load smtp servers digester.addObjectCreate("mail-servers/smtp-server", getSMTPMailServerClass()); digester.addSetProperties("mail-servers/smtp-server"); digester.addBeanPropertySetter("mail-servers/smtp-server/?"); digester.addBeanPropertySetter("mail-servers/smtp-server/jndi-location", "jndiLocation"); digester.addSetRoot("mail-servers/smtp-server", "create"); InputStream is = getConfigurationInputStream(configFile); digester.parse(is); } catch (Exception e) { log.fatal(e, e); throw new RuntimeException("Error in mail config: " + e.getMessage(), e); } }
} else { CustomAction ca = (CustomAction) item; scxmlRules.setNamespaceURI(ca.getNamespaceURI()); String xpfLocalName = STR_SLASH + ca.getLocalName(); Class klass = ca.getActionClass(); scxmlRules.setNamespaceURI(NAMESPACE_SCXML);
final PathResolver pr, final List customActions) { ExtendedBaseRules scxmlRules = new ExtendedBaseRules(); scxmlRules.setNamespaceURI(NAMESPACE_SCXML); scxmlRules.add(XP_SM, new ObjectCreateRule(SCXML.class)); scxmlRules.add(XP_SM, new SetPropertiesRule()); scxmlRules.add(XP_SM, new SetCurrentNamespacesRule());
/** * Add Digester rules for all <state> element attributes. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param customActions The list of custom actions this digester needs * to be able to process * @param pr The PathResolver * @param scxml The root document, if this one is src'ed in */ private static void addStatePropertiesRules(final String xp, final ExtendedBaseRules scxmlRules, final List customActions, final PathResolver pr, final SCXML scxml) { scxmlRules.add(xp, new SetPropertiesRule(new String[] {"id", "final"}, new String[] {"id", "isFinal"})); scxmlRules.add(xp, new DigestSrcAttributeRule(scxml, customActions, pr)); }
/** * Add Digester rules for all actions ("executable" elements). * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param pr The {@link PathResolver} for this document * @param customActions The list of custom actions this digester needs * to be able to process */ private static void addActionRules(final String xp, final ExtendedBaseRules scxmlRules, final PathResolver pr, final List customActions) { // Actions in SCXML namespace addActionRulesTuple(xp + XPF_ASN, scxmlRules, Assign.class); scxmlRules.add(xp + XPF_ASN, new SetPathResolverRule(pr)); addActionRulesTuple(xp + XPF_EVT, scxmlRules, Event.class); addSendRulesTuple(xp + XPF_SND, scxmlRules); addActionRulesTuple(xp + XPF_CAN, scxmlRules, Cancel.class); addActionRulesTuple(xp + XPF_LOG, scxmlRules, Log.class); // Actions in Commons SCXML namespace scxmlRules.setNamespaceURI(NAMESPACE_COMMONS_SCXML); addActionRulesTuple(xp + XPF_VAR, scxmlRules, Var.class); addActionRulesTuple(xp + XPF_EXT, scxmlRules, Exit.class); // Reset namespace scxmlRules.setNamespaceURI(NAMESPACE_SCXML); }
} else { CustomAction ca = (CustomAction) item; scxmlRules.setNamespaceURI(ca.getNamespaceURI()); String xpfLocalName = STR_SLASH + ca.getLocalName(); Class klass = ca.getActionClass(); scxmlRules.setNamespaceURI(NAMESPACE_SCXML);
rulesList = findExactAncesterMatch(pattern); if (rulesList != null) { if (parentMatchEnd) { parentMatched = parentMatch(key, pattern, parentPattern); basicMatched = basicMatch(key, pattern);
/** * Add Digester rules for all <datamodel> elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param pr The PathResolver * @param scxml The parent SCXML document (or null) */ private static void addDatamodelRules(final String xp, final ExtendedBaseRules scxmlRules, final SCXML scxml, final PathResolver pr) { scxmlRules.add(xp, new ObjectCreateRule(Datamodel.class)); scxmlRules.add(xp + XPF_DATA, new ObjectCreateRule(Data.class)); scxmlRules.add(xp + XPF_DATA, new SetPropertiesRule()); scxmlRules.add(xp + XPF_DATA, new SetCurrentNamespacesRule()); scxmlRules.add(xp + XPF_DATA, new SetNextRule("addData")); try { scxmlRules.add(xp + XPF_DATA, new ParseDataRule(pr)); } catch (ParserConfigurationException pce) { org.apache.commons.logging.Log log = LogFactory. getLog(SCXMLParser.class); log.error(ERR_PARSER_CFG_DATA, pce); } scxmlRules.add(xp, new SetNextRule("setDatamodel")); }
/** * Add Digester rules for all <datamodel> elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param pr The PathResolver * @param scxml The parent SCXML document (or null) */ private static void addDatamodelRules(final String xp, final ExtendedBaseRules scxmlRules, final SCXML scxml, final PathResolver pr) { scxmlRules.add(xp, new ObjectCreateRule(Datamodel.class)); scxmlRules.add(xp + XPF_DATA, new ObjectCreateRule(Data.class)); scxmlRules.add(xp + XPF_DATA, new SetPropertiesRule()); scxmlRules.add(xp + XPF_DATA, new SetCurrentNamespacesRule()); scxmlRules.add(xp + XPF_DATA, new SetNextRule("addData")); try { scxmlRules.add(xp + XPF_DATA, new ParseDataRule(pr)); } catch (ParserConfigurationException pce) { org.apache.commons.logging.Log log = LogFactory. getLog(SCXMLDigester.class); log.error(ERR_PARSER_CFG_DATA, pce); } scxmlRules.add(xp, new SetNextRule("setDatamodel")); }
/** * Add Digester rules for all pseudo state (initial, history) element * attributes. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param customActions The list of custom actions this digester needs * to be able to process * @param pr The PathResolver * @param scxml The root document, if this one is src'ed in */ private static void addPseudoStatePropertiesRules(final String xp, final ExtendedBaseRules scxmlRules, final List customActions, final PathResolver pr, final SCXML scxml) { scxmlRules.add(xp, new SetPropertiesRule(new String[] {"id"}, new String[] {"id"})); scxmlRules.add(xp, new DigestSrcAttributeRule(scxml, customActions, pr)); }
/** * Add Digester rules for all <state> element attributes. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param customActions The list of custom actions this digester needs * to be able to process * @param pr The PathResolver * @param scxml The root document, if this one is src'ed in */ private static void addStatePropertiesRules(final String xp, final ExtendedBaseRules scxmlRules, final List customActions, final PathResolver pr, final SCXML scxml) { scxmlRules.add(xp, new SetPropertiesRule( new String[] {"id", "final", "initial"}, new String[] {"id", "final", "first"})); scxmlRules.add(xp, new DigestSrcAttributeRule(scxml, customActions, pr)); }
/** * Add the run of the mill Digester rules for any element. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param klass The class in the Java object model to be instantiated * in the ObjectCreateRule for this action * @param args The attributes to be mapped into the object model * @param props The properties that args get mapped to * @param addMethod The method that the SetNextRule should call */ private static void addSimpleRulesTuple(final String xp, final ExtendedBaseRules scxmlRules, final Class klass, final String[] args, final String[] props, final String addMethod) { scxmlRules.add(xp, new ObjectCreateRule(klass)); if (args == null) { scxmlRules.add(xp, new SetPropertiesRule()); } else { scxmlRules.add(xp, new SetPropertiesRule(args, props)); } scxmlRules.add(xp, new SetNextRule(addMethod)); }
/** * Add the run of the mill Digester rules for any element. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param klass The class in the Java object model to be instantiated * in the ObjectCreateRule for this action * @param args The attributes to be mapped into the object model * @param props The properties that args get mapped to * @param addMethod The method that the SetNextRule should call */ private static void addSimpleRulesTuple(final String xp, final ExtendedBaseRules scxmlRules, final Class klass, final String[] args, final String[] props, final String addMethod) { scxmlRules.add(xp, new ObjectCreateRule(klass)); if (args == null) { scxmlRules.add(xp, new SetPropertiesRule()); } else { scxmlRules.add(xp, new SetPropertiesRule(args, props)); } scxmlRules.add(xp, new SetNextRule(addMethod)); }
/** * Add Digester rules that are common across all actions elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param klass The class in the Java object model to be instantiated * in the ObjectCreateRule for this action */ private static void addActionRulesTuple(final String xp, final ExtendedBaseRules scxmlRules, final Class klass) { addSimpleRulesTuple(xp, scxmlRules, klass, null, null, "addAction"); scxmlRules.add(xp, new SetExecutableParentRule()); scxmlRules.add(xp, new SetCurrentNamespacesRule()); }
/** * Add Digester rules that are common across all actions elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param klass The class in the Java object model to be instantiated * in the ObjectCreateRule for this action */ private static void addActionRulesTuple(final String xp, final ExtendedBaseRules scxmlRules, final Class klass) { addSimpleRulesTuple(xp, scxmlRules, klass, null, null, "addAction"); scxmlRules.add(xp, new SetExecutableParentRule()); scxmlRules.add(xp, new SetCurrentNamespacesRule()); }
/** * Add Digester rules for all <invoke> elements. * * @param xp The Digester style XPath expression of the parent * XML element * @param scxmlRules The rule set to be used for digestion * @param customActions The list of {@link CustomAction}s this digester * instance will process, can be null or empty * @param pr The PathResolver * @param scxml The parent SCXML document (or null) */ private static void addInvokeRules(final String xp, final ExtendedBaseRules scxmlRules, final List customActions, final PathResolver pr, final SCXML scxml) { scxmlRules.add(xp, new ObjectCreateRule(Invoke.class)); scxmlRules.add(xp, new SetPropertiesRule()); scxmlRules.add(xp, new SetCurrentNamespacesRule()); scxmlRules.add(xp, new SetPathResolverRule(pr)); scxmlRules.add(xp + XPF_PRM, new ObjectCreateRule(Param.class)); scxmlRules.add(xp + XPF_PRM, new SetPropertiesRule()); scxmlRules.add(xp + XPF_PRM, new SetCurrentNamespacesRule()); scxmlRules.add(xp + XPF_PRM, new SetNextRule("addParam")); scxmlRules.add(xp + XPF_FIN, new ObjectCreateRule(Finalize.class)); scxmlRules.add(xp + XPF_FIN, new UpdateFinalizeRule()); addActionRules(xp + XPF_FIN, scxmlRules, pr, customActions); scxmlRules.add(xp + XPF_FIN, new SetNextRule("setFinalize")); scxmlRules.add(xp, new SetNextRule("setInvoke")); }