[jboss-svn-commits] JBL Code SVN: r13938 - labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Aug 1 12:08:54 EDT 2007
Author: tfennelly
Date: 2007-08-01 12:08:54 -0400 (Wed, 01 Aug 2007)
New Revision: 13938
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java
Log:
Formatted.
Modified: 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-08-01 15:20:57 UTC (rev 13937)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/ContentBasedWiretap.java 2007-08-01 16:08:54 UTC (rev 13938)
@@ -45,10 +45,8 @@
* 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 class ContentBasedWiretap extends AbstractActionPipelineProcessor {
public static final String ROUTE_TO_TAG = "route-to";
public static final String OBJECT_PATH_TAG = "object-path";
@@ -58,178 +56,147 @@
public static final String DEFAULT_CBR_CLASS = "org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter";
public ContentBasedWiretap(ConfigTree config)
- throws ConfigurationException, RegistryException,
- MessageRouterException
- {
- _config = config;
- checkMyParms();
- _registry = RegistryFactory.getRegistry();
- _cbr = ContentBasedRouterFactory.getRouter(_cbrClass);
- _mapper = new ObjectMapper();
+ throws ConfigurationException, RegistryException,
+ MessageRouterException {
+ _config = config;
+ checkMyParms();
+ _registry = RegistryFactory.getRegistry();
+ _cbr = ContentBasedRouterFactory.getRouter(_cbrClass);
+ _mapper = new ObjectMapper();
}
- public void initialise ()
- {
- if (_destinations.size() < 1)
- {
- _logger
- .warn("Missing or empty destination list - This action class won't have any effect");
- }
+ public void initialise() {
+ if (_destinations.size() < 1) {
+ _logger
+ .warn("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);
+ * 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);
- }
+ return message;
+ }
+ catch (MessageRouterException mre) {
+ throw new ActionProcessingException(mre.getMessage(), mre);
+ }
}
- protected void noDestinations ()
- {
- // nothing by default
+ 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.");
+ 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.");
- MessageRouter.deliverMessage(MessageRouter.INTERNAL_SERVICE_CATEGORY,
- MessageRouter.DEAD_LETTER_SERVICE_NAME, message);
+ MessageRouter.deliverMessage(MessageRouter.INTERNAL_SERVICE_CATEGORY,
+ MessageRouter.DEAD_LETTER_SERVICE_NAME, message);
}
- protected final void routeMessage (Message message)
- throws MessageRouterException
- {
- List<Object> objectList = _mapper.createObjectList(message,
- _messagePathList);
- List<String> destinations = _cbr.route(_ruleSet, _ruleLanguage,
- _ruleReload, message, objectList);
- Collection<String[]> outgoingDestinations = new ArrayList<String[]>();
- for (String destination : destinations)
- {
- if (_destinations.containsKey(destination))
- {
- outgoingDestinations.add(_destinations.get(destination));
- }
- }
- if (outgoingDestinations.size() > 0)
- {
- MessageRouter.deliverMessages(outgoingDestinations, message);
- }
- else
- {
- noDestinations();
+ protected final void routeMessage(Message message)
+ throws MessageRouterException {
+ List<Object> objectList = _mapper.createObjectList(message,
+ _messagePathList);
+ List<String> destinations = _cbr.route(_ruleSet, _ruleLanguage,
+ _ruleReload, message, objectList);
+ Collection<String[]> outgoingDestinations = new ArrayList<String[]>();
+ for (String destination : destinations) {
+ if (_destinations.containsKey(destination)) {
+ outgoingDestinations.add(_destinations.get(destination));
+ }
+ }
+ if (outgoingDestinations.size() > 0) {
+ MessageRouter.deliverMessages(outgoingDestinations, message);
+ } else {
+ noDestinations();
- if (destinations.size() > 0)
- invalidRuleConfiguration(message, destinations);
- }
+ if (destinations.size() > 0)
+ invalidRuleConfiguration(message, destinations);
+ }
}
/**
- * 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;
- }
+ * 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, String[]>();
- 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);
- _destinations.put(key, new String[]
- { category, name });
- }
- 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);
- }
- }
- }
+ _destinations = new HashMap<String, String[]>();
+ 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);
+ _destinations.put(key, new String[]
+ {category, name});
+ }
+ 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);
+ }
+ }
+ }
}
@@ -254,6 +221,6 @@
protected org.jboss.soa.esb.services.routing.cbr.ContentBasedRouter _cbr;
protected static Logger _logger = Logger
- .getLogger(ContentBasedWiretap.class);
+ .getLogger(ContentBasedWiretap.class);
}
More information about the jboss-svn-commits
mailing list