6 Replies Latest reply on Aug 14, 2006 10:12 AM by arjakki

    delegation for ActionHandler - what am I missing?

    wasperen

      I have the following node in my process:

      <node name="sensor news">
       <action name="conduct news sensor" class="com.paconsulting.cucumber.rules.impl.RulesActionHandler" config-type="bean">
       <ruleEngineJndiName>java:/cucumber/RulesEngine</ruleEngineJndiName>
       <ruleBaseName>news-sensor</ruleBaseName>
       </action>
       <transition to="check errors"></transition>
       </node>

      The entire process deploys fine.
      The ActionHandler code is, simply:
      package com.paconsulting.cucumber.rules.impl;
      
      imports...
      
      public class RulesActionHandler implements ActionHandler {
       private static final long serialVersionUID = 1L;
      
       private static Log log = LogFactory.getLog(RulesActionHandler.class);
      
       private String ruleEngineJndiName = "";
       private String ruleBaseName = "";
      
       public String getRuleBaseName() {
       return ruleBaseName;
       }
       public void setRuleBaseName(String ruleBaseName) {
       this.ruleBaseName = ruleBaseName;
       }
       public String getRuleEngineJndiName() {
       return ruleEngineJndiName;
       }
       public void setRuleEngineJndiName(String ruleEngineJndiName) {
       this.ruleEngineJndiName = ruleEngineJndiName;
       }
      
       private RulesEngine getRulesEngine() {
      <snip>
       }
       public void execute(ExecutionContext executionContext) throws Exception {
       long engineId = getRulesEngine().createNewEngine(getRuleBaseName());
       assertVariables(engineId,executionContext.getContextInstance().getVariables());
       getRulesEngine().fireRules(engineId);
       refreshVariables(engineId,executionContext.getContextInstance().getVariables());
       }
       private void assertVariables(long engineId, Map variables) {
      <snip>
       }
       private void refreshVariables(long engineId, Map variables) {
      <snip>
       }
      }

      When the process engine reaches this node, is tells me:

      11:15:07,172 ERROR [BeanInstantiator] couldn't set property 'ruleEngineJndiName' to value '<ruleEngineJndiName>java:/cucumber/RulesEngine</ruleEngineJndiName>'
      11:15:07,173 ERROR [BeanInstantiator] couldn't set property 'ruleBaseName' to value '<ruleBaseName>news-sensor</ruleBaseName>'
      1


      I have tried config-type="field", config-type="bean" and leaving config-type out.
      What am I missing?

      Thanks,
      Willem

        • 1. Re: delegation for ActionHandler - what am I missing?
          kukeltje

          if you have a junit test case for this I'll have a look, send it to ronald ( at ) jbpm . org

          One thing that you could try is making the variables public, but that should not be needed afaik.

          btw, what version of jbpm are you using

          • 2. Re: delegation for ActionHandler - what am I missing?
            wasperen

            Ooops.... Maybe I should have deployed the new services jar....

            Thanks for triggering that in my tired brain!

            Willem

            • 3. Re: delegation for ActionHandler - what am I missing?
              kukeltje

              You're welcome :-)

              btw, services jar? You mean generic classes not included in the process archive? Did you deploy these on the classpath or some other way?

              • 4. Re: delegation for ActionHandler - what am I missing?
                arjakki

                Hi ,

                Remove the code that has shown below and try it out it should work.


                imports...

                public class RulesActionHandler implements ActionHandler {
                private static final long serialVersionUID = 1L;

                private static Log log =LogFactory.getLogRulesActionHandler.class);

                private String ruleEngineJndiName = "";
                private String ruleBaseName = "";


                ==============REMOVE THIS CODE=====================
                public String getRuleBaseName() {
                return ruleBaseName;
                }
                public void setRuleBaseName(String ruleBaseName) {
                this.ruleBaseName = ruleBaseName;
                }
                public String getRuleEngineJndiName() {
                return ruleEngineJndiName;
                }
                public void setRuleEngineJndiName(String ruleEngineJndiName) {
                this.ruleEngineJndiName = ruleEngineJndiName;
                }


                ===============REMOVE ENDED=====================

                private RulesEngine getRulesEngine() {

                }
                public void execute(ExecutionContext executionContext) throws
                Exception {
                long engineId =
                getRulesEngine().createNewEngine(getRuleBaseName());

                assertVariables(engineId,executionContext.getContextInstance().getVariables());
                getRulesEngine().fireRules(engineId);

                refreshVariables(engineId,executionContext.getContextInstance().getVariables());
                }
                private void assertVariables(long engineId, Map variables) {

                }
                private void refreshVariables(long engineId, Map variables) {

                }
                }



                I think when you define in the processdefinition.xml the variables
                <action .....>
                java:/cucumber/RulesEngine
                news-sensor


                the corresponding variables in the ActionHandler get's populated with the values i don't think that you have to write setter and getter methods for that.

                Let me know if doesn't work.

                Abhiram


                • 5. Re: delegation for ActionHandler - what am I missing?
                  kukeltje

                  Abhiram,

                  He already solved it as he has posted. He just did not deploy the right classes (the variables were not in there)

                  Why do you think removing these methods would solve anything???? Is it not allowed to have getters and setters with variables in an actionhandler? I've never read that anywhere. It is indeed not needed since via reflection they will be populated, but it never hurts.

                  • 6. Re: delegation for ActionHandler - what am I missing?
                    arjakki

                    kukeltje,

                    Thanks for letting me know. Yes your correct it never hurts having setter and getter methods.

                    Abhiram