activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r467432 - in /incubator/activemq/sandbox/activemq-xmpp: ./ src/main/java/org/apache/activemq/transport/xmpp/ src/main/resources/ src/test/java/org/apache/activemq/transport/xmpp/
Date Tue, 24 Oct 2006 18:34:44 GMT
Author: jstrachan
Date: Tue Oct 24 11:34:43 2006
New Revision: 467432

URL: http://svn.apache.org/viewvc?view=rev&rev=467432
Log:
fixes so that the Spark Jabber client can connect to ActiveMQ

Added:
    incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-info.xsd   (with props)
    incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-items.xsd   (with props)
Modified:
    incubator/activemq/sandbox/activemq-xmpp/pom.xml
    incubator/activemq/sandbox/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/ProtocolConverter.java
    incubator/activemq/sandbox/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/XmppTransport.java
    incubator/activemq/sandbox/activemq-xmpp/src/main/resources/jabber-client.xsd
    incubator/activemq/sandbox/activemq-xmpp/src/test/java/org/apache/activemq/transport/xmpp/XmppTest.java

Modified: incubator/activemq/sandbox/activemq-xmpp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/activemq-xmpp/pom.xml?view=diff&rev=467432&r1=467431&r2=467432
==============================================================================
--- incubator/activemq/sandbox/activemq-xmpp/pom.xml (original)
+++ incubator/activemq/sandbox/activemq-xmpp/pom.xml Tue Oct 24 11:34:43 2006
@@ -38,7 +38,7 @@
     <repository>
       <id>codehaus</id>
       <name>Codehaus Maven 2 Repository</name>
-      <url>https://repository.codehaus.org/</url>
+      <url>http://repository.codehaus.org/</url>
     </repository>
     <repository>
       <id>maven2-repository.dev.java.net</id>

Modified: incubator/activemq/sandbox/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/ProtocolConverter.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/ProtocolConverter.java?view=diff&rev=467432&r1=467431&r2=467432
==============================================================================
--- incubator/activemq/sandbox/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/ProtocolConverter.java
(original)
+++ incubator/activemq/sandbox/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/ProtocolConverter.java
Tue Oct 24 11:34:43 2006
@@ -26,6 +26,7 @@
 import jabber.client.Error;
 import jabber.client.Iq;
 import jabber.client.Message;
+import jabber.client.Presence;
 import jabber.iq.auth.Query;
 import org.apache.activemq.command.*;
 import org.apache.activemq.transport.xmpp.command.Handler;
@@ -34,6 +35,7 @@
 import org.apache.activemq.util.LongSequenceGenerator;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
 
 import javax.jms.JMSException;
 import java.io.PrintWriter;
@@ -147,8 +149,13 @@
     protected void onIq(final Iq iq) throws Exception {
         Object any = iq.getAny();
 
+        log.debug("Received Iq");
+
         if (any instanceof Query) {
             Query query = (Query) any;
+            if (log.isDebugEnabled()) {
+                log.debug("Iq Query: " + query.getResource() + " username: " + query.getUsername());
+            }
             if (query.getPassword() == null) {
                 Iq result = createResult(iq);
                 Query required = new Query();
@@ -159,7 +166,7 @@
                 return;
             }
 
-            connectionInfo.setClientId(query.getResource());
+            //connectionInfo.setClientId(query.getResource());
             connectionInfo.setUserName(query.getUsername());
             connectionInfo.setPassword(query.getPassword());
 
@@ -194,7 +201,82 @@
             });
 
         }
+        else if (any instanceof Presence) {
+            Presence presence = (Presence) any;
+
+            if (log.isDebugEnabled()) {
+                log.debug("Presence: " + presence.getFrom() + " showOrStatusOrPriority: "
+ presence.getShowOrStatusOrPriority());
+            }
+
+            /*
+            Iq result = createResult(iq);
+            Presence answer = new Presence();
+            answer.setFrom(transport.getFrom());
+            answer.setType("");
+            result.setAny(answer);
+            transport.marshall(result);
+            */
+
+        }
+        else if (any instanceof jabber.iq._private.Query) {
+            jabber.iq._private.Query query = (jabber.iq._private.Query) any;
+
+            if (log.isDebugEnabled()) {
+                log.debug("Private: " + query.getAny());
+            }
+
+            Iq result = createResult(iq);
+            jabber.iq._private.Query answer = new jabber.iq._private.Query();
+            result.setAny(answer);
+            transport.marshall(result);
+        }
+        else if (any instanceof jabber.iq.roster.Query) {
+            jabber.iq.roster.Query query = (jabber.iq.roster.Query) any;
+
+            if (log.isDebugEnabled()) {
+                log.debug("Roster: " + query.getItem());
+            }
+
+            Iq result = createResult(iq);
+            jabber.iq.roster.Query roster = new jabber.iq.roster.Query();
+            result.setAny(roster);
+            transport.marshall(result);
+        }
+        else if (any instanceof org.jabber.protocol.disco_items.Query) {
+            org.jabber.protocol.disco_items.Query query = (org.jabber.protocol.disco_items.Query)
any;
+
+            if (log.isDebugEnabled()) {
+                log.debug("Disco Items query node: " + query.getNode() + " item: " + query.getItem());
+            }
+
+            Iq result = createResult(iq);
+            org.jabber.protocol.disco_items.Query roster = new org.jabber.protocol.disco_items.Query();
+            result.setAny(roster);
+            transport.marshall(result);
+        }
+        else if (any instanceof org.jabber.protocol.disco_info.Query) {
+            org.jabber.protocol.disco_info.Query query = (org.jabber.protocol.disco_info.Query)
any;
+
+            if (log.isDebugEnabled()) {
+                log.debug("Disco Info query node: " + query.getNode() + " features: " + query.getFeature()
+ " identity: " + query.getIdentity());
+            }
+
+            Iq result = createResult(iq);
+            org.jabber.protocol.disco_info.Query answer = new org.jabber.protocol.disco_info.Query();
+            // TODO
+            //answer.getFeature().add(new Conference)
+
+            result.setAny(answer);
+            transport.marshall(result);
+        }
         else {
+            if (any instanceof Element) {
+                Element element = (Element) any;
+                log.warn("Unknown Id element namespace: " + element.getNamespaceURI() + "
localName: " + element.getLocalName());
+            }
+            else {
+                log.warn("Unknown Id: " + any + " of type: " + any.getClass().getName());
+            }
             Iq result = createResult(iq);
             jabber.client.Error error = new Error();
             error.setUnexpectedRequest("Don't understand: " + any.toString());

Modified: incubator/activemq/sandbox/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/XmppTransport.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/XmppTransport.java?view=diff&rev=467432&r1=467431&r2=467432
==============================================================================
--- incubator/activemq/sandbox/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/XmppTransport.java
(original)
+++ incubator/activemq/sandbox/activemq-xmpp/src/main/java/org/apache/activemq/transport/xmpp/XmppTransport.java
Tue Oct 24 11:34:43 2006
@@ -152,7 +152,7 @@
 
     @Override
     public void run() {
-        log.trace("XMPP consumer thread starting");
+        log.debug("XMPP consumer thread starting");
 
         try {
             XMLInputFactory xif = XMLInputFactory.newInstance();
@@ -251,7 +251,10 @@
         // TODO it would be preferable to use class discovery here!
         context = JAXBContext.newInstance("jabber.client" + ":jabber.server"
                 + ":jabber.iq._private" + ":jabber.iq.auth" + ":jabber.iq.gateway" + ":jabber.iq.last"
+ ":jabber.iq.oob"
-                + ":jabber.iq.pass" + ":jabber.iq.roster" + ":jabber.iq.time" + ":jabber.iq.version"
+ ":org.jabber.etherx.streams"
+                + ":jabber.iq.pass" + ":jabber.iq.roster" + ":jabber.iq.time" + ":jabber.iq.version"
+                + ":org.jabber.etherx.streams" + ":org.jabber.protocol.activity" + ":org.jabber.protocol.address"
+                + ":org.jabber.protocol.amp" + ":org.jabber.protocol.amp_errors"
+                + ":org.jabber.protocol.disco_info" + ":org.jabber.protocol.disco_items"
                 + ":ietf.params.xml.ns.xmpp_sasl" + ":ietf.params.xml.ns.xmpp_stanzas"
                 + ":ietf.params.xml.ns.xmpp_streams" + ":ietf.params.xml.ns.xmpp_tls");
 

Added: incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-info.xsd
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-info.xsd?view=auto&rev=467432
==============================================================================
--- incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-info.xsd (added)
+++ incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-info.xsd Tue Oct 24
11:34:43 2006
@@ -0,0 +1,54 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+
+<xs:schema
+    xmlns:xs='http://www.w3.org/2001/XMLSchema'
+    targetNamespace='http://jabber.org/protocol/disco#info'
+    xmlns='http://jabber.org/protocol/disco#info'
+    elementFormDefault='qualified'>
+
+  <xs:annotation>
+    <xs:documentation>
+      The protocol documented by this schema is defined in
+      JEP-0030: http://www.jabber.org/jeps/jep-0030.html
+    </xs:documentation>
+  </xs:annotation>
+
+  <xs:element name='query'>
+    <xs:complexType>
+      <xs:sequence minOccurs='0'>
+        <xs:element ref='identity' maxOccurs='unbounded'/>
+        <xs:element ref='feature' maxOccurs='unbounded'/>
+      </xs:sequence>
+      <xs:attribute name='node' type='xs:string' use='optional'/>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:element name='identity'>
+    <xs:complexType>
+      <xs:simpleContent>
+        <xs:extension base='empty'>
+          <xs:attribute name='category' type='xs:string' use='required'/>
+          <xs:attribute name='name' type='xs:string' use='optional'/>
+          <xs:attribute name='type' type='xs:string' use='required'/>
+        </xs:extension>
+      </xs:simpleContent>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:element name='feature'>
+    <xs:complexType>
+      <xs:simpleContent>
+        <xs:extension base='empty'>
+          <xs:attribute name='var' type='xs:string' use='required'/>
+        </xs:extension>
+      </xs:simpleContent>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:simpleType name='empty'>
+    <xs:restriction base='xs:string'>
+      <xs:enumeration value=''/>
+    </xs:restriction>
+  </xs:simpleType>
+
+</xs:schema>

Propchange: incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-info.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-info.xsd
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-info.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-items.xsd
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-items.xsd?view=auto&rev=467432
==============================================================================
--- incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-items.xsd (added)
+++ incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-items.xsd Tue Oct 24
11:34:43 2006
@@ -0,0 +1,51 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+
+<xs:schema
+    xmlns:xs='http://www.w3.org/2001/XMLSchema'
+    targetNamespace='http://jabber.org/protocol/disco#items'
+    xmlns='http://jabber.org/protocol/disco#items'
+    elementFormDefault='qualified'>
+
+  <xs:annotation>
+    <xs:documentation>
+      The protocol documented by this schema is defined in
+      JEP-0030: http://www.jabber.org/jeps/jep-0030.html
+    </xs:documentation>
+  </xs:annotation>
+
+  <xs:element name='query'>
+    <xs:complexType>
+      <xs:sequence minOccurs='0'>
+        <xs:element ref='item' minOccurs='0' maxOccurs='unbounded'/>
+      </xs:sequence>
+      <xs:attribute name='node' type='xs:string' use='optional'/>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:element name='item'>
+    <xs:complexType>
+      <xs:simpleContent>
+        <xs:extension base='empty'>
+          <xs:attribute name='action' use='optional'>
+            <xs:simpleType>
+              <xs:restriction base='xs:NCName'>
+                <xs:enumeration value='remove'/>
+                <xs:enumeration value='update'/>
+              </xs:restriction>
+            </xs:simpleType>
+          </xs:attribute>
+          <xs:attribute name='jid' type='xs:string' use='required'/>
+          <xs:attribute name='name' type='xs:string' use='optional'/>
+          <xs:attribute name='node' type='xs:string' use='optional'/>
+        </xs:extension>
+      </xs:simpleContent>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:simpleType name='empty'>
+    <xs:restriction base='xs:string'>
+      <xs:enumeration value=''/>
+    </xs:restriction>
+  </xs:simpleType>
+
+</xs:schema>

Propchange: incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-items.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-items.xsd
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: incubator/activemq/sandbox/activemq-xmpp/src/main/resources/disco-items.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/activemq/sandbox/activemq-xmpp/src/main/resources/jabber-client.xsd
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/activemq-xmpp/src/main/resources/jabber-client.xsd?view=diff&rev=467432&r1=467431&r2=467432
==============================================================================
--- incubator/activemq/sandbox/activemq-xmpp/src/main/resources/jabber-client.xsd (original)
+++ incubator/activemq/sandbox/activemq-xmpp/src/main/resources/jabber-client.xsd Tue Oct
24 11:34:43 2006
@@ -67,7 +67,18 @@
     </xs:complexType>
   </xs:element>
 
+
+  <xs:element name='thread'>
+    <xs:complexType>
+      <xs:simpleContent>
+        <xs:extension base='xs:NMTOKEN'/>
+      </xs:simpleContent>
+    </xs:complexType>
+  </xs:element>
+
+  <!--
   <xs:element name='thread' type='xs:NMTOKEN'/>
+  -->
 
   <xs:element name='presence'>
     <xs:complexType>

Modified: incubator/activemq/sandbox/activemq-xmpp/src/test/java/org/apache/activemq/transport/xmpp/XmppTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/activemq-xmpp/src/test/java/org/apache/activemq/transport/xmpp/XmppTest.java?view=diff&rev=467432&r1=467431&r2=467432
==============================================================================
--- incubator/activemq/sandbox/activemq-xmpp/src/test/java/org/apache/activemq/transport/xmpp/XmppTest.java
(original)
+++ incubator/activemq/sandbox/activemq-xmpp/src/test/java/org/apache/activemq/transport/xmpp/XmppTest.java
Tue Oct 24 11:34:43 2006
@@ -28,7 +28,7 @@
 public class XmppTest extends TestCase {
 
     private XmppBroker broker = new XmppBroker();
-    private boolean block = false;
+    private boolean block = true;
 
     public void testConnect() throws Exception {
         //ConnectionConfiguration config = new ConnectionConfiguration("localhost", 61222);
@@ -40,7 +40,7 @@
             XMPPConnection con = new XMPPConnection("localhost", 61222);
             con.login("amq-user", "amq-pwd");
             Chat chat = con.createChat("test@localhost");
-            for (int i = 0; i < 1000; i++) {
+            for (int i = 0; i < 10; i++) {
                 System.out.println("Sending message: " + i);
                 chat.sendMessage("Hello from Message: " + i);
             }



Mime
View raw message