[jboss-svn-commits] JBL Code SVN: r15261 - in labs/jbossesb/trunk/product: services/jbrules/src/main/java/org/jboss and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Sep 20 11:16:55 EDT 2007
Author: kurt.stam at jboss.com
Date: 2007-09-20 11:16:55 -0400 (Thu, 20 Sep 2007)
New Revision: 15261
Added:
labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/
labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/
labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/
labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/BusinessRulesProcessor.java
labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedRouter.java
labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedWiretap.java
labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/MessageFilter.java
Removed:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/BusinessRulesProcessor.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedRouter.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/MessageFilter.java
Log:
JBESB-704, moving these actions to fix classloading issues on hot redeployment.
Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/BusinessRulesProcessor.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/BusinessRulesProcessor.java 2007-09-20 15:10:43 UTC (rev 15260)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/BusinessRulesProcessor.java 2007-09-20 15:16:55 UTC (rev 15261)
@@ -1,68 +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.
- */
-
-/**
- * Routes the Message argument to a fixed list of services ([category,name])
- * @author kstam at jboss.com
- * @since Version 4.2
- */
-package org.jboss.soa.esb.actions;
-
-import java.util.List;
-
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.mapping.ObjectMappingException;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.routing.MessageRouterException;
-
-public class BusinessRulesProcessor extends ContentBasedRouter
-{
- public BusinessRulesProcessor(ConfigTree config) throws ConfigurationException, RegistryException, MessageRouterException
- {
- super(config);
- }
- /**
- * Inspect the content of the message using a rule set
- * Router the message to one or more destinations, using the ContentBasedRouter to figure out
- * to which destinations it is going to be routed too.
- *
- * @param message
- * @return Message
- * @throws ActionProcessingException
- */
- public Message process(Message message) throws ActionProcessingException
- {
- try {
- List<Object> objectList = _mapper.createObjectList(message, _messagePathList);
- _cbr.route(_ruleSet, _ruleLanguage, _ruleReload, message, objectList);
- } catch (ObjectMappingException ome) {
- throw new ActionProcessingException(ome.getMessage(), ome);
- } catch (MessageRouterException mre) {
- throw new ActionProcessingException(mre.getMessage(), mre);
- }
- return message;
- }
-
-
-}
Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedRouter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedRouter.java 2007-09-20 15:10:43 UTC (rev 15260)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedRouter.java 2007-09-20 15:16:55 UTC (rev 15261)
@@ -1,65 +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 org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.routing.MessageRouterException;
-/**
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- * @author kstam at jboss.com
- *
- */
-public class ContentBasedRouter extends ContentBasedWiretap
-{
- public ContentBasedRouter(ConfigTree config) throws ConfigurationException, RegistryException, MessageRouterException
- {
- super(config) ;
- }
- /** Router the message to one or more destinations, using the ContentBasedRouter to figure out
- * to which destinations it is going to be routed too.
- *
- * @param message
- * @return Message
- * @throws ActionProcessingException
- */
- public Message process(Message message) throws ActionProcessingException
- {
- super.process(message) ;
- return null ;
- }
-
- /**
- * @deprecated no longer needed, leaving this in here for backwards compatibility,
- * use the default "process".
- * */
- public Message split(Message message) throws ActionProcessingException
- {
- _logger.warn("Depricated, please use the default 'process' method in your configuration");
- return process(message);
- }
-
- protected static Logger _logger = Logger.getLogger(ContentBasedRouter.class);
-}
Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java 2007-09-20 15:10:43 UTC (rev 15260)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java 2007-09-20 15:16:55 UTC (rev 15261)
@@ -1,258 +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.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.Service;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.client.ServiceInvoker;
-import org.jboss.soa.esb.client.MessageMulticaster;
-import org.jboss.soa.esb.listeners.message.MessageDeliverException;
-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;
-import org.jboss.soa.esb.services.routing.MessageRouterException;
-import org.jboss.soa.esb.services.routing.cbr.ContentBasedRouterFactory;
-
-/**
- * @author <a
- * href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
- * @author kstam at jboss.com
- * @author kevin.conner at jboss.com
- */
-public class ContentBasedWiretap extends AbstractActionPipelineProcessor {
-
- public static final String ROUTE_TO_TAG = "route-to";
-
- public static final String OBJECT_PATH_TAG = "object-path";
-
- public static final String OBJECT_PATH = "esb";
-
- public static final String DEFAULT_CBR_CLASS = "org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter";
-
- private static final String INTERNAL_SERVICE_CATEGORY = "JBossESB-Internal";
- private static final String DEAD_LETTER_SERVICE_NAME = "DeadLetterService";
- ServiceInvoker dlQueueInvoker;
-
- public ContentBasedWiretap(ConfigTree config)
- throws ConfigurationException, RegistryException,
- MessageRouterException {
- _config = config;
- checkMyParms();
- _registry = RegistryFactory.getRegistry();
- _cbr = ContentBasedRouterFactory.getRouter(_cbrClass);
- _cbr.setConfigTree(config);
- _mapper = new ObjectMapper();
- try {
- dlQueueInvoker = new ServiceInvoker(INTERNAL_SERVICE_CATEGORY, DEAD_LETTER_SERVICE_NAME);
- } catch (MessageDeliverException e) {
- new MessageRouterException(e);
- }
- }
-
- public void initialise() {
- if (messageMulticaster.getRecipientCount() == 0) {
- // some classes don't need to worry about this anyway.
-
- _logger.debug("Missing or empty destination list - This action class won't have any effect");
- }
- }
-
- /**
- * Router the message to one or more destinations, using the
- * ContentBasedRouter to figure out to which destinations it is going to
- * be routed too.
- *
- * @param message
- * @return Message
- * @throws ActionProcessingException
- */
- public Message process(Message message) throws ActionProcessingException {
- try {
- routeMessage(message);
-
- return message;
- }
- catch (MessageRouterException mre) {
- throw new ActionProcessingException(mre.getMessage(), mre);
- }
- }
-
- protected void noDestinations() {
- // nothing by default
- }
-
- protected void invalidRuleConfiguration(Message message,
- List<String> destinations) throws MessageRouterException {
- _logger
- .error("The rule destination(s) "
- + destinations
- + " was not found in the destination names in the configuration "
- + _destinations.keySet()
- + ". Please fix your configuration.");
-
- try {
- dlQueueInvoker.deliverAsync(message);
- } catch (MessageDeliverException e) {
- throw new MessageRouterException("Failed to deliver message to Dead Letter Channel.", e);
- }
- }
-
- protected final void routeMessage(Message message)
- throws MessageRouterException {
- try {
- List<Object> objectList = _mapper.createObjectList(message,
- _messagePathList);
- List<String> destinations = _cbr.route(_ruleSet, _ruleLanguage,
- _ruleReload, message, objectList);
- List<Service> outgoingDestinations = new ArrayList<Service>();
- for (String destination : destinations) {
- if (_destinations.containsKey(destination)) {
- outgoingDestinations.add(_destinations.get(destination));
- }
- }
- if (outgoingDestinations.size() > 0) {
- try {
- messageMulticaster.sendToSubset(message, outgoingDestinations);
- } catch (RegistryException e) {
- throw new MessageRouterException(e);
- } catch (MessageDeliverException e) {
- throw new MessageRouterException(e);
- }
- } else {
- noDestinations();
-
- if (destinations.size() > 0) {
- invalidRuleConfiguration(message, destinations);
- }
- }
- } catch (ObjectMappingException ome) {
- throw new MessageRouterException(ome);
- }
- }
-
- /**
- * Reading the piece of configTree specific to the CBR, and setting the
- * configuration.
- *
- * @throws ConfigurationException
- */
- protected void checkMyParms() throws ConfigurationException {
- if (_config.getAttribute(ListenerTagNames.RULE_SET_TAG) == null) {
- _logger.error("Required attribute " + ListenerTagNames.RULE_SET_TAG
- + " not found in " + _config.getName() + ".");
- throw new ConfigurationException("Required attribute"
- + ListenerTagNames.RULE_SET_TAG + " not found.");
- } else {
- _ruleSet = _config.getAttribute(ListenerTagNames.RULE_SET_TAG);
- if (_ruleSet == null) {
- throw new ConfigurationException("Required attribute "
- + ListenerTagNames.RULE_SET_TAG + " not found.");
- }
- _ruleLanguage = _config
- .getAttribute(ListenerTagNames.RULE_LANGUAGE_TAG);
- String ruleReload = _config
- .getAttribute(ListenerTagNames.RULE_RELOAD_TAG);
- if (ruleReload != null && "true".equals(ruleReload)) {
- _ruleReload = true;
- }
- }
- if (_config.getAttribute(ListenerTagNames.CBR_CLASS) != null) {
- _cbrClass = _config.getAttribute(ListenerTagNames.CBR_CLASS);
- } else {
- _cbrClass = DEFAULT_CBR_CLASS;
- }
-
- _destinations = new HashMap<String, Service>();
- ConfigTree[] destList = _config.getChildren(ROUTE_TO_TAG);
- if (destList != null) {
- for (ConfigTree curr : destList) {
- try {
- String key = curr
- .getRequiredAttribute(ListenerTagNames.DESTINATION_NAME_TAG);
- String category = curr.getAttribute(
- ListenerTagNames.SERVICE_CATEGORY_NAME_TAG, "");
- String name = curr
- .getRequiredAttribute(ListenerTagNames.SERVICE_NAME_TAG);
- Service service = new Service(category, name);
- _destinations.put(key, service);
- messageMulticaster.addRecipient(service);
- }
- catch (Exception e) {
- throw new ConfigurationException(
- "Problems with destination list", e);
- }
- }
- }
- _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 Map<String, Service> _destinations;
-
- protected MessageMulticaster messageMulticaster = new MessageMulticaster();
-
- protected String _cbrClass;
-
- protected String _ruleSet;
-
- protected String _ruleLanguage;
-
- protected boolean _ruleReload;
-
- protected List<String> _messagePathList;
-
- protected ObjectMapper _mapper;
-
- protected Registry _registry;
-
- protected org.jboss.soa.esb.services.routing.cbr.ContentBasedRouter _cbr;
-
- protected static Logger _logger = Logger
- .getLogger(ContentBasedWiretap.class);
-
-}
Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/MessageFilter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/MessageFilter.java 2007-09-20 15:10:43 UTC (rev 15260)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/MessageFilter.java 2007-09-20 15:16:55 UTC (rev 15261)
@@ -1,86 +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.
- */
-
-/**
- * Routes the Message argument to a fixed list of services ([category,name])
- * @author kstam at redhat.com
- * @since Version 4.2
- */
-package org.jboss.soa.esb.actions;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.routing.MessageRouterException;
-
-public class MessageFilter extends ContentBasedRouter
-{
- public static final String ROUTE_TO_TAG = "route-to";
-
- private Logger log = Logger.getLogger(this.getClass());
-
- public MessageFilter(ConfigTree config) throws ConfigurationException,
- RegistryException, MessageRouterException
- {
- super(config);
- }
-
- /**
- * Inspect the content of the message using a rule set Router the
- * message to one or more destinations, using the ContentBasedRouter to
- * figure out to which destinations it is going to be routed too.
- *
- * @param message
- * @return Message
- * @throws ActionProcessingException
- */
- public Message process (Message message) throws ActionProcessingException
- {
- try
- {
-
- routeMessage(message);
- }
- catch (MessageRouterException mre)
- {
- throw new ActionProcessingException(mre.getMessage(), mre);
- }
-
- return null;
- }
-
- protected void noDestinations ()
- {
- log
- .debug("No destinations where found, the Message is filtered");
- }
-
- protected void invalidRuleConfiguration (Message message,
- List<String> destinations) throws MessageRouterException
- {
- // do nothing
- }
-}
Copied: labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/BusinessRulesProcessor.java (from rev 15258, labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/BusinessRulesProcessor.java)
===================================================================
--- labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/BusinessRulesProcessor.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/BusinessRulesProcessor.java 2007-09-20 15:16:55 UTC (rev 15261)
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+/**
+ * Routes the Message argument to a fixed list of services ([category,name])
+ * @author kstam at jboss.com
+ * @since Version 4.2
+ */
+package org.jboss.soa.esb.actions;
+
+import java.util.List;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.mapping.ObjectMappingException;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+
+public class BusinessRulesProcessor extends ContentBasedRouter
+{
+ public BusinessRulesProcessor(ConfigTree config) throws ConfigurationException, RegistryException, MessageRouterException
+ {
+ super(config);
+ }
+ /**
+ * Inspect the content of the message using a rule set
+ * Router the message to one or more destinations, using the ContentBasedRouter to figure out
+ * to which destinations it is going to be routed too.
+ *
+ * @param message
+ * @return Message
+ * @throws ActionProcessingException
+ */
+ public Message process(Message message) throws ActionProcessingException
+ {
+ try {
+ List<Object> objectList = _mapper.createObjectList(message, _messagePathList);
+ _cbr.route(_ruleSet, _ruleLanguage, _ruleReload, message, objectList);
+ } catch (ObjectMappingException ome) {
+ throw new ActionProcessingException(ome.getMessage(), ome);
+ } catch (MessageRouterException mre) {
+ throw new ActionProcessingException(mre.getMessage(), mre);
+ }
+ return message;
+ }
+
+
+}
Copied: labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedRouter.java (from rev 15258, labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedRouter.java)
===================================================================
--- labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedRouter.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedRouter.java 2007-09-20 15:16:55 UTC (rev 15261)
@@ -0,0 +1,65 @@
+/*
+ * 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 org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+/**
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ * @author kstam at jboss.com
+ *
+ */
+public class ContentBasedRouter extends ContentBasedWiretap
+{
+ public ContentBasedRouter(ConfigTree config) throws ConfigurationException, RegistryException, MessageRouterException
+ {
+ super(config) ;
+ }
+ /** Router the message to one or more destinations, using the ContentBasedRouter to figure out
+ * to which destinations it is going to be routed too.
+ *
+ * @param message
+ * @return Message
+ * @throws ActionProcessingException
+ */
+ public Message process(Message message) throws ActionProcessingException
+ {
+ super.process(message) ;
+ return null ;
+ }
+
+ /**
+ * @deprecated no longer needed, leaving this in here for backwards compatibility,
+ * use the default "process".
+ * */
+ public Message split(Message message) throws ActionProcessingException
+ {
+ _logger.warn("Depricated, please use the default 'process' method in your configuration");
+ return process(message);
+ }
+
+ protected static Logger _logger = Logger.getLogger(ContentBasedRouter.class);
+}
Copied: labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedWiretap.java (from rev 15258, labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java)
===================================================================
--- labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedWiretap.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/ContentBasedWiretap.java 2007-09-20 15:16:55 UTC (rev 15261)
@@ -0,0 +1,258 @@
+/*
+ * 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.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.client.MessageMulticaster;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+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;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+import org.jboss.soa.esb.services.routing.cbr.ContentBasedRouterFactory;
+
+/**
+ * @author <a
+ * href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ * @author kstam at jboss.com
+ * @author kevin.conner at jboss.com
+ */
+public class ContentBasedWiretap extends AbstractActionPipelineProcessor {
+
+ public static final String ROUTE_TO_TAG = "route-to";
+
+ public static final String OBJECT_PATH_TAG = "object-path";
+
+ public static final String OBJECT_PATH = "esb";
+
+ public static final String DEFAULT_CBR_CLASS = "org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter";
+
+ private static final String INTERNAL_SERVICE_CATEGORY = "JBossESB-Internal";
+ private static final String DEAD_LETTER_SERVICE_NAME = "DeadLetterService";
+ ServiceInvoker dlQueueInvoker;
+
+ public ContentBasedWiretap(ConfigTree config)
+ throws ConfigurationException, RegistryException,
+ MessageRouterException {
+ _config = config;
+ checkMyParms();
+ _registry = RegistryFactory.getRegistry();
+ _cbr = ContentBasedRouterFactory.getRouter(_cbrClass);
+ _cbr.setConfigTree(config);
+ _mapper = new ObjectMapper();
+ try {
+ dlQueueInvoker = new ServiceInvoker(INTERNAL_SERVICE_CATEGORY, DEAD_LETTER_SERVICE_NAME);
+ } catch (MessageDeliverException e) {
+ new MessageRouterException(e);
+ }
+ }
+
+ public void initialise() {
+ if (messageMulticaster.getRecipientCount() == 0) {
+ // some classes don't need to worry about this anyway.
+
+ _logger.debug("Missing or empty destination list - This action class won't have any effect");
+ }
+ }
+
+ /**
+ * Router the message to one or more destinations, using the
+ * ContentBasedRouter to figure out to which destinations it is going to
+ * be routed too.
+ *
+ * @param message
+ * @return Message
+ * @throws ActionProcessingException
+ */
+ public Message process(Message message) throws ActionProcessingException {
+ try {
+ routeMessage(message);
+
+ return message;
+ }
+ catch (MessageRouterException mre) {
+ throw new ActionProcessingException(mre.getMessage(), mre);
+ }
+ }
+
+ protected void noDestinations() {
+ // nothing by default
+ }
+
+ protected void invalidRuleConfiguration(Message message,
+ List<String> destinations) throws MessageRouterException {
+ _logger
+ .error("The rule destination(s) "
+ + destinations
+ + " was not found in the destination names in the configuration "
+ + _destinations.keySet()
+ + ". Please fix your configuration.");
+
+ try {
+ dlQueueInvoker.deliverAsync(message);
+ } catch (MessageDeliverException e) {
+ throw new MessageRouterException("Failed to deliver message to Dead Letter Channel.", e);
+ }
+ }
+
+ protected final void routeMessage(Message message)
+ throws MessageRouterException {
+ try {
+ List<Object> objectList = _mapper.createObjectList(message,
+ _messagePathList);
+ List<String> destinations = _cbr.route(_ruleSet, _ruleLanguage,
+ _ruleReload, message, objectList);
+ List<Service> outgoingDestinations = new ArrayList<Service>();
+ for (String destination : destinations) {
+ if (_destinations.containsKey(destination)) {
+ outgoingDestinations.add(_destinations.get(destination));
+ }
+ }
+ if (outgoingDestinations.size() > 0) {
+ try {
+ messageMulticaster.sendToSubset(message, outgoingDestinations);
+ } catch (RegistryException e) {
+ throw new MessageRouterException(e);
+ } catch (MessageDeliverException e) {
+ throw new MessageRouterException(e);
+ }
+ } else {
+ noDestinations();
+
+ if (destinations.size() > 0) {
+ invalidRuleConfiguration(message, destinations);
+ }
+ }
+ } catch (ObjectMappingException ome) {
+ throw new MessageRouterException(ome);
+ }
+ }
+
+ /**
+ * Reading the piece of configTree specific to the CBR, and setting the
+ * configuration.
+ *
+ * @throws ConfigurationException
+ */
+ protected void checkMyParms() throws ConfigurationException {
+ if (_config.getAttribute(ListenerTagNames.RULE_SET_TAG) == null) {
+ _logger.error("Required attribute " + ListenerTagNames.RULE_SET_TAG
+ + " not found in " + _config.getName() + ".");
+ throw new ConfigurationException("Required attribute"
+ + ListenerTagNames.RULE_SET_TAG + " not found.");
+ } else {
+ _ruleSet = _config.getAttribute(ListenerTagNames.RULE_SET_TAG);
+ if (_ruleSet == null) {
+ throw new ConfigurationException("Required attribute "
+ + ListenerTagNames.RULE_SET_TAG + " not found.");
+ }
+ _ruleLanguage = _config
+ .getAttribute(ListenerTagNames.RULE_LANGUAGE_TAG);
+ String ruleReload = _config
+ .getAttribute(ListenerTagNames.RULE_RELOAD_TAG);
+ if (ruleReload != null && "true".equals(ruleReload)) {
+ _ruleReload = true;
+ }
+ }
+ if (_config.getAttribute(ListenerTagNames.CBR_CLASS) != null) {
+ _cbrClass = _config.getAttribute(ListenerTagNames.CBR_CLASS);
+ } else {
+ _cbrClass = DEFAULT_CBR_CLASS;
+ }
+
+ _destinations = new HashMap<String, Service>();
+ ConfigTree[] destList = _config.getChildren(ROUTE_TO_TAG);
+ if (destList != null) {
+ for (ConfigTree curr : destList) {
+ try {
+ String key = curr
+ .getRequiredAttribute(ListenerTagNames.DESTINATION_NAME_TAG);
+ String category = curr.getAttribute(
+ ListenerTagNames.SERVICE_CATEGORY_NAME_TAG, "");
+ String name = curr
+ .getRequiredAttribute(ListenerTagNames.SERVICE_NAME_TAG);
+ Service service = new Service(category, name);
+ _destinations.put(key, service);
+ messageMulticaster.addRecipient(service);
+ }
+ catch (Exception e) {
+ throw new ConfigurationException(
+ "Problems with destination list", e);
+ }
+ }
+ }
+ _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 Map<String, Service> _destinations;
+
+ protected MessageMulticaster messageMulticaster = new MessageMulticaster();
+
+ protected String _cbrClass;
+
+ protected String _ruleSet;
+
+ protected String _ruleLanguage;
+
+ protected boolean _ruleReload;
+
+ protected List<String> _messagePathList;
+
+ protected ObjectMapper _mapper;
+
+ protected Registry _registry;
+
+ protected org.jboss.soa.esb.services.routing.cbr.ContentBasedRouter _cbr;
+
+ protected static Logger _logger = Logger
+ .getLogger(ContentBasedWiretap.class);
+
+}
Copied: labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/MessageFilter.java (from rev 15258, labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/MessageFilter.java)
===================================================================
--- labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/MessageFilter.java (rev 0)
+++ labs/jbossesb/trunk/product/services/jbrules/src/main/java/org/jboss/soa/esb/actions/MessageFilter.java 2007-09-20 15:16:55 UTC (rev 15261)
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+/**
+ * Routes the Message argument to a fixed list of services ([category,name])
+ * @author kstam at redhat.com
+ * @since Version 4.2
+ */
+package org.jboss.soa.esb.actions;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.routing.MessageRouterException;
+
+public class MessageFilter extends ContentBasedRouter
+{
+ public static final String ROUTE_TO_TAG = "route-to";
+
+ private Logger log = Logger.getLogger(this.getClass());
+
+ public MessageFilter(ConfigTree config) throws ConfigurationException,
+ RegistryException, MessageRouterException
+ {
+ super(config);
+ }
+
+ /**
+ * Inspect the content of the message using a rule set Router the
+ * message to one or more destinations, using the ContentBasedRouter to
+ * figure out to which destinations it is going to be routed too.
+ *
+ * @param message
+ * @return Message
+ * @throws ActionProcessingException
+ */
+ public Message process (Message message) throws ActionProcessingException
+ {
+ try
+ {
+
+ routeMessage(message);
+ }
+ catch (MessageRouterException mre)
+ {
+ throw new ActionProcessingException(mre.getMessage(), mre);
+ }
+
+ return null;
+ }
+
+ protected void noDestinations ()
+ {
+ log
+ .debug("No destinations where found, the Message is filtered");
+ }
+
+ protected void invalidRuleConfiguration (Message message,
+ List<String> destinations) throws MessageRouterException
+ {
+ // do nothing
+ }
+}
More information about the jboss-svn-commits
mailing list