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 as...@apache.org on 2007/06/30 08:09:58 UTC
svn commit: r552107 - in
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms:
JMSConnectionFactory.java JMSMessageReceiver.java JMSOutTransportInfo.java
JMSSender.java
Author: asankha
Date: Fri Jun 29 23:09:55 2007
New Revision: 552107
URL: http://svn.apache.org/viewvc?view=rev&rev=552107
Log:
commiting patch by Mark B. for AXIS2-2816
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConnectionFactory.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSMessageReceiver.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSOutTransportInfo.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSSender.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConnectionFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConnectionFactory.java?view=diff&rev=552107&r1=552106&r2=552107
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConnectionFactory.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSConnectionFactory.java Fri Jun 29 23:09:55 2007
@@ -122,7 +122,17 @@
* The JMS Message receiver for this connection factory
*/
private JMSMessageReceiver msgRcvr = null;
-
+ /**
+ * The actual password for the connection factory after retrieval from JNDI.
+ * If this is not supplied, the OS username will be used by default
+ */
+ private String user = null;
+ /**
+ * The actual password for the connection factory after retrieval from JNDI.
+ * If this is not supplied, the OS credentials will be used by default
+ */
+ private String pass = null;
+
/**
* Create a JMSConnectionFactory for the given Axis2 name and JNDI name
*
@@ -157,6 +167,13 @@
createInitialContext();
}
conFactory = (ConnectionFactory) context.lookup(jndiName);
+
+ if (jndiUser != null)
+ user = (String ) context.lookup(jndiUser);
+
+ if (jndiPass != null)
+ pass = (String ) context.lookup(jndiPass);
+
log.debug("Connected to the actual connection factory : " + jndiName);
}
@@ -185,8 +202,8 @@
*/
public void setJndiUser(String jndiUser) {
this.jndiUser = jndiUser;
- }
-
+ }
+
/**
* Get the JNDI name of the actual factory password
*
@@ -213,11 +230,11 @@
Connection con = null;
try {
if ((jndiUser == null) || (jndiPass == null)){
- // User the OS username and credentials
- con = conFactory.createConnection();
+ // Use the OS username and credentials
+ con = conFactory.createConnection();
} else{
// use an explicit username and password
- con = conFactory.createConnection(jndiUser, jndiPass);
+ con = conFactory.createConnection(user, pass);
}
Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(destinationJndi);
@@ -240,7 +257,7 @@
}
}
}
-
+
serviceDestinationMapping.put(destinationName, serviceName);
log.info("Mapping JNDI name : " + destinationJndi + " and JMS Destination name : " +
destinationName + " against service : " + serviceName);
@@ -289,7 +306,7 @@
public String getJndiName() {
return jndiName;
}
-
+
/**
* Get the JNDI name of the actual factory username
*
@@ -298,7 +315,7 @@
public String getJndiUser() {
return jndiUser;
}
-
+
/**
* Get the JNDI name of the actual factory password
*
@@ -307,6 +324,25 @@
public String getJndiPass() {
return jndiPass;
}
+
+
+ /**
+ * This is the real password for the connection factory after the JNDI lookup
+ *
+ * @return the real password for the connection factory after the JNDI lookup
+ */
+ public String getPass() {
+ return pass;
+ }
+
+ /**
+ * This is the real username for the connection factory after the JNDI lookup
+ *
+ * @return the eal username for the connection factory after the JNDI lookup
+ */
+ public String getUser() {
+ return user;
+ }
/**
* Get the actual underlying connection factory
@@ -357,10 +393,10 @@
try {
if ((jndiUser == null) || (jndiPass == null)){
// User the OS username and credentials
- connection = conFactory.createConnection();
+ connection = conFactory.createConnection();
} else{
// use an explicit username and password
- connection = conFactory.createConnection(jndiUser, jndiPass);
+ connection = conFactory.createConnection(user, pass);
}
} catch (JMSException e) {
handleException("Error creating a JMS connection using the " +
@@ -389,7 +425,6 @@
public void listenOnDestination(String destinationJndi) throws JMSException {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = null;
-
try {
Object o = context.lookup(destinationJndi);
destination = (Destination) o;
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSMessageReceiver.java?view=diff&rev=552107&r1=552106&r2=552107
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSMessageReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSMessageReceiver.java Fri Jun 29 23:09:55 2007
@@ -167,9 +167,16 @@
axisConf.getAxisConfiguration().getTransportOut(Constants.TRANSPORT_JMS));
// the reply is assumed to be on the JMSReplyTo destination, using
// the same incoming connection factory
- msgContext.setProperty(Constants.OUT_TRANSPORT_INFO,
- new JMSOutTransportInfo(jmsConFac.getConFactory(),
- message.getJMSReplyTo()));
+
+
+ JMSOutTransportInfo jmsOutTransportInfo;
+
+ if ((jmsConFac.getJndiUser() == null) || (jmsConFac.getJndiPass() == null))
+ jmsOutTransportInfo= new JMSOutTransportInfo(jmsConFac.getConFactory(), message.getJMSReplyTo());
+ else
+ jmsOutTransportInfo= new JMSOutTransportInfo(jmsConFac.getConFactory(), jmsConFac.getUser(), jmsConFac.getPass(), message.getJMSReplyTo());
+
+ msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, jmsOutTransportInfo);
msgContext.setServerSide(true);
msgContext.setMessageID(message.getJMSMessageID());
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSOutTransportInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSOutTransportInfo.java?view=diff&rev=552107&r1=552106&r2=552107
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSOutTransportInfo.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSOutTransportInfo.java Fri Jun 29 23:09:55 2007
@@ -35,6 +35,8 @@
private static final Log log = LogFactory.getLog(JMSOutTransportInfo.class);
private ConnectionFactory connectionFactory = null;
+ private String connectionFactoryUser = null;
+ private String connectionFactoryPassword = null;
private Destination destination = null;
private String contentType = null;
@@ -51,6 +53,19 @@
}
/**
+ * Creates an instance using the given connection factory and destination
+ *
+ * @param connectionFactory the connection factory
+ * @param dest the destination
+ */
+ JMSOutTransportInfo(ConnectionFactory connectionFactory, String connectionFactoryUser, String connectionFactoryPassword, Destination dest) {
+ this.connectionFactory = connectionFactory;
+ this.connectionFactoryUser = connectionFactoryUser;
+ this.connectionFactoryPassword = connectionFactoryPassword;
+ this.destination = dest;
+ }
+
+ /**
* Creates and instance using the given URL
*
* @param url the URL
@@ -69,6 +84,8 @@
}
connectionFactory = getConnectionFactory(context, props);
+ connectionFactoryUser = getConnectionFactoryUser(context, props);
+ connectionFactoryPassword = getConnectionFactoryPass(context, props);
destination = getDestination(context, url);
}
}
@@ -97,6 +114,50 @@
}
/**
+ * Get the referenced ConnectionFactory Username (if supplied) using the properties from the context
+ *
+ * @param context the context to use for lookup
+ * @param props the properties which contains the JNDI name of the factory username
+ * @return the connection factory username (or null if one is not in the JNDI tree)
+ */
+ private String getConnectionFactoryUser(Context context, Hashtable props) {
+ try {
+
+ String conFacJndiUser = (String) props.get(JMSConstants.CONFAC_JNDI_NAME_USER);
+ if (conFacJndiUser != null) {
+ return (String) context.lookup(conFacJndiUser);
+ } else {
+ return null;
+ }
+ } catch (NamingException e) {
+ handleException("Cannot get JMS Connection factory username with props : " + props, e);
+ }
+ return null;
+ }
+
+ /**
+ * Get the referenced ConnectionFactory Password (if supplied) using the properties from the context
+ *
+ * @param context the context to use for lookup
+ * @param props the properties which contains the JNDI name of the factory password
+ * @return the connection factory password (or null if one is not in the JNDI tree)
+ */
+ private String getConnectionFactoryPass(Context context, Hashtable props) {
+ try {
+
+ String conFacJndiPass = (String) props.get(JMSConstants.CONFAC_JNDI_NAME_PASS);
+ if (conFacJndiPass != null) {
+ return (String) context.lookup(conFacJndiPass);
+ } else {
+ return null;
+ }
+ } catch (NamingException e) {
+ handleException("Cannot get JMS Connection factory password with props : " + props, e);
+ }
+ return null;
+ }
+
+ /**
* Get the JMS destination specified by the given URL from the context
*
* @param context the Context to lookup
@@ -138,7 +199,15 @@
return connectionFactory;
}
- public void setContentType(String contentType) {
+ public String getConnectionFactoryPassword() {
+ return connectionFactoryPassword;
+ }
+
+ public String getConnectionFactoryUser() {
+ return connectionFactoryUser;
+ }
+
+ public void setContentType(String contentType) {
this.contentType = contentType;
}
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSSender.java?view=diff&rev=552107&r1=552106&r2=552107
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/jms/JMSSender.java Fri Jun 29 23:09:55 2007
@@ -86,7 +86,17 @@
Connection con = null;
try {
- con = connectionFac.createConnection();
+ String user = transportInfo.getConnectionFactoryUser();
+ String password = transportInfo.getConnectionFactoryPassword();
+
+ if ((user == null) || (password == null)){
+ // Use the OS username and credentials
+ con = connectionFac.createConnection();
+ } else{
+ // use an explicit username and password
+ con = connectionFac.createConnection(user, password);
+ }
+
Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
Message message = createJMSMessage(msgContext, session);
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org