You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2008/12/31 19:38:55 UTC

svn commit: r730441 - in /activemq/camel/branches/camel-1.x: ./ components/camel-xmpp/ components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/ components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/

Author: janstey
Date: Wed Dec 31 10:38:54 2008
New Revision: 730441

URL: http://svn.apache.org/viewvc?rev=730441&view=rev
Log:
Merged revisions 730436 via svnmerge from 
https://svn.apache.org/repos/asf/activemq/camel/trunk

........
  r730436 | janstey | 2008-12-31 14:33:37 -0330 (Wed, 31 Dec 2008) | 1 line
  
  CAMEL-1209 - get xmpp working with google talk
........

Added:
    activemq/camel/branches/camel-1.x/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/GoogleTalkTest.java
      - copied unchanged from r730436, activemq/camel/trunk/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/GoogleTalkTest.java
Modified:
    activemq/camel/branches/camel-1.x/   (props changed)
    activemq/camel/branches/camel-1.x/components/camel-xmpp/pom.xml
    activemq/camel/branches/camel-1.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java
    activemq/camel/branches/camel-1.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java
    activemq/camel/branches/camel-1.x/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/UriConfigurationTest.java

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: activemq/camel/branches/camel-1.x/components/camel-xmpp/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-xmpp/pom.xml?rev=730441&r1=730440&r2=730441&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-xmpp/pom.xml (original)
+++ activemq/camel/branches/camel-1.x/components/camel-xmpp/pom.xml Wed Dec 31 10:38:54 2008
@@ -52,6 +52,12 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-core</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
 
     <dependency>
       <groupId>commons-logging</groupId>

Modified: activemq/camel/branches/camel-1.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java?rev=730441&r1=730440&r2=730441&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java Wed Dec 31 10:38:54 2008
@@ -52,6 +52,7 @@
     private String room;
     private String participant;
     private String nickname;
+    private String serviceName;
 
     public XmppEndpoint(String uri, XmppComponent component) {
         super(uri, component);
@@ -192,6 +193,14 @@
         this.nickname = nickname;
     }
 
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }    
+    
     public XMPPConnection getConnection() throws XMPPException {
         if (connection == null) {
             connection = createConnection();
@@ -207,8 +216,12 @@
     // -------------------------------------------------------------------------
     protected XMPPConnection createConnection() throws XMPPException {
         XMPPConnection connection;
-        if (port > 0) {
-            connection = new XMPPConnection(new ConnectionConfiguration(host, port));
+        if (port > 0) {            
+            if (getServiceName() == null) {
+                connection = new XMPPConnection(new ConnectionConfiguration(host, port));
+            } else {
+                connection = new XMPPConnection(new ConnectionConfiguration(host, port, getServiceName()));
+            }
         } else {
             connection = new XMPPConnection(host);
         }
@@ -270,5 +283,4 @@
     public boolean isSingleton() {
         return true;
     }
-
 }

Modified: activemq/camel/branches/camel-1.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java?rev=730441&r1=730440&r2=730441&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java Wed Dec 31 10:38:54 2008
@@ -21,6 +21,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jivesoftware.smack.Chat;
+import org.jivesoftware.smack.ChatManager;
 import org.jivesoftware.smack.MessageListener;
 import org.jivesoftware.smack.XMPPException;
 import org.jivesoftware.smack.packet.Message;
@@ -47,10 +48,11 @@
         String threadId = exchange.getExchangeId();
 
         try {
-            Chat chat = endpoint.getConnection().getChatManager().getThreadChat(threadId);
+            ChatManager chatManager = endpoint.getConnection().getChatManager();
+            Chat chat = chatManager.getThreadChat(threadId);
 
             if (chat == null) {
-                chat = endpoint.getConnection().getChatManager().createChat(getParticipant(), threadId, new MessageListener() {
+                chat = chatManager.createChat(getParticipant(), threadId, new MessageListener() {
                     public void processMessage(Chat chat, Message message) {
                         // not here to do conversation
                     }
@@ -60,7 +62,6 @@
             // TODO it would be nice if we could reuse the message from the exchange
             Message message = new Message();
             message.setTo(participant);
-            message.setFrom(endpoint.getUser());
             message.setThread(threadId);
             message.setType(Message.Type.normal);
 

Modified: activemq/camel/branches/camel-1.x/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/UriConfigurationTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/UriConfigurationTest.java?rev=730441&r1=730440&r2=730441&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/UriConfigurationTest.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/UriConfigurationTest.java Wed Dec 31 10:38:54 2008
@@ -29,7 +29,7 @@
     protected CamelContext context = new DefaultCamelContext();
 
     public void testPrivateChatConfiguration() throws Exception {
-        Endpoint endpoint = context.getEndpoint("xmpp://camel-user@localhost:123/test-user@localhost?password=secret");
+        Endpoint endpoint = context.getEndpoint("xmpp://camel-user@localhost:123/test-user@localhost?password=secret&serviceName=someCoolChat");
         assertTrue("Endpoint not an XmppEndpoint: " + endpoint, endpoint instanceof XmppEndpoint);
         XmppEndpoint xmppEndpoint = (XmppEndpoint) endpoint;
 
@@ -39,6 +39,7 @@
         assertEquals("camel-user", xmppEndpoint.getUser());
         assertEquals("test-user@localhost", xmppEndpoint.getParticipant());
         assertEquals("secret", xmppEndpoint.getPassword());
+        assertEquals("someCoolChat", xmppEndpoint.getServiceName());
     }
 
     public void testGroupChatConfiguration() throws Exception {