Author: sumedha
Date: Sun Nov 2 18:14:34 2008
New Revision: 709998
URL: http://svn.apache.org/viewvc?rev=709998&view=rev
Log:
Fixing NPE when shutting down the XMPP transport,Fixing EPR address
Modified:
webservices/commons/trunk/modules/transport/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPListener.java
webservices/commons/trunk/modules/transport/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPSender.java
Modified:
webservices/commons/trunk/modules/transport/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPListener.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPListener.java?rev=709998&r1=709997&r2=709998&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPListener.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPListener.java
Sun Nov 2 18:14:34 2008
@@ -49,7 +49,8 @@
public class XMPPListener implements TransportListener {
private static Log log = LogFactory.getLog(XMPPListener.class);
private ConfigurationContext configurationContext = null;
- private String replyTo = "";
+ private String xmppServerUsername = "";
+ private String xmppServerUrl = "";
/**
* A Map containing the connection factories managed by this,
@@ -76,7 +77,7 @@
throws AxisFault {
log.info("Initializing XMPPListener...");
configurationContext = configurationCtx;
- initializeConnectionFactories(configurationContext,transportIn);
+ initializeConnectionFactories(transportIn);
if (connectionFactories.isEmpty()) {
log.warn("No XMPP connection factories defined." +
"Will not listen for any XMPP messages");
@@ -90,10 +91,7 @@
* @param configurationContext
* @param transportIn
*/
- private void initializeConnectionFactories(
- ConfigurationContext configurationContext,
- TransportInDescription transportIn) throws AxisFault{
-
+ private void initializeConnectionFactories(TransportInDescription
transportIn) throws AxisFault{
Iterator serversToListenOn = transportIn.getParameters().iterator();
while (serversToListenOn.hasNext()) {
Parameter connection = (Parameter) serversToListenOn.next();
@@ -112,9 +110,11 @@
while (params.hasNext()) {
Parameter param = (Parameter) params.next();
if(XMPPConstants.XMPP_SERVER_URL.equals(param.getName())){
-
serverCredentials.setServerUrl((String)param.getValue());
+ xmppServerUrl = (String)param.getValue();
+ serverCredentials.setServerUrl(xmppServerUrl);
}else
if(XMPPConstants.XMPP_SERVER_USERNAME.equals(param.getName())){
-
serverCredentials.setAccountName((String)param.getValue());
+ xmppServerUsername = (String) param.getValue();
+ serverCredentials.setAccountName(xmppServerUsername);
}else
if(XMPPConstants.XMPP_SERVER_PASSWORD.equals(param.getName())){
serverCredentials.setPassword((String)param.getValue());
}else
if(XMPPConstants.XMPP_SERVER_TYPE.equals(param.getName())){
@@ -133,7 +133,7 @@
* Stop XMPP listener & disconnect from all XMPP Servers
*/
public void stop() {
- if (!workerPool.isShutdown()) {
+ if (workerPool != null && !workerPool.isShutdown()) {
workerPool.shutdown();
}
//TODO : Iterate through all connections in connectionFactories & call
disconnect()
@@ -155,8 +155,7 @@
*/
public EndpointReference[] getEPRsForService(String serviceName, String
ip) throws AxisFault {
return new EndpointReference[]{new
EndpointReference(XMPPConstants.XMPP_PREFIX +
- replyTo + "?" + configurationContext
- .getServiceContextPath() + "/" + serviceName)};
+ xmppServerUsername +"@"+ xmppServerUrl +"/" +
serviceName)};
}
Modified:
webservices/commons/trunk/modules/transport/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPSender.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/transport/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPSender.java?rev=709998&r1=709997&r2=709998&view=diff
==============================================================================
---
webservices/commons/trunk/modules/transport/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPSender.java
(original)
+++
webservices/commons/trunk/modules/transport/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPSender.java
Sun Nov 2 18:14:34 2008
@@ -47,10 +47,12 @@
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.Message;
+import org.apache.axis2.description.AxisOperation;
public class XMPPSender extends AbstractHandler implements TransportSender {
Log log = null;
XMPPConnectionFactory connectionFactory;
+ XMPPServerCredentials serverCredentials;
public XMPPSender() {
log = LogFactory.getLog(XMPPSender.class);
@@ -71,8 +73,8 @@
TransportOutDescription transportOut) throws AxisFault {
//if connection details are available from axis configuration
//use those & connect to jabber server(s)
- XMPPServerCredentials serverCredentials = new
XMPPServerCredentials();
-
getConnectionDetailsFromAxisConfiguration(serverCredentials,transportOut);
+ serverCredentials = new XMPPServerCredentials();
+ getConnectionDetailsFromAxisConfiguration(transportOut);
connectionFactory = new XMPPConnectionFactory();
connectionFactory.connect(serverCredentials);
}
@@ -82,8 +84,7 @@
* @param msgCtx
*/
private void connectUsingClientOptions(MessageContext msgCtx) throws
AxisFault{
- XMPPServerCredentials serverCredentials = new
XMPPServerCredentials();
- getConnectionDetailsFromClientOptions(serverCredentials,msgCtx);
+ getConnectionDetailsFromClientOptions(msgCtx);
connectionFactory = new XMPPConnectionFactory();
connectionFactory.connect(serverCredentials);
}
@@ -151,11 +152,19 @@
message.setProperty(XMPPConstants.IN_REPLY_TO,
xmppOutTransportInfo.getInReplyTo());
}else{
xmppConnection =
xmppOutTransportInfo.getConnectionFactory().getXmppConnection();
- message.setProperty(XMPPConstants.IS_SERVER_SIDE, new
Boolean(true));
+ message.setProperty(XMPPConstants.IS_SERVER_SIDE,new
Boolean(true));
message.setProperty(XMPPConstants.SERVICE_NAME,
serviceName);
- message.setProperty(XMPPConstants.ACTION,
options.getAction());
- }
-
+ String action = options.getAction();
+ if (action == null) {
+ AxisOperation axisOperation =
msgCtx.getAxisOperation();
+ if (axisOperation != null) {
+ action = axisOperation.getSoapAction();
+ }
+ }
+ if (action != null) {
+ message.setProperty(XMPPConstants.ACTION,
action);
+ }
+ }
if(xmppConnection == null){
handleException("Connection to XMPP Server is not
established.");
}
@@ -220,9 +229,8 @@
* @param serverCredentials
* @param transportOut
*/
- private void
getConnectionDetailsFromAxisConfiguration(XMPPServerCredentials
serverCredentials,
- TransportOutDescription transportOut){
- if(transportOut != null){
+ private void
getConnectionDetailsFromAxisConfiguration(TransportOutDescription transportOut){
+ if(transportOut != null){
Parameter serverUrl =
transportOut.getParameter(XMPPConstants.XMPP_SERVER_URL);
if (serverUrl != null) {
serverCredentials.setServerUrl(Utils.getParameterValue(serverUrl));
@@ -250,9 +258,8 @@
* @param serverCredentials
* @param msgContext
*/
- private void
getConnectionDetailsFromClientOptions(XMPPServerCredentials serverCredentials,
- MessageContext msgContext){
- Options clientOptions = msgContext.getOptions();
+ private void getConnectionDetailsFromClientOptions(MessageContext
msgContext){
+ Options clientOptions = msgContext.getOptions();
if
(clientOptions.getProperty(XMPPConstants.XMPP_SERVER_USERNAME) != null){
serverCredentials.setAccountName((String)clientOptions.getProperty(XMPPConstants.XMPP_SERVER_USERNAME));