activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r524031 - in /activemq/camel/trunk: ./ camel-xmpp/ camel-xmpp/src/ camel-xmpp/src/main/ camel-xmpp/src/main/java/ camel-xmpp/src/main/java/org/ camel-xmpp/src/main/java/org/apache/ camel-xmpp/src/main/java/org/apache/camel/ camel-xmpp/src/m...
Date Fri, 30 Mar 2007 10:22:12 GMT
Author: jstrachan
Date: Fri Mar 30 03:22:08 2007
New Revision: 524031

URL: http://svn.apache.org/viewvc?view=rev&rev=524031
Log:
added an XMPP transport

Added:
    activemq/camel/trunk/camel-xmpp/
    activemq/camel/trunk/camel-xmpp/pom.xml   (with props)
    activemq/camel/trunk/camel-xmpp/src/
    activemq/camel/trunk/camel-xmpp/src/main/
    activemq/camel/trunk/camel-xmpp/src/main/java/
    activemq/camel/trunk/camel-xmpp/src/main/java/org/
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/RuntimeXmppException.java   (with props)
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppBinding.java   (with props)
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppComponent.java   (with props)
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppConsumer.java   (with props)
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java   (with props)
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpointResolver.java   (with props)
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppExchange.java   (with props)
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java   (with props)
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppMessage.java   (with props)
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java   (with props)
    activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/package.html   (with props)
    activemq/camel/trunk/camel-xmpp/src/main/resources/
    activemq/camel/trunk/camel-xmpp/src/main/resources/META-INF/
    activemq/camel/trunk/camel-xmpp/src/main/resources/META-INF/services/
    activemq/camel/trunk/camel-xmpp/src/main/resources/META-INF/services/org/
    activemq/camel/trunk/camel-xmpp/src/main/resources/META-INF/services/org/apache/
    activemq/camel/trunk/camel-xmpp/src/main/resources/META-INF/services/org/apache/camel/
    activemq/camel/trunk/camel-xmpp/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/
    activemq/camel/trunk/camel-xmpp/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/xmpp
    activemq/camel/trunk/camel-xmpp/src/test/
    activemq/camel/trunk/camel-xmpp/src/test/java/
    activemq/camel/trunk/camel-xmpp/src/test/java/org/
    activemq/camel/trunk/camel-xmpp/src/test/java/org/apache/
    activemq/camel/trunk/camel-xmpp/src/test/java/org/apache/camel/
    activemq/camel/trunk/camel-xmpp/src/test/java/org/apache/camel/component/
    activemq/camel/trunk/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/
    activemq/camel/trunk/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/UriConfigurationTest.java   (with props)
    activemq/camel/trunk/camel-xmpp/src/test/resources/
Modified:
    activemq/camel/trunk/pom.xml

Added: activemq/camel/trunk/camel-xmpp/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/pom.xml?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/pom.xml (added)
+++ activemq/camel/trunk/camel-xmpp/pom.xml Fri Mar 30 03:22:08 2007
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-parent</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-xmpp</artifactId>
+  <name>Camel :: XMPP</name>
+  <description>Camel XMPP support</description>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>jivesoftware</groupId>
+      <artifactId>smack</artifactId>
+      <version>2.2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>jivesoftware</groupId>
+      <artifactId>smackx</artifactId>
+      <version>2.2.1</version>
+    </dependency>
+
+<!--
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring</artifactId>
+    </dependency>
+-->
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Propchange: activemq/camel/trunk/camel-xmpp/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-xmpp/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-xmpp/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/RuntimeXmppException.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/RuntimeXmppException.java?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/RuntimeXmppException.java (added)
+++ activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/RuntimeXmppException.java Fri Mar 30 03:22:08 2007
@@ -0,0 +1,37 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xmpp;
+
+import org.jivesoftware.smack.XMPPException;
+
+/**
+ * A runtime exception thrown if sending or receiving from XMPP fails
+ *
+ * @version $Revision:520964 $
+ */
+public class RuntimeXmppException extends RuntimeException {
+    private static final long serialVersionUID = -2141493732308871761L;
+
+    public RuntimeXmppException(XMPPException cause) {
+        super(cause);
+    }
+    public RuntimeXmppException(String message, XMPPException cause) {
+        super(message, cause);
+    }
+
+}

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/RuntimeXmppException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/RuntimeXmppException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/RuntimeXmppException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppBinding.java?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppBinding.java (added)
+++ activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppBinding.java Fri Mar 30 03:22:08 2007
@@ -0,0 +1,66 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xmpp;
+
+import org.jivesoftware.smack.packet.Message;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A Strategy used to convert between a Camel {@XmppExchange} and {@XmppMessage} to and from a
+ * XMPP {@link Message}
+ *
+ * @version $Revision$
+ */
+public class XmppBinding {
+    
+    /**
+     * Populates the given XMPP message from the inbound exchange
+     */
+    public void populateXmppMessage(Message message, XmppExchange exchange) {
+        message.setBody(exchange.getIn().getBody(String.class));
+
+        Set<Map.Entry<String, Object>> entries = exchange.getIn().getHeaders().entrySet();
+        for (Map.Entry<String, Object> entry : entries) {
+            String name = entry.getKey();
+            Object value = entry.getValue();
+            if (shouldOutputHeader(exchange, name, value)) {
+                message.setProperty(name, value);
+            }
+        }
+        message.setProperty("exchangeId", exchange.getExchangeId());
+    }
+
+    /**
+     * Extracts the body from the XMPP message
+     *
+     * @param exchange
+     * @param message
+     */
+    public Object extractBodyFromXmpp(XmppExchange exchange, Message message) {
+        return message.getBody();
+    }
+
+    /**
+     * Strategy to allow filtering of headers which are put on the XMPP message
+     */
+    protected boolean shouldOutputHeader(XmppExchange exchange, String headerName, Object headerValue) {
+        return true;
+    }
+}

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppBinding.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppBinding.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppComponent.java?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppComponent.java (added)
+++ activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppComponent.java Fri Mar 30 03:22:08 2007
@@ -0,0 +1,83 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xmpp;
+
+import com.sun.jndi.toolkit.url.Uri;
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.URISupport;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+
+/**
+ * @version $Revision:520964 $
+ */
+public class XmppComponent extends DefaultComponent<XmppExchange> {
+    /**
+     * Static builder method
+     */
+    public static XmppComponent xmppComponent() {
+        return new XmppComponent();
+    }
+
+    protected XmppComponent() {
+    }
+
+    public XmppComponent(CamelContext context) {
+        super(context);
+    }
+
+    public XmppEndpoint createEndpoint(Uri uri) throws URISyntaxException {
+        // lets figure out from the URI whether its a queue, topic etc
+
+        String path = uri.getPath();
+        return createEndpoint(uri.toString(), path);
+    }
+
+    public XmppEndpoint createEndpoint(String uri, String path) throws URISyntaxException {
+        ObjectHelper.notNull(getContext(), "context");
+
+        XmppEndpoint endpoint = new XmppEndpoint(uri, getContext());
+
+        URI u = new URI(uri);
+        endpoint.setHost(u.getHost());
+        endpoint.setPort(u.getPort());
+        if (u.getUserInfo() != null) {
+            endpoint.setUser(u.getUserInfo());
+        }
+        String remainingPath = u.getPath();
+        if (remainingPath != null) {
+            if (remainingPath.startsWith("/")) {
+                remainingPath = remainingPath.substring(1);
+            }
+
+            // assume its a participant
+            if (remainingPath.length() > 0) {
+                endpoint.setParticipant(remainingPath);
+            }
+        }
+
+        Map options = URISupport.parseParamters(u);
+        IntrospectionSupport.setProperties(endpoint, options);
+        return endpoint;
+    }
+}

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppComponent.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppComponent.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppConsumer.java?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppConsumer.java (added)
+++ activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppConsumer.java Fri Mar 30 03:22:08 2007
@@ -0,0 +1,80 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xmpp;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.DefaultConsumer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jivesoftware.smack.PacketListener;
+import org.jivesoftware.smack.packet.Message;
+import org.jivesoftware.smack.packet.Packet;
+import org.jivesoftware.smack.packet.RosterPacket;
+
+import java.util.Iterator;
+
+/**
+ * A {@link Consumer} which listens to XMPP packets
+ *
+ * @version $Revision$
+ */
+public class XmppConsumer extends DefaultConsumer<XmppExchange> implements PacketListener {
+    private static final transient Log log = LogFactory.getLog(XmppConsumer.class);
+    private final XmppEndpoint endpoint;
+
+    public XmppConsumer(XmppEndpoint endpoint, Processor<XmppExchange> processor) {
+        super(endpoint, processor);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        endpoint.getConnection().addPacketListener(this, endpoint.getFilter());
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        endpoint.getConnection().removePacketListener(this);
+        super.doStop();
+    }
+
+    public void processPacket(Packet packet) {
+        if (log.isDebugEnabled()) {
+            log.debug("<<<< " + packet);
+        }
+
+        if (packet instanceof Message) {
+            Message message = (Message) packet;
+            XmppExchange exchange = endpoint.createExchange(message);
+            getProcessor().onExchange(exchange);
+        }
+        else if (packet instanceof RosterPacket) {
+            RosterPacket rosterPacket = (RosterPacket) packet;
+            if (log.isDebugEnabled()) {
+                log.debug("Roster packet with : " + rosterPacket.getRosterItemCount());
+                Iterator rosterItems = rosterPacket.getRosterItems();
+                while (rosterItems.hasNext()) {
+                    Object item = rosterItems.next();
+                    log.debug("Roster item: " + item);
+                }
+            }
+        }
+    }
+}

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppConsumer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java (added)
+++ activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java Fri Mar 30 03:22:08 2007
@@ -0,0 +1,237 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xmpp;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jivesoftware.smack.AccountManager;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.filter.PacketFilter;
+import org.jivesoftware.smack.packet.Message;
+import org.jivesoftware.smack.packet.Presence;
+
+/**
+ * An XMPP Endpoint
+ *
+ * @version $Revision:520964 $
+ */
+public class XmppEndpoint extends DefaultEndpoint<XmppExchange> {
+    private static final transient Log log = LogFactory.getLog(XmppEndpoint.class);
+    private XmppBinding binding;
+    private XMPPConnection connection;
+    private String host;
+    private int port;
+    private String user;
+    private String password;
+    private String resource = "Camel";
+    private boolean login = true;
+    private PacketFilter filter;
+    private boolean createAccount;
+    private String room;
+    private String participant;
+
+    public XmppEndpoint(String uri, CamelContext context) {
+        super(uri, context);
+    }
+
+    public Producer<XmppExchange> createProducer() throws Exception {
+        if (room != null) {
+            return createGroupChatProducer(room);
+        }
+        else {
+            if (participant == null) {
+                throw new IllegalArgumentException("No room or participant configured on this endpoint: " + this);
+            }
+            return createPrivateChatProducer(participant);
+        }
+    }
+
+    public Producer<XmppExchange> createGroupChatProducer(String room) throws Exception {
+        return startService(new XmppGroupChatProducer(this, room));
+    }
+
+    public Producer<XmppExchange> createPrivateChatProducer(String participant) throws Exception {
+        return startService(new XmppPrivateChatProducer(this, participant));
+    }
+
+    public Consumer<XmppExchange> createConsumer(Processor<XmppExchange> processor) throws Exception {
+        return startService(new XmppConsumer(this, processor));
+    }
+
+    public XmppExchange createExchange() {
+        return new XmppExchange(getContext(), getBinding());
+    }
+
+    public XmppExchange createExchange(Message message) {
+        return new XmppExchange(getContext(), getBinding(), message);
+    }
+
+    // Properties
+    //-------------------------------------------------------------------------
+    public XmppBinding getBinding() {
+        if (binding == null) {
+            binding = new XmppBinding();
+        }
+        return binding;
+    }
+
+    /**
+     * Sets the binding used to convert from a Camel message to and from an XMPP message
+     *
+     * @param binding the binding to use
+     */
+    public void setBinding(XmppBinding binding) {
+        this.binding = binding;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public String getUser() {
+        return user;
+    }
+
+    public void setUser(String user) {
+        this.user = user;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getResource() {
+        return resource;
+    }
+
+    public void setResource(String resource) {
+        this.resource = resource;
+    }
+
+    public boolean isLogin() {
+        return login;
+    }
+
+    public void setLogin(boolean login) {
+        this.login = login;
+    }
+
+    public PacketFilter getFilter() {
+        return filter;
+    }
+
+    public void setFilter(PacketFilter filter) {
+        this.filter = filter;
+    }
+
+    public boolean isCreateAccount() {
+        return createAccount;
+    }
+
+    public void setCreateAccount(boolean createAccount) {
+        this.createAccount = createAccount;
+    }
+
+    public String getRoom() {
+        return room;
+    }
+
+    public void setRoom(String room) {
+        this.room = room;
+    }
+
+    public String getParticipant() {
+        return participant;
+    }
+
+    public void setParticipant(String participant) {
+        this.participant = participant;
+    }
+
+    public XMPPConnection getConnection() throws XMPPException {
+        if (connection == null) {
+            connection = createConnection();
+        }
+        return connection;
+    }
+
+    public void setConnection(XMPPConnection connection) {
+        this.connection = connection;
+    }
+
+    // Implementation methods
+    //-------------------------------------------------------------------------
+    protected XMPPConnection createConnection() throws XMPPException {
+        XMPPConnection connection;
+        if (port > 0) {
+            connection = new XMPPConnection(host, port);
+        }
+        else {
+            connection = new XMPPConnection(host);
+        }
+        if (login && !connection.isAuthenticated()) {
+            if (user != null) {
+                log.info("Logging in to XMPP as user: " + user + " on connection: " + connection);
+                if (password == null) {
+                    log.warn("No password configured for user: " + user);
+                }
+
+                if (createAccount) {
+                    AccountManager accountManager = new AccountManager(connection);
+                    accountManager.createAccount(user, password);
+                }
+                if (resource != null) {
+                    connection.login(user, password, resource);
+                }
+                else {
+                    connection.login(user, password);
+                }
+            }
+            else {
+                log.info("Logging in anonymously to XMPP on connection: " + connection);
+                connection.loginAnonymously();
+            }
+
+            // now lets send a presence
+            connection.sendPacket(new Presence(Presence.Type.AVAILABLE));
+        }
+        return connection;
+    }
+}

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpointResolver.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpointResolver.java?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpointResolver.java (added)
+++ activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpointResolver.java Fri Mar 30 03:22:08 2007
@@ -0,0 +1,87 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xmpp;
+
+import org.apache.camel.EndpointResolver;
+import org.apache.camel.Component;
+import org.apache.camel.CamelContext;
+import org.apache.camel.util.ObjectHelper;
+
+import java.net.URISyntaxException;
+import java.util.concurrent.Callable;
+
+/**
+ * An implementation of {@link EndpointResolver} that creates
+ * {@link XmppEndpoint} objects.
+ * <p/>
+ * The syntax for a XMPP URI looks like:
+ * <p/>
+ * <pre><code>xmpp:[component:]destination</code></pre>
+ * the component is optional, and if it is not specified, the default component name
+ * is assumed.
+ *
+ * @version $Revision:520964 $
+ */
+public class XmppEndpointResolver implements EndpointResolver<XmppExchange> {
+    public static final String DEFAULT_COMPONENT_NAME = XmppEndpointResolver.class.getName();
+
+    /**
+     * Finds the {@see JmsComponent} specified by the uri.  If the {@see JmsComponent}
+     * object do not exist, it will be created.
+     */
+    public Component resolveComponent(CamelContext container, String uri) {
+        String id[] = getEndpointId(uri);
+        return resolveJmsComponent(container, id[0]);
+    }
+
+    /**
+     * Finds the {@see QueueEndpoint} specified by the uri.  If the {@see QueueEndpoint} or it's associated
+     * {@see QueueComponent} object do not exist, they will be created.
+     */
+    public XmppEndpoint resolveEndpoint(CamelContext container, String uri) throws URISyntaxException {
+        String id[] = getEndpointId(uri);
+        XmppComponent component = resolveJmsComponent(container, id[0]);
+        return component.createEndpoint(uri, id[1]);
+    }
+
+    /**
+     * @return an array that looks like: [componentName,endpointName]
+     */
+    private String[] getEndpointId(String uri) {
+        String rc[] = {DEFAULT_COMPONENT_NAME, null};
+        String splitURI[] = ObjectHelper.splitOnCharacter(uri, ":", 3);
+        if (splitURI[2] != null) {
+            rc[0] = splitURI[1];
+            rc[1] = splitURI[2];
+        }
+        else {
+            rc[1] = splitURI[1];
+        }
+        return rc;
+    }
+
+    @SuppressWarnings("unchecked")
+    private XmppComponent resolveJmsComponent(final CamelContext container, final String componentName) {
+        Component rc = container.getOrCreateComponent(componentName, new Callable() {
+            public XmppComponent call() throws Exception {
+                return new XmppComponent(container);
+            }
+        });
+        return (XmppComponent) rc;
+    }
+}

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpointResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpointResolver.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpointResolver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppExchange.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppExchange.java?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppExchange.java (added)
+++ activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppExchange.java Fri Mar 30 03:22:08 2007
@@ -0,0 +1,109 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xmpp;
+
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.jivesoftware.smack.packet.Message;
+
+/**
+ * Represents an {@ilnk Exchange} for working with XMPP
+ *
+ * @version $Revision:520964 $
+ */
+public class XmppExchange extends DefaultExchange {
+    private XmppBinding binding;
+
+    public XmppExchange(CamelContext context, XmppBinding binding) {
+        super(context);
+        this.binding = binding;
+    }
+
+    public XmppExchange(CamelContext context, XmppBinding binding, Message message) {
+        this(context, binding);
+        setIn(new XmppMessage(message));
+    }
+
+    @Override
+    public XmppMessage getIn() {
+        return (XmppMessage) super.getIn();
+    }
+
+    @Override
+    public XmppMessage getOut() {
+        return (XmppMessage) super.getOut();
+    }
+
+    @Override
+    public XmppMessage getFault() {
+        return (XmppMessage) super.getFault();
+    }
+
+    public XmppBinding getBinding() {
+        return binding;
+    }
+
+    @Override
+    public Exchange newInstance() {
+        return new XmppExchange(getContext(), binding);
+    }
+
+    // Expose the underlying XMPP APIs
+    //-------------------------------------------------------------------------
+
+    /**
+     * Return the underlying XMPP In message
+     *
+     * @return the XMPP In message
+     */
+    public Message getInMessage() {
+        return getIn().getXmppMessage();
+    }
+
+    /**
+     * Return the underlying XMPP Out message
+     *
+     * @return the XMPP out message
+     */
+    public Message getOutMessage() {
+        return getOut().getXmppMessage();
+    }
+
+    /**
+     * Return the underlying XMPP Fault message
+     *
+     * @return the XMPP fault message
+     */
+    public Message getFaultMessage() {
+        return getOut().getXmppMessage();
+    }
+
+    // Implementation methods
+    //-------------------------------------------------------------------------
+
+    @Override
+    protected XmppMessage createInMessage() {
+        return new XmppMessage();
+    }
+
+    @Override
+    protected XmppMessage createOutMessage() {
+        return new XmppMessage();
+    }
+}

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppExchange.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppExchange.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppExchange.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java (added)
+++ activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java Fri Mar 30 03:22:08 2007
@@ -0,0 +1,101 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xmpp;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jivesoftware.smack.GroupChat;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.packet.Message;
+
+/**
+ * @version $Revision$
+ */
+public class XmppGroupChatProducer extends DefaultProducer<XmppExchange> {
+    private static final transient Log log = LogFactory.getLog(XmppGroupChatProducer.class);
+    private final XmppEndpoint endpoint;
+    private final String room;
+    private GroupChat chat;
+
+    public XmppGroupChatProducer(XmppEndpoint endpoint, String room) {
+        super(endpoint);
+        this.endpoint = endpoint;
+        this.room = room;
+        if (room == null) {
+            throw new IllegalArgumentException("No room property specified");
+        }
+    }
+
+    public void onExchange(Exchange exchange) {
+        // lets convert to the type of an exchange
+        XmppExchange xmppExchange = endpoint.convertTo(XmppExchange.class, exchange);
+        onExchange(xmppExchange);
+    }
+
+    public void onExchange(XmppExchange exchange) {
+        // TODO it would be nice if we could reuse the message from the exchange
+        Message message = chat.createMessage();
+        message.setTo(room);
+        message.setFrom(endpoint.getUser());
+
+        endpoint.getBinding().populateXmppMessage(message, exchange);
+        if (log.isDebugEnabled()) {
+            log.debug(">>>> " + message);
+        }
+        try {
+            chat.sendMessage(message);
+        }
+        catch (XMPPException e) {
+            throw new RuntimeXmppException(e);
+        }
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        if (chat == null) {
+            chat = endpoint.getConnection().createGroupChat(room);
+        }
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        if (chat != null) {
+            chat.leave();
+            chat = null;
+        }
+        super.doStop();
+    }
+
+    // Properties
+    //-------------------------------------------------------------------------
+    public GroupChat getChat() {
+        return chat;
+    }
+
+    public void setChat(GroupChat chat) {
+        this.chat = chat;
+    }
+
+    public String getRoom() {
+        return room;
+    }
+}

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppGroupChatProducer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppMessage.java?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppMessage.java (added)
+++ activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppMessage.java Fri Mar 30 03:22:08 2007
@@ -0,0 +1,103 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xmpp;
+
+import org.apache.camel.impl.DefaultMessage;
+import org.jivesoftware.smack.packet.Message;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * Represents a {@link org.apache.camel.Message} for working with XMPP
+ *
+ * @version $Revision:520964 $
+ */
+public class XmppMessage extends DefaultMessage {
+    private Message xmppMessage;
+
+    public XmppMessage() {
+        this(new Message());
+    }
+
+    public XmppMessage(Message jmsMessage) {
+        this.xmppMessage = jmsMessage;
+    }
+
+    @Override
+    public String toString() {
+        if (xmppMessage != null) {
+            return "XmppMessage: " + xmppMessage;
+        }
+        else {
+            return "XmppMessage: " + getBody();
+        }
+    }
+
+    @Override
+    public XmppExchange getExchange() {
+        return (XmppExchange) super.getExchange();
+    }
+
+    /**
+     * Returns the underlying XMPP message
+     *
+     * @return the underlying XMPP message
+     */
+    public Message getXmppMessage() {
+        return xmppMessage;
+    }
+
+    public void setXmppMessage(Message xmppMessage) {
+        this.xmppMessage = xmppMessage;
+    }
+
+    public Object getHeader(String name) {
+        return xmppMessage.getProperty(name);
+    }
+
+    @Override
+    public void setHeader(String name, Object value) {
+        xmppMessage.setProperty(name, value);
+    }
+
+    @Override
+    public Map<String, Object> getHeaders() {
+        Map<String, Object> answer = new HashMap<String, Object>();
+        Iterator iter = xmppMessage.getPropertyNames();
+        while (iter.hasNext()) {
+            String name = (String) iter.next();
+            answer.put(name, xmppMessage.getProperty(name));
+        }
+        return answer;
+    }
+
+    @Override
+    public XmppMessage newInstance() {
+        return new XmppMessage();
+    }
+
+    @Override
+    protected Object createBody() {
+        if (xmppMessage != null) {
+            return getExchange().getBinding().extractBodyFromXmpp(getExchange(), xmppMessage);
+        }
+        return null;
+    }
+}

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppMessage.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppMessage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java (added)
+++ activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java Fri Mar 30 03:22:08 2007
@@ -0,0 +1,100 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xmpp;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jivesoftware.smack.Chat;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.packet.Message;
+
+/**
+ * @version $Revision$
+ */
+public class XmppPrivateChatProducer extends DefaultProducer<XmppExchange> {
+    private static final transient Log log = LogFactory.getLog(XmppPrivateChatProducer.class);
+    private final XmppEndpoint endpoint;
+    private final String participant;
+    private Chat chat;
+
+    public XmppPrivateChatProducer(XmppEndpoint endpoint, String participant) {
+        super(endpoint);
+        this.endpoint = endpoint;
+        this.participant = participant;
+        if (participant == null) {
+            throw new IllegalArgumentException("No participant property specified");
+        }
+    }
+
+    public void onExchange(Exchange exchange) {
+        // lets convert to the type of an exchange
+        XmppExchange xmppExchange = endpoint.convertTo(XmppExchange.class, exchange);
+        onExchange(xmppExchange);
+    }
+
+    public void onExchange(XmppExchange exchange) {
+        // TODO it would be nice if we could reuse the message from the exchange
+        Message message = chat.createMessage();
+        message.setTo(participant);
+        message.setFrom(endpoint.getUser());
+        message.setThread(exchange.getExchangeId());
+        message.setType(Message.Type.NORMAL);
+
+        endpoint.getBinding().populateXmppMessage(message, exchange);
+        if (log.isDebugEnabled()) {
+            log.debug(">>>> " + message);
+        }
+        try {
+            chat.sendMessage(message);
+        }
+        catch (XMPPException e) {
+            throw new RuntimeXmppException(e);
+        }
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        if (chat == null) {
+            chat = endpoint.getConnection().createChat(getParticipant());
+        }
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        chat = null;
+        super.doStop();
+    }
+
+    // Properties
+    //-------------------------------------------------------------------------
+    public Chat getChat() {
+        return chat;
+    }
+
+    public void setChat(Chat chat) {
+        this.chat = chat;
+    }
+
+    public String getParticipant() {
+        return participant;
+    }
+}

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/package.html
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/package.html?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/package.html (added)
+++ activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/package.html Fri Mar 30 03:22:08 2007
@@ -0,0 +1,25 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+   
+    http://www.apache.org/licenses/LICENSE-2.0
+   
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Defines the XMPP transport for communicating over Jabber
+
+</body>
+</html>

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/package.html
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/package.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: activemq/camel/trunk/camel-xmpp/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/xmpp
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/xmpp?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/xmpp (added)
+++ activemq/camel/trunk/camel-xmpp/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/xmpp Fri Mar 30 03:22:08 2007
@@ -0,0 +1 @@
+class=org.apache.camel.component.xmpp.XmppEndpointResolver

Added: activemq/camel/trunk/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/UriConfigurationTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/UriConfigurationTest.java?view=auto&rev=524031
==============================================================================
--- activemq/camel/trunk/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/UriConfigurationTest.java (added)
+++ activemq/camel/trunk/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/UriConfigurationTest.java Fri Mar 30 03:22:08 2007
@@ -0,0 +1,58 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xmpp;
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+
+import javax.xml.namespace.QName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+
+/**
+ * @version $Revision: $
+ */
+public class UriConfigurationTest extends TestCase {
+    protected CamelContext context = new DefaultCamelContext();
+
+    public void testPrivateChatConfiguration() throws Exception {
+        Endpoint endpoint = context.resolveEndpoint("xmpp://camel-user@localhost:123/test-user@localhost");
+        assertTrue("Endpoint not an XmppEndpoint: " + endpoint, endpoint instanceof XmppEndpoint);
+        XmppEndpoint xmppEndpoint = (XmppEndpoint) endpoint;
+
+
+        assertEquals("localhost", xmppEndpoint.getHost());
+        assertEquals(123, xmppEndpoint.getPort());
+        assertEquals("camel-user", xmppEndpoint.getUser());
+        assertEquals("test-user@localhost", xmppEndpoint.getParticipant());
+    }
+
+    public void testGroupChatConfiguration() throws Exception {
+        Endpoint endpoint = context.resolveEndpoint("xmpp://camel-user@im.google.com:123?room=cheese");
+        assertTrue("Endpoint not an XmppEndpoint: " + endpoint, endpoint instanceof XmppEndpoint);
+        XmppEndpoint xmppEndpoint = (XmppEndpoint) endpoint;
+
+
+        assertEquals("im.google.com", xmppEndpoint.getHost());
+        assertEquals(123, xmppEndpoint.getPort());
+        assertEquals("camel-user", xmppEndpoint.getUser());
+        assertEquals("cheese", xmppEndpoint.getRoom());
+    }
+}

Propchange: activemq/camel/trunk/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/UriConfigurationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/UriConfigurationTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/UriConfigurationTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: activemq/camel/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/pom.xml?view=diff&rev=524031&r1=524030&r2=524031
==============================================================================
--- activemq/camel/trunk/pom.xml (original)
+++ activemq/camel/trunk/pom.xml Fri Mar 30 03:22:08 2007
@@ -115,12 +115,13 @@
     <module>camel-core</module>
     <module>camel-cxf</module>
     <module>camel-http</module>
-    <module>camel-jms</module>
+    <module>camel-itest</module>
     <module>camel-jbi</module>
+    <module>camel-jms</module>
     <module>camel-mina</module>
     <module>camel-script</module>
     <module>camel-spring</module>
-    <module>camel-itest</module>
+    <module>camel-xmpp</module>
   </modules>
 
   <scm>



Mime
View raw message