[jboss-svn-commits] JBL Code SVN: r7295 - labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Nov 1 18:00:00 EST 2006
Author: jokum
Date: 2006-11-01 17:59:58 -0500 (Wed, 01 Nov 2006)
New Revision: 7295
Added:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/AbstractListener.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/AbstractPassiveListener.java
Log:
Introduced the concept of an active and passive listener
Added: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/AbstractListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/AbstractListener.java 2006-11-01 21:35:17 UTC (rev 7294)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/AbstractListener.java 2006-11-01 22:59:58 UTC (rev 7295)
@@ -0,0 +1,65 @@
+package org.jboss.soa.esb.listeners.message;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.helpers.ConfigTree;
+
+/**
+ * Base class for listener implementations which will be responsible for implementing some sort of
+ * blocking receive whithin the run() method.
+ *
+ * @author <a href="mailto:johan.kumps at telenet.be">Johan Kumps</a>
+ *
+ */
+public abstract class AbstractListener implements Runnable {
+
+ /* The logger for this class */
+ protected Logger logger = Logger.getLogger(HttpListener.class);
+
+ /* The configuration to be used by this listener*/
+ protected ConfigTree _config = null;
+
+ /* The listener controller*/
+ protected EsbListenerController _controller = null;
+
+ /* The default number of thread in the action pipeline execution thread pool */
+ protected int m_iMaxThr = 1;
+
+ /* The maximum number of threads in the action processing thread pool */
+ protected int m_iUpperThreadLimit = 10; // just in case - override if you
+
+ /* The name of the attribute in the configuration containing the number of threads in the pool*/
+ public static final String PARM_MAX_THREADS = "maxThreads";
+
+ /* The thread pool executing the action processing pipeline*/
+ protected ExecutorService pipelineExecutorPool = null;
+
+ /**
+ * Constructor configuring this listener instance and thread pool executing the
+ * action processing pipeline.
+ *
+ * @param controller the EsbListenerController instance controlling this listener
+ * @param configTree the configuration for this listener instance
+ */
+ protected AbstractListener(EsbListenerController controller,
+ ConfigTree configTree) {
+ this._controller = controller;
+ this._config = configTree;
+
+ // The number of threads configured
+ String maxThreads = configTree.getAttribute(PARM_MAX_THREADS);
+ if (maxThreads != null) {
+ int iMax = Integer.parseInt(maxThreads);
+ this.m_iMaxThr = Math.min(iMax, m_iUpperThreadLimit);
+ if (this.logger.isInfoEnabled()){
+ this.logger.info("Action processing pipeline will be handled by " + m_iMaxThr + " threads.");
+ }
+ } else {
+ this.logger.warn("Attribute maxThreads has not been set. Action pipeline will be processed by only one thread");
+ }
+ this.pipelineExecutorPool = Executors.newFixedThreadPool(m_iMaxThr);
+ }
+
+}
Added: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/AbstractPassiveListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/AbstractPassiveListener.java 2006-11-01 21:35:17 UTC (rev 7294)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/AbstractPassiveListener.java 2006-11-01 22:59:58 UTC (rev 7295)
@@ -0,0 +1,23 @@
+package org.jboss.soa.esb.listeners.message;
+
+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(EsbListenerController controller, ConfigTree configTree) {
+ super(controller, configTree);
+ }
+
+ public void run() {
+ //nothing to be done here because channel implementation is taking care of
+ // blocking receive stuff
+ }
+
+}
More information about the jboss-svn-commits
mailing list