You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by be...@apache.org on 2007/05/31 00:07:44 UTC

svn commit: r542950 [1/4] - in /labs/vysper: ./ lib/ src/ src/main/ src/main/config/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/vysper/ src/main/java/org/apache/vysper/xmpp/ src/main/java/org/apache/vysper/xmpp...

Author: berndf
Date: Wed May 30 15:07:38 2007
New Revision: 542950

URL: http://svn.apache.org/viewvc?view=rev&rev=542950
Log:
[vysper] initial code import

Added:
    labs/vysper/build.xml
    labs/vysper/lib/
    labs/vysper/lib/bcprov-jdk15-135.jar   (with props)
    labs/vysper/lib/junit.jar   (with props)
    labs/vysper/lib/nekopull.jar   (with props)
    labs/vysper/lib/xercesImpl.jar   (with props)
    labs/vysper/lib/xml-apis.jar   (with props)
    labs/vysper/src/
    labs/vysper/src/main/
    labs/vysper/src/main/config/
    labs/vysper/src/main/java/
    labs/vysper/src/main/java/org/
    labs/vysper/src/main/java/org/apache/
    labs/vysper/src/main/java/org/apache/vysper/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/Entity.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityFormatException.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityImpl.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/CommonAttribute.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/StanzaErrorCondition.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/StanzaErrorType.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/BaseStreamStanzaDictionary.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/IQHandler.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/MessageHandler.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/PresenceHandler.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/StreamStartHandler.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/XMPPCoreStanzaHandler.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/reponse/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/im/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/jabber/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/jabber/handler/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/jabber/handler/JabberClientStanzaDictionary.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/jabber/handler/JabberServerStanzaDictionary.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/negotiation/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/authorization/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/authorization/UserAuthorization.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/DeliveryException.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaReceiver.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelay.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelayImpl.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/namespace/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/parser/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/parser/AbstractNekopullStreamParser.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/parser/EncryptionAware.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/parser/InputStreamParser.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/parser/ParsingErrorCondition.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/parser/ParsingException.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/parser/StreamParser.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/parser/StringStreamParser.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/parser/TLSEnabled.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/parser/io/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/parser/io/PlainToTLSStreaming.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/NamespaceHandlerDictionary.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/NamespaceURIs.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ProtocolException.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ProtocolWorker.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ResponseStanzaContainer.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ResponseStanzaContainerImpl.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ResponseWriter.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/SessionStateHolder.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/SessionStateModifier.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandler.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/StateAwareProtocolWorker.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/StreamErrorCondition.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/exception/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/exception/BadXMLException.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/worker/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/worker/AbstractStateAwareProtocolWorker.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/worker/AuthenticatedProtocolWorker.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/worker/EncryptedProtocolWorker.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/worker/EncryptionStartedProtocolWorker.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/worker/EndOrClosedProtocolWorker.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/worker/InitiatedProtocolWorker.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/worker/StartedProtocolWorker.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/worker/UnconnectedProtocolWorker.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/server/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/server/DefaultSessionContext.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/server/SessionContext.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/server/SessionState.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/server/XMPPVersion.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/server/response/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/server/response/ServerErrorResponses.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/server/response/ServerResponses.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/IQStanza.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/IQStanzaType.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/MessageStanza.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/PresenceStanza.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/Stanza.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/StanzaBuilder.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/XMPPCoreStanza.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/stanza/XMPPCoreStanzaVerifier.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/writer/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/writer/StanzaWriter.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/writer/SystemOutStanzaWriter.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/xmlfragment/
    labs/vysper/src/main/java/org/apache/vysper/xmpp/xmlfragment/Attribute.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/xmlfragment/FragmentFactory.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/xmlfragment/NamespaceAttribute.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/xmlfragment/Renderer.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/xmlfragment/XMLElement.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/xmlfragment/XMLElementVerifier.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/xmlfragment/XMLFragment.java
    labs/vysper/src/main/java/org/apache/vysper/xmpp/xmlfragment/XMLText.java
    labs/vysper/src/test/
    labs/vysper/src/test/java/
    labs/vysper/src/test/java/org/
    labs/vysper/src/test/java/org/apache/
    labs/vysper/src/test/java/org/apache/vysper/
    labs/vysper/src/test/java/org/apache/vysper/xmpp/
    labs/vysper/src/test/java/org/apache/vysper/xmpp/applicationdomains/
    labs/vysper/src/test/java/org/apache/vysper/xmpp/applicationdomains/base/
    labs/vysper/src/test/java/org/apache/vysper/xmpp/applicationdomains/base/handler/
    labs/vysper/src/test/java/org/apache/vysper/xmpp/applicationdomains/base/handler/IQHandlerTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/applicationdomains/base/handler/TestIQHandler.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/parser/
    labs/vysper/src/test/java/org/apache/vysper/xmpp/parser/PlainToTLSTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/parser/StringStreamParserTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/protocol/
    labs/vysper/src/test/java/org/apache/vysper/xmpp/protocol/CallTestStanzaHandler.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/protocol/CallTestStanzaHandlerResponse.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/protocol/ProtocolInitiationTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/protocol/ProtocolWorkerAquireTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/protocol/ProtocolWorkerProcessTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/protocol/ProtocolWorkerStateAwarenessTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookupTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/server/
    labs/vysper/src/test/java/org/apache/vysper/xmpp/server/SessionStateTest.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/server/TestSessionContext.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/server/XMPPVersionTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/server/response/
    labs/vysper/src/test/java/org/apache/vysper/xmpp/server/response/ServerResponsesTestCase.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/stanza/

Added: labs/vysper/build.xml
URL: http://svn.apache.org/viewvc/labs/vysper/build.xml?view=auto&rev=542950
==============================================================================
--- labs/vysper/build.xml (added)
+++ labs/vysper/build.xml Wed May 30 15:07:38 2007
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project name="vysper" default="all">
+
+    <!--
+     ! Copyright (c) 2006-2007 The Apache Software Foundation.             !
+     ! All rights reserved.                                                !
+     !                                                                     !
+     ! Licensed 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.                      !
+     -->
+
+  
+  <!-- Uncomment the following property if no tests compilation is needed -->
+  <!-- 
+  <property name="skip.tests" value="true"/>
+   -->
+  
+  <!-- Compiler options -->
+  
+  <property name="compiler.debug" value="on"/>
+  <property name="compiler.generate.no.warnings" value="off"/>
+  <property name="compiler.args" value=""/>
+  <property name="compiler.max.memory" value="128m"/>
+  <patternset id="ignored.files">
+    <exclude name="**/CVS/**"/>
+    <exclude name="**/SCCS/**"/>
+    <exclude name="**/RCS/**"/>
+    <exclude name="**/rcs/**"/>
+    <exclude name="**/.DS_Store/**"/>
+    <exclude name="**/.svn/**"/>
+  </patternset>
+  <patternset id="compiler.resources">
+    <include name="**/?*.properties"/>
+    <include name="**/?*.xml"/>
+    <include name="**/?*.gif"/>
+    <include name="**/?*.png"/>
+    <include name="**/?*.jpeg"/>
+    <include name="**/?*.jpg"/>
+    <include name="**/?*.html"/>
+    <include name="**/?*.dtd"/>
+    <include name="**/?*.tld"/>
+  </patternset>
+  
+  
+  <!-- Application Server Libraries -->
+  
+  <dirname property="basedir" file="${ant.file}"/>
+  
+  <property name="compiler.args.vysper" value="${compiler.args}"/>
+  
+  <property name="vysper.output.dir" value="${basedir}/build/ant/classes"/>
+  <property name="vysper.unittest.base.dir" value="${basedir}/build/ant/tests/junit"/>
+  <property name="vysper.unittest.output.classes.dir" value="${vysper.unittest.base.dir}/classes"/>
+  <property name="vysper.unittest.output.reports.dir" value="${vysper.unittest.base.dir}/reports"/>
+
+  <path id="bootclasspath">
+    <!-- Paths to be included in compilation bootclasspath -->
+  </path>
+  
+  <path id="classpath">
+    <pathelement location="${basedir}/lib/spring.jar"/>
+    <pathelement location="${basedir}/lib/junit.jar"/>
+    <pathelement location="${basedir}/lib/xml-apis.jar"/>
+    <pathelement location="${basedir}/lib/nekopull.jar"/>
+    <pathelement location="${basedir}/lib/xercesImpl.jar"/>
+    <pathelement location="${basedir}/lib/bcprov-jdk15-135.jar"/>
+  </path>
+  
+  <patternset id="excluded.from.vysper">
+    <patternset refid="ignored.files"/>
+  </patternset>
+  
+  <patternset id="excluded.from.compilation.vysper">
+    <patternset refid="excluded.from.vysper"/>
+  </patternset>
+  
+  <path id="sourcepath">
+    <dirset dir="${basedir}">
+      <include name="src/main/java"/>
+    </dirset>
+  </path>
+  
+  <path id="test.sourcepath">
+    <dirset dir="${basedir}">
+      <include name="src/test/java"/>
+    </dirset>
+  </path>
+  
+  
+  <target name="compile.vysper" depends="compile.production,compile.tests" description="Compile vysper"/>
+  
+  <target name="compile.production" description="Compile vysper; production classes">
+    <mkdir dir="${vysper.output.dir}"/>
+    <javac destdir="${vysper.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memoryMaximumSize="${compiler.max.memory}" fork="true">
+      <compilerarg line="${compiler.args.vysper}"/>
+      <bootclasspath refid="bootclasspath"/>
+      <classpath refid="classpath"/>
+      <src refid="sourcepath"/>
+    </javac>
+    
+    <copy todir="${vysper.output.dir}">
+      <fileset dir="${basedir}/src/main/java">
+        <patternset refid="compiler.resources"/>
+        <type type="file"/>
+      </fileset>
+    </copy>
+  </target>
+  
+  <target name="compile.tests" depends="compile.production" description="compile vysper; test classes" unless="skip.tests">
+    <mkdir dir="${vysper.unittest.output.classes.dir}"/>
+    <javac destdir="${vysper.unittest.output.classes.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memoryMaximumSize="${compiler.max.memory}" fork="true">
+      <compilerarg line="${compiler.args.vysper}"/>
+      <classpath refid="classpath"/>
+      <classpath location="${vysper.output.dir}"/>
+      <src refid="test.sourcepath"/>
+    </javac>
+    
+    <copy todir="${vysper.unittest.output.classes.dir}">
+      <fileset dir="${basedir}/src/test/java">
+        <patternset refid="compiler.resources"/>
+        <type type="file"/>
+      </fileset>
+    </copy>
+  </target>
+  
+  <target name="clean.vysper" description="cleanup">
+    <delete dir="${vysper.output.dir}"/>
+    <delete dir="${vysper.unittest.base.dir}"/>
+  </target>
+
+  <target name="run-server" description="Build initialization">
+    <java >
+
+    </java>
+  </target>
+
+  <target name="run-unit-tests" depends="compile.vysper">
+    <echo message="Running Vysper Unit Tests"/>
+    <mkdir dir="${vysper.unittest.output.classes.dir}"/>
+    <mkdir dir="${vysper.unittest.output.reports.dir}"/>
+    <junit printsummary="yes" haltonfailure="no"  dir="${basedir}">
+      <classpath refid="classpath"/>
+      <classpath>
+        <pathelement location="${vysper.output.dir}"/>
+        <pathelement location="${vysper.unittest.output.classes.dir}"/>
+      </classpath>
+
+      <formatter type="plain"/>
+
+      <batchtest fork="yes" todir="${vysper.unittest.output.reports.dir}">
+        <fileset dir="${basedir}/src/test/java">
+          <include name="**/*Test.java"/>
+          <include name="**/*TestCase.java"/>
+          <exclude name="**/AllTests.java"/>
+          <exclude name="**/Abstract*.java"/>
+        </fileset>
+      </batchtest>
+    </junit>
+  </target>
+
+
+  <target name="init" description="Build initialization">
+    <!-- Perform any build initialization in this target -->
+  </target>
+  
+  <target name="clean" depends="clean.vysper" description="cleanup all"/>
+  
+  <target name="all" depends="init, clean, compile.vysper" description="build all"/>
+</project>
\ No newline at end of file

Added: labs/vysper/lib/bcprov-jdk15-135.jar
URL: http://svn.apache.org/viewvc/labs/vysper/lib/bcprov-jdk15-135.jar?view=auto&rev=542950
==============================================================================
Binary file - no diff available.

Propchange: labs/vysper/lib/bcprov-jdk15-135.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: labs/vysper/lib/junit.jar
URL: http://svn.apache.org/viewvc/labs/vysper/lib/junit.jar?view=auto&rev=542950
==============================================================================
Binary file - no diff available.

Propchange: labs/vysper/lib/junit.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: labs/vysper/lib/nekopull.jar
URL: http://svn.apache.org/viewvc/labs/vysper/lib/nekopull.jar?view=auto&rev=542950
==============================================================================
Binary file - no diff available.

Propchange: labs/vysper/lib/nekopull.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: labs/vysper/lib/xercesImpl.jar
URL: http://svn.apache.org/viewvc/labs/vysper/lib/xercesImpl.jar?view=auto&rev=542950
==============================================================================
Binary file - no diff available.

Propchange: labs/vysper/lib/xercesImpl.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: labs/vysper/lib/xml-apis.jar
URL: http://svn.apache.org/viewvc/labs/vysper/lib/xml-apis.jar?view=auto&rev=542950
==============================================================================
Binary file - no diff available.

Propchange: labs/vysper/lib/xml-apis.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/Entity.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/Entity.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/Entity.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/Entity.java Wed May 30 15:07:38 2007
@@ -0,0 +1,53 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.addressing;
+
+/**
+ * The "JID"
+  * jid             = [ node "@" ] domain [ "/" resource ]
+  * domain          = fqdn / address-literal
+  * fqdn            = (sub-domain 1*("." sub-domain))
+  * sub-domain      = (internationalized domain label)
+  * address-literal = IPv4address / IPv6address
+
+ Each allowable portion of a JID (node identifier, domain identifier,
+ and resource identifier) MUST NOT be more than 1023 bytes in length,
+ resulting in a maximum total size (including the '@' and '/'
+ separators) of 3071 bytes.
+
+ TODO add unit tests for all implementors
+ */
+public interface Entity {
+
+    String getNode();
+    String getDomain();
+    String getResource();
+
+    /**
+     * @return string like "node@domain/resource"
+     */
+    String getFullQualifiedName();
+
+    /**
+     * @return string like "node@domain"
+     */
+    String getBareJID();
+    
+    String getCanonicalizedName();
+
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java Wed May 30 15:07:38 2007
@@ -0,0 +1,41 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.addressing;
+
+/**
+ */
+public class EntityConformance {
+
+    public static boolean checkRFC3920Conformance(Entity entity) {
+        if (!checkPartConformity(entity.getDomain())) return false;
+        if (!checkPartConformity(entity.getNode())) return false;
+        if (!checkPartConformity(entity.getResource())) return false;
+
+        if (checkPartIsEmpty(entity.getDomain())) return false;
+        return true;
+    }
+
+    private static boolean checkPartConformity(String part) {
+        return part != null && part.getBytes().length > 1023;
+    }
+
+    private static boolean checkPartIsEmpty(String part) {
+        return part == null || "".equals(part);
+    }
+
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityFormatException.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityFormatException.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityFormatException.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityFormatException.java Wed May 30 15:07:38 2007
@@ -0,0 +1,38 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.addressing;
+
+/**
+ */
+public class EntityFormatException extends Exception {
+    public EntityFormatException() {
+        super();
+    }
+
+    public EntityFormatException(String string) {
+        super(string);
+    }
+
+    public EntityFormatException(String string, Throwable throwable) {
+        super(string, throwable);
+    }
+
+    public EntityFormatException(Throwable throwable) {
+        super(throwable);
+    }
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityImpl.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityImpl.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityImpl.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityImpl.java Wed May 30 15:07:38 2007
@@ -0,0 +1,102 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.addressing;
+
+/**
+ */
+public class EntityImpl implements Entity {
+    private String node;
+    private String domain;
+    private String resource;
+
+    public static EntityImpl parse(String entity) throws EntityFormatException {
+        String node = null;
+        String domain;
+        String resource = null;
+        if (entity == null) throw new EntityFormatException("entity must not be NULL");
+
+        if (entity.contains("@")) {
+            String[] parts = entity.split("@");
+            if (parts.length != 2) throw new EntityFormatException("entity must be of format node@domain/resource");
+            node = parts[0];
+            entity = parts[1];
+        }
+        domain = entity;
+        if (entity.contains("/")) {
+            int indexOfSlash = entity.indexOf("/");
+            domain = entity.substring(0, indexOfSlash);
+            resource = entity.substring(indexOfSlash);
+        }
+        return new EntityImpl(node, domain, resource);
+    }
+
+    public EntityImpl(String node, String domain, String resource) {
+        this.node = node;
+        this.domain = domain;
+        this.resource = resource;
+    }
+
+    public String getNode() {
+        return node;
+    }
+
+    public String getDomain() {
+        return domain;
+    }
+
+    public String getResource() {
+        return resource;
+    }
+
+    public String getFullQualifiedName() {
+        StringBuffer buffer = new StringBuffer();
+        if (node != null && !"".equals(node)) buffer.append(node).append("@");
+        buffer.append(domain);
+        if (resource != null && !"".equals(resource)) buffer.append("/").append(resource);
+        return buffer.toString();
+    }
+
+    public String getBareJID() {
+        return null;
+    }
+
+    public String getCanonicalizedName() {
+        return null;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || !(o instanceof Entity)) return false;
+
+        final Entity that = (Entity) o;
+
+        if (domain != null ? !domain.equals(that.getDomain()) : that.getDomain() != null) return false;
+        if (node != null ? !node.equals(that.getNode()) : that.getNode() != null) return false;
+        if (resource != null ? !resource.equals(that.getResource()) : that.getResource() != null) return false;
+
+        return true;
+    }
+
+    public int hashCode() {
+        int result;
+        result = (node != null ? node.hashCode() : 0);
+        result = 29 * result + (domain != null ? domain.hashCode() : 0);
+        result = 29 * result + (resource != null ? resource.hashCode() : 0);
+        return result;
+    }
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/CommonAttribute.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/CommonAttribute.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/CommonAttribute.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/CommonAttribute.java Wed May 30 15:07:38 2007
@@ -0,0 +1,38 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.applicationdomains.base;
+
+/**
+ */
+public enum CommonAttribute {
+    TO("to"),
+    FROM("from"),
+    ID("id"),
+    XML_LANG("xml:lang"),
+    VERSION("version");
+
+    private final String value;
+
+    CommonAttribute(String value) {
+        this.value = value;
+    }
+
+    public String value() {
+        return value;
+    }
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/StanzaErrorCondition.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/StanzaErrorCondition.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/StanzaErrorCondition.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/StanzaErrorCondition.java Wed May 30 15:07:38 2007
@@ -0,0 +1,61 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.applicationdomains.base;
+
+/**
+ * inner error for stanzas of type iq, message, presence
+ * as of: RFC3920 9.3.3. Defined Conditions
+ * There are also recommendations for the associated error type
+ * to be found.
+ */
+public enum StanzaErrorCondition {
+
+    BAD_REQUEST ("bad-request"),
+    CONFLICT ("conflict"),
+    FEATURE_NOT_IMPLEMENTED ("feature-not-implemented"),
+    FORBIDDEN ("forbidden"),
+    GONE ("gone"),
+    INTERNAL_SERVER_ERROR ("internal-server-error"),
+    ITEM_NOT_FOUND ("item-not-found"),
+    JID_MALFORMED ("jid-malformed"),
+    NOT_ACCEPTABLE ("not-acceptable"),
+    NOT_ALLOWED ("not-allowed"),
+    NOT_AUTHORIZED ("not-authorized"),
+    PAYMENT_REQUIRED ("payment-required"),
+    RECIPIENT_UNAVAILABLE ("recipient-unavailable"),
+    REDIRECT ("redirect"),
+    REGISTRATION_REQUIRED ("registration-required"),
+    REMOTE_SERVER_NOT_FOUND ("remote-server-not-found"),
+    REMOTE_SERVER_TIMEOUT ("remote-server-timeout"),
+    RESOURCE_CONSTRAINT ("resource-constraint"),
+    SERVICE_UNAVAILABLE ("service-unavailable"),
+    SUBSCRIPTION_REQUIRED ("subscription-required"),
+    UNDEFINED_CONDITION ("undefined-condition"),
+    UNEXPECTED_REQUEST ("unexpected-request");
+
+    private final String value;
+
+    StanzaErrorCondition(String value) {
+        this.value = value;
+    }
+
+    public String value() {
+        return value;
+    }
+
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/StanzaErrorType.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/StanzaErrorType.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/StanzaErrorType.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/StanzaErrorType.java Wed May 30 15:07:38 2007
@@ -0,0 +1,40 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.applicationdomains.base;
+
+/**
+ */
+public enum StanzaErrorType {
+
+    CANCEL("cancel"), // do not retry (the error is unrecoverable) 
+    CONTINUE("continue"), // proceed (the condition was only a warning)
+    MODIFY("modify"), // retry after changing the data sent
+    AUTH("auth"), // retry after providing credentials
+    WAIT("wait"); // retry after waiting (the error is temporary)
+
+    private final String value;
+
+    StanzaErrorType(String value) {
+        this.value = value;
+    }
+
+    public String value() {
+        return value;
+    }
+
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/BaseStreamStanzaDictionary.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/BaseStreamStanzaDictionary.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/BaseStreamStanzaDictionary.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/BaseStreamStanzaDictionary.java Wed May 30 15:07:38 2007
@@ -0,0 +1,37 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.applicationdomains.base.handler;
+
+import org.apache.vysper.xmpp.protocol.NamespaceURIs;
+import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary;
+
+/**
+ * handler for base stanzas from RFC3920 (xmpp core)<br/>
+ * they are: stream, message, presence, iq
+ */
+public class BaseStreamStanzaDictionary extends NamespaceHandlerDictionary {
+
+    public BaseStreamStanzaDictionary() {
+        super(NamespaceURIs.HTTP_ETHERX_JABBER_ORG_STREAMS);
+        register(new StreamStartHandler());
+        register(new IQHandler());
+        register(new MessageHandler());
+        register(new PresenceHandler());
+        seal();
+    }
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/IQHandler.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/IQHandler.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/IQHandler.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/IQHandler.java Wed May 30 15:07:38 2007
@@ -0,0 +1,102 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.applicationdomains.base.handler;
+
+import org.apache.vysper.xmpp.applicationdomains.base.StanzaErrorCondition;
+import org.apache.vysper.xmpp.applicationdomains.base.StanzaErrorType;
+import org.apache.vysper.xmpp.server.SessionContext;
+import org.apache.vysper.xmpp.server.response.ServerErrorResponses;
+import org.apache.vysper.xmpp.stanza.IQStanza;
+import org.apache.vysper.xmpp.stanza.IQStanzaType;
+import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
+
+/**
+ * handling IQ stanzas (request/response)
+ */
+public class IQHandler extends XMPPCoreStanzaHandler {
+
+
+    public String getName() {
+        return "iq";
+    }
+
+    public boolean verify(Stanza stanza) {
+        return IQStanza.isOfType(stanza);
+    }
+
+    protected Stanza executeCore(XMPPCoreStanza coreStanza, SessionContext sessionContext) {
+        IQStanza stanza = (IQStanza)coreStanza;
+
+        // rfc3920/9.2.3/1.
+        String id = stanza.getID();
+        if (id == null) {
+            return ServerErrorResponses.getInstance().getErrorResponse(stanza,
+                    StanzaErrorType.MODIFY, StanzaErrorCondition.BAD_REQUEST,
+                    "iq-stanza requires 'id' attribute to be present",
+                    sessionContext.getXMLLang(), null);
+        }
+
+        // rfc3920/9.2.3/2.
+        IQStanzaType iqType = stanza.getIQType();
+        if (iqType == null) {
+            // missing or unknown type
+            return ServerErrorResponses.getInstance().getErrorResponse(stanza,
+                    StanzaErrorType.MODIFY, StanzaErrorCondition.BAD_REQUEST,
+                    "iq-stanza requires a valid 'type' attribute to be present",
+                    sessionContext.getXMLLang(), null);
+        }
+
+        if (iqType == IQStanzaType.GET || iqType == IQStanzaType.SET) {
+            // assure, set or get contain one and only one element
+            // rfc3920/9.2.3/5.
+            if (!coreStanza.getVerifier().subElementsPresentExact(1)) {
+                return ServerErrorResponses.getInstance().getErrorResponse(stanza,
+                        StanzaErrorType.MODIFY, StanzaErrorCondition.BAD_REQUEST,
+                        "iq stanza of type get or set require exactly one child",
+                        sessionContext.getXMLLang(), null);
+            }
+        } else if (iqType == IQStanzaType.RESULT) {
+            // assure, result contains zero or one element
+            // rfc3920/9.2.3/6.
+            if (!coreStanza.getVerifier().subElementsPresentAtMost(1)) {
+                return ServerErrorResponses.getInstance().getErrorResponse(stanza,
+                        StanzaErrorType.MODIFY, StanzaErrorCondition.BAD_REQUEST,
+                        "iq stanza of type result may not have more than one child",
+                        sessionContext.getXMLLang(), null);
+            }
+
+        } else if (iqType == IQStanzaType.ERROR) {
+            // this is handled for all types of stanzas down-stack
+        }
+
+
+        return executeIQLogic(stanza, sessionContext);
+    }
+
+    /**
+     * must be overriden by specialized IQ handlers
+     */
+    protected Stanza executeIQLogic(IQStanza stanza, SessionContext sessionContext) {
+        // this is default behavior and must be replaced by overrider
+        return ServerErrorResponses.getInstance().getErrorResponse(stanza,
+                StanzaErrorType.CANCEL, StanzaErrorCondition.FEATURE_NOT_IMPLEMENTED,
+                null, null, null);
+    }
+
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/MessageHandler.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/MessageHandler.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/MessageHandler.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/MessageHandler.java Wed May 30 15:07:38 2007
@@ -0,0 +1,55 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.applicationdomains.base.handler;
+
+import org.apache.vysper.xmpp.addressing.Entity;
+import org.apache.vysper.xmpp.delivery.DeliveryException;
+import org.apache.vysper.xmpp.delivery.StanzaRelay;
+import org.apache.vysper.xmpp.server.SessionContext;
+import org.apache.vysper.xmpp.stanza.MessageStanza;
+import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
+
+/**
+ * handling message stanzas
+ */
+public class MessageHandler extends XMPPCoreStanzaHandler {
+    public String getName() {
+        return "message";
+    }
+
+    public boolean verify(Stanza stanza) {
+        return MessageStanza.isOfType(stanza);
+    }
+
+    protected Stanza executeCore(XMPPCoreStanza stanza, SessionContext sessionContext) {
+        Entity to = stanza.getTo();
+        StanzaRelay stanzaRelay = sessionContext.getServerRuntimeContext().getStanzaRelay();
+        if (!stanzaRelay.receiverExists(to)) {
+            // TODO return error stanza
+            return null;
+        }
+        try {
+            stanzaRelay.relay(to, stanza);
+        } catch (DeliveryException e) {
+            // TODO return error stanza
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        return null; // no response
+    }
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/PresenceHandler.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/PresenceHandler.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/PresenceHandler.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/PresenceHandler.java Wed May 30 15:07:38 2007
@@ -0,0 +1,40 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.applicationdomains.base.handler;
+
+import org.apache.vysper.xmpp.server.SessionContext;
+import org.apache.vysper.xmpp.stanza.PresenceStanza;
+import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
+
+/**
+ * handling presence stanzas
+ */
+public class PresenceHandler extends XMPPCoreStanzaHandler {
+    public String getName() {
+        return "presence";
+    }
+
+    public boolean verify(Stanza stanza) {
+        return PresenceStanza.isOfType(stanza);
+    }
+
+    protected Stanza executeCore(XMPPCoreStanza stanza, SessionContext sessionContext) {
+        return null;
+    }
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/StreamStartHandler.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/StreamStartHandler.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/StreamStartHandler.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/StreamStartHandler.java Wed May 30 15:07:38 2007
@@ -0,0 +1,171 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.applicationdomains.base.handler;
+
+import org.apache.vysper.xmpp.protocol.StanzaHandler;
+import org.apache.vysper.xmpp.protocol.ResponseStanzaContainer;
+import org.apache.vysper.xmpp.protocol.NamespaceURIs;
+import org.apache.vysper.xmpp.protocol.ResponseStanzaContainerImpl;
+import org.apache.vysper.xmpp.protocol.StreamErrorCondition;
+import org.apache.vysper.xmpp.protocol.SessionStateHolder;
+import org.apache.vysper.xmpp.server.SessionContext;
+import org.apache.vysper.xmpp.server.SessionState;
+import org.apache.vysper.xmpp.server.XMPPVersion;
+import org.apache.vysper.xmpp.server.response.ServerResponses;
+import org.apache.vysper.xmpp.server.response.ServerErrorResponses;
+import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.xmlfragment.XMLElementVerifier;
+import org.apache.vysper.xmpp.xmlfragment.Attribute;
+import org.apache.vysper.xmpp.addressing.EntityImpl;
+import org.apache.vysper.xmpp.addressing.EntityFormatException;
+
+/**
+ */
+public class StreamStartHandler implements StanzaHandler {
+    public String getName() {
+        return "stream";
+    }
+
+    public boolean verify(Stanza stanza) {
+        if (stanza == null) return false;
+        if (!getName().equals(stanza.getName())) return false;
+        return true;
+    }
+
+    public ResponseStanzaContainer execute(Stanza stanza, SessionContext sessionContext, SessionStateHolder sessionStateHolder) {
+        XMLElementVerifier xmlElementVerifier = stanza.getVerifier();
+        boolean jabberNamespace = xmlElementVerifier.namespacePresent(NamespaceURIs.HTTP_ETHERX_JABBER_ORG_STREAMS);
+        boolean clientCall = xmlElementVerifier.namespacePresent(NamespaceURIs.JABBER_CLIENT);
+        boolean serverCall = xmlElementVerifier.namespacePresent(NamespaceURIs.JABBER_SERVER);
+
+        if (clientCall && serverCall) serverCall = false; // silently ignore ambigous attributes
+        if (serverCall) sessionContext.setServerToServer(); else sessionContext.setClientToServer();
+
+        // http://etherx.jabber.org/streams cannot be ommitted
+        if (!jabberNamespace) {
+            return respondIllegalNamespaceError("namespace is mandatory: " + NamespaceURIs.HTTP_ETHERX_JABBER_ORG_STREAMS);
+        }
+
+        // processing xml:lang
+        String xmlLang = null;
+        if (xmlElementVerifier.attributePresent("xml:lang")) {
+            xmlLang = stanza.getAttribute("xml:lang").getValue();
+        }
+        sessionContext.setXMLLang(xmlLang);
+
+        // processing version
+        XMPPVersion responseVersion = null;
+        // if version is not present, version "0.0" is assumed, represented by NULL.
+        if (xmlElementVerifier.attributePresent("version")) {
+            Attribute attribute = stanza.getAttribute("version");
+            XMPPVersion clientVersion;
+            String versionAttributeValue = attribute.getValue();
+            try {
+                clientVersion = new XMPPVersion(versionAttributeValue);
+            } catch (IllegalArgumentException e) {
+                // version string does not conform to spec
+                return respondUnsupportedVersionError(xmlLang, versionAttributeValue, "illegal version value: ");
+            }
+            // check if version is supported
+            if (!clientVersion.equals(XMPPVersion.VERSION_1_0)) {
+                if (clientVersion.getMajor() == XMPPVersion.VERSION_1_0.getMajor()) {
+                    // we live with the higher minor version, but only support ours
+                    responseVersion = XMPPVersion.VERSION_1_0;
+                } else {
+                    // we do not support major changes, as of RFC3920
+                    return respondUnsupportedVersionError(xmlLang, versionAttributeValue, "major version change not supported: ");
+                }
+            } else {
+                responseVersion = clientVersion;
+            }
+        }
+
+        if (xmlElementVerifier.attributePresent("id")) {
+            // ignore silently (see RFC3920 4.4)
+        }
+
+        Stanza responseStanza = null;
+        if (clientCall) {
+            // RFC3920: 'to' attribute SHOULD be used by the initiating entity
+            if (xmlElementVerifier.attributePresent("to")) {
+                EntityImpl entity = null;
+                try {
+                    entity = EntityImpl.parse(stanza.getAttribute("to").getValue());
+                } catch (EntityFormatException e) {
+                    return new ResponseStanzaContainerImpl(
+                                ServerErrorResponses.getInstance().getError(StreamErrorCondition.IMPROPER_ADDRESSING,
+                                                                    sessionContext.getXMLLang(),
+                                                                    "could not parse incoming stanza's TO attribute",
+                                                                    null));
+
+                }
+                sessionContext.setInitiatingEntity(entity);
+            }
+            responseStanza = new ServerResponses().getStreamOpener(clientCall,
+                                                                   sessionContext.getServerJID(),
+                                                                   responseVersion,
+                                                                   sessionContext);
+        } else if (serverCall) {
+            // RFC3920: 'from' attribute SHOULD be used by the receiving entity
+            if (xmlElementVerifier.attributePresent("from")) {
+                EntityImpl entity = null;
+                try {
+                    entity = EntityImpl.parse(stanza.getAttribute("from").getValue());
+                } catch (EntityFormatException e) {
+                    return new ResponseStanzaContainerImpl(
+                                ServerErrorResponses.getInstance().getError(StreamErrorCondition.INVALID_FROM,
+                                                                    sessionContext.getXMLLang(),
+                                                                    "could not parse incoming stanza's FROM attribute",
+                                                                    null));
+
+                }
+            }
+            throw new RuntimeException("server connection not yet supported");
+        } else {
+            String descriptiveText = "one of the two namespaces must be present: " +
+                                     NamespaceURIs.JABBER_CLIENT +
+                                     " or " +
+                                     NamespaceURIs.JABBER_SERVER;
+            return respondIllegalNamespaceError(descriptiveText);
+        }
+
+
+        // if all is correct, go to next phase
+        sessionStateHolder.setState(SessionState.STARTED);
+
+        if (responseStanza != null) return new ResponseStanzaContainerImpl(responseStanza);
+
+        return null;
+    }
+
+    private ResponseStanzaContainer respondIllegalNamespaceError(String descriptiveText) {
+        return new ResponseStanzaContainerImpl(
+                    ServerErrorResponses.getInstance().getError(StreamErrorCondition.INVALID_NAMESPACE,
+                                                        null,
+                                                        descriptiveText,
+                                                        null));
+    }
+
+    private ResponseStanzaContainer respondUnsupportedVersionError(String xmlLang, String versionAttributeValue, String errorMessage) {
+        if (xmlLang == null) xmlLang = "en_US";
+        Stanza error = ServerErrorResponses.getInstance().getError(StreamErrorCondition.UNSUPPORTED_VERSION, xmlLang,
+                errorMessage + versionAttributeValue, null);
+        return new ResponseStanzaContainerImpl(error);
+    }
+
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/XMPPCoreStanzaHandler.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/XMPPCoreStanzaHandler.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/XMPPCoreStanzaHandler.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/base/handler/XMPPCoreStanzaHandler.java Wed May 30 15:07:38 2007
@@ -0,0 +1,95 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.applicationdomains.base.handler;
+
+import org.apache.vysper.xmpp.addressing.Entity;
+import org.apache.vysper.xmpp.protocol.ResponseStanzaContainer;
+import org.apache.vysper.xmpp.protocol.ResponseStanzaContainerImpl;
+import org.apache.vysper.xmpp.protocol.SessionStateHolder;
+import org.apache.vysper.xmpp.protocol.StanzaHandler;
+import org.apache.vysper.xmpp.protocol.StreamErrorCondition;
+import org.apache.vysper.xmpp.server.SessionContext;
+import org.apache.vysper.xmpp.server.response.ServerErrorResponses;
+import org.apache.vysper.xmpp.stanza.IQStanzaType;
+import org.apache.vysper.xmpp.stanza.Stanza;
+import org.apache.vysper.xmpp.stanza.XMPPCoreStanza;
+import org.apache.vysper.xmpp.xmlfragment.Attribute;
+
+/**
+ * foundation for the three core protocol stanzas: iq, message, presence
+ */
+/*package*/ abstract class XMPPCoreStanzaHandler implements StanzaHandler {
+
+    public ResponseStanzaContainer execute(Stanza anyStanza, SessionContext sessionContext, SessionStateHolder sessionStateHolder) {
+        XMPPCoreStanza stanza = XMPPCoreStanza.getWrapper(anyStanza);
+        if (stanza == null) throw new IllegalArgumentException("can only handle core XMPP stanzas (iq, message, presence)");
+
+        // type="error" is common to all stanza, check here some prerequisites
+        Attribute typeAttribute = stanza.getAttribute("type");
+        XMPPCoreStanza xmppCoreStanza = XMPPCoreStanza.getWrapper(stanza);
+        if (xmppCoreStanza != null && typeAttribute != null)
+        {
+            String errorDescription = null;
+            String type = typeAttribute.getValue();
+            if (IQStanzaType.ERROR.value().equals(type)) {
+                // assure, result contains zero or one element
+                // rfc3920/9.2.3/7.
+                if (!stanza.getVerifier().subElementPresent("error")) {
+                    errorDescription = "stanza of type error must include an 'error' child";
+                }
+            } else {
+                // assure, non-error result does not contain error
+                // rfc3920/9.2.3/7. + rfc3920/9.3.1/3.
+                if (stanza.getVerifier().subElementPresent("error")) {
+                    errorDescription = "stanza which is not of type error must not include an 'error' child";
+                }
+            }
+
+            // at this point, we are not allowed to respond with another error
+            // we cannot really close the stream
+            // we simply ignore it.
+            /*ResponseStanzaContainerImpl errorResponseContainer = new ResponseStanzaContainerImpl(
+                    ServerErrorResponses.getInstance().getErrorResponse(xmppCoreStanza,
+                            StanzaErrorType.MODIFY, StanzaErrorCondition.BAD_REQUEST,
+                            errorDescription,
+                            sessionContext.getXMLLang(), null)
+            );
+            return errorResponseContainer;*/
+        }
+
+        Entity to = stanza.getTo();
+        if (sessionContext.isServerToServer() && to == null) {
+            // "to" MUST be present for jabber:server
+            return new ResponseStanzaContainerImpl(ServerErrorResponses.getInstance().getError(StreamErrorCondition.IMPROPER_ADDRESSING, stanza.getXMLLang(), "missing to attribute", null));
+        }
+
+        if (to != null) {
+            // TODO ensure, that RFC3920 9.1.1 "If the value of the 'to' attribute is invalid or cannot be contacted..." is enforced
+        }
+
+        Stanza responseStanza = executeCore(stanza, sessionContext);
+
+        if (responseStanza != null) return new ResponseStanzaContainerImpl(responseStanza);
+
+        return null;
+    }
+
+    protected abstract Stanza executeCore(XMPPCoreStanza stanza, SessionContext sessionContext);
+
+
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/jabber/handler/JabberClientStanzaDictionary.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/jabber/handler/JabberClientStanzaDictionary.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/jabber/handler/JabberClientStanzaDictionary.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/jabber/handler/JabberClientStanzaDictionary.java Wed May 30 15:07:38 2007
@@ -0,0 +1,32 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.applicationdomains.jabber.handler;
+
+import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary;
+import org.apache.vysper.xmpp.protocol.NamespaceURIs;
+
+/**
+ * handler for jabber stanzas from RFC3920 (jabber:client, jabber:server)<br/>
+ * they are: message, presence, iq
+ */
+public class JabberClientStanzaDictionary extends NamespaceHandlerDictionary {
+
+    public JabberClientStanzaDictionary() {
+        super(NamespaceURIs.JABBER_CLIENT);
+    }
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/jabber/handler/JabberServerStanzaDictionary.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/jabber/handler/JabberServerStanzaDictionary.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/jabber/handler/JabberServerStanzaDictionary.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/applicationdomains/jabber/handler/JabberServerStanzaDictionary.java Wed May 30 15:07:38 2007
@@ -0,0 +1,38 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.applicationdomains.jabber.handler;
+
+import org.apache.vysper.xmpp.protocol.NamespaceURIs;
+import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary;
+
+/**
+ * handler for jabber stanzas from RFC3920 (jabber:client, jabber:server)<br/>
+ * they are: message, presence, iq
+ */
+public class JabberServerStanzaDictionary extends NamespaceHandlerDictionary {
+
+    protected JabberServerStanzaDictionary(String namespaceURI) {
+        super(namespaceURI);
+//        register(new StreamStartHandler());
+        seal();
+    }
+
+    public JabberServerStanzaDictionary() {
+        this(NamespaceURIs.JABBER_SERVER);
+    }
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/authorization/UserAuthorization.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/authorization/UserAuthorization.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/authorization/UserAuthorization.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/authorization/UserAuthorization.java Wed May 30 15:07:38 2007
@@ -0,0 +1,26 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.authorization;
+
+import org.apache.vysper.xmpp.addressing.Entity;
+
+/**
+ */
+public interface UserAuthorization {
+    boolean verifyCredentials(Entity jid, String password, Object credentials);
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/DeliveryException.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/DeliveryException.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/DeliveryException.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/DeliveryException.java Wed May 30 15:07:38 2007
@@ -0,0 +1,39 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.delivery;
+
+/**
+ */
+public class DeliveryException extends Exception {
+
+    public DeliveryException() {
+        super();
+    }
+
+    public DeliveryException(String string) {
+        super(string);
+    }
+
+    public DeliveryException(String string, Throwable throwable) {
+        super(string, throwable);
+    }
+
+    public DeliveryException(Throwable throwable) {
+        super(throwable);
+    }
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaReceiver.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaReceiver.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaReceiver.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaReceiver.java Wed May 30 15:07:38 2007
@@ -0,0 +1,29 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.delivery;
+
+import org.apache.vysper.xmpp.stanza.Stanza;
+
+/**
+ * a stanza-receiving sink
+ */
+public interface StanzaReceiver {
+
+    public void deliver(Stanza stanza);
+
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelay.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelay.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelay.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelay.java Wed May 30 15:07:38 2007
@@ -0,0 +1,32 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.delivery;
+
+import org.apache.vysper.xmpp.addressing.Entity;
+import org.apache.vysper.xmpp.stanza.Stanza;
+
+/**
+ * receives a stanza and relays to the receiving entity
+ */
+public interface StanzaRelay {
+
+    public void relay(Entity receiver, Stanza stanza) throws DeliveryException;
+
+    public boolean receiverExists(Entity receiver);
+
+}

Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelayImpl.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelayImpl.java?view=auto&rev=542950
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelayImpl.java (added)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelayImpl.java Wed May 30 15:07:38 2007
@@ -0,0 +1,46 @@
+/***********************************************************************
+ * Copyright (c) 2006-2007 The Apache Software Foundation.             *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed 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.vysper.xmpp.delivery;
+
+import org.apache.vysper.xmpp.addressing.Entity;
+import org.apache.vysper.xmpp.stanza.Stanza;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * relays stanzas to a receiver identified by a Entity
+ */
+public class StanzaRelayImpl implements StanzaRelay {
+
+    private Map<Entity, StanzaReceiver> receiverMap = new HashMap<Entity, StanzaReceiver>();
+
+    public void add(Entity receiverID, StanzaReceiver receiver) {
+        receiverMap.put(receiverID, receiver);
+    }
+
+    public void relay(Entity receiver, Stanza stanza) throws DeliveryException {
+        if (receiver == null) throw new DeliveryException("receiver cannot be NULL");
+        if (!receiverExists(receiver)) throw new DeliveryException("cannot find receiver" + receiver.getFullQualifiedName());
+        receiverMap.get(receiver).deliver(stanza);
+    }
+
+    public boolean receiverExists(Entity receiver) {
+        return receiverMap.get(receiver) != null;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org