[jboss-svn-commits] JBL Code SVN: r33031 - in labs/jbossesb/trunk/product/rosetta: tests/src/org/jboss/soa/esb/actions/routing and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon May 24 06:57:13 EDT 2010
Author: tfennelly
Date: 2010-05-24 06:57:13 -0400 (Mon, 24 May 2010)
New Revision: 33031
Removed:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/HttpRouter.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/HttpRouterUnitTest.java
Log:
https://jira.jboss.org/browse/JBESB-1912
There are two HttpRouter actions in codebase
Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/HttpRouter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/HttpRouter.java 2010-05-24 10:24:32 UTC (rev 33030)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/HttpRouter.java 2010-05-24 10:57:13 UTC (rev 33031)
@@ -1,147 +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.routing;
-
-import org.apache.log4j.Logger;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
-import org.jboss.soa.esb.actions.ActionProcessingException;
-import org.jboss.soa.esb.actions.ActionUtils;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.listeners.message.MessageDeliverException;
-import org.jboss.soa.esb.message.body.content.BytesBody;
-import org.jboss.soa.esb.message.MessagePayloadProxy;
-
-/**
- * HttpRouter Action Processor. This ActionProcessor will forward the message to an url for further processing.
- * If the routeUrl property is not set a default url will be used.
- *
- * <p/> Sample Action Configuration:
- *
- * <pre>
- * <Action class="org.jboss.soa.esb.actions.routing.HttpRouter">
- * <property name="routeUrl" value="http://localhost:8888"</property>
- * </Action>
- * </pre>
- *
- *
- *
- * @author <a href="mailto:johan.kumps at telenet.be">Johan Kumps</a>
- * @deprecated {@link org.jboss.soa.esb.actions.routing.http.HttpRouter} can provide the same functionality and more.
- */
- at Deprecated
-public class HttpRouter extends AbstractActionPipelineProcessor {
-
- /* The logger for this class */
- private static Logger logger = Logger.getLogger(HttpRouter.class);
-
- /* The url to route the message to */
- private String urlToRouteTo = null;
-
- /*
- * The url to route the message to if the url was not set in the
- * configuration
- */
- private static final String DEFAULT_URL_TO_ROUTE_TO = "http://localhost:5400";
- private MessagePayloadProxy payloadProxy;
-
- /**
- * Constructing a HttpRouter instance
- *
- * @param configTree
- * the configuration to use in this HttpRouter instance
- */
- public HttpRouter(ConfigTree configTree) {
- urlToRouteTo = obtainAttribute(configTree,
- ListenerTagNames.HTTP_ROUTER_ROUTE_URL,
- DEFAULT_URL_TO_ROUTE_TO);
- payloadProxy = new MessagePayloadProxy(configTree,
- new String[] {BytesBody.BYTES_LOCATION, ActionUtils.POST_ACTION_DATA},
- new String[] {ActionUtils.POST_ACTION_DATA});
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.jboss.soa.esb.actions.ActionProcessor#process(java.lang.Object)
- */
- public org.jboss.soa.esb.message.Message process(
- org.jboss.soa.esb.message.Message message)
- throws ActionProcessingException {
-
- Object oCurr;
-
- try {
- oCurr = payloadProxy.getPayload(message);
- } catch (MessageDeliverException e) {
- throw new ActionProcessingException(e);
- }
-
- if (logger.isInfoEnabled()) {
- logger
- .info("HttpRouter currently routing message " + message
- + " with payload <<" + oCurr + ">> to "
- + this.urlToRouteTo);
- }
-
- try {
- InvokerLocator locator = new InvokerLocator(this.urlToRouteTo);
-
- Client remotingClient = new Client(locator);
- remotingClient.connect();
- try
- {
- remotingClient.invoke(oCurr, null);
- return null;
- }
- finally
- {
- remotingClient.disconnect() ;
- }
- } catch (Throwable e) {
- String errorMessage = "Exception while sending message [" + oCurr
- + "] to destination [" + this.urlToRouteTo + "].";
- logger.error(errorMessage, e);
- throw new ActionProcessingException(errorMessage, e);
- }
- }
-
- /**
- * Method obtaining an attribute from the configuration tree
- *
- * @param configTree
- * the configuration to use
- * @param p_sAtt
- * the name of the attribute to get
- * @param p_sDefault
- * the default value for the attribute if not set
- * @return the value of the attribute or the default one is not set in
- * configuration tree
- */
- private String obtainAttribute(final ConfigTree configTree, String p_sAtt, String p_sDefault) {
- String sVal = configTree.getAttribute(p_sAtt);
- return (null != sVal) ? sVal : p_sDefault;
- }
-}
Deleted: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/HttpRouterUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/HttpRouterUnitTest.java 2010-05-24 10:24:32 UTC (rev 33030)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/HttpRouterUnitTest.java 2010-05-24 10:57:13 UTC (rev 33031)
@@ -1,114 +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.routing;
-
-import static org.junit.Assert.fail;
-import junit.framework.JUnit4TestAdapter;
-
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.actions.ActionProcessingException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.body.content.BytesBody;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class HttpRouterUnitTest
-{
- private Logger log = Logger.getLogger( HttpRouterUnitTest.class );
-
- private Message msg = MessageFactory.getInstance().getMessage();
- private ConfigTree tree = new ConfigTree("test");
-
- @Before
- public void setUp()
- {
- msg.getBody().add("hello world".getBytes());
- }
-
-
- @Test ( expected = ActionProcessingException.class )
- public void testRouter_UnknownHost() throws ActionProcessingException
- {
- setRouterURL( "http://foo.bar" );
- HttpRouter router = new HttpRouter(tree);
- log.warn( "The following errors are intentional" );
- router.process(msg);
- }
-
- /**
- * Should this test really be here? Is this not dependant on a
- * running http server...
- */
- @Test ( timeout=7000, expected = ActionProcessingException.class )
- @Ignore
- public void testRouter_IP_Address() throws ActionProcessingException
- {
- setRouterURL( "http://172.16.127.160:9090" );
- HttpRouter router = new HttpRouter(tree);
-
- Message msg = MessageFactory.getInstance().getMessage();
-
- msg.getBody().add("hello world".getBytes());
-
- boolean exception = false;
-
- try
- {
- router.process(msg);
- }
- catch (ActionProcessingException ex)
- {
- exception = true;
- }
-
- if (!exception)
- fail();
-
- tree.setAttribute(ListenerTagNames.HTTP_ROUTER_ROUTE_URL, "http://172.16.127.160:9090");
-
- router = new HttpRouter(tree);
-
- try
- {
- router.process(msg);
- }
- catch (ActionProcessingException ex)
- {
- //fail();
- }
- }
-
- private void setRouterURL( String url )
- {
- tree.setAttribute(ListenerTagNames.HTTP_ROUTER_ROUTE_URL, url);
- }
-
- public static junit.framework.Test suite() {
- return new JUnit4TestAdapter(HttpRouterUnitTest.class);
- }
-
-}
More information about the jboss-svn-commits
mailing list