[jboss-svn-commits] JBL Code SVN: r10124 - in labs/jbossesb/trunk/product/core/listeners: tests/src/org/jboss/soa/esb/listeners and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Mar 11 18:00:03 EDT 2007
Author: mark.little at jboss.com
Date: 2007-03-11 18:00:02 -0400 (Sun, 11 Mar 2007)
New Revision: 10124
Added:
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControllerServiceUnitTest.java
Removed:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/HttpListener.java
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControlerServiceUnitTest.java
Modified:
labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/LifecycleUtilUnitTest.java
Log:
http://jira.jboss.com/jira/browse/JBESB-348
Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/HttpListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/HttpListener.java 2007-03-11 21:16:43 UTC (rev 10123)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/HttpListener.java 2007-03-11 22:00:02 UTC (rev 10124)
@@ -1,365 +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.listeners.message;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.management.MBeanServer;
-
-import org.apache.log4j.Logger;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.ListenerInitializationException;
-import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.listeners.lifecycle.AbstractManagedLifecycle;
-import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.util.Util;
-
-/**
- * Http listener implementation using the JBoss Remoting channel.
- *
- * The listener will listen to messages on the configured listenHttpUrl. If this
- * is not set, the default http://localhost:5400 will be used.
- *
- * This listener expects an Object message whose type is org.jboss.soa.esb.message.Message
- *
- * Sample listener Configuration:
- *
- * <HttpListener listenerClass="org.jboss.soa.esb.listeners.message.HttpListener"/>
- *
- * <pre>
- * <HttpListener listenerClass="org.jboss.soa.esb.listeners.message.HttpListener">
- * <action class=&quotorg.jboss.soa.esb.actions.routing.EchoRouter"/>
- * </HttpListener>
- * </pre>
- *
- * @author <a href="mailto:johan.kumps at telenet.be">Johan Kumps</a>
- *
- */
-public class HttpListener extends AbstractManagedLifecycle implements ServerInvocationHandler {
-
- /**
- * serial version uid for this class
- */
- private static final long serialVersionUID = -2939297462625444965L;
-
- /* The logger for this class */
- protected Logger logger = Logger.getLogger(HttpListener.class);
-
- /* The url this listener will listen on */
- private static final String LISTEN_HTTP_URL = "listenHttpUrl";
-
- /* The url to listen on */
- public String listenHttpUrl = null;
-
- /* The default transport this listener will listen on */
- private static final String transport = "http";
-
- /* The default hostname this listener will listen on */
- private static final String host = "localhost";
-
- /* The default port this listener will listen on */
- private static final int port = 5400;
-
- /**
- * The default maximum thread count.
- */
- private static final int defaultMaxThreads = 1 ;
-
- /**
- * The config for this listener.
- */
- private final ConfigTree config ;
-
- /**
- * The remoting connector.
- */
- private Connector connector ;
- /**
- * The maximum thread count.
- */
- private int maxThreads ;
- /**
- * The executor service for the tasks.
- */
- private ExecutorService executor ;
-
- /**
- * Constructor initialising this HttpListener
- *
- * @param commandListener
- * @param listenerConfig
- * @param actionDefinitionFactory
- * @throws ConfigurationException
- * @throws ListenerInitializationException
- */
- public HttpListener(final ConfigTree config)
- throws ConfigurationException
- {
- super(config) ;
- this.config = config ;
- checkParams() ;
- }
-
- /**
- * Handle the initialisation of the managed instance.
- *
- * @throws ManagedLifecycleException for errors while initialisation.
- */
- protected void doInitialise()
- throws ManagedLifecycleException
- {
- // nothing to initialise here.
- }
-
- /**
- * Handle the start of the managed instance.
- *
- * @throws ManagedLifecycleException for errors while starting.
- */
- protected void doStart()
- throws ManagedLifecycleException
- {
- checkExecutorTermination() ;
-
- final Connector connector ;
- try
- {
- final InvokerLocator locator = new InvokerLocator(listenHttpUrl);
- connector = new Connector(locator);
- connector.create();
-
- connector.addInvocationHandler("HttpInvocationHandler", this);
-
- // Starting the server deamon
- connector.start();
-
- if (logger.isInfoEnabled())
- {
- logger.info("Started HttpListener deamon with locator uri of: " + listenHttpUrl);
- }
- }
- catch (final Exception ex)
- {
- logger.warn("Unexpected error starting HttpListener", ex) ;
- throw new ManagedLifecycleException(ex) ;
- }
-
- this.connector = connector ;
- executor = Executors.newFixedThreadPool(maxThreads) ;
- }
-
- /**
- * Handle the stop of the managed instance.
- *
- * @throws ManagedLifecycleException
- * for errors while stopping.
- */
- protected void doStop()
- throws ManagedLifecycleException
- {
- try
- {
- connector.stop() ;
- connector.destroy() ;
- }
- finally
- {
- connector = null ;
- }
- executor.shutdown() ;
- }
-
- /**
- * Handle the destroy of the managed instance.
- *
- * @throws ManagedLifecycleException for errors while destroying.
- */
- protected void doDestroy()
- throws ManagedLifecycleException
- {
- checkExecutorTermination() ;
- }
-
- /**
- * Check that the existing executor has been closed down.
- * @throws ManagedLifecycleException If executor tasks are still active.
- */
- private void checkExecutorTermination()
- throws ManagedLifecycleException
- {
- if (executor != null)
- {
- try
- {
- try
- {
- if (!executor.awaitTermination(getTerminationPeriod(), TimeUnit.MILLISECONDS))
- {
- throw new ManagedLifecycleException("Tasks remain active in executor") ;
- }
- }
- catch (final InterruptedException ie)
- {
- throw new ManagedLifecycleException("Interrupted waiting for active tasks to terminate") ;
- }
- }
- finally
- {
- executor = null ;
- }
- }
- }
-
- /*
- * Method being invoked when a request comes in.
- *
- * (non-Javadoc)
- *
- * @see org.jboss.remoting.ServerInvocationHandler#invoke(org.jboss.remoting.InvocationRequest)
- */
- @SuppressWarnings("unchecked")
- public Object invoke(InvocationRequest invocationRequest) throws Throwable {
- Object payload = invocationRequest.getParameter();
-
- if (logger.isInfoEnabled()) {
- logger.info("HttpInvocationListener is invoked...The given payload is : " + payload);
- }
- if (payload instanceof Message){
- final ActionProcessingPipeline pipelineRunner = new ActionProcessingPipeline((Message)payload, config) ;
- executor.execute(pipelineRunner) ;
- } else {
- logger.error("Unsupported HttpListener message type: " + payload.getClass().getName());
- }
-
- return payload;
- }
- /**
- * Adds a callback handler that will listen for callbacks from the server
- * invoker handler.
- *
- * @param callbackHandler
- */
- public void addListener(InvokerCallbackHandler callbackHandler) {
- // NO OP as do not handling callback listeners in this example
- }
-
- /**
- * Removes the callback handler that was listening for callbacks from the
- * server invoker handler.
- *
- * @param callbackHandler
- */
- public void removeListener(InvokerCallbackHandler callbackHandler) {
- // NO OP as do not handling callback listeners in this example
- }
-
- /**
- * set the mbean server that the handler can reference
- *
- * @param server
- */
- public void setMBeanServer(MBeanServer server) {
- // NO OP as do not need reference to MBeanServer for this handler
- }
-
- /**
- * set the invoker that owns this handler
- *
- * @param invoker
- */
- public void setInvoker(ServerInvoker invoker) {
- // NO OP as do not need reference back to the server invoker
- }
-
- /**
- * Method getting the url this HttpListener instance is listening on
- *
- * @return the current listenHttpUrl
- */
- public String getListenHttpUrl() {
- return listenHttpUrl;
- }
-
- /**
- * Method setting the listenHttpUrl property to listen on
- *
- * @param listenHttpUrl
- * the listenHttpUrl to be used by this HttpListener instance
- */
- public void setListenHttpUrl(String listenHttpUrl) {
- this.listenHttpUrl = listenHttpUrl;
- }
-
- /**
- * Check for mandatory and optional attributes in parameter tree
- */
- private void checkParams()
- throws ConfigurationException
- {
- // listener url
- listenHttpUrl = config.getAttribute(LISTEN_HTTP_URL);
- if (listenHttpUrl == null)
- {
- listenHttpUrl = getDefaultListenHttpUrl();
- if (logger.isInfoEnabled())
- {
- logger.info("Attribute listenHttpUrl has not been set on the HttpListener. Using default "
- + getDefaultListenHttpUrl());
- }
- }
-
- final String maxThreadVal = config.getAttribute(ListenerTagNames.MAX_THREADS_TAG) ;
-
- if (!Util.isNullString(maxThreadVal))
- {
- try
- {
- maxThreads = Integer.parseInt(maxThreadVal) ;
- }
- catch (NumberFormatException nfe)
- {
- maxThreads = defaultMaxThreads ;
- logger.warn("Invalid " + ListenerTagNames.MAX_THREADS_TAG + " attribute, defaulting to <" + maxThreads + ">") ;
- }
- }
- }
-
- /**
- * Method returning the default listenHttpUrl for this HttpListener instance
- *
- * @return the default listen url
- */
- private String getDefaultListenHttpUrl() {
- return HttpListener.transport + "://" + HttpListener.host + ":"
- + HttpListener.port;
- }
-}
Modified: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/LifecycleUtilUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/LifecycleUtilUnitTest.java 2007-03-11 21:16:43 UTC (rev 10123)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/LifecycleUtilUnitTest.java 2007-03-11 22:00:02 UTC (rev 10124)
@@ -37,7 +37,7 @@
try
{
- LifecycleUtil.getListeners("foobar");
+ LifecycleUtil.getListeners("fubar");
}
catch (IllegalArgumentException ex)
{
@@ -61,8 +61,6 @@
}
catch (IllegalArgumentException ex)
{
- ex.printStackTrace();
-
fail();
}
Deleted: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControlerServiceUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControlerServiceUnitTest.java 2007-03-11 21:16:43 UTC (rev 10123)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControlerServiceUnitTest.java 2007-03-11 22:00:02 UTC (rev 10124)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * 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,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-
-package org.jboss.soa.esb.listeners.config;
-
-import junit.framework.TestCase;
-
-public class ConfigurationControlerServiceUnitTest extends TestCase
-{
- public void testService ()
- {
- ConfigurationControllerService service = new ConfigurationControllerService();
- String conf = service.getConfigurationFile();
-
- service.setConfigurationFile(conf);
-
- System.setProperty("jboss.server.config.url", "http://foo.bar");
-
- try
- {
- service.startService();
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- fail();
- }
-
- try
- {
- service.stopService();
- }
- catch (Exception ex)
- {
- fail();
- }
- }
-}
Copied: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControllerServiceUnitTest.java (from rev 10114, labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControlerServiceUnitTest.java)
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControllerServiceUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControllerServiceUnitTest.java 2007-03-11 22:00:02 UTC (rev 10124)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.soa.esb.listeners.config;
+
+import junit.framework.TestCase;
+
+public class ConfigurationControllerServiceUnitTest extends TestCase
+{
+ public void testService ()
+ {
+ ConfigurationControllerService service = new ConfigurationControllerService();
+ String conf = service.getConfigurationFile();
+
+ service.setConfigurationFile(conf);
+
+ System.setProperty("jboss.server.config.url", "http://foo.bar");
+
+ try
+ {
+ service.startService();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ fail();
+ }
+
+ try
+ {
+ service.stopService();
+ }
+ catch (Exception ex)
+ {
+ fail();
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list