[jboss-svn-commits] JBL Code SVN: r14530 - in labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners: gateway and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Aug 24 11:20:05 EDT 2007
Author: mark.little at jboss.com
Date: 2007-08-24 11:20:05 -0400 (Fri, 24 Aug 2007)
New Revision: 14530
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HibernateGatewayListener.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HibernateInterceptor.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java
Log:
http://jira.jboss.com/jira/browse/JBESB-835 and http://jira.jboss.com/jira/browse/JBESB-887
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java 2007-08-24 14:26:47 UTC (rev 14529)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerUtil.java 2007-08-24 15:20:05 UTC (rev 14530)
@@ -305,6 +305,7 @@
{
value = tree.getAttribute(tag);
if (null == value)
+ {
if (null == defaultValue)
throw new ConfigurationException("Missing or invalid "
+ tag + " attribute");
@@ -313,6 +314,7 @@
warnDefault(tag, defaultValue);
value = defaultValue;
}
+ }
return value;
}
catch (Exception e)
@@ -345,6 +347,19 @@
} // ________________________________
/**
+ * Default value of null.
+ *
+ * @param p_oP
+ * @param p_sAtt
+ * @return
+ */
+
+ public static String getValue (ConfigTree p_oP, String p_sAtt)
+ {
+ return getValue(p_oP, p_sAtt, null);
+ } // ________________________________
+
+ /**
* Find an attribute in the tree (arg 0) or assign default value (arg 2).
* If there is no value associated with the attribute and the default
* value is null, then a ConfigurationException will be thrown. For more
@@ -360,7 +375,9 @@
* @throws ConfigurationException -
* If requested attribute not found and no default value
* supplied by invoker
+ * @deprecated <b>DO NOT USE</b>. Use {@link ListenerUtil#getValue()} instead.
*/
+
public static String obtainAtt (ConfigTree p_oP, String p_sAtt, String p_sDefault)
throws ConfigurationException
{
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java 2007-08-24 14:26:47 UTC (rev 14529)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java 2007-08-24 15:20:05 UTC (rev 14530)
@@ -314,7 +314,7 @@
checkInputSuffix();
// WORK suffix (will rename in input directory)
- _workingSuffix = ListenerUtil.obtainAtt(config, ListenerTagNames.FILE_WORK_SFX_TAG, ".esbWork").trim();
+ _workingSuffix = ListenerUtil.getValue(config, ListenerTagNames.FILE_WORK_SFX_TAG, ".esbWork").trim();
if (_workingSuffix.length() < 1) {
throw new ConfigurationException("Invalid "+ ListenerTagNames.FILE_WORK_SFX_TAG + " attribute");
}
@@ -326,11 +326,11 @@
// ERROR directory and suffix (defaults to input dir and
// ".esbError"
// suffix)
- String sErrDir = ListenerUtil.obtainAtt(config, ListenerTagNames.FILE_ERROR_DIR_TAG, sInpDir);
+ String sErrDir = ListenerUtil.getValue(config, ListenerTagNames.FILE_ERROR_DIR_TAG, sInpDir);
_errorDirectory = fileFromString(sErrDir);
seeIfOkToWorkOnDir(_errorDirectory);
- _errorSuffix = ListenerUtil.obtainAtt(config, ListenerTagNames.FILE_ERROR_SFX_TAG, ".esbError").trim();
+ _errorSuffix = ListenerUtil.getValue(config, ListenerTagNames.FILE_ERROR_SFX_TAG, ".esbError").trim();
if (_errorSuffix.length() < 1) {
throw new ConfigurationException("Invalid " + ListenerTagNames.FILE_ERROR_SFX_TAG + " attribute");
}
@@ -339,7 +339,7 @@
}
// Do users wish to delete files that were processed OK ?
- String sPostDel = ListenerUtil.obtainAtt(config, ListenerTagNames.FILE_POST_DEL_TAG, "false").trim();
+ String sPostDel = ListenerUtil.getValue(config, ListenerTagNames.FILE_POST_DEL_TAG, "false").trim();
_deleteAfterOK = Boolean.parseBoolean(sPostDel);
if (_deleteAfterOK) {
return;
@@ -347,10 +347,10 @@
// POST (done) directory and suffix (defaults to input dir and
// ".esbDone" suffix)
- String sPostDir = ListenerUtil.obtainAtt(config, ListenerTagNames.FILE_POST_DIR_TAG, sInpDir);
+ String sPostDir = ListenerUtil.getValue(config, ListenerTagNames.FILE_POST_DIR_TAG, sInpDir);
_postProcessDirectory = fileFromString(sPostDir);
seeIfOkToWorkOnDir(_postProcessDirectory);
- _postProcessSuffix = ListenerUtil.obtainAtt(config, ListenerTagNames.FILE_POST_SFX_TAG, ".esbDone").trim();
+ _postProcessSuffix = ListenerUtil.getValue(config, ListenerTagNames.FILE_POST_SFX_TAG, ".esbDone").trim();
if (_postProcessDirectory.equals(_inputDirectory)) {
if (_postProcessSuffix.length() < 1) {
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HibernateGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HibernateGatewayListener.java 2007-08-24 14:26:47 UTC (rev 14529)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HibernateGatewayListener.java 2007-08-24 15:20:05 UTC (rev 14530)
@@ -70,7 +70,10 @@
public HibernateGatewayListener(ConfigTree config) throws ConfigurationException {
super(config);
m_config = config;
- m_cfgFile = ListenerUtil.obtainAtt(m_config, HibernateEpr.HIBERNATE_CFG_TAG, null);
+ m_cfgFile = ListenerUtil.getValue(m_config, HibernateEpr.HIBERNATE_CFG_TAG, null);
+
+ if (m_cfgFile == null)
+ throw new ConfigurationException("No configuration file specified!");
}
@Override
@@ -87,12 +90,20 @@
// Need to loop through messagefilters and add them as interceptors
for (ConfigTree ct : m_config.getChildren(MESSAGE_FILTER)) {
try {
- String tempEvent = ListenerUtil.obtainAtt(ct, HibernateEpr.EVENT_TAG, null);
+ String tempEvent = ListenerUtil.getValue(ct, HibernateEpr.EVENT_TAG, null);
+
+ if (tempEvent == null)
+ throw new ConfigurationException("No event specified.");
+
String[] events = tempEvent.split(",");
for (int i = 0; i<events.length; i++) {
HibernateEventBean heb = new HibernateEventBean();
heb.setEvent(events[i]);
- heb.setClassname(ListenerUtil.obtainAtt(ct, HibernateEpr.CLASS_NAME_TAG, null));
+ heb.setClassname(ListenerUtil.getValue(ct, HibernateEpr.CLASS_NAME_TAG, null));
+
+ if (heb.getClassname() == null)
+ throw new ConfigurationException("No classname specified.");
+
eventList.add(heb);
}
} catch (ConfigurationException ce) {
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HibernateInterceptor.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HibernateInterceptor.java 2007-08-24 14:26:47 UTC (rev 14529)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HibernateInterceptor.java 2007-08-24 15:20:05 UTC (rev 14530)
@@ -98,10 +98,17 @@
m_events = f_list;
try {
- m_targetServiceCategory = ListenerUtil.obtainAtt(m_config,
+ m_targetServiceCategory = ListenerUtil.getValue(m_config,
ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG, null);
- m_targetServiceName = ListenerUtil.obtainAtt(m_config,
+ m_targetServiceName = ListenerUtil.getValue(m_config,
ListenerTagNames.TARGET_SERVICE_NAME_TAG, null);
+
+ if (m_targetServiceCategory == null)
+ throw new ManagedLifecycleException("No target service category defined!");
+
+ if (m_targetServiceName == null)
+ throw new ManagedLifecycleException("No target service name defined!");
+
m_targetEprs = RegistryUtil.getEprs(m_targetServiceCategory,m_targetServiceName);
if (null == m_targetEprs || m_targetEprs.size() < 1)
throw new ManagedLifecycleException("EPR <" + m_targetServiceName + "> not found in registry") ;
@@ -110,8 +117,8 @@
+ m_targetServiceName + "> not found in registry");
} catch (final RegistryException re) {
throw new ManagedLifecycleException("Unexpected registry exception", re) ;
- } catch (ConfigurationException e) {
- throw new ManagedLifecycleException(e.getMessage(), e);
+ } catch (ManagedLifecycleException ex) {
+ throw ex;
}
try {
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java 2007-08-24 14:26:47 UTC (rev 14529)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java 2007-08-24 15:20:05 UTC (rev 14530)
@@ -246,16 +246,24 @@
* classpath
*/
protected void checkMyParms() throws ConfigurationException {
- // Third arg is null - Exception will be thrown if attribute is not
- // found
- _targetServiceCategory = ListenerUtil.obtainAtt(_config,
+
+ _targetServiceCategory = ListenerUtil.getValue(_config,
ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG, null);
- _targetServiceName = ListenerUtil.obtainAtt(_config,
+ _targetServiceName = ListenerUtil.getValue(_config,
ListenerTagNames.TARGET_SERVICE_NAME_TAG, null);
- _queueName = ListenerUtil.obtainAtt(_config,
+ if (_targetServiceCategory == null)
+ throw new ConfigurationException("No service category defined!");
+
+ if (_targetServiceName == null)
+ throw new ConfigurationException("No service name defined!");
+
+ _queueName = ListenerUtil.getValue(_config,
JMSEpr.DESTINATION_NAME_TAG, null);
+ if (_queueName == null)
+ throw new ConfigurationException("No queue name defined!");
+
resolveComposerClass();
// No problem if selector is null - everything in queue will be returned
@@ -331,7 +339,7 @@
+ sJndiURL + "," + sJndiContextFactory + ","
+ sJndiPkgPrefix + ">");
- String sFactClass = ListenerUtil.obtainAtt(_config,
+ String sFactClass = ListenerUtil.getValue(_config,
JMSEpr.CONNECTION_FACTORY_TAG, "ConnectionFactory");
if (null == _config.getAttribute(JMSEpr.CONNECTION_FACTORY_TAG))
_logger.debug("No value specified for "
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java 2007-08-24 14:26:47 UTC (rev 14529)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/SqlTableGatewayListener.java 2007-08-24 15:20:05 UTC (rev 14530)
@@ -267,11 +267,17 @@
private void checkMyParms() throws ConfigurationException {
// Third arg is null - Exception will be thrown if attribute is not
// found
- _targetServiceCategory = ListenerUtil.obtainAtt(_config,
+ _targetServiceCategory = ListenerUtil.getValue(_config,
ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG, null);
- _targetServiceName = ListenerUtil.obtainAtt(_config,
+ _targetServiceName = ListenerUtil.getValue(_config,
ListenerTagNames.TARGET_SERVICE_NAME_TAG, null);
+ if (_targetServiceCategory == null)
+ throw new ConfigurationException("No service category defined!");
+
+ if (_targetServiceName == null)
+ throw new ConfigurationException("No service name defined!");
+
// Polling interval
String sAux = _config
.getAttribute(ListenerTagNames.POLL_LATENCY_SECS_TAG);
@@ -292,18 +298,30 @@
resolveComposerClass();
- _driver = ListenerUtil.obtainAtt(_config, JDBCEpr.DRIVER_TAG, null);
- _url = ListenerUtil.obtainAtt(_config, JDBCEpr.URL_TAG, null);
- _user = ListenerUtil.obtainAtt(_config, JDBCEpr.USERNAME_TAG, null);
- _password = ListenerUtil.obtainAtt(_config, JDBCEpr.PASSWORD_TAG, "");
+ _driver = ListenerUtil.getValue(_config, JDBCEpr.DRIVER_TAG, null);
+ _url = ListenerUtil.getValue(_config, JDBCEpr.URL_TAG, null);
+ _user = ListenerUtil.getValue(_config, JDBCEpr.USERNAME_TAG, null);
+ _password = ListenerUtil.getValue(_config, JDBCEpr.PASSWORD_TAG, "");
+ if (_driver == null)
+ throw new ConfigurationException("No driver specified!");
+
+ if (_url == null)
+ throw new ConfigurationException("No url specified!");
+
+ if (_user == null)
+ throw new ConfigurationException("No user specified!");
+
+ if (_password == null)
+ throw new ConfigurationException("No password specified!");
+
_tableName = _config.getAttribute(ListenerTagNames.SQL_TABLE_NAME_TAG);
if (null == _tableName)
_tableName = _config.getRequiredAttribute(JDBCEpr.TABLE_NAME_TAG);
if (Util.isNullString(_tableName))
throw new ConfigurationException("Empty or invalid table name");
- _selectFields = ListenerUtil.obtainAtt(_config,
+ _selectFields = ListenerUtil.getValue(_config,
ListenerTagNames.SQL_SELECT_FIELDS_TAG, "*");
if (Util.isNullString(_selectFields))
throw new ConfigurationException(
@@ -323,21 +341,21 @@
throw new ConfigurationException(
"A valid inProcessField attribute must be specified");
- _where = ListenerUtil.obtainAtt(_config,
+ _where = ListenerUtil.getValue(_config,
ListenerTagNames.SQL_WHERE_CONDITION_TAG, "");
if (_where.trim().length() < 1)
_logger.debug("No value specified for: "
+ ListenerTagNames.SQL_WHERE_CONDITION_TAG);
- _orderBy = ListenerUtil.obtainAtt(_config,
+ _orderBy = ListenerUtil.getValue(_config,
ListenerTagNames.SQL_ORDER_BY_TAG, "");
if (_orderBy.trim().length() < 1)
_logger.debug("No value specified for: "
+ ListenerTagNames.SQL_ORDER_BY_TAG);
- _inProcessVals = ListenerUtil.obtainAtt(_config,
+ _inProcessVals = ListenerUtil.getValue(_config,
ListenerTagNames.SQL_IN_PROCESS_VALUES_TAG,
DEFAULT_IN_PROCESS_STATES);
- _deleteAfterOK = Boolean.parseBoolean(ListenerUtil.obtainAtt(_config,
+ _deleteAfterOK = Boolean.parseBoolean(ListenerUtil.getValue(_config,
ListenerTagNames.SQL_POST_DEL_TAG, "false"));
if (null == _config.getAttribute(ListenerTagNames.SQL_POST_DEL_TAG))
_logger
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java 2007-08-24 14:26:47 UTC (rev 14529)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/jca/JcaInflowGateway.java 2007-08-24 15:20:05 UTC (rev 14530)
@@ -59,11 +59,17 @@
{
super(config);
- serviceCategory = ListenerUtil.obtainAtt(config,
+ serviceCategory = ListenerUtil.getValue(config,
ListenerTagNames.TARGET_SERVICE_CATEGORY_TAG, null);
- serviceName = ListenerUtil.obtainAtt(config,
+ serviceName = ListenerUtil.getValue(config,
ListenerTagNames.TARGET_SERVICE_NAME_TAG, null);
+ if (serviceCategory == null)
+ throw new ConfigurationException("No service category defined!");
+
+ if (serviceName == null)
+ throw new ConfigurationException("No service name defined!");
+
ConfigTree spec = config.getFirstChild("activation-config");
for (ConfigTree configProperty : spec.getChildren("property"))
{
More information about the jboss-svn-commits
mailing list