[jboss-svn-commits] JBL Code SVN: r8059 - 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
Tue Dec 5 04:54:25 EST 2006
Author: tfennelly
Date: 2006-12-05 04:54:23 -0500 (Tue, 05 Dec 2006)
New Revision: 8059
Added:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/EsbListenerController.java
Log:
readded controller interface
Added: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/EsbListenerController.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/EsbListenerController.java 2006-12-05 09:27:27 UTC (rev 8058)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/EsbListenerController.java 2006-12-05 09:54:23 UTC (rev 8059)
@@ -0,0 +1,187 @@
+/*
+ * 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.message;
+
+import java.text.SimpleDateFormat;
+import java.util.Map;
+
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.services.registry.RegistryException;
+
+/**
+ * EsbListenerController interface.
+ * <p/>
+ * An implementation of this intervace controls the lifecycle of a set of ESB Aware listeners. Instance
+ * creation should be managed via the {@link org.jboss.soa.esb.listeners.message.EsbListenerControllerFactory}
+ * class.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public interface EsbListenerController {
+
+ public static final String PARM_RELOAD_SECS = "parameterReloadSecs";
+
+ public static final String PARM_END_TIME = "endTime";
+
+ // Attribute name that denotes listener class to be instantiated in a child
+ // thread
+ // This attribute is not in the root node but in first level child
+ // ConfigTrees
+ public static final String PARM_LISTENER_CLASS = "listenerClass";
+
+ /**
+ * Obtain a shallow copy of needed atributes in this object's last loaded
+ * parameter tree <p/>The local bject is cloned so child threads can use it
+ * as they choose to without interfering with the environment
+ * <p />
+ * Listener processes controlled by this object should keep a reference to
+ * this object at construction time, and not call this method again unless
+ * they specifically need updated values. Parameter reload could have
+ * happened since last call
+ *
+ * @return Map - a shallow copy of the attributes Map
+ */
+ @SuppressWarnings("unchecked")
+ public abstract Map<String, Object> getControllerAttributes();
+
+ public static final SimpleDateFormat s_oDateParse = new SimpleDateFormat(
+ "yyyyMMdd hh:mm:ss");
+
+ public static enum State {
+ Loading_parameters, Running, Ready, Shutting_down, Done_OK, Exception_thrown;
+ int m_iCompletionCode = 0;
+
+ Exception m_oException = null;
+
+ public int getCompletionCode() {
+ return m_iCompletionCode;
+ };
+
+ public Exception getException() {
+ return m_oException;
+ }
+ };
+
+ public abstract State getState();
+
+ /**
+ * Check to see if all needed parameters are there, and assign default
+ * values to some of them
+ *
+ * @param p_oP
+ * ConfigTree - Where to look for the mandatory/optional
+ * configuration attributes
+ * @throws Exception -
+ * If attributes are wrong or not enough for a proper runtime
+ * configuration
+ */
+ public abstract void checkParms(ConfigTree p_oP) throws Exception;
+
+ /**
+ * Main execution loop <p/> Will continue to run until either <p/>a) run
+ * time is expired <p/>b) quiesce command is received in command queue
+ * <p/>For every child element that contains a PARM_LISTENER_CLASS
+ * attribute, this method will try to launch a child thread instantiating an
+ * object of that class, and will call it's run() method <p/>Once all child
+ * processes are trigered, the main thread will either <p/>1) wait for a
+ * message in the command queue (if one was configured) until next reload or
+ * end of run period expired <p/>or 2) Just sleep if there's no command
+ * queue to listen on
+ */
+ public abstract void run();
+
+ public abstract void requestEnd();
+
+ /**
+ * Accessor to determine if execution time is expired or shutdown requested
+ *
+ * @return boolean if processing has to stop (all child threads will be
+ * allowed to finish)
+ */
+ public abstract boolean endRequested();
+
+ /**
+ * Accessor to determine if execution time is not expired, and no shutdown
+ * request received
+ *
+ * @return boolean - true if run time has not expired and quiesce has not
+ * been requested
+ */
+ public abstract boolean endNotRequested();
+
+ /**
+ * Provide a common accessor to determine if parameters have to be reloaded
+ * <p/> For child threads this means thread execution has to end
+ * </p>
+ * Child processes should only call this method when they are idle (as
+ * opposed to in the middle of executing a unit of work)
+ *
+ * @return boolean - true if it's time to reload parameters
+ */
+ public abstract boolean timeToReload();
+
+ /**
+ * Helper accessor for child processes that provides info to determine if
+ * they can continue with yet another execution cycle
+ *
+ * @return boolean - true if runtime is not expired and not time yet to
+ * reload parameters
+ */
+ public abstract boolean continueLooping(); // ________________________________
+
+ public abstract long millisToWait();
+
+ /**
+ * @deprecated use register (ConfigTree config, EPR address) instead.
+ * @param name
+ * @param address
+ */
+ public abstract void register(String name, EPR address); // ________________________________
+
+ /**
+ * @deprecated use unRegister (String serviceCategoryName, String serviceName, EPR epr) instead.
+ * @param name
+ */
+ public abstract void unRegister(String name); // ________________________________
+
+ /**
+ * Register an EPR in the registry.
+ *
+ * @param config - a config tree containing the deployment-configuration of the service.
+ * @param epr - the epr (EndPoint Reference) of the service.
+ *
+ * @throws RegistryException
+ */
+ public abstract void register(ConfigTree config, EPR epr)
+ throws RegistryException;
+
+ /**
+ * Unregister the EPR from the registry.
+ *
+ * @param serviceCategoryName - name of the category of the service ('Content Based Routing')
+ * @param serviceName - name of the service ("
+ * @param epr
+ * @throws RegistryException
+ */
+ public abstract void unRegister(String serviceCategoryName, String serviceName, EPR epr) throws RegistryException;
+
+}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list