incubator-nuvem-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r1100659 - in /incubator/nuvem/trunk/nuvem-standalone: ./ src/main/java/org/apache/nuvem/cloud/xmpp/ src/main/java/org/apache/nuvem/cloud/xmpp/client/ src/main/java/org/apache/nuvem/cloud/xmpp/server/ src/main/java/org/apache/nuvem/xmpp/ sr...
Date Sat, 07 May 2011 23:23:13 GMT
Author: johnp
Date: Sat May  7 23:23:12 2011
New Revision: 1100659

URL: http://svn.apache.org/viewvc?rev=1100659&view=rev
Log:
module restructuring + few folder structure changes to keep it consistent with all other modules

Added:
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/AbstractConnector.java
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/DefaultPresenceManager.java
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/DefaultXMPPEndPoint.java
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/MessageAdapter.java
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/MessageListenerAdapter.java
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/NuvemPacketFilter.java
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/NuvemPacketListener.java
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/PresenceAdapter.java
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/RosterListenerAdapter.java
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/SSLConnector.java
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/SimpleConnector.java
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/StatusAdapter.java
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/server/
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/server/DefaultXMPPServer.java
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/xmpp/
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/xmpp/client/
    incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/xmpp/server/
    incubator/nuvem/trunk/nuvem-standalone/src/main/resources/
    incubator/nuvem/trunk/nuvem-standalone/src/main/resources/META-INF/
    incubator/nuvem/trunk/nuvem-standalone/src/main/resources/META-INF/sca-contribution.xml
    incubator/nuvem/trunk/nuvem-standalone/src/main/resources/config/
    incubator/nuvem/trunk/nuvem-standalone/src/main/resources/config/bogus_mina_tls.cert   (with props)
    incubator/nuvem/trunk/nuvem-standalone/src/main/resources/config/xmpp.cert
    incubator/nuvem/trunk/nuvem-standalone/src/main/resources/nuvemxmpp.composite
    incubator/nuvem/trunk/nuvem-standalone/src/test/
    incubator/nuvem/trunk/nuvem-standalone/src/test/java/
    incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/
    incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/
    incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/
    incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/
    incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/data/
    incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/data/impl/
    incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/data/impl/MapDocumentServiceImplTestCase.java
    incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/xmpp/
    incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/xmpp/client/
    incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/xmpp/client/DefaultXMPPEndPointTestCase.java
    incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/xmpp/client/XMPPEndPointIntegrationTest.java
    incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/xmpp/server/
    incubator/nuvem/trunk/nuvem-standalone/src/test/resources/
    incubator/nuvem/trunk/nuvem-standalone/src/test/resources/testnuvemxmpp.composite
Modified:
    incubator/nuvem/trunk/nuvem-standalone/pom.xml

Modified: incubator/nuvem/trunk/nuvem-standalone/pom.xml
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/pom.xml?rev=1100659&r1=1100658&r2=1100659&view=diff
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/pom.xml (original)
+++ incubator/nuvem/trunk/nuvem-standalone/pom.xml Sat May  7 23:23:12 2011
@@ -1,56 +1,135 @@
 <?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 xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.nuvem</groupId>
-        <artifactId>nuvem</artifactId>
-        <version>1.0-incubating-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
-    </parent>
-    <artifactId>nuvem-cloud-standalone</artifactId>
+	<!--
+		* 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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.apache.nuvem</groupId>
+		<artifactId>nuvem</artifactId>
+		<version>1.0-incubating-SNAPSHOT</version>
+		<relativePath>../pom.xml</relativePath>
+	</parent>
+	<artifactId>nuvem-standalone</artifactId>
 	<version>1.0-incubating-SNAPSHOT</version>
-    <name>Apache Nuvem Cloud API Implementation for Standlone Applications</name>
+	<name>Apache Nuvem Cloud API Implementation for Standlone Applications</name>
 
 	<dependencies>
 		<dependency>
 			<groupId>org.apache.nuvem</groupId>
-			<artifactId>nuvem-cloud-api</artifactId>
+			<artifactId>nuvem-api</artifactId>
 			<version>${project.version}</version>
 		</dependency>
 
-        <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-node-impl</artifactId>
-            <version>${tuscany.version}</version>
-            <scope>test</scope>
-        </dependency>
-        
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.8.1</version>
-            <scope>test</scope>
-        </dependency>
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-assembly</artifactId>
+			<version>${tuscany.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-node-impl</artifactId>
+			<version>${tuscany.version}</version>
+			<scope>test</scope>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-sca-api</artifactId>
+			<version>${tuscany.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-implementation-java-runtime</artifactId>
+			<version>${tuscany.version}</version>
+			<scope>runtime</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-domain-node</artifactId>
+			<version>${tuscany.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.8.1</version>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.vysper</groupId>
+			<artifactId>vysper-server</artifactId>
+			<type>pom</type>
+			<version>1.0.0-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.vysper</groupId>
+			<artifactId>vysper-core</artifactId>
+			<version>1.0.0-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.vysper</groupId>
+			<artifactId>vysper-extensions</artifactId>
+			<type>pom</type>
+			<version>1.0.0-SNAPSHOT</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.5.3</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-simple</artifactId>
+			<version>1.5.3</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>jcl-over-slf4j</artifactId>
+			<version>1.5.3</version>
+		</dependency>
+
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.8.1</version>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>jivesoftware</groupId>
+			<artifactId>smackx</artifactId>
+			<version>3.1.0</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.easymock</groupId>
+			<artifactId>easymock</artifactId>
+			<version>3.0</version>
+			<scope>test</scope>
+		</dependency>
+
 	</dependencies>
 </project>
 

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/AbstractConnector.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/AbstractConnector.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/AbstractConnector.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/AbstractConnector.java Sat May  7 23:23:12 2011
@@ -0,0 +1,99 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.apache.nuvem.cloud.xmpp.XMPPConnectException;
+import org.apache.nuvem.cloud.xmpp.XMPPConnector;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.oasisopen.sca.annotation.Property;
+
+/**
+ * Common Template to establish conneciton to the XMPPServer, which is extended
+ * by a more specific mechanisms.
+ * 
+ * 
+ */
+public abstract class AbstractConnector implements
+		XMPPConnector<XMPPConnection> {
+	/**
+	 * Logger.
+	 */
+	protected static final Logger log = Logger.getLogger(XMPPConnector.class
+			.getName());
+
+	@Property(required = false)
+	protected String host = "localhost";
+	@Property(required = false)
+	protected int port = 5222;
+	@Property(required = false)
+	protected String serviceName;
+	@Property
+	protected String clientJID = "nuvem@localhost";
+	@Property
+	protected String clientPassword = "password";
+	@Property(required = false)
+	protected String authenticationMechanism = "PLAIN";
+
+	/**
+	 * The XMPP Connection.
+	 */
+	protected XMPPConnection connection;
+
+	/**
+	 * Connects to the XMPP Server and returns the XMPPConnection.
+	 */
+	public XMPPConnection getConnection() {
+		if (connection != null)
+			return connection;
+		log.info("Initializing a new connection...");
+		checkConfigurations();
+		try {
+			log.info("Connecting to XMPP Server....");
+			establishConnection();
+			log.info("Authenticating with the XMPP Server....");
+			authenticateWithServer();
+			log.info("EndPoint connected to XMPP Server successfuly!");
+		} catch (XMPPException e) {
+			log.severe("Error while connecting to the XMPP Server..."
+					+ e.getMessage());
+			throw new XMPPConnectException(
+					"error while connecting to the xmpp server", e);
+		}
+		return connection;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public XMPPConnection getConnection(Map<String, String> connectionProperties) {
+		throw new UnsupportedOperationException("still not supported");
+	}
+
+	protected abstract void checkConfigurations();
+
+	protected abstract void establishConnection() throws XMPPException;
+
+	protected abstract void authenticateWithServer() throws XMPPException;
+
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/DefaultPresenceManager.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/DefaultPresenceManager.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/DefaultPresenceManager.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/DefaultPresenceManager.java Sat May  7 23:23:12 2011
@@ -0,0 +1,57 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import org.apache.commons.lang.Validate;
+import org.apache.nuvem.cloud.xmpp.XMPPConnector;
+import org.apache.nuvem.cloud.xmpp.presence.PresenceListener;
+import org.apache.nuvem.cloud.xmpp.presence.PresenceManager;
+import org.apache.nuvem.cloud.xmpp.AbstractPresenceManager;
+import org.jivesoftware.smack.XMPPConnection;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Utility Service to provide all presence related operations.
+ * 
+ */
+@Service(PresenceManager.class)
+public class DefaultPresenceManager extends AbstractPresenceManager {
+
+	/**
+	 * Connecter to fetch XMPP Connection.
+	 */
+	@Reference
+	protected XMPPConnector<XMPPConnection> connector;
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void registerListener(PresenceListener listener) {
+		Validate.notNull(listener);
+		connector.getConnection().getRoster().addRosterListener(
+				new RosterListenerAdapter(listener));
+		//Keeps a reference to the listener for later use.
+		listeners.add(listener);
+	}
+
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/DefaultXMPPEndPoint.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/DefaultXMPPEndPoint.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/DefaultXMPPEndPoint.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/DefaultXMPPEndPoint.java Sat May  7 23:23:12 2011
@@ -0,0 +1,183 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import java.util.logging.Logger;
+
+import org.apache.commons.lang.Validate;
+import org.apache.nuvem.cloud.xmpp.JID;
+import org.apache.nuvem.cloud.xmpp.Status;
+import org.apache.nuvem.cloud.xmpp.XMPPConnector;
+import org.apache.nuvem.cloud.xmpp.XMPPEndPoint;
+import org.apache.nuvem.cloud.xmpp.message.Message;
+import org.apache.nuvem.cloud.xmpp.presence.PresenceManager;
+import org.apache.nuvem.cloud.xmpp.AbstractXMPPEndPoint;
+import org.jivesoftware.smack.Chat;
+import org.jivesoftware.smack.Roster;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.packet.Presence;
+import org.jivesoftware.smack.packet.Presence.Type;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * A Default Implemention of XMPP Client for cloud platforms without explicit
+ * XMPP support.
+ * 
+ */
+@Service(XMPPEndPoint.class)
+@Scope("COMPOSITE")
+public class DefaultXMPPEndPoint extends AbstractXMPPEndPoint implements
+		XMPPEndPoint {
+
+	/**
+	 * Logger.
+	 */
+	private static final Logger log = Logger.getLogger(XMPPEndPoint.class
+			.getName());
+
+	@Reference
+	protected XMPPConnector<XMPPConnection> connector;
+
+	@Reference
+	protected PresenceManager presenceManager; 
+	
+	
+	/**
+	 * The packet filter to decide what packets to recieve from the XMPP
+	 * Server..
+	 */
+	private NuvemPacketFilter filter;
+
+	/**
+	 * The Packet listener.
+	 */
+	private NuvemPacketListener listener;
+
+	/**
+	 * Default constructor.
+	 */
+	public DefaultXMPPEndPoint() {
+
+	}
+
+	public DefaultXMPPEndPoint(XMPPConnector<XMPPConnection> connector) {
+		Validate.notNull(connector);
+		this.connector = connector;
+	}
+
+	@Init
+	public void init() {
+		log.info("Initializing DefaultXMPPEndPoint using connector "
+				+ connector.getDescription());
+		filter = new NuvemPacketFilter(this);
+		listener = new NuvemPacketListener(this);
+		connector.getConnection().addPacketListener(this.listener, filter);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public Status sendMessage(Message message) {
+		XMPPConnection connection = connector.getConnection();
+		if (message == null || message.recipient() == null) {
+			throw new IllegalArgumentException("invalid message");
+		}
+		Status deliveryStatus = new Status();
+
+		org.apache.nuvem.cloud.xmpp.message.MessageListener nuvemListener = getListenerFor(message
+				.recipient());
+
+		Chat chat = connection.getChatManager().createChat(
+				message.recipient().asString(),
+				new MessageListenerAdapter(nuvemListener));
+		try {
+			chat.sendMessage(message.payLoad().content());
+		} catch (XMPPException e) {
+			log.severe("error while sending xmpp message to "
+					+ message.recipient().asString());
+			deliveryStatus = StatusAdapter.toStatus(e.getXMPPError());
+		}
+		return deliveryStatus;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public Status invite(JID jid) {
+		throw new UnsupportedOperationException("not supported yet");
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public Status invite(String jid) {
+		throw new UnsupportedOperationException("not supported yet");
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public boolean isPresent(JID jid) {
+		XMPPConnection connection = connector.getConnection();
+		if (jid == null)
+			throw new IllegalArgumentException(
+					"Illegal JID passed for finding presence");
+
+		Roster roster = connection.getRoster();
+		Presence presence = roster.getPresence(jid.asString());
+		if (presence != null)
+			return presence.getType() == Type.available;
+		return false;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public boolean isPresent(String id) {
+		XMPPConnection connection = connector.getConnection();
+
+		if (id == null)
+			throw new IllegalArgumentException(
+					"Illegal JID passed for finding presence");
+
+		Roster roster = connection.getRoster();
+		Presence presence = roster.getPresence(id);
+		if (presence != null)
+			return presence.getType() == Type.available;
+		return false;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public boolean isConnected() {
+		return connector.getConnection().isConnected();
+	}
+
+	@Override
+	public PresenceManager presenceManager() {
+		return presenceManager;
+	}
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/MessageAdapter.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/MessageAdapter.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/MessageAdapter.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/MessageAdapter.java Sat May  7 23:23:12 2011
@@ -0,0 +1,62 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import org.apache.nuvem.cloud.xmpp.message.MessageBuilder;
+import org.jivesoftware.smack.packet.Message;
+import org.jivesoftware.smack.packet.Presence;
+
+/**
+ * Adapter to transform nuvem message into smack message.
+ * 
+ * 
+ */
+public class MessageAdapter {
+
+	/**
+	 * Converts nuvem specific message object to the one smack API accepts.
+	 * 
+	 */
+	public static Message toSmackMessage(
+			org.apache.nuvem.cloud.xmpp.message.Message nuvemMessage,
+			String sender) {
+		Message smackMessage = new Message();
+		smackMessage.setFrom(sender);
+		smackMessage.setBody(nuvemMessage.payLoad().content());
+		smackMessage.setTo(nuvemMessage.recipient().asString());
+		return smackMessage;
+	}
+
+
+	/**
+	 * Converts smack message to Nuvem Message.
+	 * 
+	 * @param message
+	 *            the smack message.
+	 * @return nuvem message.
+	 */
+	public static org.apache.nuvem.cloud.xmpp.message.Message toNuvemMessage(
+			Message message) {
+		return new MessageBuilder().from(message.getFrom()).toRecipient(
+				message.getTo()).containing(message.getBody()).build();
+	}
+
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/MessageListenerAdapter.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/MessageListenerAdapter.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/MessageListenerAdapter.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/MessageListenerAdapter.java Sat May  7 23:23:12 2011
@@ -0,0 +1,53 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import org.apache.nuvem.cloud.xmpp.message.MessageBuilder;
+import org.jivesoftware.smack.Chat;
+import org.jivesoftware.smack.MessageListener;
+import org.jivesoftware.smack.packet.Message;
+
+/**
+ * Message Listener to listen to smack api and adapt it to nuvem specific
+ * messages.
+ * 
+ */
+public class MessageListenerAdapter implements MessageListener {
+
+	/**
+	 * The Nuvem Listener.
+	 */
+	private org.apache.nuvem.cloud.xmpp.message.MessageListener nuvemListener;
+
+	public MessageListenerAdapter(
+			org.apache.nuvem.cloud.xmpp.message.MessageListener nuvemMessageListener) {
+		if (nuvemMessageListener == null)
+			throw new IllegalArgumentException("listener should not be null");
+		this.nuvemListener = nuvemMessageListener;
+	}
+
+	@Override
+	public void processMessage(Chat chat, Message message) {
+		nuvemListener.listen(new MessageBuilder().from(message.getFrom())
+				.containing(message.getBody()).build());
+	}
+
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/NuvemPacketFilter.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/NuvemPacketFilter.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/NuvemPacketFilter.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/NuvemPacketFilter.java Sat May  7 23:23:12 2011
@@ -0,0 +1,57 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.nuvem.cloud.xmpp.JID;
+import org.apache.nuvem.cloud.xmpp.XMPPEndPoint;
+import org.apache.nuvem.cloud.xmpp.message.MessageListener;
+import org.jivesoftware.smack.filter.PacketFilter;
+import org.jivesoftware.smack.packet.Message;
+import org.jivesoftware.smack.packet.Packet;
+
+/**
+ * A package filter to accept only necessary packets based on the the listeners
+ * registered for the reciever.
+ * 
+ */
+public class NuvemPacketFilter implements PacketFilter {
+
+	private XMPPEndPoint endPoint;
+
+	public NuvemPacketFilter(XMPPEndPoint endPoint) {
+		this.endPoint = endPoint;
+	}
+
+	/**
+	 * Accepts only those packets for which a {@link MessageListener} is
+	 * registered.
+	 */
+	public boolean accept(Packet packet) {
+		if (packet instanceof Message) {
+			String from = StringUtils.substringBeforeLast(packet.getFrom(),
+					"/");
+			return endPoint.getListenerFor(new JID(from)) != null;
+		}
+		return false;
+	}
+
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/NuvemPacketListener.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/NuvemPacketListener.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/NuvemPacketListener.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/NuvemPacketListener.java Sat May  7 23:23:12 2011
@@ -0,0 +1,56 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.nuvem.cloud.xmpp.JID;
+import org.apache.nuvem.cloud.xmpp.XMPPEndPoint;
+import org.apache.nuvem.cloud.xmpp.message.MessageListener;
+import org.jivesoftware.smack.PacketListener;
+import org.jivesoftware.smack.packet.Message;
+import org.jivesoftware.smack.packet.Packet;
+
+/**
+ * Listens to Packets from XMPP Server and transfers them to the appropriate
+ * Listener registered with the XMPPEndPoint.
+ * 
+ */
+public class NuvemPacketListener implements PacketListener {
+
+	private XMPPEndPoint endPoint;
+
+	public NuvemPacketListener(XMPPEndPoint endPoint) {
+		this.endPoint = endPoint;
+	}
+
+	@Override
+	public void processPacket(Packet packet) {
+		if (packet instanceof Message) {
+			String from = StringUtils.substringBeforeLast(packet.getFrom(),
+					"/");
+			MessageListener listener = endPoint
+					.getListenerFor(new JID(from));
+			listener.listen(MessageAdapter
+					.toNuvemMessage((Message) packet));
+		}
+	}
+
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/PresenceAdapter.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/PresenceAdapter.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/PresenceAdapter.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/PresenceAdapter.java Sat May  7 23:23:12 2011
@@ -0,0 +1,91 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.nuvem.cloud.xmpp.JID;
+import org.apache.nuvem.cloud.xmpp.presence.Presence;
+import org.apache.nuvem.cloud.xmpp.presence.PresenceBuilder;
+import org.apache.nuvem.cloud.xmpp.presence.Presence.Show;
+import org.apache.nuvem.cloud.xmpp.presence.Presence.Type;
+import org.jivesoftware.smack.packet.Presence.Mode;
+
+/**
+ * Hepls convert smack specific presence object into nuvem specific presence
+ * object.
+ * 
+ */
+public final class PresenceAdapter {
+
+	private static final Map<Mode, Presence.Show> showConverstionMap = new HashMap<Mode, Show>();
+	private static final Map<org.jivesoftware.smack.packet.Presence.Type, Presence.Type> typeConversionMap = new HashMap<org.jivesoftware.smack.packet.Presence.Type, Type>();
+
+	static {
+		showConverstionMap.put(Mode.available, Show.AVAILABLE);
+		showConverstionMap.put(Mode.away, Show.AWAY);
+		showConverstionMap.put(Mode.chat, Show.CHAT);
+		showConverstionMap.put(Mode.dnd, Show.DND);
+		showConverstionMap.put(Mode.xa, Show.XA);
+
+		typeConversionMap.put(
+				org.jivesoftware.smack.packet.Presence.Type.available,
+				Type.AVAILABLE);
+		typeConversionMap.put(
+				org.jivesoftware.smack.packet.Presence.Type.unavailable,
+				Type.UNAVAILABLE);
+		typeConversionMap.put(
+				org.jivesoftware.smack.packet.Presence.Type.subscribe,
+				Type.SUBSCRIBE);
+		typeConversionMap.put(
+				org.jivesoftware.smack.packet.Presence.Type.subscribed,
+				Type.SUBSCRIBED);
+		typeConversionMap.put(
+				org.jivesoftware.smack.packet.Presence.Type.unsubscribe,
+				Type.UNSUBSCRIBE);
+		typeConversionMap.put(
+				org.jivesoftware.smack.packet.Presence.Type.unsubscribed,
+				Type.UNSUBSCRIBED);
+		typeConversionMap.put(
+				org.jivesoftware.smack.packet.Presence.Type.error, Type.ERROR);
+	}
+
+	/**
+	 * Converts smack's {@link org.jivesoftware.smack.packet.Presence} to
+	 * Nuvem's {@link org.apache.nuvem.cloud.xmpp.presence.Presence} object.
+	 */
+	public static Presence toNuvemPresence(
+			org.jivesoftware.smack.packet.Presence presence) {
+		String from = presence.getFrom();
+		String to = presence.getTo();
+		String status = presence.getStatus();
+		Show show = showConverstionMap.get(presence.getMode());
+		Type type = typeConversionMap.get(presence.getType());
+		PresenceBuilder builder = new PresenceBuilder().withShow(show)
+				.withType(type).withStatus(status);
+		builder.from(new JID(from));
+		if (StringUtils.isNotEmpty(to)) {
+			builder.to(new JID(to));
+		}
+		return builder.build();
+	}
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/RosterListenerAdapter.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/RosterListenerAdapter.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/RosterListenerAdapter.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/RosterListenerAdapter.java Sat May  7 23:23:12 2011
@@ -0,0 +1,63 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import java.util.Collection;
+
+import org.apache.nuvem.cloud.xmpp.presence.PresenceListener;
+
+/**
+ * Listens to smack roster events and adapts it to nuvem roster events.
+ * 
+ */
+public class RosterListenerAdapter implements
+		org.jivesoftware.smack.RosterListener {
+
+	/**
+	 * Nuvem Roster Listener.
+	 */
+	private PresenceListener listener;
+
+	public RosterListenerAdapter(PresenceListener listener) {
+		this.listener = listener;
+	}
+
+	@Override
+	public void entriesAdded(Collection<String> arg0) {
+
+	}
+
+	@Override
+	public void entriesDeleted(Collection<String> arg0) {
+
+	}
+
+	@Override
+	public void entriesUpdated(Collection<String> arg0) {
+
+	}
+
+	@Override
+	public void presenceChanged(org.jivesoftware.smack.packet.Presence presence) {
+		listener.listen(PresenceAdapter
+				.toNuvemPresence(presence));
+	}
+}
\ No newline at end of file

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/SSLConnector.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/SSLConnector.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/SSLConnector.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/SSLConnector.java Sat May  7 23:23:12 2011
@@ -0,0 +1,98 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import java.util.Map;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.nuvem.cloud.xmpp.XMPPConnector;
+import org.jivesoftware.smack.ConnectionConfiguration;
+import org.jivesoftware.smack.SASLAuthentication;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Establishes a secure Stream to the XMPPServer.
+ * 
+ */
+@Service(XMPPConnector.class)
+public final class SSLConnector extends AbstractConnector {
+
+	@Property
+	protected String trustStorePath;
+	@Property
+	protected String trustStorePassword;
+	@Reference(required = false)
+	protected SocketFactory socketFactory = SSLSocketFactory.getDefault();
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public XMPPConnection getConnection(Map<String, String> connectionProperties) {
+		throw new UnsupportedOperationException("still not supported");
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public String getDescription() {
+		return "Single Connection Default connector";
+	}
+
+	@Override
+	protected void checkConfigurations() {
+		if (host == null || port == 0 || clientJID == null
+				|| clientPassword == null || trustStorePassword == null
+				|| trustStorePath == null) {
+			throw new IllegalStateException(
+					"the configuration parameters are not initlaized properly!");
+		}
+	}
+
+	/**
+	 * Establishes a secure connection with the XMPP Server.
+	 */
+	protected void establishConnection() throws XMPPException {
+		ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration(
+				host, port, serviceName);
+		connectionConfiguration
+				.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
+		connectionConfiguration.setSocketFactory(socketFactory);
+		connectionConfiguration.setTruststorePath(trustStorePath);
+		connectionConfiguration.setTruststorePassword(trustStorePassword);
+		SASLAuthentication.supportSASLMechanism(authenticationMechanism, 0);
+		this.connection = new XMPPConnection(connectionConfiguration);
+		this.connection.connect();
+	}
+
+	/**
+	 * Authenticates with the XMPP Server.
+	 */
+	protected void authenticateWithServer() throws XMPPException {
+		this.connection.login(this.clientJID, this.clientPassword);
+
+	}
+
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/SimpleConnector.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/SimpleConnector.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/SimpleConnector.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/SimpleConnector.java Sat May  7 23:23:12 2011
@@ -0,0 +1,75 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import org.apache.nuvem.cloud.xmpp.XMPPConnector;
+import org.jivesoftware.smack.ConnectionConfiguration;
+import org.jivesoftware.smack.SASLAuthentication;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Helps establish a connection to the XMPP Server and returns the same
+ * connection instance once connected. This specific implementation of
+ * {@link XMPPConnector} will try to connect to the XMPPServer in an unsecured
+ * way called. For more secure way of connecting to the XMPP server, please use
+ * {@link SSLConnector}
+ * 
+ */
+@Service(XMPPConnector.class)
+public class SimpleConnector extends AbstractConnector {
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public String getDescription() {
+		return "Single Connection Default connector";
+	}
+
+	@Override
+	protected void checkConfigurations() {
+		if (host == null || port == 0 || clientJID == null
+				|| clientPassword == null) {
+			throw new IllegalStateException(
+					"the configuration parameters are not initlaized properly!");
+		}
+	}
+
+	/**
+	 * Establishes a simple connection with the XMPP Server.
+	 */
+	protected void establishConnection() throws XMPPException {
+		ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration(
+				host, port, serviceName);
+		SASLAuthentication.supportSASLMechanism(authenticationMechanism, 0);
+		this.connection = new XMPPConnection(connectionConfiguration);
+		connection.connect();
+	}
+
+	/**
+	 * Authenticates with the XMPPServer using client JID and password.
+	 */
+	protected void authenticateWithServer() throws XMPPException {
+		this.connection.login(this.clientJID, this.clientPassword);
+
+	}
+
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/StatusAdapter.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/StatusAdapter.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/StatusAdapter.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/client/StatusAdapter.java Sat May  7 23:23:12 2011
@@ -0,0 +1,61 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.nuvem.cloud.xmpp.Error;
+import org.apache.nuvem.cloud.xmpp.ErrorCode;
+import org.apache.nuvem.cloud.xmpp.Status;
+import org.jivesoftware.smack.packet.XMPPError;
+
+/**
+ * Acts as an adapter to transform the status recieved by the the send API to
+ * the form compatible with nuvem.
+ */
+public class StatusAdapter {
+
+	/**
+	 * converstion map.
+	 */
+	private static Map<Integer, ErrorCode> converstionMap;
+
+	static {
+		converstionMap = new HashMap<Integer, ErrorCode>();
+		converstionMap.put(Integer.valueOf(400), ErrorCode.BAD_FORMAT);
+		converstionMap.put(Integer.valueOf(401), ErrorCode.NOT_AUTHORIZED);
+		converstionMap.put(Integer.valueOf(408), ErrorCode.CONNECTION_TIMEOUT);
+	}
+
+	public static Status toStatus(XMPPError xmppError) {
+		Status status = new Status();
+		if (xmppError != null
+				&& converstionMap.containsKey(xmppError.getCode())) {
+			status.addError(new Error(converstionMap.get(xmppError.getCode()),
+					xmppError.getMessage()));
+			return status;
+		}
+		status.addError(new Error(ErrorCode.UNKNOWN_ERROR, xmppError
+				.getMessage()));
+		return status;
+
+	}
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/server/DefaultXMPPServer.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/server/DefaultXMPPServer.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/server/DefaultXMPPServer.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/java/org/apache/nuvem/cloud/xmpp/server/DefaultXMPPServer.java Sat May  7 23:23:12 2011
@@ -0,0 +1,122 @@
+/*
+ * 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.nuvem.cloud.xmpp.server;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.nuvem.cloud.xmpp.XMPPServer;
+import org.apache.vysper.mina.TCPEndpoint;
+import org.apache.vysper.stanzasession.StanzaSessionFactory;
+import org.apache.vysper.storage.StorageProviderRegistry;
+import org.apache.vysper.storage.inmemory.MemoryStorageProviderRegistry;
+import org.apache.vysper.xmpp.authorization.AccountManagement;
+import org.apache.vysper.xmpp.modules.extension.xep0049_privatedata.PrivateDataModule;
+import org.apache.vysper.xmpp.modules.extension.xep0054_vcardtemp.VcardTempModule;
+import org.apache.vysper.xmpp.modules.extension.xep0092_software_version.SoftwareVersionModule;
+import org.apache.vysper.xmpp.modules.extension.xep0119_xmppping.XmppPingModule;
+import org.apache.vysper.xmpp.modules.extension.xep0202_entity_time.EntityTimeModule;
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * Default XMPP Server
+ */
+@Service(XMPPServer.class)
+public class DefaultXMPPServer implements XMPPServer {
+
+	private static String DEFAULT_HOST = "localhost";
+
+	private org.apache.vysper.xmpp.server.XMPPServer server;
+
+	/**
+	 * Default constructor
+	 */
+	public DefaultXMPPServer() {
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public void start() {
+		try {
+			StorageProviderRegistry providerRegistry = new MemoryStorageProviderRegistry();
+
+			final AccountManagement accountManagement = (AccountManagement) providerRegistry
+					.retrieve(AccountManagement.class);
+
+			accountManagement.addUser("nuvem@localhost", "password");
+			accountManagement.addUser("reciever@localhost", "password");
+
+			server = new org.apache.vysper.xmpp.server.XMPPServer(DEFAULT_HOST);
+			server.addEndpoint(new TCPEndpoint());
+			server.addEndpoint(new StanzaSessionFactory());
+			server.setStorageProviderRegistry(providerRegistry);
+
+			server
+					.setTLSCertificateInfo(new File(
+							"C:\\john\\nuvem\\ssl\\bogus_mina_tls.cert"),
+							"boguspw");
+
+			try {
+				server.start();
+				System.out.println("vysper server is running...");
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+
+			server.addModule(new SoftwareVersionModule());
+			server.addModule(new EntityTimeModule());
+			server.addModule(new VcardTempModule());
+			server.addModule(new XmppPingModule());
+			server.addModule(new PrivateDataModule());
+
+			// server.addModule(new MUCModule());
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+	}
+
+	/**
+	 * Stop the XMPP Server and perform any cleanup necessary
+	 */
+	public void stop() {
+		server.stop();
+
+	}
+
+	/**
+	 * For debug/test purposes only
+	 * 
+	 * @param args
+	 * @throws IOException
+	 */
+	public static void main(String args[]) throws IOException {
+		DefaultXMPPServer server = new DefaultXMPPServer();
+		server.start();
+		System.out.println("XMPP server started !!!");
+		System.in.read();
+		System.out.println("Stopping ...");
+		server.stop();
+		System.out.println();
+	}
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/resources/META-INF/sca-contribution.xml
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/resources/META-INF/sca-contribution.xml?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/resources/META-INF/sca-contribution.xml (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/resources/META-INF/sca-contribution.xml Sat May  7 23:23:12 2011
@@ -0,0 +1,25 @@
+<?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.    
+-->
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+	xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1" 
+	xmlns:xmpp="http://nuvemxmpp">
+
+	<export.java package="org.apache.nuvem.cloud.xmpp.client" />
+</contribution>
\ No newline at end of file

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/resources/config/bogus_mina_tls.cert
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/resources/config/bogus_mina_tls.cert?rev=1100659&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/nuvem/trunk/nuvem-standalone/src/main/resources/config/bogus_mina_tls.cert
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/resources/config/xmpp.cert
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/resources/config/xmpp.cert?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/resources/config/xmpp.cert (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/resources/config/xmpp.cert Sat May  7 23:23:12 2011
@@ -0,0 +1,13 @@
+-----BEGIN CERTIFICATE-----
+MIICTjCCAbcCBE2Y3+wwDQYJKoZIhvcNAQEEBQAwbjELMAkGA1UEBhMCSU4xEzARBgNVBAgTCkth
+cmFuYXRha2ExEjAQBgNVBAcTCUJhbmdhbG9yZTEPMA0GA1UEChMGYXBhY2hlMQ4wDAYDVQQLEwVu
+dXZlbTEVMBMGA1UEAxMMSm9obiBQcmFkZWVwMB4XDTExMDQwMzIxMDAyOFoXDTExMDcwMjIxMDAy
+OFowbjELMAkGA1UEBhMCSU4xEzARBgNVBAgTCkthcmFuYXRha2ExEjAQBgNVBAcTCUJhbmdhbG9y
+ZTEPMA0GA1UEChMGYXBhY2hlMQ4wDAYDVQQLEwVudXZlbTEVMBMGA1UEAxMMSm9obiBQcmFkZWVw
+MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCCILFDAUPmDytYj4PTEn8Fqdr66BaLsclAcvqL
+65kqmoELJOr+9g0QO5vneJVXv1HDbVs+z0+YZgUwBPu/kE5d1j8ZYJhbxgxWOSPBsWb1Fcr72VRc
+duSwSlqIuDIx5Kzgd4yltvyE5QLepve6buWgiGYcQx3Ezu1H/SQR7JUjrwIDAQABMA0GCSqGSIb3
+DQEBBAUAA4GBAFs2SsUTIBPZn5itVuRWCSVc+o9i7dej/XD/x1uRwCxUj2oX5CSTOMib7NFZe2cU
+NDJlE/tHlJTXRpcvDcBDFvQRExLvhQYd/Gsvccyx5JUmHYHCs3S/Rdx4mqXIXlJ4IKpG3hsDNeKg
+3TdzJMoAbS3iYe7SI61fBejDLAKEvPVo
+-----END CERTIFICATE-----

Added: incubator/nuvem/trunk/nuvem-standalone/src/main/resources/nuvemxmpp.composite
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/main/resources/nuvemxmpp.composite?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/main/resources/nuvemxmpp.composite (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/main/resources/nuvemxmpp.composite Sat May  7 23:23:12 2011
@@ -0,0 +1,66 @@
+<?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.
+	-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+	xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+	targetNamespace="http://nuvemxmpp" name="xmpp">
+
+
+	<component name="XMPPComponent">
+		<implementation.java
+			class="org.apache.nuvem.cloud.xmpp.client.DefaultXMPPEndPoint" />
+		<service name="XMPPEndPoint">
+			<interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPEndPoint" />
+		</service>
+		<reference name="connector" target="SimpleConnector/XMPPConnector">
+			<interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPConnector" />
+		</reference>
+		<reference name="presenceManager" target="PresenceComponent/PresenceManager">
+            <interface.java interface="org.apache.nuvem.cloud.xmpp.presence.PresenceManager" />
+        </reference>
+	</component>
+
+	<component name="PresenceComponent">
+		<implementation.java
+			class="org.apache.nuvem.cloud.xmpp.client.DefaultPresenceManager" />
+		<service name="PresenceManager">
+			<interface.java interface="org.apache.nuvem.cloud.xmpp.presence.PresenceManager" />
+		</service>
+		<reference name="connector" target="SimpleConnector/XMPPConnector">
+			<interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPConnector" />
+		</reference>
+	</component>
+	
+	<component name="SimpleConnector">
+		<implementation.java class="org.apache.nuvem.cloud.xmpp.client.SimpleConnector" />
+		<service name="XMPPConnector">
+			<interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPConnector" />
+		</service>
+		<property name="clientJID">nuvem@localhost</property>
+		<property name="clientPassword">password</property>
+	</component>
+
+	<component name="SSLConnector">
+		<implementation.java class="org.apache.nuvem.cloud.xmpp.client.SSLConnector" />
+		<service name="XMPPConnector">
+			<interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPConnector" />
+		</service>
+		<property name="clientJID">nuvem@localhost</property>
+		<property name="clientPassword">password</property>
+		<property name="trustStorePath">truststorepath</property>
+		<property name="trustStorePassword">changeit</property>
+	</component>
+
+</composite>

Added: incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/data/impl/MapDocumentServiceImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/data/impl/MapDocumentServiceImplTestCase.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/data/impl/MapDocumentServiceImplTestCase.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/data/impl/MapDocumentServiceImplTestCase.java Sat May  7 23:23:12 2011
@@ -0,0 +1,5 @@
+package org.apache.nuvem.cloud.data.impl;
+
+public class MapDocumentServiceImplTestCase {
+
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/xmpp/client/DefaultXMPPEndPointTestCase.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/xmpp/client/DefaultXMPPEndPointTestCase.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/xmpp/client/DefaultXMPPEndPointTestCase.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/xmpp/client/DefaultXMPPEndPointTestCase.java Sat May  7 23:23:12 2011
@@ -0,0 +1,105 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+
+import org.apache.nuvem.cloud.xmpp.Status;
+import org.apache.nuvem.cloud.xmpp.XMPPConnector;
+import org.apache.nuvem.cloud.xmpp.XMPPEndPoint;
+import org.jivesoftware.smack.Chat;
+import org.jivesoftware.smack.ChatManager;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.packet.XMPPError;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DefaultXMPPEndPointTestCase {
+
+	private static final String RECIPIENT = "recipient@host.com";
+
+	private static final String MESSAGE = "hi";
+
+	private XMPPConnector<XMPPConnection> connector;
+	private XMPPConnection connection;
+	private ChatManager chatManager;
+	private Chat chat;
+
+	private XMPPEndPoint endPoint;
+
+	@Before
+	public void init() {
+		connection = createMock(XMPPConnection.class);
+		chatManager = createMock(ChatManager.class);
+		connector = createMock(XMPPConnector.class);
+		expect(connector.getConnection()).andReturn(connection);
+		chat = createMock(Chat.class);
+		endPoint = new DefaultXMPPEndPoint(connector);
+	}
+
+
+	@Test
+	public void shouldBeAbleToSendMessage() throws XMPPException,
+			IllegalArgumentException, IllegalAccessException {
+		expect(connection.isConnected()).andReturn(true);
+		expect(connection.getChatManager()).andReturn(chatManager);
+		expect(
+				chatManager.createChat(isA(String.class),
+						isA(MessageListenerAdapter.class)))
+				.andReturn(chat);
+		chat.sendMessage(MESSAGE);
+		expectLastCall();
+		replay(connection);
+		replay(chatManager);
+		replay(chat);
+		replay(connector);
+		Status status = endPoint.sendTextMessage(MESSAGE, RECIPIENT);
+		Assert.assertNotNull(status);
+		Assert.assertTrue(!status.hasErrors());
+	}
+
+	@Test
+	public void shouldBeAbleToIdentifyErrors() throws IllegalArgumentException,
+			IllegalAccessException, XMPPException {
+		expect(connection.isConnected()).andReturn(true);
+		expect(connection.getChatManager()).andReturn(chatManager);
+		expect(
+				chatManager.createChat(isA(String.class),
+						isA(MessageListenerAdapter.class)))
+				.andReturn(chat);
+		chat.sendMessage(MESSAGE);
+		expectLastCall().andThrow(
+				new XMPPException("error", new XMPPError(302, "error")));
+		replay(connection);
+		replay(chatManager);
+		replay(chat);
+		replay(connector);
+		Status status = endPoint.sendTextMessage(MESSAGE, RECIPIENT);
+		Assert.assertNotNull(status);
+		Assert.assertTrue(status.hasErrors());
+	}
+
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/xmpp/client/XMPPEndPointIntegrationTest.java
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/xmpp/client/XMPPEndPointIntegrationTest.java?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/xmpp/client/XMPPEndPointIntegrationTest.java (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/test/java/org/apache/nuvem/cloud/xmpp/client/XMPPEndPointIntegrationTest.java Sat May  7 23:23:12 2011
@@ -0,0 +1,102 @@
+/*
+ * 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.nuvem.cloud.xmpp.client;
+
+import junit.framework.Assert;
+
+import org.apache.nuvem.cloud.xmpp.JID;
+import org.apache.nuvem.cloud.xmpp.XMPPEndPoint;
+import org.apache.nuvem.cloud.xmpp.XMPPServer;
+import org.apache.nuvem.cloud.xmpp.message.Message;
+import org.apache.nuvem.cloud.xmpp.message.MessageListener;
+import org.apache.nuvem.cloud.xmpp.server.DefaultXMPPServer;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class XMPPEndPointIntegrationTest {
+
+	private static XMPPServer server;
+	private static Node xmppNode;
+	private static XMPPEndPoint xmppEndPointSender;
+	private static XMPPEndPoint xmppEndPointReciever;
+
+	@BeforeClass
+	public static void setUp() throws Exception {
+		server = new DefaultXMPPServer();
+		server.start();
+		xmppNode = NodeFactory.getInstance().createNode(
+				"testnuvemxmpp.composite");
+		xmppNode.start();
+		xmppEndPointSender = xmppNode.getService(XMPPEndPoint.class,
+				"TestXMPPComponentSender/XMPPEndPoint");
+		xmppEndPointReciever = xmppNode.getService(XMPPEndPoint.class,
+				"TestXMPPComponentReciever/XMPPEndPoint");
+
+	}
+
+	@AfterClass
+	public static void tearDown() throws Exception {
+		if (xmppNode != null) {
+			xmppNode.stop();
+		}
+		if (server != null) {
+			server.stop();
+		}
+	}
+
+
+	@Test
+	public void SendAndRecieveMessage() throws InterruptedException {
+		final String message = "hello xmpp";
+		MessageListenerValidator validator = new MessageListenerValidator(
+				message);
+		xmppEndPointReciever.registerListner(new JID("nuvem@localhost"),
+				validator);
+		xmppEndPointSender.sendTextMessage(message, "reciever@localhost");
+		Thread.sleep(3000);
+		validator.checkIfValidMessageRecieved();
+	}
+
+	public class MessageListenerValidator implements MessageListener {
+
+		private Message recievedMessage = null;
+
+		private String expectedMessage;
+
+		public MessageListenerValidator(String expectedMessage) {
+			this.expectedMessage = expectedMessage;
+		}
+
+		@Override
+		public void listen(Message message) {
+			this.recievedMessage = message;
+		}
+
+		public void checkIfValidMessageRecieved() {
+			Assert.assertNotNull(recievedMessage);
+			Assert.assertTrue(expectedMessage.equals(recievedMessage.payLoad()
+					.content()));
+		}
+	}
+
+}

Added: incubator/nuvem/trunk/nuvem-standalone/src/test/resources/testnuvemxmpp.composite
URL: http://svn.apache.org/viewvc/incubator/nuvem/trunk/nuvem-standalone/src/test/resources/testnuvemxmpp.composite?rev=1100659&view=auto
==============================================================================
--- incubator/nuvem/trunk/nuvem-standalone/src/test/resources/testnuvemxmpp.composite (added)
+++ incubator/nuvem/trunk/nuvem-standalone/src/test/resources/testnuvemxmpp.composite Sat May  7 23:23:12 2011
@@ -0,0 +1,104 @@
+<?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.
+	-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+	xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+	targetNamespace="http://testnuvemxmpp" name="xmpp">
+
+
+	<component name="TestXMPPComponentSender">
+		<implementation.java
+			class="org.apache.nuvem.cloud.xmpp.client.DefaultXMPPEndPoint" />
+		<service name="XMPPEndPoint">
+			<interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPEndPoint" />
+		</service>
+		<reference name="connector" target="TestSimpleSenderConnector/XMPPConnector">
+			<interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPConnector" />
+		</reference>
+		<reference name="presenceManager" target="TestSenderPresenceComponent/PresenceManager">
+            <interface.java interface="org.apache.nuvem.cloud.xmpp.presence.PresenceManager" />
+        </reference>
+	</component>
+
+	<component name="TestSenderPresenceComponent">
+		<implementation.java
+			class="org.apache.nuvem.cloud.xmpp.client.DefaultPresenceManager" />
+		<service name="PresenceManager">
+			<interface.java
+				interface="org.apache.nuvem.cloud.xmpp.presence.PresenceManager" />
+		</service>
+		<reference name="connector" target="TestSimpleSenderConnector/XMPPConnector">
+            <interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPConnector" />
+        </reference>
+	</component>
+
+	<component name="TestSSLConnector">
+		<implementation.java class="org.apache.nuvem.cloud.xmpp.client.SSLConnector" />
+		<service name="XMPPConnector">
+			<interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPConnector" />
+		</service>
+		<property name="clientJID">nuvem@localhost</property>
+		<property name="clientPassword">password</property>
+		<property name="trustStorePath">truststorepath</property>
+		<property name="trustStorePassword">changeit</property>
+	</component>
+
+	<component name="TestXMPPComponentReciever">
+		<implementation.java
+			class="org.apache.nuvem.cloud.xmpp.client.DefaultXMPPEndPoint" />
+		<service name="XMPPEndPoint">
+			<interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPEndPoint" />
+		</service>
+		<reference name="connector" target="TestSimpleRecieverConnector/XMPPConnector">
+			<interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPConnector" />
+		</reference>
+		<reference name="presenceManager" target="TestRecieverPresenceComponent/PresenceManager">
+            <interface.java interface="org.apache.nuvem.cloud.xmpp.presence.PresenceManager" />
+        </reference>
+	</component>
+
+    <component name="TestRecieverPresenceComponent">
+        <implementation.java
+            class="org.apache.nuvem.cloud.xmpp.client.DefaultPresenceManager" />
+        <service name="PresenceManager">
+            <interface.java
+                interface="org.apache.nuvem.cloud.xmpp.presence.PresenceManager" />
+        </service>
+        <reference name="connector" target="TestSimpleRecieverConnector/XMPPConnector">
+            <interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPConnector" />
+        </reference>
+    </component>
+
+
+	<component name="TestSimpleRecieverConnector">
+		<implementation.java class="org.apache.nuvem.cloud.xmpp.client.SimpleConnector" />
+		<service name="XMPPConnector">
+			<interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPConnector" />
+		</service>
+		<property name="clientJID">reciever@localhost</property>
+		<property name="clientPassword">password</property>
+	</component>
+
+	<component name="TestSimpleSenderConnector">
+		<implementation.java class="org.apache.nuvem.cloud.xmpp.client.SimpleConnector" />
+		<service name="XMPPConnector">
+			<interface.java interface="org.apache.nuvem.cloud.xmpp.XMPPConnector" />
+		</service>
+		<property name="clientJID">nuvem@localhost</property>
+		<property name="clientPassword">password</property>
+	</component>
+
+
+</composite>



Mime
View raw message