You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2002/09/25 01:47:01 UTC
cvs commit: xml-axis/java/src/org/apache/axis/transport/jms JMSConnector.java JMSConnectorFactory.java JMSConstants.java JMSEndpoint.java QueueConnector.java SimpleJMSListener.java TopicConnector.java
dims 2002/09/24 16:47:01
Modified: java build.xml
java/samples/jms JMSTest.java
java/src/org/apache/axis/transport/jms JMSConnector.java
JMSConnectorFactory.java JMSConstants.java
JMSEndpoint.java QueueConnector.java
SimpleJMSListener.java TopicConnector.java
Added: java/src/org/apache/axis/components/jms
BeanVendorAdapter.java JMSVendorAdapter.java
JMSVendorAdapterFactory.java JNDIVendorAdapter.java
SonicMQVendorAdapter.java
Log:
Patch for JMS transport from Jaime (http://marc.theaimsgroup.com/?t=103253238500005&r=1&w=2)
Revision Changes Path
1.196 +1 -0 xml-axis/java/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/build.xml,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -r1.195 -r1.196
--- build.xml 20 Sep 2002 20:55:02 -0000 1.195
+++ build.xml 24 Sep 2002 23:47:01 -0000 1.196
@@ -107,6 +107,7 @@
<exclude name="**/org/apache/axis/transport/configuration/EngineConfigurationFactoryServlet.java" unless="servlet.present"/>
<exclude name="**/org/apache/axis/transport/http/CommonsHTTPSender.java" unless="commons-httpclient.present"/>
<exclude name="**/org/apache/axis/transport/jms/*" unless="jms.present"/>
+ <exclude name="**/org/apache/axis/components/jms/*" unless="jms.present"/>
<exclude name="**/org/apache/axis/server/JNDIAxisServerFactory.java" unless="servlet.present"/>
<exclude name="**/org/apache/axis/security/servlet/*" unless="servlet.present"/>
<exclude name="**/javax/xml/soap/*.java" unless="attachments.present"/>
1.2 +27 -56 xml-axis/java/samples/jms/JMSTest.java
Index: JMSTest.java
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/jms/JMSTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JMSTest.java 17 Sep 2002 16:50:36 -0000 1.1
+++ JMSTest.java 24 Sep 2002 23:47:01 -0000 1.2
@@ -67,7 +67,6 @@
import org.apache.axis.transport.jms.JMSTransport;
import org.apache.axis.transport.jms.JMSConstants;
import org.apache.axis.transport.jms.SimpleJMSListener;
-import org.apache.axis.transport.jms.SonicConstants;
import java.util.HashMap;
@@ -104,54 +103,31 @@
Options opts = new Options( args );
// first check if we should print usage
- if ((opts.isFlagSet('?') > 0) || (opts.isFlagSet('h') > 0)) {
+ if ((opts.isFlagSet('?') > 0) || (opts.isFlagSet('h') > 0))
printUsage();
- }
+ HashMap connectorMap = SimpleJMSListener.createConnectorMap(opts);
+ HashMap cfMap = SimpleJMSListener.createCFMap(opts);
+ String destination = opts.isValueSet('d');
+ String username = opts.getUser();
+ String password = opts.getPassword();
// create the jms listener
- SimpleJMSListener listener = new SimpleJMSListener(opts);
+ SimpleJMSListener listener = new SimpleJMSListener(connectorMap,
+ cfMap,
+ destination,
+ username,
+ password,
+ false);
listener.start();
args = opts.getRemainingArgs();
- if ( args == null ) {
+ if ( args == null || args.length == 0)
printUsage();
- }
-
- int numArgs = args.length;
- String[] symbols = new String[numArgs];
- for (int i = 0; i < numArgs; i++) {
- symbols[i] = args[i];
- }
Service service = new Service(new XMLStringProvider(wsdd));
- HashMap cfProps = new HashMap();
- cfProps.put(SonicConstants.BROKER_URL, opts.isValueSet('b'));
- cfProps.put(SonicConstants.DEFAULT_USERNAME, opts.getUser());
- cfProps.put(SonicConstants.DEFAULT_PASSWORD, opts.getPassword());
-
- // do we have a jndi name?
- String jndiName = opts.isValueSet('n');
- if (jndiName != null) {
- // w/ a jndi name, we can get the appropriate connection factory
- cfProps.put(JMSConstants.CONNECTION_FACTORY_JNDI_NAME, jndiName);
- } else {
- // w/o a jndi name, we default to using the Sonic-specific method
- // for creating a connection factory, which is by specifying the
- // appropriate connection factory class from SonicConstants.java
-
- // topics or queues?
- String cf = null;
- if (opts.isFlagSet('t') > 0) {
- cf = SonicConstants.TCF_CLASS;
- } else {
- cf = SonicConstants.QCF_CLASS;
- }
- cfProps.put(JMSConstants.CONNECTION_FACTORY_CLASS, cf);
- }
-
// create the transport
- JMSTransport transport = new JMSTransport(null, cfProps);
+ JMSTransport transport = new JMSTransport(connectorMap, cfMap);
// create a new Call object
Call call = (Call) service.createCall();
@@ -162,25 +138,23 @@
call.setTransport(transport);
// set additional params on the call if desired
-
- //call.setUsername(opts.getUser() );
- //call.setPassword(opts.getPassword() );
-
+ //call.setUsername(username );
+ //call.setPassword(password );
//call.setProperty(JMSConstants.WAIT_FOR_RESPONSE, Boolean.FALSE);
//call.setProperty(JMSConstants.PRIORITY, new Integer(5));
//call.setProperty(JMSConstants.DELIVERY_MODE,
// new Integer(javax.jms.DeliveryMode.PERSISTENT));
//call.setProperty(JMSConstants.TIME_TO_LIVE, new Long(20000));
- call.setProperty(JMSConstants.DESTINATION, "SampleQ1");
+ call.setProperty(JMSConstants.DESTINATION, destination);
call.setTimeout(new Integer(10000));
Float res = new Float(0.0F);
// invoke a call for each of the symbols and print out
- for (int i = 0; i < symbols.length; i++) {
- res = (Float) call.invoke(new Object[] {symbols[i]});
- System.out.println(symbols[i] + ": " + res);
+ for (int i = 0; i < args.length; i++) {
+ res = (Float) call.invoke(new Object[] {args[i]});
+ System.out.println(args[i] + ": " + res);
}
// shutdown
@@ -194,18 +168,15 @@
System.out.println(" Usage: JMSTest <symbol 1> <symbol 2> <symbol 3> ...");
System.out.println(" Opts: -? this message");
System.out.println();
- System.out.println(" -b brokerurl");
- System.out.println(" -u username");
- System.out.println(" -w password");
- System.out.println();
- System.out.println(" -d destination");
- System.out.println(" -t topic [absence of -t indicates queue]");
+ System.out.println(" -c connection factory properties filename");
+ System.out.println(" -d destination");
+ System.out.println(" -t topic [absence of -t indicates queue]");
System.out.println();
- System.out.println(" -n jndi name for connection factory");
- System.out.println(" [jndi name obviates need for -t option]");
+ System.out.println(" -u username");
+ System.out.println(" -w password");
System.out.println();
- System.out.println(" -s single-threaded listener");
- System.out.println(" [absence of option => multithreaded]");
+ System.out.println(" -s single-threaded listener");
+ System.out.println(" [absence of option => multithreaded]");
System.exit(1);
}
1.1 xml-axis/java/src/org/apache/axis/components/jms/BeanVendorAdapter.java
Index: BeanVendorAdapter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.axis.components.jms;
import java.util.HashMap;
import javax.jms.ConnectionFactory;
import javax.jms.QueueConnectionFactory;
import javax.jms.Queue;
import javax.jms.QueueSession;
import javax.jms.TopicConnectionFactory;
import javax.jms.Topic;
import javax.jms.TopicSession;
import org.apache.axis.utils.ClassUtils;
import org.apache.axis.utils.BeanUtils;
import org.apache.axis.utils.BeanPropertyDescriptor;
/**
* Uses ClassUtils.forName and reflection to configure ConnectionFactory. Uses
* the input sessions to create destinations.
*
* @author Jaime Meritt (jmeritt@sonicsoftware.com)
*/
public class BeanVendorAdapter extends JMSVendorAdapter
{
protected final static String CONNECTION_FACTORY_CLASS =
"transport.jms.ConnectionFactoryClass";
public QueueConnectionFactory getQueueConnectionFactory(HashMap cfConfig)
throws Exception
{
return (QueueConnectionFactory)getConnectionFactory(cfConfig);
}
public TopicConnectionFactory getTopicConnectionFactory(HashMap cfConfig)
throws Exception
{
return (TopicConnectionFactory)getConnectionFactory(cfConfig);
}
private ConnectionFactory getConnectionFactory(HashMap cfConfig)
throws Exception
{
String classname = (String)cfConfig.get(CONNECTION_FACTORY_CLASS);
if(classname == null || classname.trim().length() == 0)
throw new IllegalArgumentException("noCFClass");
Class factoryClass = ClassUtils.forName(classname);
ConnectionFactory factory = (ConnectionFactory)factoryClass.newInstance();
callSetters(cfConfig, factoryClass, factory);
return factory;
}
private void callSetters(HashMap cfConfig,
Class factoryClass,
ConnectionFactory factory)
throws Exception
{
BeanPropertyDescriptor[] bpd = BeanUtils.getPd(factoryClass);
for(int i = 0; i < bpd.length; i++)
{
BeanPropertyDescriptor thisBPD = bpd[i];
String propName = thisBPD.getName();
if(cfConfig.containsKey(propName))
{
Object value = cfConfig.get(propName);
if(value == null)
continue;
String validType = thisBPD.getType().getName();
if(!value.getClass().getName().equals(validType))
throw new IllegalArgumentException("badType");
if(!thisBPD.isWriteable())
throw new IllegalArgumentException("notWriteable");
if(thisBPD.isIndexed())
throw new IllegalArgumentException("noIndexedSupport");
thisBPD.set(factory, value);
}
}
}
}
1.1 xml-axis/java/src/org/apache/axis/components/jms/JMSVendorAdapter.java
Index: JMSVendorAdapter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.axis.components.jms;
import java.util.HashMap;
import javax.jms.QueueConnectionFactory;
import javax.jms.TopicConnectionFactory;
import javax.jms.Queue;
import javax.jms.QueueSession;
import javax.jms.Topic;
import javax.jms.TopicSession;
/**
* SPI Interface that all JMSVendorAdaptors must implement. Allows for
* ConnectionFactory creation and Destination lookup
*
* @author Jaime Meritt (jmeritt@sonicsoftware.com)
*/
public abstract class JMSVendorAdapter
{
public abstract QueueConnectionFactory getQueueConnectionFactory(HashMap cfProps)
throws Exception;
public abstract TopicConnectionFactory getTopicConnectionFactory(HashMap cfProps)
throws Exception;
public Queue getQueue(QueueSession session, String name)
throws Exception
{
return session.createQueue(name);
}
public Topic getTopic(TopicSession session, String name)
throws Exception
{
return session.createTopic(name);
}
}
1.1 xml-axis/java/src/org/apache/axis/components/jms/JMSVendorAdapterFactory.java
Index: JMSVendorAdapterFactory.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.axis.components.jms;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
import javax.jms.ConnectionFactory;
import org.apache.axis.AxisProperties;
import org.apache.commons.discovery.tools.SPInterface;
/**
* Discovery class used to locate vendor adapters. Switch the default
* JNDI-based implementation by using the
* org.apache.axis.components.jms.JMSVendorAdapter system property
*
* @author Jaime Meritt (jmeritt@sonicsoftware.com)
*/
public class JMSVendorAdapterFactory
{
private static final SPInterface spInterface = new SPInterface(JMSVendorAdapter.class);
private static final Class defaultClass = JNDIVendorAdapter.class;
public static final JMSVendorAdapter getJMSVendorAdapter()
{
return (JMSVendorAdapter)AxisProperties.newInstance(spInterface,
defaultClass);
}
}
1.1 xml-axis/java/src/org/apache/axis/components/jms/JNDIVendorAdapter.java
Index: JNDIVendorAdapter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.axis.components.jms;
import java.util.HashMap;
import java.util.Hashtable;
import javax.jms.ConnectionFactory;
import javax.jms.QueueConnectionFactory;
import javax.jms.Queue;
import javax.jms.QueueSession;
import javax.jms.TopicConnectionFactory;
import javax.jms.Topic;
import javax.jms.TopicSession;
import javax.naming.Context;
import javax.naming.InitialContext;
/**
* Uses JNDI to locate ConnectionFactory and Destinations
*
* @author Jaime Meritt (jmeritt@sonicsoftware.com)
*/
public class JNDIVendorAdapter extends JMSVendorAdapter
{
private Context context;
public final static String CONNECTION_FACTORY_JNDI_NAME =
"transport.jms.ConnectionFactoryJNDIName";
public QueueConnectionFactory getQueueConnectionFactory(HashMap cfConfig)
throws Exception
{
return (QueueConnectionFactory)getConnectionFactory(cfConfig);
}
public TopicConnectionFactory getTopicConnectionFactory(HashMap cfConfig)
throws Exception
{
return (TopicConnectionFactory)getConnectionFactory(cfConfig);
}
private ConnectionFactory getConnectionFactory(HashMap cfProps)
throws Exception
{
if(cfProps == null)
throw new IllegalArgumentException("noCFProps");
String jndiName = (String)cfProps.get(CONNECTION_FACTORY_JNDI_NAME);
if(jndiName == null || jndiName.trim().length() == 0)
throw new IllegalArgumentException("noCFName");
Hashtable environment = new Hashtable(cfProps);
context = new InitialContext(environment);
return (ConnectionFactory)context.lookup(jndiName);
}
public Queue getQueue(QueueSession session, String name)
throws Exception
{
return (Queue)context.lookup(name);
}
public Topic getTopic(TopicSession session, String name)
throws Exception
{
return (Topic)context.lookup(name);
}
}
1.1 xml-axis/java/src/org/apache/axis/components/jms/SonicMQVendorAdapter.java
Index: SonicMQVendorAdapter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001, 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.axis.components.jms;
import java.util.HashMap;
import javax.jms.ConnectionFactory;
import javax.jms.QueueConnectionFactory;
import javax.jms.TopicConnectionFactory;
/**
* Defines SonicMQ specific constants for connnection factory creation.
* Overrides methods in BeanVendorAdapter to fill in MQ classnames
*
* @author Jaime Meritt (jmeritt@sonicsoftware.com)
*/
public class SonicMQVendorAdapter extends BeanVendorAdapter
{
private final static String QCF_CLASS =
"progress.message.jclient.QueueConnectionFactory";
private final static String TCF_CLASS =
"progress.message.jclient.TopicConnectionFactory";
/**
* <code>SonicConnectionFactory</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.
* The value must be a <code>java.lang.String</code>
* See the SonicMQ documentation for information on this property
*/
public final static String BROKER_URL = "brokerURL";
/**
* <code>SonicConnectionFactory</code> parameter valid for either domains. 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 secure brokers.
* The value must be a <code>java.lang.String</code>
* See the SonicMQ documentation for information on this property
*/
public final static String DEFAULT_USERNAME = "defaultUser";
/**
* <code>SonicConnectionFactory</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 secure brokers.
* The value must be a <code>java.lang.String</code>
* See the SonicMQ documentation for information on this property
*/
public final static String DEFAULT_PASSWORD = "defaultPassword";
/**
* <code>SonicConnectionFactory</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>
* The value must be a <code>java.lang.Long</code>
* See the SonicMQ documentation for information on this property
*/
public final static String PING_INTERVAL = "pingIntervalLong";
/**
* <code>SonicConnectionFactory</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>
* The value must be a <code>java.lang.Integer</code>
* See the SonicMQ documentation for information on this property
*/
public final static String RECONNECT_INTERVAL = "reconnectIntervalInteger";
/**
* <code>SonicConnectionFactory</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>
* The value must be a <code>java.lang.Integer</code>
* See the SonicMQ documentation for information on this property
*/
public final static String RECONNECT_TIMEOUT = "reconnectTimeoutInteger";
/**
* <code>SonicConnectionFactory</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>
* The value must be a <code>java.lang.String</code>
* See the SonicMQ documentation for information on this property
*/
public final static String CONNECT_ID = "connectID";
/**
* <code>SonicConnectionFactory</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>
* The value must be a <code>java.lang.String</code>
* See the SonicMQ documentation for information on this property
*/
public final static String CONNECTION_URLS = "connectionURLs";
/**
* <code>SonicConnectionFactory</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>
* The value must be a <code>java.lang.Boolean</code>
* See the SonicMQ documentation for information on this property
*/
public final static String LOAD_BALANCING = "loadBalancingBoolean";
/**
* <code>SonicConnectionFactory</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>
* The value must be a <code>java.lang.Long</code>
* See the SonicMQ documentation for information on this property
*/
public final static String MONITOR_INTERVAL = "monitorInterval";
/**
* <code>SonicConnectionFactory</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>
* The value must be a <code>java.lang.Boolean</code>
* See the SonicMQ documentation for information on this property
*/
public final static String PERSISTENT_DELIVERY = "persistentDeliveryBoolean";
/**
* <code>SonicConnectionFactory</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>
* The value must be a <code>java.lang.Boolean</code>
* See the SonicMQ documentation for information on this property
*/
public final static String SEQUENTIAL = "sequentialBoolean";
/**
* <code>SonicConnectionFactory</code> parameter valid for the PTP domain. This should
* be used as a key in the environment map passed into calls to
* <code>createConnector</code> in <code>JMSConnectorFactory</code>
* The value must be a <code>java.lang.Integer</code>
* See the SonicMQ documentation for information on this property
*/
public final static String PREFETCH_COUNT = "prefetchCountInteger";
/**
* <code>SonicConnectionFactory</code> parameter valid for the PTP domain. This should
* be used as a key in the environment map passed into calls to
* <code>createConnector</code> in <code>JMSConnectorFactory</code>
* The value must be a <code>java.lang.Integer</code>
* See the SonicMQ documentation for information on this property
*/
public final static String PREFETCH_THRESHOLD = "prefetchThresholdInteger";
/**
* <code>SonicConnectionFactory</code> parameter valid for the PubSub domain. This should
* be used as a key in the environment map passed into calls to
* <code>createConnector</code> in <code>JMSConnectorFactory</code>
* The value must be a <code>java.lang.Boolean</code>
* See the SonicMQ documentation for information on this property
*/
public final static String SELECTOR_AT_BROKER = "selectorAtBroker";
public QueueConnectionFactory getQueueConnectionFactory(HashMap cfConfig)
throws Exception
{
cfConfig = (HashMap)cfConfig.clone();
cfConfig.put(CONNECTION_FACTORY_CLASS, QCF_CLASS);
return super.getQueueConnectionFactory(cfConfig);
}
public TopicConnectionFactory getTopicConnectionFactory(HashMap cfConfig)
throws Exception
{
cfConfig = (HashMap)cfConfig.clone();
cfConfig.put(CONNECTION_FACTORY_CLASS, TCF_CLASS);
return super.getTopicConnectionFactory(cfConfig);
}
}
1.2 +26 -36 xml-axis/java/src/org/apache/axis/transport/jms/JMSConnector.java
Index: JMSConnector.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/jms/JMSConnector.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JMSConnector.java 17 Sep 2002 16:50:35 -0000 1.1
+++ JMSConnector.java 24 Sep 2002 23:47:01 -0000 1.2
@@ -78,6 +78,8 @@
import javax.naming.Context;
import javax.naming.NamingException;
+import org.apache.axis.components.jms.JMSVendorAdapter;
+
// No vendor dependent exception classes
//import progress.message.client.EUserAlreadyConnected;
//import progress.message.jclient.ErrorCodes;
@@ -95,16 +97,16 @@
*/
public abstract class JMSConnector
{
- protected int m_numRetries;
- protected long m_connectRetryInterval;
- protected long m_interactRetryInterval;
- protected long m_timeoutTime;
- protected long m_poolTimeout;
- protected AsyncConnection m_receiveConnection;
- protected SyncConnection m_sendConnection;
- protected int m_numSessions;
- protected boolean m_allowReceive;
- private Context m_context;
+ protected int m_numRetries;
+ protected long m_connectRetryInterval;
+ protected long m_interactRetryInterval;
+ protected long m_timeoutTime;
+ protected long m_poolTimeout;
+ protected AsyncConnection m_receiveConnection;
+ protected SyncConnection m_sendConnection;
+ protected int m_numSessions;
+ protected boolean m_allowReceive;
+ protected JMSVendorAdapter m_adapter;
public JMSConnector(ConnectionFactory connectionFactory,
int numRetries,
@@ -116,7 +118,7 @@
String clientID,
String username,
String password,
- Context context)
+ JMSVendorAdapter adapter)
throws JMSException
{
m_numRetries = numRetries;
@@ -126,7 +128,7 @@
m_poolTimeout = timeoutTime/(long)numRetries;
m_numSessions = numSessions;
m_allowReceive = allowReceive;
- m_context = context;
+ m_adapter = adapter;
// try to connect initially so we can fail fast
// in the case of irrecoverable errors.
@@ -204,19 +206,7 @@
m_receiveConnection.shutdown();
}
- public JMSEndpoint createEndpoint(String destinationName)
- throws JMSException, NamingException
- {
- if(m_context == null)
- return internalCreateEndpoint(destinationName);
- else
- {
- Destination destination = (Destination)m_context.lookup(destinationName);
- return createEndpoint(destination);
- }
- }
-
- protected abstract JMSEndpoint internalCreateEndpoint(String destinationName)
+ public abstract JMSEndpoint createEndpoint(String destinationName)
throws JMSException;
public abstract JMSEndpoint createEndpoint(Destination destination)
@@ -325,7 +315,7 @@
{
internalOnConnect();
}
- catch(JMSException e)
+ catch(Exception e)
{
// insert code to handle non recoverable errors
// simply retry
@@ -397,7 +387,7 @@
}
private final void internalOnConnect()
- throws JMSException
+ throws Exception
{
onConnect();
synchronized(m_lifecycleLock)
@@ -416,7 +406,7 @@
try { m_connection.close(); } catch(Throwable e) { } // ignore
}
- protected abstract void onConnect()throws JMSException;
+ protected abstract void onConnect()throws Exception;
protected abstract void onShutdown();
protected abstract void onException();
}
@@ -475,7 +465,7 @@
}
byte[] call(JMSEndpoint endpoint, byte[] message, long timeout, HashMap properties)
- throws JMSException
+ throws Exception
{
long timeoutTime = System.currentTimeMillis() + timeout;
while(true)
@@ -528,7 +518,7 @@
/** @todo add in handling for security exceptions
* @todo add support for timeouts */
void send(JMSEndpoint endpoint, byte[] message, HashMap properties)
- throws JMSException
+ throws Exception
{
long timeoutTime = System.currentTimeMillis() + m_timeoutTime;
while(true)
@@ -654,7 +644,7 @@
throws JMSException;
void send(JMSEndpoint endpoint, byte[] message, HashMap properties)
- throws JMSException
+ throws Exception
{
BytesMessage jmsMessage = m_session.createBytesMessage();
jmsMessage.writeBytes(message);
@@ -678,7 +668,7 @@
byte[] call(JMSEndpoint endpoint, byte[] message, long timeout,
HashMap properties)
- throws JMSException
+ throws Exception
{
Destination reply = createTemporaryDestination();
MessageConsumer subscriber = createConsumer(reply);
@@ -802,7 +792,7 @@
protected abstract ListenerSession createListenerSession(
javax.jms.Connection connection,
Subscription subscription)
- throws JMSException;
+ throws Exception;
protected void onShutdown()
{
@@ -829,7 +819,7 @@
* @param subscription
*/
void subscribe(Subscription subscription)
- throws JMSException
+ throws Exception
{
long timeoutTime = System.currentTimeMillis() + m_timeoutTime;
synchronized(m_subscriptionLock)
@@ -926,7 +916,7 @@
}
protected void onConnect()
- throws JMSException
+ throws Exception
{
synchronized(m_subscriptionLock)
{
@@ -968,7 +958,7 @@
ListenerSession(Session session,
MessageConsumer consumer,
Subscription subscription)
- throws JMSException
+ throws Exception
{
super(session);
m_subscription = subscription;
1.2 +14 -79 xml-axis/java/src/org/apache/axis/transport/jms/JMSConnectorFactory.java
Index: JMSConnectorFactory.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/jms/JMSConnectorFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JMSConnectorFactory.java 17 Sep 2002 16:50:35 -0000 1.1
+++ JMSConnectorFactory.java 24 Sep 2002 23:47:01 -0000 1.2
@@ -66,12 +66,8 @@
import javax.jms.TopicConnectionFactory;
import javax.jms.JMSException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.apache.axis.utils.ClassUtils;
-import org.apache.axis.utils.BeanUtils;
-import org.apache.axis.utils.BeanPropertyDescriptor;
+import org.apache.axis.components.jms.JMSVendorAdapterFactory;
+import org.apache.axis.components.jms.JMSVendorAdapter;
/**
* JMSConnectorFactory is a factory class for creating JMSConnectors. It can
@@ -159,90 +155,29 @@
String clientID = MapUtils.removeStringProperty(connectorConfig,
JMSConstants.CLIENT_ID,
null);
+ String domain = MapUtils.removeStringProperty(connectorConfig,
+ JMSConstants.DOMAIN,
+ JMSConstants.DOMAIN_DEFAULT);
if(cfConfig == null)
throw new IllegalArgumentException("noCfConfig");
- ConnectionFactory factory = null;
- Context context = null;
- if(cfConfig.containsKey(JMSConstants.CONNECTION_FACTORY_JNDI_NAME))
- {
- context = getContext(cfConfig);
- factory = getConnectionFactoryFromJNDI(cfConfig, context);
- }
- else if(cfConfig.containsKey(JMSConstants.CONNECTION_FACTORY_CLASS))
+ JMSVendorAdapter adapter = JMSVendorAdapterFactory.getJMSVendorAdapter();
+ if(domain.equals(JMSConstants.DOMAIN_QUEUE))
{
- factory = getConnectionFactoryFromBean(cfConfig);
- }
- else
- throw new IllegalArgumentException("invalidCfConfig");
-
- if(factory instanceof QueueConnectionFactory)
- {
- return new QueueConnector((QueueConnectionFactory)factory,
+ return new QueueConnector(adapter.getQueueConnectionFactory(cfConfig),
numRetries, numSessions, connectRetryInterval,
interactRetryInterval, timeoutTime,
- allowReceive, clientID, username, password, context);
+ allowReceive, clientID, username, password,
+ adapter);
}
- else // (factory instanceof TopicConnectionFactory)
+ else // domain is Topic
{
- return new TopicConnector((TopicConnectionFactory)factory,
+ return new TopicConnector(adapter.getTopicConnectionFactory(cfConfig),
numRetries, numSessions, connectRetryInterval,
interactRetryInterval, timeoutTime,
- allowReceive, clientID, username, password, context);
+ allowReceive, clientID, username, password,
+ adapter);
}
}
-
- private static ConnectionFactory getConnectionFactoryFromBean(HashMap cfConfig)
- throws Exception
- {
- String classname = (String)cfConfig.get(JMSConstants.CONNECTION_FACTORY_CLASS);
- Class factoryClass = ClassUtils.forName(classname);
- ConnectionFactory factory = (ConnectionFactory)factoryClass.newInstance();
- callSetters(cfConfig, factoryClass, factory);
- return factory;
-
- }
-
- private static Context getContext(HashMap cfConfig)
- throws Exception
- {
- Hashtable environment = new Hashtable(cfConfig);
- return new InitialContext(environment);
- }
-
- private static ConnectionFactory getConnectionFactoryFromJNDI(HashMap cfConfig, Context context)
- throws Exception
- {
- String jndiName = (String)cfConfig.get(JMSConstants.CONNECTION_FACTORY_JNDI_NAME);
- return (ConnectionFactory)context.lookup(jndiName);
- }
-
- private static void callSetters(HashMap cfConfig,
- Class factoryClass,
- ConnectionFactory factory)
- throws Exception
- {
- BeanPropertyDescriptor[] bpd = BeanUtils.getPd(factoryClass);
- for(int i = 0; i < bpd.length; i++)
- {
- BeanPropertyDescriptor thisBPD = bpd[i];
- String propName = thisBPD.getName();
- if(cfConfig.containsKey(propName))
- {
- Object value = cfConfig.get(propName);
- String validType = thisBPD.getType().getName();
- if(!value.getClass().getName().equals(validType))
- throw new IllegalArgumentException("badType");
- if(!thisBPD.isWriteable())
- throw new IllegalArgumentException("notWriteable");
- if(thisBPD.isIndexed())
- throw new IllegalArgumentException("noIndexedSupport");
- thisBPD.set(factory, value);
- }
- }
- }
-
-
-
}
1.2 +7 -5 xml-axis/java/src/org/apache/axis/transport/jms/JMSConstants.java
Index: JMSConstants.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/jms/JMSConstants.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JMSConstants.java 17 Sep 2002 16:50:35 -0000 1.1
+++ JMSConstants.java 24 Sep 2002 23:47:01 -0000 1.2
@@ -89,7 +89,7 @@
final static String WAIT_FOR_RESPONSE = "transport.jms.WaitForResponse";
/**
- * <code>SonicConnectionFactory</code> parameter valid for either domain. This should
+ * <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.
@@ -102,11 +102,13 @@
final static String CONNECTOR = "transport.jms.Connector";
- final static String CONNECTION_FACTORY_CLASS =
- "transport.jms.ConnectionFactoryClass";
+ final static String DOMAIN = "transport.jms.Domain";
- final static String CONNECTION_FACTORY_JNDI_NAME =
- "transport.jms.ConnectionFactoryJNDIName";
+ 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>send</code> and <code>call</code>
1.2 +7 -7 xml-axis/java/src/org/apache/axis/transport/jms/JMSEndpoint.java
Index: JMSEndpoint.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/jms/JMSEndpoint.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JMSEndpoint.java 17 Sep 2002 16:50:35 -0000 1.1
+++ JMSEndpoint.java 24 Sep 2002 23:47:01 -0000 1.2
@@ -79,7 +79,7 @@
}
abstract Destination getDestination(Session session)
- throws JMSException;
+ throws Exception;
/**
* Send a message and wait for a response.
@@ -89,7 +89,7 @@
* @return
* @throws JMSException
*/
- public byte[] call(byte[] message, long timeout)throws JMSException
+ public byte[] call(byte[] message, long timeout)throws Exception
{
return m_connector.getSendConnection().call(this, message, timeout, null);
}
@@ -104,7 +104,7 @@
* @throws JMSException
*/
public byte[] call(byte[] message, long timeout, HashMap properties)
- throws JMSException
+ throws Exception
{
if(properties != null)
properties = (HashMap)properties.clone();
@@ -117,7 +117,7 @@
* @param message
* @throws JMSException
*/
- public void send(byte[] message)throws JMSException
+ public void send(byte[] message)throws Exception
{
m_connector.getSendConnection().send(this, message, null);
}
@@ -130,7 +130,7 @@
* @throws JMSException
*/
public void send(byte[] message, HashMap properties)
- throws JMSException
+ throws Exception
{
if(properties != null)
properties = (HashMap)properties.clone();
@@ -144,7 +144,7 @@
* @throws JMSException
*/
public void registerListener(MessageListener listener)
- throws JMSException
+ throws Exception
{
m_connector.getReceiveConnection().subscribe(createSubscription(listener, null));
}
@@ -157,7 +157,7 @@
* @throws JMSException
*/
public void registerListener(MessageListener listener, HashMap properties)
- throws JMSException
+ throws Exception
{
if(properties != null)
properties = (HashMap)properties.clone();
1.2 +9 -9 xml-axis/java/src/org/apache/axis/transport/jms/QueueConnector.java
Index: QueueConnector.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/jms/QueueConnector.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- QueueConnector.java 17 Sep 2002 16:50:35 -0000 1.1
+++ QueueConnector.java 24 Sep 2002 23:47:01 -0000 1.2
@@ -72,10 +72,10 @@
import javax.jms.JMSException;
import javax.jms.Destination;
-import javax.naming.Context;
-
import java.util.HashMap;
+import org.apache.axis.components.jms.JMSVendorAdapter;
+
/**
* QueueConnector is a concrete JMSConnector subclass that specifically handles
* connections to queues (ptp domain).
@@ -97,15 +97,15 @@
String clientID,
String username,
String password,
- Context context)
+ JMSVendorAdapter adapter)
throws JMSException
{
super(factory, numRetries, numSessions, connectRetryInterval,
interactRetryInterval, timeoutTime, allowReceive, clientID,
- username, password, context);
+ username, password, adapter);
}
- protected JMSEndpoint internalCreateEndpoint(String destination)
+ public JMSEndpoint createEndpoint(String destination)
{
return new QueueEndpoint(destination);
}
@@ -160,9 +160,9 @@
}
private Queue createQueue(QueueSession session, String subject)
- throws JMSException
+ throws Exception
{
- return session.createQueue(subject);
+ return m_adapter.getQueue(session, subject);
}
private QueueReceiver createReceiver(QueueSession session,
@@ -248,7 +248,7 @@
}
Destination getDestination(Session session)
- throws JMSException
+ throws Exception
{
return createQueue((QueueSession)session, m_queueName);
}
@@ -321,7 +321,7 @@
protected ListenerSession createListenerSession(javax.jms.Connection connection,
Subscription subscription)
- throws JMSException
+ throws Exception
{
QueueSession session = createQueueSession((QueueConnection)connection,
subscription.m_ackMode);
1.4 +53 -38 xml-axis/java/src/org/apache/axis/transport/jms/SimpleJMSListener.java
Index: SimpleJMSListener.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/jms/SimpleJMSListener.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SimpleJMSListener.java 18 Sep 2002 16:10:42 -0000 1.3
+++ SimpleJMSListener.java 24 Sep 2002 23:47:01 -0000 1.4
@@ -58,8 +58,12 @@
import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.BufferedInputStream;
+import java.io.IOException;
import java.util.HashMap;
+import java.util.Properties;
import javax.jms.MessageListener;
import javax.jms.BytesMessage;
@@ -76,8 +80,10 @@
import org.apache.axis.utils.Options;
import org.apache.commons.logging.Log;
+
import org.apache.axis.components.logger.LogFactory;
+
/**
* SimpleJMSListener implements the javax.jms.MessageListener interface. Its
* basic purpose is listen asynchronously for messages and to pass them off
@@ -97,52 +103,32 @@
LogFactory.getLog(SimpleJMSListener.class.getName());
// Do we use (multiple) threads to process incoming messages?
- private static boolean doThreads = true;
+ private static boolean doThreads;
private JMSConnector connector;
private JMSEndpoint endpoint;
private AxisServer server;
- public SimpleJMSListener(Options options)
+ public SimpleJMSListener(HashMap connectorMap, HashMap cfMap,
+ String destination, String username,
+ String password, boolean doThreads)
throws Exception
{
- HashMap cfMap = new HashMap();
- cfMap.put(SonicConstants.BROKER_URL, options.isValueSet('b'));
-
- // do we have a jndi name?
- String jndiName = options.isValueSet('n');
- if (jndiName != null) {
- cfMap.put(JMSConstants.CONNECTION_FACTORY_JNDI_NAME, jndiName);
- } else {
- // topics or queues?
- String cf = null;
- if (options.isFlagSet('t') > 0) {
- cf = SonicConstants.TCF_CLASS;
- } else {
- cf = SonicConstants.QCF_CLASS;
- }
- cfMap.put(JMSConstants.CONNECTION_FACTORY_CLASS, cf);
- }
-
- // single-threaded?
- if (options.isFlagSet('s') > 0) {
- doThreads = false;
- }
+ this.doThreads = doThreads;
try {
connector = JMSConnectorFactory.
- createServerConnector(null,
+ createServerConnector(connectorMap,
cfMap,
- options.getUser(),
- options.getPassword());
+ username,
+ password);
} catch (Exception e) {
log.error(Messages.getMessage("exception00"), e);
throw e;
}
// create the appropriate endpoint for the indicated destination
- endpoint = connector.createEndpoint(options.isValueSet('d'));
- endpoint.registerListener(this);
+ endpoint = connector.createEndpoint(destination);
}
// Axis server (shared between instances)
@@ -188,26 +174,58 @@
}
public void start()
+ throws Exception
{
+ endpoint.registerListener(this);
connector.start();
}
public void shutdown()
+ throws Exception
{
+ endpoint.unregisterListener(this);
connector.stop();
connector.shutdown();
}
+ public static final HashMap createConnectorMap(Options options)
+ {
+ HashMap connectorMap = new HashMap();
+ if (options.isFlagSet('t') > 0)
+ {
+ //queue is default so only setup map if topic domain is required
+ connectorMap.put(JMSConstants.DOMAIN, JMSConstants.DOMAIN_TOPIC);
+ }
+ return connectorMap;
+ }
+
+ public static final HashMap createCFMap(Options options)
+ throws IOException
+ {
+ String cfFile = options.isValueSet('c');
+ if(cfFile == null)
+ return null;
+
+ Properties cfProps = new Properties();
+ cfProps.load(new BufferedInputStream(new FileInputStream(cfFile)));
+ HashMap cfMap = new HashMap(cfProps);
+ return cfMap;
+ }
+
public static void main(String[] args) throws Exception
{
Options options = new Options(args);
// first check if we should print usage
- if ((options.isFlagSet('?') > 0) || (options.isFlagSet('h') > 0)) {
+ if ((options.isFlagSet('?') > 0) || (options.isFlagSet('h') > 0))
printUsage();
- }
- SimpleJMSListener listener = new SimpleJMSListener(options);
+ SimpleJMSListener listener = new SimpleJMSListener(createConnectorMap(options),
+ createCFMap(options),
+ options.isValueSet('d'),
+ options.getUser(),
+ options.getPassword(),
+ options.isFlagSet('s') > 0);
}
public static void printUsage()
@@ -215,15 +233,12 @@
System.out.println("Usage: SimpleJMSListener [options]");
System.out.println(" Opts: -? this message");
System.out.println();
- System.out.println(" -b brokerurl");
- System.out.println(" -u username");
- System.out.println(" -w password");
- System.out.println();
+ System.out.println(" -c connection factory properties filename");
System.out.println(" -d destination");
System.out.println(" -t topic [absence of -t indicates queue]");
System.out.println();
- System.out.println(" -n jndi name for connection factory");
- System.out.println(" [jndi name obviates need for -t option]");
+ System.out.println(" -u username");
+ System.out.println(" -w password");
System.out.println();
System.out.println(" -s single-threaded listener");
System.out.println(" [absence of option => multithreaded]");
1.2 +10 -10 xml-axis/java/src/org/apache/axis/transport/jms/TopicConnector.java
Index: TopicConnector.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/jms/TopicConnector.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TopicConnector.java 17 Sep 2002 16:50:35 -0000 1.1
+++ TopicConnector.java 24 Sep 2002 23:47:01 -0000 1.2
@@ -81,7 +81,7 @@
import javax.jms.JMSException;
import javax.jms.ExceptionListener;
-import javax.naming.Context;
+import org.apache.axis.components.jms.JMSVendorAdapter;
/**
* TopicConnector is a concrete JMSConnector subclass that specifically handles
@@ -103,12 +103,12 @@
String clientID,
String username,
String password,
- Context context)
+ JMSVendorAdapter adapter)
throws JMSException
{
super(factory, numRetries, numSessions, connectRetryInterval,
interactRetryInterval, timeoutTime, allowReceive,
- clientID, username, password, context);
+ clientID, username, password, adapter);
}
protected Connection internalConnect(ConnectionFactory connectionFactory,
@@ -150,7 +150,7 @@
clientID, username, password);
}
- protected JMSEndpoint internalCreateEndpoint(String destination)
+ public JMSEndpoint createEndpoint(String destination)
{
return new TopicEndpoint(destination);
}
@@ -178,14 +178,14 @@
}
private Topic createTopic(TopicSession session, String subject)
- throws JMSException
+ throws Exception
{
- return session.createTopic(subject);
+ return m_adapter.getTopic(session, subject);
}
private TopicSubscriber createSubscriber(TopicSession session,
TopicSubscription subscription)
- throws JMSException
+ throws Exception
{
if(subscription.isDurable())
return createDurableSubscriber(session,
@@ -241,7 +241,7 @@
protected ListenerSession createListenerSession(javax.jms.Connection connection,
Subscription subscription)
- throws JMSException
+ throws Exception
{
TopicSession session = createTopicSession((TopicConnection)connection,
subscription.m_ackMode);
@@ -257,7 +257,7 @@
TopicListenerSession(TopicSession session,
TopicSubscriber subscriber,
TopicSubscription subscription)
- throws JMSException
+ throws Exception
{
super(session, subscriber, subscription);
}
@@ -360,7 +360,7 @@
}
Destination getDestination(Session session)
- throws JMSException
+ throws Exception
{
return createTopic((TopicSession)session, m_topicName);
}