[jboss-svn-commits] JBL Code SVN: r16447 - labs/jbossesb/workspace/jdelong/ruleservice/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Nov 8 21:46:22 EST 2007
Author: jeffdelong
Date: 2007-11-08 21:46:22 -0500 (Thu, 08 Nov 2007)
New Revision: 16447
Added:
labs/jbossesb/workspace/jdelong/ruleservice/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/BusinessRulesProcessor.java
Removed:
labs/jbossesb/workspace/jdelong/ruleservice/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/BusinessRulesProcessor.java
Log:
Deleted: labs/jbossesb/workspace/jdelong/ruleservice/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/BusinessRulesProcessor.java
===================================================================
--- labs/jbossesb/workspace/jdelong/ruleservice/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/BusinessRulesProcessor.java 2007-11-09 02:21:49 UTC (rev 16446)
+++ labs/jbossesb/workspace/jdelong/ruleservice/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/BusinessRulesProcessor.java 2007-11-09 02:46:22 UTC (rev 16447)
@@ -1,259 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.soa.esb.actions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.jboss.internal.soa.esb.services.rules.RuleServiceException;
-import org.jboss.internal.soa.esb.services.rules.RuleServiceFactory;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.services.rules.ListenerTagNames;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.mapping.ObjectMapper;
-import org.jboss.soa.esb.message.mapping.ObjectMappingException;
-import org.jboss.soa.esb.services.registry.Registry;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.RegistryFactory;
-
-/**
- * This action invokes the rules service (typically Drools).
- * We keep a HashMap of stateful session working memories.
- *
- * @author jdelong at redhat.com
- *
- */
-public class BusinessRulesProcessor extends AbstractActionPipelineProcessor {
-
- public static final String OBJECT_PATH_TAG = "object-path";
-
- public static final String OBJECT_PATH = "esb";
-
- public static final String DEFAULT_RS_CLASS = "org.jboss.internal.soa.esb.services.rules.DroolsRuleService";
-
- public BusinessRulesProcessor(ConfigTree config)
- throws ConfigurationException, RegistryException,
- RuleServiceException {
- _config = config;
- checkMyParms();
- _registry = RegistryFactory.getRegistry();
- _rs = RuleServiceFactory.getRuleService(_rsClass);
- _rs.setConfigTree(config);
- _mapper = new ObjectMapper(config);
-
- }
-
- /**
- * Invoke the appropriate rule service method based on the attributes in the message and
- * configuration
- *
- * @param message
- * @return Message
- * @throws ActionProcessingException
- */
- public Message process(Message message) throws ActionProcessingException {
- try {
- List<Object> objectList = _mapper.createObjectList(message,
- _messagePathList);
- if (message.getProperties().getProperty("dispose") != null) {
- _dispose = (Boolean) message.getProperties().getProperty(
- "dispose");
- }
- if (message.getProperties().getProperty("continue") != null) {
- _continue = (Boolean) message.getProperties().getProperty(
- "continue");
- }
-
- if (!_stateful) {
-
- if (_ruleSet != null) {
- _rs.executeStatelessRules(_ruleSet, _ruleLanguage,
- _ruleReload, message, objectList);
- }
-
- if (_decisionTable != null) {
- _rs.executeStatelessRulesFromDecisionTable(_decisionTable,
- _ruleReload, message, objectList);
- }
-
- if (_ruleAgentProperties != null) {
- _rs.executeStatelessRulesFromRuleAgent(
- _ruleAgentProperties, message, objectList);
- }
-
- } else {
- if (_continue) {
- if (_ruleSet != null) {
- _rs.continueStatefulRulesExecution(_ruleSet, _dispose,
- message, objectList);
- }
-
- if (_decisionTable != null) {
- _rs.continueStatefulRulesExecution(_decisionTable,
- _dispose, message, objectList);
- }
-
- if (_ruleAgentProperties != null) {
- _rs.continueStatefulRulesExecution(
- _ruleAgentProperties, _dispose, message,
- objectList);
- }
-
- } else {
- if (_ruleSet != null) {
- _rs.executeStatefulRules(_ruleSet, _ruleLanguage,
- _ruleReload, _dispose, message, objectList);
- }
-
- if (_decisionTable != null) {
- _rs.executeStatefulRulesFromDecisionTable(
- _decisionTable, _ruleReload, _dispose, message,
- objectList);
- }
-
- if (_ruleAgentProperties != null) {
- _rs.executeStatefulRulesFromRuleAgent(
- _ruleAgentProperties, _dispose, message,
- objectList);
- }
- }
-
- }
-
- } catch (ObjectMappingException ome) {
- throw new ActionProcessingException(ome.getMessage(), ome);
- } catch (RuleServiceException mre) {
- throw new ActionProcessingException(mre.getMessage(), mre);
- }
- return message;
- }
-
- /**
- * Reading the piece of configTree specific to the RuleService, and setting the
- * configuration.
- *
- * @throws ConfigurationException
- */
- protected void checkMyParms() throws ConfigurationException {
- if (_config.getAttribute(ListenerTagNames.RULE_SET_TAG) == null
- && _config.getAttribute(ListenerTagNames.DECISION_TABLE_TAG) == null
- && _config
- .getAttribute(ListenerTagNames.RULE_AGENT_PROPERTIES_TAG) == null) {
-
- _logger.error("One of the following attributes "
- + ListenerTagNames.RULE_SET_TAG + ", "
- + ListenerTagNames.DECISION_TABLE_TAG + ", "
- + ListenerTagNames.RULE_AGENT_PROPERTIES_TAG
- + " is required, and none of them were found in "
- + _config.getName() + ".");
- throw new ConfigurationException("One of the Required attributes: "
- + ListenerTagNames.RULE_SET_TAG + ", "
- + ListenerTagNames.DECISION_TABLE_TAG + ", "
- + ListenerTagNames.RULE_AGENT_PROPERTIES_TAG
- + " was not found.");
- } else {
- if (_config.getAttribute(ListenerTagNames.RULE_SET_TAG) != null) {
- _ruleSet = _config.getAttribute(ListenerTagNames.RULE_SET_TAG);
- _ruleLanguage = _config
- .getAttribute(ListenerTagNames.RULE_LANGUAGE_TAG);
- }
-
- if (_config.getAttribute(ListenerTagNames.DECISION_TABLE_TAG) != null) {
- _decisionTable = _config
- .getAttribute(ListenerTagNames.DECISION_TABLE_TAG);
- }
-
- if (_config
- .getAttribute(ListenerTagNames.RULE_AGENT_PROPERTIES_TAG) != null) {
- _ruleAgentProperties = _config
- .getAttribute(ListenerTagNames.RULE_AGENT_PROPERTIES_TAG);
- }
-
- String ruleReload = _config
- .getAttribute(ListenerTagNames.RULE_RELOAD_TAG);
- if (ruleReload != null && "true".equals(ruleReload)) {
- _ruleReload = true;
- }
-
- String stateful = _config
- .getAttribute(ListenerTagNames.STATEFUL_TAG);
- if (stateful != null && "true".equals(stateful)) {
- _stateful = true;
- }
-
- }
- if (_config.getAttribute(ListenerTagNames.RS_CLASS) != null) {
- _rsClass = _config.getAttribute(ListenerTagNames.RS_CLASS);
- } else {
- _rsClass = DEFAULT_RS_CLASS;
- }
-
- _messagePathList = new ArrayList<String>();
- ConfigTree[] objectList = _config.getChildren(OBJECT_PATH_TAG);
- if (objectList != null) {
- for (ConfigTree curr : objectList) {
- try {
- String objectPath = curr.getRequiredAttribute(OBJECT_PATH);
- _messagePathList.add(objectPath);
- } catch (Exception e) {
- throw new ConfigurationException(
- "Problems with object path list", e);
- }
- }
- }
-
- }
-
- protected ConfigTree _config;
-
- protected String _rsClass;
-
- protected String _ruleSet;
-
- protected String _ruleLanguage;
-
- protected String _decisionTable;
-
- protected String _ruleAgentProperties;
-
- protected boolean _ruleReload;
-
- protected boolean _dispose = true;
-
- protected boolean _continue;
-
- protected boolean _stateful = false;
-
- protected List<String> _messagePathList;
-
- protected ObjectMapper _mapper;
-
- protected Registry _registry;
-
- protected org.jboss.soa.esb.services.rules.RuleService _rs;
-
- protected static Logger _logger = Logger
- .getLogger(BusinessRulesProcessor.class);
-
-}
Copied: labs/jbossesb/workspace/jdelong/ruleservice/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/BusinessRulesProcessor.java (from rev 16446, labs/jbossesb/workspace/jdelong/ruleservice/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/BusinessRulesProcessor.java)
===================================================================
--- labs/jbossesb/workspace/jdelong/ruleservice/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/BusinessRulesProcessor.java (rev 0)
+++ labs/jbossesb/workspace/jdelong/ruleservice/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/BusinessRulesProcessor.java 2007-11-09 02:46:22 UTC (rev 16447)
@@ -0,0 +1,259 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.services.rules.RuleServiceException;
+import org.jboss.internal.soa.esb.services.rules.RuleServiceFactory;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.services.rules.ListenerTagNames;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.mapping.ObjectMapper;
+import org.jboss.soa.esb.message.mapping.ObjectMappingException;
+import org.jboss.soa.esb.services.registry.Registry;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.registry.RegistryFactory;
+
+/**
+ * This action invokes the rules service (typically Drools).
+ * We keep a HashMap of stateful session working memories.
+ *
+ * @author jdelong at redhat.com
+ *
+ */
+public class BusinessRulesProcessor extends AbstractActionPipelineProcessor {
+
+ public static final String OBJECT_PATH_TAG = "object-path";
+
+ public static final String OBJECT_PATH = "esb";
+
+ public static final String DEFAULT_RS_CLASS = "org.jboss.internal.soa.esb.services.rules.DroolsRuleService";
+
+ public BusinessRulesProcessor(ConfigTree config)
+ throws ConfigurationException, RegistryException,
+ RuleServiceException {
+ _config = config;
+ checkMyParms();
+ _registry = RegistryFactory.getRegistry();
+ _rs = RuleServiceFactory.getRuleService(_rsClass);
+ _rs.setConfigTree(config);
+ _mapper = new ObjectMapper(config);
+
+ }
+
+ /**
+ * Invoke the appropriate rule service method based on the attributes in the message and
+ * configuration
+ *
+ * @param message
+ * @return Message
+ * @throws ActionProcessingException
+ */
+ public Message process(Message message) throws ActionProcessingException {
+ try {
+ List<Object> objectList = _mapper.createObjectList(message,
+ _messagePathList);
+ if (message.getProperties().getProperty("dispose") != null) {
+ _dispose = (Boolean) message.getProperties().getProperty(
+ "dispose");
+ }
+ if (message.getProperties().getProperty("continue") != null) {
+ _continue = (Boolean) message.getProperties().getProperty(
+ "continue");
+ }
+
+ if (!_stateful) {
+
+ if (_ruleSet != null) {
+ _rs.executeStatelessRules(_ruleSet, _ruleLanguage,
+ _ruleReload, message, objectList);
+ }
+
+ if (_decisionTable != null) {
+ _rs.executeStatelessRulesFromDecisionTable(_decisionTable,
+ _ruleReload, message, objectList);
+ }
+
+ if (_ruleAgentProperties != null) {
+ _rs.executeStatelessRulesFromRuleAgent(
+ _ruleAgentProperties, message, objectList);
+ }
+
+ } else {
+ if (_continue) {
+ if (_ruleSet != null) {
+ _rs.continueStatefulRulesExecution(_ruleSet, _dispose,
+ message, objectList);
+ }
+
+ if (_decisionTable != null) {
+ _rs.continueStatefulRulesExecution(_decisionTable,
+ _dispose, message, objectList);
+ }
+
+ if (_ruleAgentProperties != null) {
+ _rs.continueStatefulRulesExecution(
+ _ruleAgentProperties, _dispose, message,
+ objectList);
+ }
+
+ } else {
+ if (_ruleSet != null) {
+ _rs.executeStatefulRules(_ruleSet, _ruleLanguage,
+ _ruleReload, _dispose, message, objectList);
+ }
+
+ if (_decisionTable != null) {
+ _rs.executeStatefulRulesFromDecisionTable(
+ _decisionTable, _ruleReload, _dispose, message,
+ objectList);
+ }
+
+ if (_ruleAgentProperties != null) {
+ _rs.executeStatefulRulesFromRuleAgent(
+ _ruleAgentProperties, _dispose, message,
+ objectList);
+ }
+ }
+
+ }
+
+ } catch (ObjectMappingException ome) {
+ throw new ActionProcessingException(ome.getMessage(), ome);
+ } catch (RuleServiceException mre) {
+ throw new ActionProcessingException(mre.getMessage(), mre);
+ }
+ return message;
+ }
+
+ /**
+ * Reading the piece of configTree specific to the RuleService, and setting the
+ * configuration.
+ *
+ * @throws ConfigurationException
+ */
+ protected void checkMyParms() throws ConfigurationException {
+ if (_config.getAttribute(ListenerTagNames.RULE_SET_TAG) == null
+ && _config.getAttribute(ListenerTagNames.DECISION_TABLE_TAG) == null
+ && _config
+ .getAttribute(ListenerTagNames.RULE_AGENT_PROPERTIES_TAG) == null) {
+
+ _logger.error("One of the following attributes "
+ + ListenerTagNames.RULE_SET_TAG + ", "
+ + ListenerTagNames.DECISION_TABLE_TAG + ", "
+ + ListenerTagNames.RULE_AGENT_PROPERTIES_TAG
+ + " is required, and none of them were found in "
+ + _config.getName() + ".");
+ throw new ConfigurationException("One of the Required attributes: "
+ + ListenerTagNames.RULE_SET_TAG + ", "
+ + ListenerTagNames.DECISION_TABLE_TAG + ", "
+ + ListenerTagNames.RULE_AGENT_PROPERTIES_TAG
+ + " was not found.");
+ } else {
+ if (_config.getAttribute(ListenerTagNames.RULE_SET_TAG) != null) {
+ _ruleSet = _config.getAttribute(ListenerTagNames.RULE_SET_TAG);
+ _ruleLanguage = _config
+ .getAttribute(ListenerTagNames.RULE_LANGUAGE_TAG);
+ }
+
+ if (_config.getAttribute(ListenerTagNames.DECISION_TABLE_TAG) != null) {
+ _decisionTable = _config
+ .getAttribute(ListenerTagNames.DECISION_TABLE_TAG);
+ }
+
+ if (_config
+ .getAttribute(ListenerTagNames.RULE_AGENT_PROPERTIES_TAG) != null) {
+ _ruleAgentProperties = _config
+ .getAttribute(ListenerTagNames.RULE_AGENT_PROPERTIES_TAG);
+ }
+
+ String ruleReload = _config
+ .getAttribute(ListenerTagNames.RULE_RELOAD_TAG);
+ if (ruleReload != null && "true".equals(ruleReload)) {
+ _ruleReload = true;
+ }
+
+ String stateful = _config
+ .getAttribute(ListenerTagNames.STATEFUL_TAG);
+ if (stateful != null && "true".equals(stateful)) {
+ _stateful = true;
+ }
+
+ }
+ if (_config.getAttribute(ListenerTagNames.RS_CLASS) != null) {
+ _rsClass = _config.getAttribute(ListenerTagNames.RS_CLASS);
+ } else {
+ _rsClass = DEFAULT_RS_CLASS;
+ }
+
+ _messagePathList = new ArrayList<String>();
+ ConfigTree[] objectList = _config.getChildren(OBJECT_PATH_TAG);
+ if (objectList != null) {
+ for (ConfigTree curr : objectList) {
+ try {
+ String objectPath = curr.getRequiredAttribute(OBJECT_PATH);
+ _messagePathList.add(objectPath);
+ } catch (Exception e) {
+ throw new ConfigurationException(
+ "Problems with object path list", e);
+ }
+ }
+ }
+
+ }
+
+ protected ConfigTree _config;
+
+ protected String _rsClass;
+
+ protected String _ruleSet;
+
+ protected String _ruleLanguage;
+
+ protected String _decisionTable;
+
+ protected String _ruleAgentProperties;
+
+ protected boolean _ruleReload;
+
+ protected boolean _dispose = true;
+
+ protected boolean _continue;
+
+ protected boolean _stateful = false;
+
+ protected List<String> _messagePathList;
+
+ protected ObjectMapper _mapper;
+
+ protected Registry _registry;
+
+ protected org.jboss.soa.esb.services.rules.RuleService _rs;
+
+ protected static Logger _logger = Logger
+ .getLogger(BusinessRulesProcessor.class);
+
+}
More information about the jboss-svn-commits
mailing list