[jboss-svn-commits] JBL Code SVN: r7328 - labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/old

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Nov 2 10:03:08 EST 2006


Author: jokum
Date: 2006-11-02 10:03:06 -0500 (Thu, 02 Nov 2006)
New Revision: 7328

Added:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/old/AbstractPassiveListener.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/old/HttpListener.java
Log:
HttpListener added to old architecture

Added: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/old/AbstractPassiveListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/old/AbstractPassiveListener.java	2006-11-02 15:02:49 UTC (rev 7327)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/old/AbstractPassiveListener.java	2006-11-02 15:03:06 UTC (rev 7328)
@@ -0,0 +1,28 @@
+package org.jboss.soa.esb.listeners.old;
+
+import org.jboss.soa.esb.actions.ActionDefinitionFactory;
+import org.jboss.soa.esb.helpers.ConfigTree;
+
+/**
+ * Base class to be implmented by listener implementations which use a channel
+ * implementation doing the listening stuff like periodically receiving on a
+ * queue.
+ * 
+ * @author <a href="mailto:johan.kumps at telenet.be">Johan Kumps</a>
+ * 
+ */
+public abstract class AbstractPassiveListener extends AbstractListener {
+
+	protected AbstractPassiveListener(GpListener p_oDad, ConfigTree p_oParms,
+			ActionDefinitionFactory actionDefinitionFactory) throws Exception {
+		super(p_oDad, p_oParms, actionDefinitionFactory);
+	}
+
+	@Override
+	protected Object[] receive() {
+		// nothing to be done here because channel implementation is taking care
+		// of blocking receive stuff
+		return null;
+	}
+
+}

Added: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/old/HttpListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/old/HttpListener.java	2006-11-02 15:02:49 UTC (rev 7327)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/old/HttpListener.java	2006-11-02 15:03:06 UTC (rev 7328)
@@ -0,0 +1,143 @@
+package org.jboss.soa.esb.listeners.old;
+
+import javax.management.MBeanServer;
+
+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.actions.ActionDefinitionFactory;
+import org.jboss.soa.esb.actions.ActionProcessor;
+import org.jboss.soa.esb.helpers.ConfigTree;
+
+/**
+ * 
+ * 
+ * @author Johan Kumps
+ * 
+ */
+public class HttpListener extends AbstractPassiveListener implements ServerInvocationHandler{
+
+	/* The url to listen on */
+	public String listenHttpUrl = null;
+
+	/* The url this listener will listen on */
+	private static final String LISTEN_HTTP_URL = "listenHttpURL";
+
+	/* 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;
+
+	public HttpListener(GpListener p_oDad, ConfigTree p_oParms, ActionDefinitionFactory actionDefinitionFactory) throws Exception
+	  {
+		super(p_oDad, p_oParms, actionDefinitionFactory);
+		this.listenHttpUrl = GpListener.obtainAtt(p_oParms,LISTEN_HTTP_URL, this.getDefaultListenHttpUrl());
+		// initialize the HTTP server
+		this.initServer();
+	  }
+
+	/**
+	 * Check for mandatory and optional attributes in parameter tree
+	 * 
+	 * @throws Exception -
+	 *             if actionClass not specified or not in classpath or invalid
+	 *             int values for maxThreads or pollLatencySecs
+	 * 
+	 */
+	protected void checkParams() throws Exception {
+		// listener url
+		this.listenHttpUrl = GpListener.obtainAtt(this.listenerConfig, LISTEN_HTTP_URL,
+				this.getDefaultListenHttpUrl());
+	}
+	
+	public Object invoke(InvocationRequest invocationRequest) throws Throwable {
+		//Retrieving the real payload of this invocationRequest
+		Object payload = invocationRequest.getParameter();
+
+		if (this.logger.isInfoEnabled()) {
+			this.logger
+					.info("HttpInvocationListener is invoked...The given payload is : "
+							+ payload);
+		}
+		//Start the action processing pipeline
+		ActionProcessingPipeline pipelineRunner = new ActionProcessingPipeline(payload);
+		this.pipelineExecutorPool.submit(pipelineRunner);
+		
+		return payload;
+	}
+
+	/**
+	 * Method returning the default listenHttpUrl for this HttpListener instance
+	 * 
+	 * @return the default listen url
+	 */
+	private String getDefaultListenHttpUrl() {
+		return HttpListener.transport + "://" + HttpListener.host + ":"
+				+ HttpListener.port;
+	}
+
+	private void initServer() throws Exception {
+		InvokerLocator locator = new InvokerLocator(this.listenHttpUrl);
+		if (this.logger.isInfoEnabled()) {
+			this.logger.info("Starting remoting server with locator uri of: "
+					+ this.listenHttpUrl);
+		}
+		Connector connector = new Connector(locator);
+		connector.create();
+		connector.addInvocationHandler("HttpInvocationHandler", this);
+
+		// Starting the server deamon
+		connector.start();
+
+		if (this.logger.isInfoEnabled()) {
+			this.logger.info("HttpListener deamon started successfully!");
+		}		
+
+	}
+
+	@Override
+	protected void processingError(Object initialMsg, ActionProcessor processor, Throwable error) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	protected void processingComplete(Object initialMsg) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	protected void close() {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void setMBeanServer(MBeanServer arg0) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void setInvoker(ServerInvoker arg0) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void addListener(InvokerCallbackHandler arg0) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void removeListener(InvokerCallbackHandler arg0) {
+		// TODO Auto-generated method stub
+		
+	}
+
+}




More information about the jboss-svn-commits mailing list