Author: hemapani
Date: Wed Dec 15 10:46:37 2010
New Revision: 1049485
URL: http://svn.apache.org/viewvc?rev=1049485&view=rev
Log:
Fix a bug in the XMPP transport which lead to faluires when it is loaded
Modified:
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPListener.java
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPSender.java
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientSidePacketListener.java
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConnectionFactory.java
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConstants.java
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPOutTransportInfo.java
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPPacketListener.java
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPServerCredentials.java
Modified:
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPListener.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPListener.java?rev=1049485&r1=1049484&r2=1049485&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPListener.java
(original)
+++
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPListener.java
Wed Dec 15 10:46:37 2010
@@ -19,6 +19,14 @@
package org.apache.axis2.transport.xmpp;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
@@ -39,20 +47,18 @@ import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.Roster.SubscriptionMode;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
public class XMPPListener implements TransportListener {
+
+ /**
+ Uncomment this enable XMPP logging, this is useful for testing.
+ static {
+ XMPPConnection.DEBUG_ENABLED = true;
+ }
+ **/
private static Log log = LogFactory.getLog(XMPPListener.class);
private ConfigurationContext configurationContext = null;
- private String xmppServerUsername = "";
- private String xmppServerUrl = "";
+ private XMPPServerCredentials serverCredentials;
/**
* A Map containing the connection factories managed by this,
@@ -108,21 +114,20 @@ public class XMPPListener implements Tra
}
Iterator params = pi.getParameters().iterator();
- XMPPServerCredentials serverCredentials =
- new XMPPServerCredentials();
+ serverCredentials = new XMPPServerCredentials();
while (params.hasNext()) {
Parameter param = (Parameter) params.next();
if(XMPPConstants.XMPP_SERVER_URL.equals(param.getName())){
- xmppServerUrl = (String)param.getValue();
- serverCredentials.setServerUrl(xmppServerUrl);
+
serverCredentials.setServerUrl((String)param.getValue());
}else
if(XMPPConstants.XMPP_SERVER_USERNAME.equals(param.getName())){
- xmppServerUsername = (String) param.getValue();
- serverCredentials.setAccountName(xmppServerUsername);
+
serverCredentials.setAccountName((String)param.getValue());
}else
if(XMPPConstants.XMPP_SERVER_PASSWORD.equals(param.getName())){
serverCredentials.setPassword((String)param.getValue());
}else
if(XMPPConstants.XMPP_SERVER_TYPE.equals(param.getName())){
-
serverCredentials.setServerType((String)param.getValue());
+
serverCredentials.setServerType((String)param.getValue());
+ }else
if(XMPPConstants.XMPP_DOMAIN_NAME.equals(param.getName())){
+
serverCredentials.setDomainName((String)param.getValue());
}
}
XMPPConnectionFactory xmppConnectionFactory = new
XMPPConnectionFactory();
@@ -158,8 +163,10 @@ public class XMPPListener implements Tra
* @param ip
*/
public EndpointReference[] getEPRsForService(String serviceName, String
ip) throws AxisFault {
+ String domainName = serverCredentials.getDomainName() == null?
serverCredentials.getDomainName()
+ : serverCredentials.getServerUrl();
return new EndpointReference[]{new
EndpointReference(XMPPConstants.XMPP_PREFIX +
- xmppServerUsername +"@"+ xmppServerUrl +"/" +
serviceName)};
+ serverCredentials.getAccountName() +"@"+ domainName
+"/services/" + serviceName)};
}
Modified:
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPSender.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPSender.java?rev=1049485&r1=1049484&r2=1049485&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPSender.java
(original)
+++
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/XMPPSender.java
Wed Dec 15 10:46:37 2010
@@ -19,12 +19,15 @@
package org.apache.axis2.transport.xmpp;
-import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
+import java.util.UUID;
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAP12Version;
+import org.apache.axiom.soap.SOAPVersion;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.client.Options;
@@ -39,7 +42,8 @@ import org.apache.axis2.description.WSDL
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.axis2.transport.OutTransportInfo;
import org.apache.axis2.transport.TransportSender;
-import org.apache.axis2.transport.xmpp.util.XMPPClientSidePacketListener;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.transport.xmpp.util.XMPPClientResponseManager;
import org.apache.axis2.transport.xmpp.util.XMPPConnectionFactory;
import org.apache.axis2.transport.xmpp.util.XMPPConstants;
import org.apache.axis2.transport.xmpp.util.XMPPOutTransportInfo;
@@ -66,11 +70,14 @@ import org.jivesoftware.smack.packet.Mes
public class XMPPSender extends AbstractHandler implements TransportSender {
static Log log = null;
- XMPPConnectionFactory connectionFactory;
+
XMPPServerCredentials serverCredentials;
+ private XMPPClientResponseManager xmppClientSidePacketListener;
+ private XMPPConnectionFactory defaultConnectionFactory;
public XMPPSender() {
log = LogFactory.getLog(XMPPSender.class);
+ xmppClientSidePacketListener = new XMPPClientResponseManager();
}
public void cleanup(MessageContext msgContext) throws AxisFault {
@@ -89,20 +96,11 @@ public class XMPPSender extends Abstract
//if connection details are available from axis configuration
//use those & connect to jabber server(s)
serverCredentials = new XMPPServerCredentials();
- getConnectionDetailsFromAxisConfiguration(transportOut);
- connectionFactory = new XMPPConnectionFactory();
- connectionFactory.connect(serverCredentials);
+ getConnectionDetailsFromAxisConfiguration(transportOut);
+
+ defaultConnectionFactory = new XMPPConnectionFactory();
}
- /**
- * Extract connection details from Client options
- * @param msgCtx
- */
- private void connectUsingClientOptions(MessageContext msgCtx) throws
AxisFault{
- getConnectionDetailsFromClientOptions(msgCtx);
- connectionFactory = new XMPPConnectionFactory();
- connectionFactory.connect(serverCredentials);
- }
public void stop() {}
@@ -136,22 +134,44 @@ public class XMPPSender extends Abstract
* @throws AxisFault on error
*/
public void sendMessage(MessageContext msgCtx, String targetAddress,
+
OutTransportInfo outTransportInfo) throws AxisFault {
XMPPConnection xmppConnection = null;
XMPPOutTransportInfo xmppOutTransportInfo = null;
+ XMPPConnectionFactory connectionFactory;
//if on client side,create connection to xmpp server
- if(!msgCtx.isServerSide()){
- connectUsingClientOptions(msgCtx);
+ if(msgCtx.isServerSide()){
+ xmppOutTransportInfo =
(XMPPOutTransportInfo)msgCtx.getProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO);
+ connectionFactory =
xmppOutTransportInfo.getConnectionFactory();
+ }else{
+ getConnectionDetailsFromClientOptions(msgCtx);
+ connectionFactory = defaultConnectionFactory;
}
+ synchronized (this) {
+ xmppConnection = connectionFactory.getXmppConnection();
+ if(xmppConnection == null){
+ connectionFactory.connect(serverCredentials);
+ xmppConnection = connectionFactory.getXmppConnection();
+ }
+ }
+
Message message = new Message();
Options options = msgCtx.getOptions();
- String serviceName = XMPPUtils.getServiceName(targetAddress);
+ String serviceName = XMPPUtils.getServiceName(targetAddress);
+
+ SOAPVersion version = msgCtx.getEnvelope().getVersion();
+ if(version instanceof SOAP12Version){
+ message.setProperty(XMPPConstants.CONTENT_TYPE,
HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML+ "; action="+
msgCtx.getSoapAction());
+ }else{
+ message.setProperty(XMPPConstants.CONTENT_TYPE,
HTTPConstants.MEDIA_TYPE_TEXT_XML);
+ }
+
if (targetAddress != null) {
xmppOutTransportInfo = new
XMPPOutTransportInfo(targetAddress);
-
xmppOutTransportInfo.setConnectionFactory(connectionFactory);
+
xmppOutTransportInfo.setConnectionFactory(defaultConnectionFactory);
} else if (msgCtx.getTo() != null &&
!msgCtx.getTo().hasAnonymousAddress()) {
//TODO
@@ -159,12 +179,11 @@ public class XMPPSender extends Abstract
xmppOutTransportInfo = (XMPPOutTransportInfo)
msgCtx.getProperty(Constants.OUT_TRANSPORT_INFO);
}
-
- xmppConnection =
xmppOutTransportInfo.getConnectionFactory().getXmppConnection();
-
+ try{
if(msgCtx.isServerSide()){
message.setProperty(XMPPConstants.IS_SERVER_SIDE, new
Boolean(false));
message.setProperty(XMPPConstants.IN_REPLY_TO,
xmppOutTransportInfo.getInReplyTo());
+ message.setProperty(XMPPConstants.SEQUENCE_ID,
xmppOutTransportInfo.getSequenceID());
}else{
//message is going to be processed on server side
message.setProperty(XMPPConstants.IS_SERVER_SIDE,new
Boolean(true));
@@ -186,25 +205,21 @@ public class XMPPSender extends Abstract
handleException("Connection to XMPP Server is not
established.");
}
+
+
//initialize the chat manager using connection
ChatManager chatManager = xmppConnection.getChatManager();
- Chat chat =
chatManager.createChat(xmppOutTransportInfo.getDestinationAccount(), null);
+ Chat chat =
chatManager.createChat(xmppOutTransportInfo.getDestinationAccount(), null);
- try
- {
boolean waitForResponse =
msgCtx.getOperationContext() != null &&
WSDL2Constants.MEP_URI_OUT_IN.equals(
msgCtx.getOperationContext().getAxisOperation().getMessageExchangePattern());
- //int endOfXMLDeclaration = soapMessage.indexOf("?>");
- //String modifiedSOAPMessage =
soapMessage.substring(endOfXMLDeclaration+2);
-
OMElement msgElement;
String messageToBeSent = "";
- //TODO : need to read from a constant
-
if("xmpp/text".equals(xmppOutTransportInfo.getContentType())){
+
if(XMPPConstants.XMPP_CONTENT_TYPE_STRING.equals(xmppOutTransportInfo.getContentType())){
//if request is received from a chat client,
whole soap envelope
//should not be sent.
OMElement soapBodyEle =
msgCtx.getEnvelope().getBody();
@@ -222,12 +237,13 @@ public class XMPPSender extends Abstract
messageToBeSent = msgElement.toString();
message.setBody(messageToBeSent);
-
- XMPPClientSidePacketListener
xmppClientSidePacketListener = null;
+ String key = null;
if(waitForResponse && !msgCtx.isServerSide()){
PacketFilter filter = new
PacketTypeFilter(message.getClass());
- xmppClientSidePacketListener = new
XMPPClientSidePacketListener(msgCtx);
xmppConnection.addPacketListener(xmppClientSidePacketListener,filter);
+ key = UUID.randomUUID().toString();
+
xmppClientSidePacketListener.listenForResponse(key, msgCtx);
+ message.setProperty(XMPPConstants.SEQUENCE_ID,
key);
}
chat.sendMessage(message);
@@ -236,24 +252,22 @@ public class XMPPSender extends Abstract
//If this is on client side, wait for the response from
server.
//Is this the best way to do this?
if(waitForResponse && !msgCtx.isServerSide()){
- //TODO : need to add a timeout
- while(!
xmppClientSidePacketListener.isResponseReceived()){
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- log.debug("Sleep
interrupted",e);
- }
- }
- xmppConnection.disconnect();
+ xmppClientSidePacketListener.waitFor(key);
+ //xmppConnection.disconnect();
+ log.debug("Received response sucessfully");
}
+
} catch (XMPPException e) {
log.error("Error occurred while sending the message :
"+message.toXML(),e);
handleException("Error occurred while sending the
message : "+message.toXML(),e);
- }finally{
- if(!msgCtx.isServerSide()){
- xmppConnection.disconnect();
- }
+ } catch (InterruptedException e) {
+ log.error("Error occurred while sending the message :
"+message.toXML(),e);
+ handleException("Error occurred while sending the message :
"+message.toXML(),e);
+ }finally{
+// if(xmppConnection != null && !msgCtx.isServerSide()){
+// xmppConnection.disconnect();
+// }
}
}
@@ -360,7 +374,7 @@ public class XMPPSender extends Abstract
* @return
*/
private static String prepareServicesList(MessageContext msgCtx) {
- HashMap services =
msgCtx.getConfigurationContext().getAxisConfiguration().getServices();
+ Map services =
msgCtx.getConfigurationContext().getAxisConfiguration().getServices();
StringBuffer sb = new StringBuffer();
if(services != null && services.size() > 0){
Iterator itrServiceNames =
services.keySet().iterator();
@@ -415,6 +429,8 @@ public class XMPPSender extends Abstract
ChatManager chatManager = xmppConnection.getChatManager();
Chat chat =
chatManager.createChat(xmppOutTransportInfo.getDestinationAccount(), null);
try{
+ message.setProperty(XMPPConstants.SEQUENCE_ID,
+ xmppOutTransportInfo.getSequenceID());
message.setBody(responseMsg);
chat.sendMessage(message);
log.debug("Sent message :"+message.toXML());
@@ -448,7 +464,12 @@ public class XMPPSender extends Abstract
Parameter serverType =
transportOut.getParameter(XMPPConstants.XMPP_SERVER_TYPE);
if (serverType != null) {
serverCredentials.setServerType(Utils.getParameterValue(serverType));
- }
+ }
+
+ Parameter domainName =
transportOut.getParameter(XMPPConstants.XMPP_DOMAIN_NAME);
+ if (serverUrl != null) {
+
serverCredentials.setDomainName(Utils.getParameterValue(domainName));
+ }
}
}
@@ -482,4 +503,4 @@ public class XMPPSender extends Abstract
log.error(msg);
throw new AxisFault(msg);
}
-}
\ No newline at end of file
+}
Modified:
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientSidePacketListener.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientSidePacketListener.java?rev=1049485&r1=1049484&r2=1049485&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientSidePacketListener.java
(original)
+++
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPClientSidePacketListener.java
Wed Dec 15 10:46:37 2010
@@ -19,6 +19,9 @@
package org.apache.axis2.transport.xmpp.util;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
import org.apache.axis2.context.MessageContext;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.logging.Log;
@@ -27,9 +30,6 @@ import org.jivesoftware.smack.PacketList
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
public class XMPPClientSidePacketListener implements PacketListener {
private static Log log =
LogFactory.getLog(XMPPClientSidePacketListener.class);
private MessageContext messageContext = null;
@@ -39,7 +39,9 @@ public class XMPPClientSidePacketListene
this.messageContext = messageContext;
}
- /**
+
+
+ /**
* This method will be triggered, when a message is arrived at client
side
*/
public void processPacket(Packet packet) {
Modified:
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConnectionFactory.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConnectionFactory.java?rev=1049485&r1=1049484&r2=1049485&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConnectionFactory.java
(original)
+++
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConnectionFactory.java
Wed Dec 15 10:46:37 2010
@@ -31,13 +31,14 @@ import org.jivesoftware.smack.filter.Pac
import org.jivesoftware.smack.filter.ToContainsFilter;
import java.util.HashMap;
+import java.util.Map;
public class XMPPConnectionFactory {
private static Log log = LogFactory.getLog(XMPPConnectionFactory.class);
private XMPPConnection xmppConnection = null;
private PacketFilter packetFilter = null;
- private HashMap xmppConnections = new HashMap();
-
+ private Map<String,XMPPConnectionDetails> xmppConnections = new
HashMap<String,XMPPConnectionDetails>();
+
public XMPPConnectionFactory(){}
/**
@@ -45,7 +46,7 @@ public class XMPPConnectionFactory {
* @param serverCredentials
* @throws XMPPException
*/
- public void connect(final XMPPServerCredentials serverCredentials)
throws AxisFault {
+ public XMPPConnection connect(final XMPPServerCredentials
serverCredentials) throws AxisFault {
//XMPPConnection.DEBUG_ENABLED = true;
if(XMPPConstants.XMPP_SERVER_TYPE_JABBER.equals(serverCredentials.getServerType())){
xmppConnection = new
XMPPConnection(serverCredentials.getServerUrl());
@@ -64,12 +65,12 @@ public class XMPPConnectionFactory {
}
if(xmppConnection.isConnected()){
+ String resource =
serverCredentials.getResource()+ new Object().hashCode();
if(! xmppConnection.isAuthenticated()){
try {
-
xmppConnection.login(serverCredentials.getAccountName()+"@"+
-
serverCredentials.getServerUrl(),
+
xmppConnection.login(serverCredentials.getAccountName(),
serverCredentials.getPassword(),
-
serverCredentials.getResource(),
+ resource,
true);
} catch (XMPPException e) {
try {
@@ -78,11 +79,11 @@ public class XMPPConnectionFactory {
+"@"+serverCredentials.getServerUrl()
+".Retrying in 2 secs",e);
Thread.sleep(2000);
-
xmppConnection.login(serverCredentials.getAccountName()+"@"+
-
serverCredentials.getServerUrl(),
-
serverCredentials.getPassword(),
-
serverCredentials.getResource(),
- true);
+
xmppConnection.login(serverCredentials.getAccountName(),
+ serverCredentials.getPassword(),
+ resource,
+ true);
+
} catch (InterruptedException
e1) {
log.error("Sleep
interrupted.",e1);
} catch (XMPPException e2) {
@@ -93,12 +94,9 @@ public class XMPPConnectionFactory {
}
}
//Listen for Message type packets from
specified server url
- //packetFilter = new AndFilter(new
PacketTypeFilter(Message.class),
- // new
FromContainsFilter(serverCredentials.getServerUrl()));
packetFilter = new
FromContainsFilter(serverCredentials.getServerUrl());
}
- }
-
+ }
}else
if(XMPPConstants.XMPP_SERVER_TYPE_GOOGLETALK.equals(serverCredentials.getServerType())){
ConnectionConfiguration connectionConfiguration =
new
ConnectionConfiguration(XMPPConstants.GOOGLETALK_URL
@@ -111,9 +109,6 @@ public class XMPPConnectionFactory {
,
serverCredentials.getPassword()
,serverCredentials.getResource(),
true);
- //packetFilter = new AndFilter(new
PacketTypeFilter(Message.class),
- // new
FromContainsFilter(XMPPConstants.GOOGLETALK_FROM));
- //packetFilter = new
FromContainsFilter(XMPPConstants.GOOGLETALK_FROM);
packetFilter = new
ToContainsFilter("@gmail.com");
} catch (XMPPException e1) {
@@ -129,41 +124,44 @@ public class XMPPConnectionFactory {
}
public void connectionClosedOnError(
Exception e1) {
- log.debug("Connection to
"+serverCredentials.getServerUrl()
+ log.error("Connection to
"+serverCredentials.getServerUrl()
+ " closed with error.",e1);
}
public void reconnectingIn(int seconds) {
- log.debug("Connection to
"+serverCredentials.getServerUrl()
+ log.error("Connection to
"+serverCredentials.getServerUrl()
+" failed. Reconnecting in
"+seconds+"s");
}
public void reconnectionFailed(Exception e) {
- log.debug("Reconnection to
"+serverCredentials.getServerUrl()+" failed.",e);
+ log.error("Reconnection to
"+serverCredentials.getServerUrl()+" failed.",e);
}
public void reconnectionSuccessful() {
log.debug("Reconnection to
"+serverCredentials.getServerUrl()+" successful.");
}
};
- if(xmppConnection != null){
-
xmppConnection.addConnectionListener(connectionListener);
+ if(xmppConnection != null && xmppConnection.isConnected()){
+
xmppConnection.addConnectionListener(connectionListener);
+ log.info("Connected to "
+serverCredentials.getAccountName()+ "@"
+ + serverCredentials.getServerUrl()+
"/"+ serverCredentials.getResource());
+ }else{
+ log.warn(" Not Connected to "
+serverCredentials.getAccountName()+ "@"
+ + serverCredentials.getServerUrl()+
"/"+ serverCredentials.getResource());
}
- }
-
- public XMPPConnection getConnection(String connectionIdentifier){
- return
(XMPPConnection)xmppConnections.get(connectionIdentifier);
- }
-
-
- public XMPPConnection getXmppConnection() {
return xmppConnection;
+ }
+
+ public XMPPConnection getXmppConnection(){
+ return xmppConnection;
}
- public void setXmppConnection(XMPPConnection xmppConnection) {
- this.xmppConnection = xmppConnection;
- }
public void listen(XMPPPacketListener packetListener){
xmppConnection.addPacketListener(packetListener,packetFilter);
}
public void stop() {}
+
+ public class XMPPConnectionDetails{
+ XMPPConnection connection;
+ int userCount;
+ }
}
\ No newline at end of file
Modified:
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConstants.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConstants.java?rev=1049485&r1=1049484&r2=1049485&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConstants.java
(original)
+++
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPConstants.java
Wed Dec 15 10:46:37 2010
@@ -29,6 +29,7 @@ public class XMPPConstants {
public static final String XMPP_SERVER_USERNAME =
"transport.xmpp.ServerAccountUserName";
public static final String XMPP_SERVER_PASSWORD =
"transport.xmpp.ServerAccountPassword";
public static final String XMPP_SERVER_URL = "transport.xmpp.ServerUrl";
+ public static final String XMPP_DOMAIN_NAME = "transport.xmpp.domain";
//Google talk attributes
public static final String GOOGLETALK_URL = "talk.google.com";
@@ -46,8 +47,12 @@ public class XMPPConstants {
public static final String IN_REPLY_TO = "inReplyTo";
public static final String SERVICE_NAME = "ServiceName";
public static final String ACTION = "Action";
+ public static final String CONTENT_TYPE = "ContentType";
//This is set to true, if a request message is sent through XMPPSender
//Used to distinguish messages coming from chat clients.
public static final String CONTAINS_SOAP_ENVELOPE =
"transport.xmpp.containsSOAPEnvelope";
- public static final String MESSAGE_FROM_CHAT =
"transport.xmpp.message.from.chat";
+ public static final String MESSAGE_FROM_CHAT =
"transport.xmpp.message.from.chat";
+ public static final String SEQUENCE_ID = "transport.xmpp.sequenceID";
+
+ public static final String XMPP_CONTENT_TYPE_STRING = "xmpp/text";
}
Modified:
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPOutTransportInfo.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPOutTransportInfo.java?rev=1049485&r1=1049484&r2=1049485&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPOutTransportInfo.java
(original)
+++
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPOutTransportInfo.java
Wed Dec 15 10:46:37 2010
@@ -34,6 +34,7 @@ public class XMPPOutTransportInfo implem
private String inReplyTo;
private EndpointReference from;
private XMPPConnectionFactory connectionFactory = null;
+ private String sequenceID;
public XMPPOutTransportInfo(){
@@ -80,5 +81,14 @@ public class XMPPOutTransportInfo implem
public String getContentType() {
return contentType;
- }
+ }
+
+ public String getSequenceID() {
+ return sequenceID;
+ }
+
+ public void setSequenceID(String sequenceID) {
+ this.sequenceID = sequenceID;
+ }
+
}
Modified:
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPPacketListener.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPPacketListener.java?rev=1049485&r1=1049484&r2=1049485&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPPacketListener.java
(original)
+++
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPPacketListener.java
Wed Dec 15 10:46:37 2010
@@ -21,7 +21,7 @@ package org.apache.axis2.transport.xmpp.
import java.io.ByteArrayInputStream;
import java.io.InputStream;
-import java.util.HashMap;
+import java.util.Map;
import java.util.StringTokenizer;
import java.util.concurrent.Executor;
@@ -44,6 +44,7 @@ import org.apache.axis2.description.Tran
import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.engine.AxisEngine;
import org.apache.axis2.transport.TransportUtils;
+import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.xmpp.XMPPSender;
import org.apache.axis2.util.MessageContextBuilder;
import org.apache.axis2.util.MultipleEntryHashMap;
@@ -72,7 +73,7 @@ public class XMPPPacketListener implemen
* This method gets triggered when server side gets a message
*/
public void processPacket(Packet packet) {
- log.info("Received : "+packet.toXML());
+ log.debug("Received : "+packet.toXML());
if(packet instanceof Message){
workerPool.execute(new Worker(packet));
}
@@ -112,7 +113,7 @@ public class XMPPPacketListener implemen
Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8");
msgContext.setIncomingTransportName("xmpp");
- HashMap services =
configurationContext.getAxisConfiguration()
+ Map services =
configurationContext.getAxisConfiguration()
.getServices();
AxisService axisService = (AxisService)
services.get(serviceName);
@@ -146,6 +147,7 @@ public class XMPPPacketListener implemen
if (xmppMessageId != null) {
xmppOutTransportInfo.setInReplyTo(xmppMessageId);
}
+
xmppOutTransportInfo.setSequenceID((String)message.getProperty(XMPPConstants.SEQUENCE_ID));
msgContext.setProperty(
org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
xmppOutTransportInfo);
@@ -169,7 +171,7 @@ public class XMPPPacketListener implemen
String messageBody =
StringEscapeUtils.unescapeXml(message.getBody());
if(msgContext.isServerSide()){
- log.info("Received Envelope : "+messageBody);
+ log.debug("Received Envelope : "+messageBody);
}
InputStream inputStream = new
ByteArrayInputStream(messageBody.getBytes());
@@ -177,7 +179,11 @@ public class XMPPPacketListener implemen
try {
Object obj =
message.getProperty(XMPPConstants.CONTAINS_SOAP_ENVELOPE);
if(obj != null && ((Boolean)obj).booleanValue()){
- envelope =
TransportUtils.createSOAPMessage(msgContext, inputStream, "text/xml");
+ String contentType =
(String)message.getProperty(XMPPConstants.CONTENT_TYPE);
+ if(contentType == null){
+ throw new AxisFault("Can not Find
Content type Property in the XMPP Message");
+ }
+ envelope =
TransportUtils.createSOAPMessage(msgContext, inputStream, contentType);
msgContext.setProperty(XMPPConstants.CONTAINS_SOAP_ENVELOPE, new Boolean(true));
}else{
//A text message has been received from a chat
client
@@ -332,4 +338,4 @@ public class XMPPPacketListener implemen
}
}
}
-}
\ No newline at end of file
+}
Modified:
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPServerCredentials.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPServerCredentials.java?rev=1049485&r1=1049484&r2=1049485&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPServerCredentials.java
(original)
+++
axis/axis2/java/transports/trunk/modules/xmpp/src/org/apache/axis2/transport/xmpp/util/XMPPServerCredentials.java
Wed Dec 15 10:46:37 2010
@@ -29,6 +29,7 @@ public class XMPPServerCredentials {
private String password;
private String serverType;
private String resource;
+ private String domainName;
public String getAccountName() {
return accountName;
@@ -79,6 +80,12 @@ public class XMPPServerCredentials {
this.serverType = serverType;
this.resource = resource;
}
+ public String getDomainName() {
+ return domainName;
+ }
+ public void setDomainName(String domainName) {
+ this.domainName = domainName;
+ }
}