You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2005/12/16 18:18:08 UTC
svn commit: r357187 [20/25] - in
/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2: ./
addressing/ client/ client/async/ context/ deployment/ deployment/listener/
deployment/repository/util/ deployment/scheduler/ deployment/util/
descript...
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSConnectorFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSConnectorFactory.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSConnectorFactory.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSConnectorFactory.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
/*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2001, 2002,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package org.apache.axis2.transport.jms;
@@ -31,8 +32,86 @@
* JMSConnector from an existing pool of connectors.
*/
public abstract class JMSConnectorFactory {
- protected static Log log =
- LogFactory.getLog(JMSConnectorFactory.class.getName());
+ protected static Log log = LogFactory.getLog(JMSConnectorFactory.class.getName());
+
+ /**
+ * Static method to create a client connector. Client connectors cannot
+ * accept incoming requests.
+ *
+ * @param connectorConfig
+ * @param cfConfig
+ * @param username
+ * @param password
+ * @return
+ * @throws Exception
+ */
+ public static JMSConnector createClientConnector(HashMap connectorConfig, HashMap cfConfig,
+ String username, String password, JMSVendorAdapter adapter)
+ throws Exception {
+ return createConnector(connectorConfig, cfConfig, false, username, password, adapter);
+ }
+
+ private static JMSConnector createConnector(HashMap connectorConfig, HashMap cfConfig,
+ boolean allowReceive, String username, String password, JMSVendorAdapter adapter)
+ throws Exception {
+ if (connectorConfig != null) {
+ connectorConfig = (HashMap) connectorConfig.clone();
+ }
+
+ int numRetries = MapUtils.removeIntProperty(connectorConfig, JMSConstants.NUM_RETRIES,
+ JMSConstants.DEFAULT_NUM_RETRIES);
+ int numSessions = MapUtils.removeIntProperty(connectorConfig, JMSConstants.NUM_SESSIONS,
+ JMSConstants.DEFAULT_NUM_SESSIONS);
+ long connectRetryInterval = MapUtils.removeLongProperty(connectorConfig,
+ JMSConstants.CONNECT_RETRY_INTERVAL,
+ JMSConstants.DEFAULT_CONNECT_RETRY_INTERVAL);
+ long interactRetryInterval = MapUtils.removeLongProperty(connectorConfig,
+ JMSConstants.INTERACT_RETRY_INTERVAL,
+ JMSConstants.DEFAULT_INTERACT_RETRY_INTERVAL);
+ long timeoutTime = MapUtils.removeLongProperty(connectorConfig, JMSConstants.TIMEOUT_TIME,
+ JMSConstants.DEFAULT_TIMEOUT_TIME);
+ String clientID = MapUtils.removeStringProperty(connectorConfig, JMSConstants.CLIENT_ID,
+ null);
+ String domain = MapUtils.removeStringProperty(connectorConfig, JMSConstants.DOMAIN,
+ JMSConstants.DOMAIN_DEFAULT);
+
+ // this will be set if the target endpoint address was set on the Axis call
+ JMSURLHelper jmsurl = (JMSURLHelper) connectorConfig.get(JMSConstants.JMS_URL);
+
+ if (cfConfig == null) {
+ throw new IllegalArgumentException("noCfConfig");
+ }
+
+ if (domain.equals(JMSConstants.DOMAIN_QUEUE)) {
+ return new QueueConnector(adapter.getQueueConnectionFactory(cfConfig), numRetries,
+ numSessions, connectRetryInterval, interactRetryInterval,
+ timeoutTime, allowReceive, clientID, username, password,
+ adapter, jmsurl);
+ } else // domain is Topic
+ {
+ return new TopicConnector(adapter.getTopicConnectionFactory(cfConfig), numRetries,
+ numSessions, connectRetryInterval, interactRetryInterval,
+ timeoutTime, allowReceive, clientID, username, password,
+ adapter, jmsurl);
+ }
+ }
+
+ /**
+ * Static method to create a server connector. Server connectors can
+ * accept incoming requests.
+ *
+ * @param connectorConfig
+ * @param cfConfig
+ * @param username
+ * @param password
+ * @return
+ * @throws Exception
+ */
+ public static JMSConnector createServerConnector(HashMap connectorConfig, HashMap cfConfig,
+ String username, String password, JMSVendorAdapter adapter)
+ throws Exception {
+ return createConnector(connectorConfig, cfConfig, true, username, password, adapter);
+ }
/**
* Performs an initial check on the connector properties, and then defers
@@ -46,59 +125,76 @@
* @param adapter the vendor adapter specified in the JMS URL
* @return a JMSConnector that matches the specified properties
*/
- public static JMSConnector matchConnector(java.util.Set connectors,
- HashMap connectorProps,
- HashMap cfProps,
- String username,
- String password,
- JMSVendorAdapter adapter) {
+ public static JMSConnector matchConnector(java.util.Set connectors, HashMap connectorProps,
+ HashMap cfProps, String username, String password, JMSVendorAdapter adapter) {
java.util.Iterator iter = connectors.iterator();
+
while (iter.hasNext()) {
JMSConnector conn = (JMSConnector) iter.next();
// username
String connectorUsername = conn.getUsername();
- if (!(((connectorUsername == null) && (username == null)) ||
- ((connectorUsername != null) && (username != null) && (connectorUsername.equals(username)))))
+
+ if (!(((connectorUsername == null) && (username == null))
+ || ((connectorUsername != null) && (username != null)
+ && (connectorUsername.equals(username))))) {
continue;
+ }
// password
String connectorPassword = conn.getPassword();
- if (!(((connectorPassword == null) && (password == null)) ||
- ((connectorPassword != null) && (password != null) && (connectorPassword.equals(password)))))
+
+ if (!(((connectorPassword == null) && (password == null))
+ || ((connectorPassword != null) && (password != null)
+ && (connectorPassword.equals(password))))) {
continue;
+ }
// num retries
int connectorNumRetries = conn.getNumRetries();
String propertyNumRetries = (String) connectorProps.get(JMSConstants.NUM_RETRIES);
int numRetries = JMSConstants.DEFAULT_NUM_RETRIES;
- if (propertyNumRetries != null)
+
+ if (propertyNumRetries != null) {
numRetries = Integer.parseInt(propertyNumRetries);
- if (connectorNumRetries != numRetries)
+ }
+
+ if (connectorNumRetries != numRetries) {
continue;
+ }
// client id
String connectorClientID = conn.getClientID();
String clientID = (String) connectorProps.get(JMSConstants.CLIENT_ID);
+
if (!(((connectorClientID == null) && (clientID == null))
- ||
- ((connectorClientID != null) && (clientID != null) && connectorClientID.equals(clientID))))
+ || ((connectorClientID != null) && (clientID != null)
+ && connectorClientID.equals(clientID)))) {
continue;
+ }
// domain
- String connectorDomain = (conn instanceof QueueConnector) ? JMSConstants.DOMAIN_QUEUE : JMSConstants.DOMAIN_TOPIC;
+ String connectorDomain = (conn instanceof QueueConnector)
+ ? JMSConstants.DOMAIN_QUEUE
+ : JMSConstants.DOMAIN_TOPIC;
String propertyDomain = (String) connectorProps.get(JMSConstants.DOMAIN);
String domain = JMSConstants.DOMAIN_DEFAULT;
- if (propertyDomain != null)
+
+ if (propertyDomain != null) {
domain = propertyDomain;
+ }
+
if (!(((connectorDomain == null) && (domain == null))
- ||
- ((connectorDomain != null) && (domain != null) && connectorDomain.equalsIgnoreCase(domain))))
+ || ((connectorDomain != null) && (domain != null)
+ && connectorDomain.equalsIgnoreCase(domain)))) {
continue;
+ }
// the connection factory must also match for the connector to be reused
JMSURLHelper jmsurl = conn.getJMSURL();
+
if (adapter.isMatchingConnectionFactory(conn.getConnectionFactory(), jmsurl, cfProps)) {
+
// attempt to reserve the connector
try {
JMSConnectorManager.getInstance().reserve(conn);
@@ -106,8 +202,8 @@
if (log.isDebugEnabled()) {
log.debug("JMSConnectorFactory: Found matching connector");
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
+
// ignore. the connector may be in the process of shutting down, so try the next element
continue;
}
@@ -122,104 +218,4 @@
return null;
}
-
- /**
- * Static method to create a server connector. Server connectors can
- * accept incoming requests.
- *
- * @param connectorConfig
- * @param cfConfig
- * @param username
- * @param password
- * @return
- * @throws Exception
- */
- public static JMSConnector createServerConnector(HashMap connectorConfig,
- HashMap cfConfig,
- String username,
- String password,
- JMSVendorAdapter adapter)
- throws Exception {
- return createConnector(connectorConfig, cfConfig, true,
- username, password, adapter);
- }
-
- /**
- * Static method to create a client connector. Client connectors cannot
- * accept incoming requests.
- *
- * @param connectorConfig
- * @param cfConfig
- * @param username
- * @param password
- * @return
- * @throws Exception
- */
- public static JMSConnector createClientConnector(HashMap connectorConfig,
- HashMap cfConfig,
- String username,
- String password,
- JMSVendorAdapter adapter)
- throws Exception {
- return createConnector(connectorConfig, cfConfig, false,
- username, password, adapter);
- }
-
- private static JMSConnector createConnector(HashMap connectorConfig,
- HashMap cfConfig,
- boolean allowReceive,
- String username,
- String password,
- JMSVendorAdapter adapter)
- throws Exception {
- if (connectorConfig != null)
- connectorConfig = (HashMap) connectorConfig.clone();
- int numRetries = MapUtils.removeIntProperty(connectorConfig,
- JMSConstants.NUM_RETRIES,
- JMSConstants.DEFAULT_NUM_RETRIES);
-
- int numSessions = MapUtils.removeIntProperty(connectorConfig,
- JMSConstants.NUM_SESSIONS,
- JMSConstants.DEFAULT_NUM_SESSIONS);
-
- long connectRetryInterval = MapUtils.removeLongProperty(connectorConfig,
- JMSConstants.CONNECT_RETRY_INTERVAL,
- JMSConstants.DEFAULT_CONNECT_RETRY_INTERVAL);
-
- long interactRetryInterval = MapUtils.removeLongProperty(connectorConfig,
- JMSConstants.INTERACT_RETRY_INTERVAL,
- JMSConstants.DEFAULT_INTERACT_RETRY_INTERVAL);
-
- long timeoutTime = MapUtils.removeLongProperty(connectorConfig,
- JMSConstants.TIMEOUT_TIME,
- JMSConstants.DEFAULT_TIMEOUT_TIME);
-
- String clientID = MapUtils.removeStringProperty(connectorConfig,
- JMSConstants.CLIENT_ID,
- null);
- String domain = MapUtils.removeStringProperty(connectorConfig,
- JMSConstants.DOMAIN,
- JMSConstants.DOMAIN_DEFAULT);
-
- // this will be set if the target endpoint address was set on the Axis call
- JMSURLHelper jmsurl = (JMSURLHelper) connectorConfig.get(JMSConstants.JMS_URL);
-
- if (cfConfig == null)
- throw new IllegalArgumentException("noCfConfig");
-
- if (domain.equals(JMSConstants.DOMAIN_QUEUE)) {
- return new QueueConnector(adapter.getQueueConnectionFactory(cfConfig),
- numRetries, numSessions, connectRetryInterval,
- interactRetryInterval, timeoutTime,
- allowReceive, clientID, username, password,
- adapter, jmsurl);
- } else // domain is Topic
- {
- return new TopicConnector(adapter.getTopicConnectionFactory(cfConfig),
- numRetries, numSessions, connectRetryInterval,
- interactRetryInterval, timeoutTime,
- allowReceive, clientID, username, password,
- adapter, jmsurl);
- }
- }
-}
\ No newline at end of file
+}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSConnectorManager.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSConnectorManager.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSConnectorManager.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSConnectorManager.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
/*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2001, 2002,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package org.apache.axis2.transport.jms;
@@ -31,83 +32,44 @@
public class JMSConnectorManager {
protected static Log log =
LogFactory.getLog(JMSConnectorManager.class.getName());
-
private static JMSConnectorManager s_instance = new JMSConnectorManager();
-
private static HashMap vendorConnectorPools = new HashMap();
- private int DEFAULT_WAIT_FOR_SHUTDOWN = 90000; // 1.5 minutes
+ private int DEFAULT_WAIT_FOR_SHUTDOWN = 90000; // 1.5 minutes
private JMSConnectorManager() {
}
- public static JMSConnectorManager getInstance() {
- return s_instance;
- }
-
- /**
- * Returns the pool of JMSConnectors for a particular vendor
- */
- public ShareableObjectPool getVendorPool(String vendorId) {
- return (ShareableObjectPool) vendorConnectorPools.get(vendorId);
- }
-
/**
- * Retrieves a JMSConnector that satisfies the provided connector criteria
+ * Adds a JMSConnector to the appropriate vendor pool
*/
- public JMSConnector getConnector(HashMap connectorProperties,
- HashMap connectionFactoryProperties,
- String username,
- String password,
- JMSVendorAdapter vendorAdapter)
- throws AxisFault {
- JMSConnector connector = null;
+ public void addConnectorToPool(JMSConnector conn) {
+ if (log.isDebugEnabled()) {
+ log.debug("Enter: JMSConnectorManager::addConnectorToPool");
+ }
- try {
- // check for a vendor-specific pool, and create if necessary
- ShareableObjectPool vendorConnectors = getVendorPool(vendorAdapter.getVendorId());
- if (vendorConnectors == null) {
- synchronized (vendorConnectorPools) {
- vendorConnectors = getVendorPool(vendorAdapter.getVendorId());
- if (vendorConnectors == null) {
- vendorConnectors = new ShareableObjectPool();
- vendorConnectorPools.put(vendorAdapter.getVendorId(), vendorConnectors);
- }
- }
- }
+ ShareableObjectPool vendorConnectors = null;
- // look for a matching JMSConnector among existing connectors
- synchronized (vendorConnectors) {
- try {
+ synchronized (vendorConnectorPools) {
+ String vendorId = conn.getVendorAdapter().getVendorId();
- connector = JMSConnectorFactory.matchConnector(vendorConnectors.getElements(),
- connectorProperties,
- connectionFactoryProperties,
- username,
- password,
- vendorAdapter);
- }
- catch (Exception e) {
- } // ignore. a new connector will be created if no match is found
+ vendorConnectors = getVendorPool(vendorId);
- if (connector == null) {
- connector = JMSConnectorFactory.createClientConnector(connectorProperties,
- connectionFactoryProperties,
- username,
- password,
- vendorAdapter);
- connector.start();
- }
+ // it's possible the pool does not yet exist (if, for example, the connector
+ // is created before invoking the call/JMSTransport, as is the case with
+ // SimpleJMSListener)
+ if (vendorConnectors == null) {
+ vendorConnectors = new ShareableObjectPool();
+ vendorConnectorPools.put(vendorId, vendorConnectors);
}
}
- catch (Exception e) {
- log.error(Messages.getMessage("cannotConnectError"), e);
- if (e instanceof AxisFault)
- throw (AxisFault) e;
- throw new AxisFault("cannotConnect", e);
+ synchronized (vendorConnectors) {
+ vendorConnectors.addObject(conn);
}
- return connector;
+ if (log.isDebugEnabled()) {
+ log.debug("Exit: JMSConnectorManager::addConnectorToPool");
+ }
}
/**
@@ -120,21 +82,26 @@
synchronized (vendorConnectorPools) {
Iterator iter = vendorConnectorPools.values().iterator();
+
while (iter.hasNext()) {
+
// close all connectors in the vendor pool
ShareableObjectPool pool = (ShareableObjectPool) iter.next();
- synchronized (pool) {
+
+ synchronized (pool) {
Object[] elements = pool.getElements().toArray();
- for (int i=0;i<elements.length;i++) {
+
+ for (int i = 0; i < elements.length; i++) {
JMSConnector conn = (JMSConnector) elements[i];
+
try {
+
// shutdown automatically decrements the ref count of a connector before closing it
// call reserve() to simulate the checkout
reserve(conn);
closeConnector(conn);
- }
- catch (Exception e) {
- } // ignore. the connector is already being deactivated
+ } catch (Exception e) {
+ } // ignore. the connector is already being deactivated
}
}
}
@@ -145,12 +112,16 @@
}
}
+ private void closeConnector(JMSConnector conn) {
+ conn.stop();
+ conn.shutdown();
+ }
+
/**
* Closes JMS connectors that match the specified endpoint address
*/
- void closeMatchingJMSConnectors(HashMap connectorProps, HashMap cfProps,
- String username, String password,
- JMSVendorAdapter vendorAdapter) {
+ void closeMatchingJMSConnectors(HashMap connectorProps, HashMap cfProps, String username,
+ String password, JMSVendorAdapter vendorAdapter) {
if (log.isDebugEnabled()) {
log.debug("Enter: JMSConnectorManager::closeMatchingJMSConnectors");
}
@@ -160,29 +131,30 @@
// get the vendor-specific pool of connectors
ShareableObjectPool vendorConnectors = null;
+
synchronized (vendorConnectorPools) {
vendorConnectors = getVendorPool(vendorId);
}
// it's possible that there is no pool for that vendor
- if (vendorConnectors == null)
+ if (vendorConnectors == null) {
return;
+ }
synchronized (vendorConnectors) {
+
// close any matched connectors
JMSConnector connector = null;
- while ((vendorConnectors.size() > 0) &&
- (connector = JMSConnectorFactory.matchConnector(vendorConnectors.getElements(),
- connectorProps,
- cfProps,
- username,
- password,
+
+ while ((vendorConnectors.size() > 0)
+ && (connector =
+ JMSConnectorFactory.matchConnector(vendorConnectors.getElements(),
+ connectorProps, cfProps, username, password,
vendorAdapter)) != null) {
closeConnector(connector);
}
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
log.warn(Messages.getMessage("failedJMSConnectorShutdown"), e);
}
@@ -191,38 +163,18 @@
}
}
- private void closeConnector(JMSConnector conn) {
- conn.stop();
- conn.shutdown();
- }
-
/**
- * Adds a JMSConnector to the appropriate vendor pool
+ * Performs a non-exclusive checkin of the JMSConnector
*/
- public void addConnectorToPool(JMSConnector conn) {
- if (log.isDebugEnabled()) {
- log.debug("Enter: JMSConnectorManager::addConnectorToPool");
- }
+ public void release(JMSConnector connector) {
+ ShareableObjectPool pool = null;
- ShareableObjectPool vendorConnectors = null;
synchronized (vendorConnectorPools) {
- String vendorId = conn.getVendorAdapter().getVendorId();
- vendorConnectors = getVendorPool(vendorId);
- // it's possible the pool does not yet exist (if, for example, the connector
- // is created before invoking the call/JMSTransport, as is the case with
- // SimpleJMSListener)
- if (vendorConnectors == null) {
- vendorConnectors = new ShareableObjectPool();
- vendorConnectorPools.put(vendorId, vendorConnectors);
- }
- }
-
- synchronized (vendorConnectors) {
- vendorConnectors.addObject(conn);
+ pool = getVendorPool(connector.getVendorAdapter().getVendorId());
}
- if (log.isDebugEnabled()) {
- log.debug("Exit: JMSConnectorManager::addConnectorToPool");
+ if (pool != null) {
+ pool.release(connector);
}
}
@@ -235,13 +187,17 @@
}
ShareableObjectPool vendorConnectors = null;
+
synchronized (vendorConnectorPools) {
vendorConnectors = getVendorPool(conn.getVendorAdapter().getVendorId());
}
- if (vendorConnectors == null)
+
+ if (vendorConnectors == null) {
return;
+ }
synchronized (vendorConnectors) {
+
// first release, to decrement the ref count (it is automatically incremented when
// the connector is matched)
vendorConnectors.release(conn);
@@ -258,23 +214,78 @@
*/
public void reserve(JMSConnector connector) throws Exception {
ShareableObjectPool pool = null;
+
synchronized (vendorConnectorPools) {
pool = getVendorPool(connector.getVendorAdapter().getVendorId());
}
- if (pool != null)
+
+ if (pool != null) {
pool.reserve(connector);
+ }
}
/**
- * Performs a non-exclusive checkin of the JMSConnector
+ * Retrieves a JMSConnector that satisfies the provided connector criteria
*/
- public void release(JMSConnector connector) {
- ShareableObjectPool pool = null;
- synchronized (vendorConnectorPools) {
- pool = getVendorPool(connector.getVendorAdapter().getVendorId());
+ public JMSConnector getConnector(HashMap connectorProperties,
+ HashMap connectionFactoryProperties, String username,
+ String password, JMSVendorAdapter vendorAdapter)
+ throws AxisFault {
+ JMSConnector connector = null;
+
+ try {
+
+ // check for a vendor-specific pool, and create if necessary
+ ShareableObjectPool vendorConnectors = getVendorPool(vendorAdapter.getVendorId());
+
+ if (vendorConnectors == null) {
+ synchronized (vendorConnectorPools) {
+ vendorConnectors = getVendorPool(vendorAdapter.getVendorId());
+
+ if (vendorConnectors == null) {
+ vendorConnectors = new ShareableObjectPool();
+ vendorConnectorPools.put(vendorAdapter.getVendorId(), vendorConnectors);
+ }
+ }
+ }
+
+ // look for a matching JMSConnector among existing connectors
+ synchronized (vendorConnectors) {
+ try {
+ connector = JMSConnectorFactory.matchConnector(vendorConnectors.getElements(),
+ connectorProperties, connectionFactoryProperties, username, password,
+ vendorAdapter);
+ } catch (Exception e) {
+ } // ignore. a new connector will be created if no match is found
+
+ if (connector == null) {
+ connector = JMSConnectorFactory.createClientConnector(connectorProperties,
+ connectionFactoryProperties, username, password, vendorAdapter);
+ connector.start();
+ }
+ }
+ } catch (Exception e) {
+ log.error(Messages.getMessage("cannotConnectError"), e);
+
+ if (e instanceof AxisFault) {
+ throw(AxisFault) e;
+ }
+
+ throw new AxisFault("cannotConnect", e);
}
- if (pool != null)
- pool.release(connector);
+
+ return connector;
+ }
+
+ public static JMSConnectorManager getInstance() {
+ return s_instance;
+ }
+
+ /**
+ * Returns the pool of JMSConnectors for a particular vendor
+ */
+ public ShareableObjectPool getVendorPool(String vendorId) {
+ return (ShareableObjectPool) vendorConnectorPools.get(vendorId);
}
/**
@@ -283,14 +294,14 @@
* Todo: max size, cleanup stale connections
*/
public class ShareableObjectPool {
+ private int m_numElements = 0;
+
// maps object to ref count wrapper
private java.util.HashMap m_elements;
// holds objects which should no longer be leased (pending removal)
private java.util.HashMap m_expiring;
- private int m_numElements = 0;
-
public ShareableObjectPool() {
m_elements = new java.util.HashMap();
m_expiring = new java.util.HashMap();
@@ -301,84 +312,96 @@
*/
public void addObject(Object obj) {
ReferenceCountedObject ref = new ReferenceCountedObject(obj);
+
synchronized (m_elements) {
- if (!m_elements.containsKey(obj) && !m_expiring.containsKey(obj))
+ if (!m_elements.containsKey(obj) && !m_expiring.containsKey(obj)) {
m_elements.put(obj, ref);
+ }
}
}
/**
+ * Decrements the connector's reference count
+ */
+ public void release(Object obj) {
+ synchronized (m_elements) {
+ ReferenceCountedObject ref = (ReferenceCountedObject) m_elements.get(obj);
+
+ ref.decrement();
+ }
+ }
+
+ public void removeObject(Object obj) {
+ removeObject(obj, DEFAULT_WAIT_FOR_SHUTDOWN);
+ }
+
+ /**
* Removes the object from the pool. If the object is reserved,
* waits the specified time before forcibly removing
* Todo: check expirations with the next request instead of holding up the current request
*/
public void removeObject(Object obj, long waitTime) {
ReferenceCountedObject ref = null;
+
synchronized (m_elements) {
ref = (ReferenceCountedObject) m_elements.get(obj);
- if (ref == null)
+
+ if (ref == null) {
return;
+ }
m_elements.remove(obj);
- if (ref.count() == 0)
+ if (ref.count() == 0) {
return;
- else
+ } else {
+
// mark the object for expiration
m_expiring.put(obj, ref);
+ }
}
// connector is now marked for expiration. wait for the ref count to drop to zero
long expiration = System.currentTimeMillis() + waitTime;
+
while (ref.count() > 0) {
try {
Thread.sleep(5000);
- }
- catch (InterruptedException e) {
- } // ignore
- if (System.currentTimeMillis() > expiration)
+ } catch (InterruptedException e) {
+ } // ignore
+
+ if (System.currentTimeMillis() > expiration) {
break;
+ }
}
// also clear from the expiring list
m_expiring.remove(obj);
}
- public void removeObject(Object obj) {
- removeObject(obj, DEFAULT_WAIT_FOR_SHUTDOWN);
- }
-
/**
* Marks the connector as in use by incrementing the connector's reference count
*/
public void reserve(Object obj) throws Exception {
synchronized (m_elements) {
- if (m_expiring.containsKey(obj))
+ if (m_expiring.containsKey(obj)) {
throw new Exception("resourceUnavailable");
+ }
ReferenceCountedObject ref = (ReferenceCountedObject) m_elements.get(obj);
+
ref.increment();
}
}
- /**
- * Decrements the connector's reference count
- */
- public void release(Object obj) {
- synchronized (m_elements) {
- ReferenceCountedObject ref = (ReferenceCountedObject) m_elements.get(obj);
- ref.decrement();
- }
+ public synchronized int size() {
+ return m_elements.size();
}
public synchronized java.util.Set getElements() {
return m_elements.keySet();
}
- public synchronized int size() {
- return m_elements.size();
- }
-
/**
* Wrapper to track the use count of an object
*/
@@ -391,18 +414,19 @@
m_refCount = 0;
}
- public synchronized void increment() {
- m_refCount++;
+ public synchronized int count() {
+ return m_refCount;
}
public synchronized void decrement() {
- if (m_refCount > 0)
+ if (m_refCount > 0) {
m_refCount--;
+ }
}
- public synchronized int count() {
- return m_refCount;
+ public synchronized void increment() {
+ m_refCount++;
}
}
}
-}
\ No newline at end of file
+}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSConstants.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSConstants.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSConstants.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
/*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2001, 2002,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package org.apache.axis2.transport.jms;
@@ -30,7 +31,6 @@
* <code>JMSEndpoint</code> and the <code>createConnector</code> method of
* <code>JMSConnectorFactory</code>.
*/
-
public interface JMSConstants {
public final static String PROTOCOL = "jms";
@@ -38,105 +38,105 @@
// the short name is used in the JMS URL. the full name is used in the Axis call.
final static String _CLIENT_ID = "clientID";
final static String _VENDOR = "vendor";
- final static String _DOMAIN = "domain";
- final static String _JMS_CORRELATION_ID = "jmsCorrelationID";
- final static String _JMS_CORRELATION_ID_AS_BYTES = "jmsCorrelationIDAsBytes";
- final static String _JMS_TYPE = "jmsType";
+ final static String _UNSUBSCRIBE = "unsubscribe";
final static String _TIME_TO_LIVE = "ttl";
- final static String _PRIORITY = "priority";
- final static String _DELIVERY_MODE = "deliveryMode";
- final static String _MESSAGE_SELECTOR = "messageSelector";
- final static String _ACKNOWLEDGE_MODE = "acknowledgeMode";
+ final static String _TIMEOUT_TIME = "timeoutTime";
final static String _SUBSCRIPTION_NAME = "subscriptionName";
- final static String _UNSUBSCRIBE = "unsubscribe";
- final static String _NO_LOCAL = "noLocal";
- final static String _NUM_RETRIES = "numRetries";
+ final static String _PRIORITY = "priority";
final static String _NUM_SESSIONS = "numSessions";
- final static String _CONNECT_RETRY_INTERVAL = "connectRetryInterval";
- final static String _INTERACT_RETRY_INTERVAL = "interactRetryInterval";
- final static String _TIMEOUT_TIME = "timeoutTime";
- final static String _MIN_TIMEOUT_TIME = "minTimeoutTime";
+ final static String _NUM_RETRIES = "numRetries";
+ final static String _NO_LOCAL = "noLocal";
+
/**
* Defines a prefix added to each application-specific property in the
* JMS URL that should be added to the JMS Message when issued.
*/
final static String _MSG_PROP_PREFIX = "msgProp.";
+ final static String _MIN_TIMEOUT_TIME = "minTimeoutTime";
+ final static String _MESSAGE_SELECTOR = "messageSelector";
+ final static String _JMS_TYPE = "jmsType";
+ final static String _JMS_CORRELATION_ID_AS_BYTES = "jmsCorrelationIDAsBytes";
+ final static String _JMS_CORRELATION_ID = "jmsCorrelationID";
+ final static String _INTERACT_RETRY_INTERVAL = "interactRetryInterval";
+ final static String _DOMAIN = "domain";
+ final static String _DELIVERY_MODE = "deliveryMode";
+ final static String _CONNECT_RETRY_INTERVAL = "connectRetryInterval";
+ final static String _ACKNOWLEDGE_MODE = "acknowledgeMode";
+ // Prefix for JMS properties
public static String JMS_PROPERTY_PREFIX = "transport.jms.";
- /**
- * <code>JMSConnectorFactory</code> parameter valid for either domain. This should
- * be used as a key in the environment map passed into calls to
- * <code>createConnector</code> in <code>JMSConnectorFactory</code>
- * This is a required property for durable subscribers.
- * The value must be a <code>java.lang.String</code>.
- * See the javax.jms javadoc for information on this property.
- */
- final static String CLIENT_ID = JMS_PROPERTY_PREFIX + _CLIENT_ID;
-
- // there is no short version
- final static String DESTINATION = JMS_PROPERTY_PREFIX + "Destination";
-
+ // key used to store the JMS vendor adapter in the message context
+ final static String VENDOR_ADAPTER = JMS_PROPERTY_PREFIX + "VendorAdapter";
final static String VENDOR = JMS_PROPERTY_PREFIX + _VENDOR;
- public final static String JNDI_VENDOR_ID = "JNDI";
- final static String DOMAIN = JMS_PROPERTY_PREFIX + _DOMAIN;
-
- final static String DOMAIN_QUEUE = "QUEUE";
- final static String DOMAIN_TOPIC = "TOPIC";
- final static String DOMAIN_DEFAULT = DOMAIN_QUEUE;
+ /**
+ * Key for properties used in the <code>registerListener</code>
+ * method. It is valid for the PubSub domain.
+ * Specifies that the durable subscription should be unsubscribed
+ * (deleted from the broker) when unregistered.
+ * The value must be a <code>java.lang.Boolean</code>.
+ */
+ final static String UNSUBSCRIBE = JMS_PROPERTY_PREFIX + _UNSUBSCRIBE;
/**
* Key for properties used in the <code>send</code> and <code>call</code>
* methods. It is valid for either domain.
- * The value must be a <code>java.lang.String</code>.
+ * The value must be a <code>java.lang.Long</code>.
* See the javax.jms javadoc for information on this property.
*/
- final static String JMS_CORRELATION_ID = JMS_PROPERTY_PREFIX + _JMS_CORRELATION_ID;
+ final static String TIME_TO_LIVE = JMS_PROPERTY_PREFIX + _TIME_TO_LIVE;
+
/**
- * Key for properties used in the <code>send</code> and <code>call</code>
- * methods. It is valid for either domain.
- * The value must be a <code>byte[]</code>.
- * See the javax.jms javadoc for information on this property.
+ * Key for properties used in the <code>createConnector</code>
+ * method. It changes the behavior of the wsclient.
+ * The value must be a <code>java.lang.Long</code>.
*/
- final static String JMS_CORRELATION_ID_AS_BYTES = JMS_PROPERTY_PREFIX + _JMS_CORRELATION_ID_AS_BYTES;
+ final static String TIMEOUT_TIME = JMS_PROPERTY_PREFIX + _TIMEOUT_TIME;
+
/**
- * Key for properties used in the <code>send</code> and <code>call</code>
- * methods. It is valid for either domain.
+ * Specifies the name of a durable subscription
+ * Key for properties used in the <code>registerListener</code>
+ * method. It is valid for the PubSub domain.
* The value must be a <code>java.lang.String</code>.
- * See the javax.jms javadoc for information on this property.
*/
- final static String JMS_TYPE = JMS_PROPERTY_PREFIX + _JMS_TYPE;
+ final static String SUBSCRIPTION_NAME = JMS_PROPERTY_PREFIX + _SUBSCRIPTION_NAME;
+
/**
* Key for properties used in the <code>send</code> and <code>call</code>
* methods. It is valid for either domain.
- * The value must be a <code>java.lang.Long</code>.
+ * The value must be a <code>java.lang.Integer</code>.
* See the javax.jms javadoc for information on this property.
*/
- final static String TIME_TO_LIVE = JMS_PROPERTY_PREFIX + _TIME_TO_LIVE;
+ final static String PRIORITY = JMS_PROPERTY_PREFIX + _PRIORITY;
+
/**
- * Key for properties used in the <code>send</code> and <code>call</code>
- * methods. It is valid for either domain.
+ * Key for properties used in the <code>createConnector</code>
+ * method. It changes the behavior of the wsclient.
* The value must be a <code>java.lang.Integer</code>.
- * See the javax.jms javadoc for information on this property.
*/
- final static String PRIORITY = JMS_PROPERTY_PREFIX + _PRIORITY;
+ final static String NUM_SESSIONS = JMS_PROPERTY_PREFIX + _NUM_SESSIONS;
+
/**
- * Key for properties used in the <code>send</code> and <code>call</code>
- * methods. It is valid for either domain.
- * The value must be a <code>java.lang.Integer</code> equal to
- * DeliveryMode.NON_PERSISTENT or DeliveryMode.PERSISTENT.
- * See the javax.jms javadoc for information on this property.
+ * Key for properties used in the <code>createConnector</code>
+ * method. It changes the behavior of the wsclient.
+ * The value must be a <code>java.lang.Integer</code>.
*/
- final static String DELIVERY_MODE = JMS_PROPERTY_PREFIX + _DELIVERY_MODE;
+ final static String NUM_RETRIES = JMS_PROPERTY_PREFIX + _NUM_RETRIES;
- final static String DELIVERY_MODE_PERSISTENT = "Persistent";
- final static String DELIVERY_MODE_NONPERSISTENT = "Nonpersistent";
- final static String DELIVERY_MODE_DISCARDABLE = "Discardable";
- final static int DEFAULT_DELIVERY_MODE = DeliveryMode.NON_PERSISTENT;
+ /**
+ * Key for properties used in the <code>registerListener</code>
+ * method. It is valid for the PubSub domain.
+ * The value must be a <code>java.lang.Boolean</code>.
+ */
+ final static String NO_LOCAL = JMS_PROPERTY_PREFIX + _NO_LOCAL;
- final static int DEFAULT_PRIORITY = Message.DEFAULT_PRIORITY;
- final static long DEFAULT_TIME_TO_LIVE = Message.DEFAULT_TIME_TO_LIVE;
+ /**
+ * Key for properties used in the <code>createConnector</code>
+ * method. It changes the behavior of the wsclient.
+ * The value must be a <code>java.lang.Long</code>.
+ */
+ final static String MIN_TIMEOUT_TIME = JMS_PROPERTY_PREFIX + _MIN_TIMEOUT_TIME;
/**
* Key for properties used in the <code>registerListener</code>
@@ -145,107 +145,113 @@
* See the javax.jms javadoc for information on this property.
*/
final static String MESSAGE_SELECTOR = JMS_PROPERTY_PREFIX + _MESSAGE_SELECTOR;
+ public final static String JNDI_VENDOR_ID = "JNDI";
+
+ // key used to store the JMS URL string in the message context
+ final static String JMS_URL = JMS_PROPERTY_PREFIX + "EndpointAddress";
+
/**
- * Key for properties used in the <code>registerListener</code>
- * method. It is valid for either domain.
- * The value must be a <code>java.lang.Integer</code> that is one of
- * Session.AUTO_ACKNOWLEDGE, Session.DUPS_OK_ACKNOWLEDGE,
- * or Session.CLIENT_ACKNOWLEDGE.
+ * Key for properties used in the <code>send</code> and <code>call</code>
+ * methods. It is valid for either domain.
+ * The value must be a <code>java.lang.String</code>.
* See the javax.jms javadoc for information on this property.
*/
- final static String ACKNOWLEDGE_MODE = JMS_PROPERTY_PREFIX + _ACKNOWLEDGE_MODE;
+ final static String JMS_TYPE = JMS_PROPERTY_PREFIX + _JMS_TYPE;
/**
- * value for ACKNOWLEDGE_MODE if left unset. It is equal to
- * Session.DUPS_OK_ACKNOWLEDGE.
+ * Key for properties used in the <code>send</code> and <code>call</code>
+ * methods. It is valid for either domain.
+ * The value must be a <code>byte[]</code>.
+ * See the javax.jms javadoc for information on this property.
*/
- final static int DEFAULT_ACKNOWLEDGE_MODE = Session.DUPS_OK_ACKNOWLEDGE;
+ final static String JMS_CORRELATION_ID_AS_BYTES = JMS_PROPERTY_PREFIX
+ + _JMS_CORRELATION_ID_AS_BYTES;
/**
- * Specifies the name of a durable subscription
- * Key for properties used in the <code>registerListener</code>
- * method. It is valid for the PubSub domain.
+ * Key for properties used in the <code>send</code> and <code>call</code>
+ * methods. It is valid for either domain.
* The value must be a <code>java.lang.String</code>.
+ * See the javax.jms javadoc for information on this property.
*/
- final static String SUBSCRIPTION_NAME = JMS_PROPERTY_PREFIX + _SUBSCRIPTION_NAME;
- /**
- * Key for properties used in the <code>registerListener</code>
- * method. It is valid for the PubSub domain.
- * Specifies that the durable subscription should be unsubscribed
- * (deleted from the broker) when unregistered.
- * The value must be a <code>java.lang.Boolean</code>.
- */
- final static String UNSUBSCRIBE = JMS_PROPERTY_PREFIX + _UNSUBSCRIBE;
- /**
- * Key for properties used in the <code>registerListener</code>
- * method. It is valid for the PubSub domain.
- * The value must be a <code>java.lang.Boolean</code>.
- */
- final static String NO_LOCAL = JMS_PROPERTY_PREFIX + _NO_LOCAL;
-
- final static boolean DEFAULT_NO_LOCAL = false;
- final static boolean DEFAULT_UNSUBSCRIBE = false;
+ final static String JMS_CORRELATION_ID = JMS_PROPERTY_PREFIX + _JMS_CORRELATION_ID;
/**
- * Key for properties used in the <code>createConnector</code>
- * method. It changes the behavior of the wsclient.
- * The value must be a <code>java.lang.Integer</code>.
- */
- final static String NUM_RETRIES = JMS_PROPERTY_PREFIX + _NUM_RETRIES;
- /**
- * Key for properties used in the <code>createConnector</code>
- * method. It changes the behavior of the wsclient.
- * The value must be a <code>java.lang.Integer</code>.
+ * A property that carries a Map of application-specific properties to be
+ * added to the JMS messages when issued.
*/
- final static String NUM_SESSIONS = JMS_PROPERTY_PREFIX + _NUM_SESSIONS;
+ final static String JMS_APPLICATION_MSG_PROPS = JMS_PROPERTY_PREFIX + "msgProps";
+
/**
* Key for properties used in the <code>createConnector</code>
* method. It changes the behavior of the wsclient.
* The value must be a <code>java.lang.Long</code>.
*/
- final static String CONNECT_RETRY_INTERVAL = JMS_PROPERTY_PREFIX + _CONNECT_RETRY_INTERVAL;
+ final static String INTERACT_RETRY_INTERVAL = JMS_PROPERTY_PREFIX + _INTERACT_RETRY_INTERVAL;
+ final static String DOMAIN_TOPIC = "TOPIC";
+ final static String DOMAIN_QUEUE = "QUEUE";
+ final static String DOMAIN_DEFAULT = DOMAIN_QUEUE;
+ final static String DOMAIN = JMS_PROPERTY_PREFIX + _DOMAIN;
+
+ // there is no short version
+ final static String DESTINATION = JMS_PROPERTY_PREFIX + "Destination";
+ final static String DELIVERY_MODE_PERSISTENT = "Persistent";
+ final static String DELIVERY_MODE_NONPERSISTENT = "Nonpersistent";
+ final static String DELIVERY_MODE_DISCARDABLE = "Discardable";
+
/**
- * Key for properties used in the <code>createConnector</code>
- * method. It changes the behavior of the wsclient.
- * The value must be a <code>java.lang.Long</code>.
+ * Key for properties used in the <code>send</code> and <code>call</code>
+ * methods. It is valid for either domain.
+ * The value must be a <code>java.lang.Integer</code> equal to
+ * DeliveryMode.NON_PERSISTENT or DeliveryMode.PERSISTENT.
+ * See the javax.jms javadoc for information on this property.
*/
- final static String INTERACT_RETRY_INTERVAL = JMS_PROPERTY_PREFIX + _INTERACT_RETRY_INTERVAL;
+ final static String DELIVERY_MODE = JMS_PROPERTY_PREFIX + _DELIVERY_MODE;
+ final static boolean DEFAULT_UNSUBSCRIBE = false;
+ final static long DEFAULT_TIME_TO_LIVE = Message.DEFAULT_TIME_TO_LIVE;
+ final static long DEFAULT_TIMEOUT_TIME = 5000;
+ final static int DEFAULT_PRIORITY = Message.DEFAULT_PRIORITY;
+ final static int DEFAULT_NUM_SESSIONS = 5;
+ final static int DEFAULT_NUM_RETRIES = 5;
+ final static boolean DEFAULT_NO_LOCAL = false;
+ final static long DEFAULT_MIN_TIMEOUT_TIME = 1000;
+ final static long DEFAULT_INTERACT_RETRY_INTERVAL = 250;
+ final static int DEFAULT_DELIVERY_MODE = DeliveryMode.NON_PERSISTENT;
+ final static long DEFAULT_CONNECT_RETRY_INTERVAL = 2000;
+
/**
- * Key for properties used in the <code>createConnector</code>
- * method. It changes the behavior of the wsclient.
- * The value must be a <code>java.lang.Long</code>.
+ * value for ACKNOWLEDGE_MODE if left unset. It is equal to
+ * Session.DUPS_OK_ACKNOWLEDGE.
*/
- final static String TIMEOUT_TIME = JMS_PROPERTY_PREFIX + _TIMEOUT_TIME;
+ final static int DEFAULT_ACKNOWLEDGE_MODE = Session.DUPS_OK_ACKNOWLEDGE;
+
/**
* Key for properties used in the <code>createConnector</code>
* method. It changes the behavior of the wsclient.
* The value must be a <code>java.lang.Long</code>.
*/
- final static String MIN_TIMEOUT_TIME = JMS_PROPERTY_PREFIX + _MIN_TIMEOUT_TIME;
-
- final static int DEFAULT_NUM_RETRIES = 5;
- final static int DEFAULT_NUM_SESSIONS = 5;
-
- final static long DEFAULT_CONNECT_RETRY_INTERVAL = 2000;
- final static long DEFAULT_TIMEOUT_TIME = 5000;
- final static long DEFAULT_MIN_TIMEOUT_TIME = 1000;
- final static long DEFAULT_INTERACT_RETRY_INTERVAL = 250;
+ final static String CONNECT_RETRY_INTERVAL = JMS_PROPERTY_PREFIX + _CONNECT_RETRY_INTERVAL;
// key used to store the JMS connector in the message context
final static String CONNECTOR = JMS_PROPERTY_PREFIX + "Connector";
- // key used to store the JMS vendor adapter in the message context
- final static String VENDOR_ADAPTER = JMS_PROPERTY_PREFIX + "VendorAdapter";
-
- // key used to store the JMS URL string in the message context
- final static String JMS_URL = JMS_PROPERTY_PREFIX + "EndpointAddress";
-
/**
- * A property that carries a Map of application-specific properties to be
- * added to the JMS messages when issued.
+ * <code>JMSConnectorFactory</code> parameter valid for either domain. This should
+ * be used as a key in the environment map passed into calls to
+ * <code>createConnector</code> in <code>JMSConnectorFactory</code>
+ * This is a required property for durable subscribers.
+ * The value must be a <code>java.lang.String</code>.
+ * See the javax.jms javadoc for information on this property.
*/
- final static String JMS_APPLICATION_MSG_PROPS =
- JMS_PROPERTY_PREFIX + "msgProps";
-
+ final static String CLIENT_ID = JMS_PROPERTY_PREFIX + _CLIENT_ID;
final static String ADAPTER_POSTFIX = "VendorAdapter";
-}
\ No newline at end of file
+
+ /**
+ * Key for properties used in the <code>registerListener</code>
+ * method. It is valid for either domain.
+ * The value must be a <code>java.lang.Integer</code> that is one of
+ * Session.AUTO_ACKNOWLEDGE, Session.DUPS_OK_ACKNOWLEDGE,
+ * or Session.CLIENT_ACKNOWLEDGE.
+ * See the javax.jms javadoc for information on this property.
+ */
+ final static String ACKNOWLEDGE_MODE = JMS_PROPERTY_PREFIX + _ACKNOWLEDGE_MODE;
+}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSEndpoint.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSEndpoint.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSEndpoint.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSEndpoint.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
/*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2001, 2002,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package org.apache.axis2.transport.jms;
@@ -31,9 +32,6 @@
m_connector = connector;
}
- abstract Destination getDestination(Session session)
- throws Exception;
-
/**
* Send a message and wait for a response.
*
@@ -55,60 +53,78 @@
* @return
* @throws javax.jms.JMSException
*/
- public byte[] call(byte[] message, long timeout, HashMap properties)
- throws Exception {
- if (properties != null)
+ public byte[] call(byte[] message, long timeout, HashMap properties) throws Exception {
+ if (properties != null) {
properties = (HashMap) properties.clone();
+ }
+
return m_connector.getSendConnection().call(this, message, timeout, properties);
}
+ protected Subscription createSubscription(MessageListener listener, HashMap properties) {
+ return new Subscription(listener, this, properties);
+ }
+
+ public boolean equals(Object object) {
+ if ((object == null) || !(object instanceof JMSEndpoint)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode() {
+ return toString().hashCode();
+ }
+
/**
- * Send a message w/o waiting for a response.
+ * Register a MessageListener.
*
- * @param message
+ * @param listener
* @throws javax.jms.JMSException
*/
- public void send(byte[] message) throws Exception {
- m_connector.getSendConnection().send(this, message, null);
+ public void registerListener(MessageListener listener) throws Exception {
+ m_connector.getReceiveConnection().subscribe(createSubscription(listener, null));
}
/**
- * Send a message w/o waiting for a response.
+ * Register a MessageListener.
*
- * @param message
+ * @param listener
* @param properties
* @throws javax.jms.JMSException
*/
- public void send(byte[] message, HashMap properties)
- throws Exception {
- if (properties != null)
+ public void registerListener(MessageListener listener, HashMap properties) throws Exception {
+ if (properties != null) {
properties = (HashMap) properties.clone();
- m_connector.getSendConnection().send(this, message, properties);
+ }
+
+ m_connector.getReceiveConnection().subscribe(createSubscription(listener, properties));
}
/**
- * Register a MessageListener.
+ * Send a message w/o waiting for a response.
*
- * @param listener
+ * @param message
* @throws javax.jms.JMSException
*/
- public void registerListener(MessageListener listener)
- throws Exception {
- m_connector.getReceiveConnection().subscribe(createSubscription(listener, null));
+ public void send(byte[] message) throws Exception {
+ m_connector.getSendConnection().send(this, message, null);
}
/**
- * Register a MessageListener.
+ * Send a message w/o waiting for a response.
*
- * @param listener
+ * @param message
* @param properties
* @throws javax.jms.JMSException
*/
- public void registerListener(MessageListener listener, HashMap properties)
- throws Exception {
- if (properties != null)
+ public void send(byte[] message, HashMap properties) throws Exception {
+ if (properties != null) {
properties = (HashMap) properties.clone();
- m_connector.getReceiveConnection().subscribe(createSubscription(listener, properties));
+ }
+
+ m_connector.getSendConnection().send(this, message, properties);
}
/**
@@ -127,23 +143,12 @@
* @param properties
*/
public void unregisterListener(MessageListener listener, HashMap properties) {
- if (properties != null)
+ if (properties != null) {
properties = (HashMap) properties.clone();
- m_connector.getReceiveConnection().unsubscribe(createSubscription(listener, properties));
- }
-
- protected Subscription createSubscription(MessageListener listener,
- HashMap properties) {
- return new Subscription(listener, this, properties);
- }
+ }
- public int hashCode() {
- return toString().hashCode();
+ m_connector.getReceiveConnection().unsubscribe(createSubscription(listener, properties));
}
- public boolean equals(Object object) {
- if (object == null || !(object instanceof JMSEndpoint))
- return false;
- return true;
- }
+ abstract Destination getDestination(Session session) throws Exception;
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSOutTransportInfo.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSOutTransportInfo.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSOutTransportInfo.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/jms/JMSOutTransportInfo.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
/*
- * Copyright 2001, 2002,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2001, 2002,2004 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package org.apache.axis2.transport.jms;
@@ -31,15 +32,15 @@
this.properties.putAll(properties);
}
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
public Destination getDestination() {
return dest;
}
-
+
public HashMap getProperties() {
return properties;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
}
}