[jboss-svn-commits] JBL Code SVN: r6094 - labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Sep 6 11:09:17 EDT 2006
Author: tfennelly
Date: 2006-09-06 11:09:15 -0400 (Wed, 06 Sep 2006)
New Revision: 6094
Modified:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/GpListener.java
Log:
Added additional constructor to support non-repository based instantiation.
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/GpListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/GpListener.java 2006-09-06 15:05:10 UTC (rev 6093)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/GpListener.java 2006-09-06 15:09:15 UTC (rev 6094)
@@ -39,6 +39,7 @@
import org.jboss.soa.esb.parameters.*;
import org.jboss.soa.esb.services.*;
import org.jboss.soa.esb.util.Util;
+import org.xml.sax.SAXException;
/**
* Controlling class that will launch listener child threads
@@ -96,9 +97,8 @@
public static final String CHLD_EMAIL_PARMS = "EmailProperties";
- private Logger m_oLogger;
+ private static Logger m_oLogger = Logger.getLogger(GpListener.class);
- private ParamRepository m_oParmRepos;
private String m_sParmsName;
private DomElement m_oParms;
@@ -145,28 +145,57 @@
private Session m_oJmsSess;
private Connection m_oJmsConn;
- public GpListener(String p_sParameterName) throws Exception
- { m_oLogger = Logger.getLogger(this.getClass());
+ /**
+ * Construct a Listener Manager from the named repository based configuration.
+ * @param p_sParameterName Name of the Repository entry containing the configuration.
+ * @throws Exception Unable to load/use the named configuration.
+ */
+ public GpListener(String p_sParameterName) throws Exception {
+ this(GpListener.getListenerConfig(p_sParameterName));
m_sParmsName = p_sParameterName;
- m_oParmRepos = ParamRepositoryFactory.getInstance();
+ }
+
+ /**
+ * Construct a Listener Manager using the specified listener configuration.
+ * @param config The configuration.
+ * @throws Exception Unable to load/use the supplied configuration.
+ */
+ public GpListener(DomElement config) throws Exception {
+ m_oParms = config;
+ m_oState = State.Loading_parameters;
- m_oState = State.Loading_parameters;
- try
- {
- String sXml = m_oParmRepos.get(m_sParmsName);
- m_oParms = DomElement.fromXml(sXml);
+ try {
checkParms(m_oParms);
setEmailSystemProperties();
- }
- catch (Exception e)
- { m_oState = State.Exception_thrown;
+ } catch (Exception e) {
+ String configSource = config.getAttr("configSource");
+
+ m_oState = State.Exception_thrown;
m_oState.m_oException = e;
- m_oLogger.fatal("Problems with initial parameter load - <"
- +p_sParameterName+">",e);
+ m_oLogger.fatal("Listener configuration and startup error. Config Source: " + (configSource != null?configSource:"unknown"), e);
+
throw e;
}
- } //________________________________
+ }
+
/**
+ * Load the named listener configuration from the configured parameter repository.
+ * @param reposParam The name of the repository entry containing the Listener configuration.
+ * @return Listener Configuration as {@link DomElement}.
+ * @throws IOException Unable to access the repository.
+ * @throws ParamRepositoryException Unable to access the configuration in the repository.
+ * @throws SAXException Unable to parse the configuration.
+ */
+ private static DomElement getListenerConfig(String reposParam) throws IOException, ParamRepositoryException, SAXException {
+ String sXml = ParamRepositoryFactory.getInstance().get(reposParam);
+ DomElement config = DomElement.fromXml(sXml);
+
+ config.setAttr("configSource", "param-repository:" + reposParam);
+
+ return config;
+ }
+
+ /**
* Check to see if all needed parameters are there, and assign default
* values to some of them
*
@@ -283,12 +312,12 @@
if (endRequested())
break;
- if (timeToReload())
+ if (m_sParmsName != null && timeToReload())
try
{
m_oState = State.Loading_parameters;
m_oLogger.info("Reloading parameters _____________________________________________________");
- DomElement oNew = DomElement.fromXml(m_oParmRepos.get(m_sParmsName));
+ DomElement oNew = GpListener.getListenerConfig(m_sParmsName);
checkParms(oNew);
m_oParms = oNew;
setEmailSystemProperties();
More information about the jboss-svn-commits
mailing list