From simpsonnathan@example.org Tue Apr 01 16:04:01 2008 Return-Path: <simpsonnathan@example.org> Delivered-To: simpsonnathan@example.org Received: (qmail 65008 invoked from network); 1 Apr 2008 16:04:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 1 Apr 2008 16:04:01 -0000 Received: (qmail 47386 invoked by uid 500); 1 Apr 2008 16:04:00 -0000 Delivered-To: simpsonnathan@example.org Received: (qmail 47280 invoked by uid 500); 1 Apr 2008 16:04:00 -0000 Mailing-List: contact simpsonnathan@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:simpsonnathan@example.org> List-Unsubscribe: <mailto:simpsonnathan@example.org> List-Post: <mailto:simpsonnathan@example.org> List-Id: <commits.labs.apache.org> Reply-To: simpsonnathan@example.org Delivered-To: mailing list simpsonnathan@example.org Received: (qmail 47269 invoked by uid 99); 1 Apr 2008 16:04:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Apr 2008 09:04:00 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Apr 2008 16:03:17 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8E5511A9832; Tue, 1 Apr 2008 09:03:29 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r643462 - /labs/site/mail.html Date: Tue, 01 Apr 2008 16:03:29 -0000 To: simpsonnathan@example.org From: simpsonnathan@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <simpsonnathan@example.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: niallp Date: Tue Apr 1 09:03:27 2008 New Revision: 643462 URL: http://svn.apache.org/viewvc?rev=643462&view=rev Log: Adjust markmail archive links to use "list home page URLs" (as per recommendation from Jason Hunter http://markmail.org/message/6vdmhdlciv6ardem) Modified: labs/site/mail.html Modified: labs/site/mail.html URL: http://svn.apache.org/viewvc/labs/site/mail.html?rev=643462&r1=643461&r2=643462&view=diff ============================================================================== --- labs/site/mail.html (original) +++ labs/site/mail.html Tue Apr 1 09:03:27 2008 @@ -44,7 +44,7 @@ <dd> <ul> <li><a href="http://mail-archives.apache.org/mod_mbox/labs-labs/" title="ASF Archive: labs">ASF Mail Archive</a></li> - <li><a href="http://labs.markmail.org/search/list:org.apache.labs.labs" title="Mark Mail: labs" class="last">Mark Mail</a></li> + <li><a href="http://markmail.org/list/org.apache.labs.labs/" title="Mark Mail: labs" class="last">Mark Mail</a></li> </ul> </dd> @@ -52,7 +52,7 @@ <dd> <ul> <li><a href="http://mail-archives.apache.org/mod_mbox/labs-commits/" title="ASF Archive: commits">ASF Mail Archive</a></li> - <li><a href="http://labs.markmail.org/search/list:org.apache.labs.commits" title="Mark Mail: commits" class="last">Mark Mail</a></li> + <li><a href="http://markmail.org/list/org.apache.labs.commits/" title="Mark Mail: commits" class="last">Mark Mail</a></li> </ul> </dd> </dl> --------------------------------------------------------------------- To unsubscribe, e-mail: simpsonnathan@example.org For additional commands, e-mail: simpsonnathan@example.org From simpsonnathan@example.org Tue Apr 08 16:16:55 2008 Return-Path: <simpsonnathan@example.org> Delivered-To: simpsonnathan@example.org Received: (qmail 19544 invoked from network); 8 Apr 2008 16:16:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 8 Apr 2008 16:16:53 -0000 Received: (qmail 24359 invoked by uid 500); 8 Apr 2008 16:16:54 -0000 Delivered-To: simpsonnathan@example.org Received: (qmail 24258 invoked by uid 500); 8 Apr 2008 16:16:53 -0000 Mailing-List: contact simpsonnathan@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:simpsonnathan@example.org> List-Unsubscribe: <mailto:simpsonnathan@example.org> List-Post: <mailto:simpsonnathan@example.org> List-Id: <commits.labs.apache.org> Reply-To: simpsonnathan@example.org Delivered-To: mailing list simpsonnathan@example.org Received: (qmail 24247 invoked by uid 99); 8 Apr 2008 16:16:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Apr 2008 09:16:53 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Apr 2008 16:16:19 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E29B31A9832; Tue, 8 Apr 2008 09:16:30 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r645987 - in /labs/vysper/src: main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java test/java/org/apache/vysper/xmpp/resourcebinding/ test/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistryTestCase.java Date: Tue, 08 Apr 2008 16:16:26 -0000 To: simpsonnathan@example.org From: simpsonnathan@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <simpsonnathan@example.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: berndf Date: Tue Apr 8 09:16:24 2008 New Revision: 645987 URL: http://svn.apache.org/viewvc?rev=645987&view=rev Log: [vysper] have a registry where we can identify sessions and bound resources (LABS-111) Added: labs/vysper/src/test/java/org/apache/vysper/xmpp/resourcebinding/ labs/vysper/src/test/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistryTestCase.java Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java?rev=645987&r1=645986&r2=645987&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java Tue Apr 8 09:16:24 2008 @@ -19,27 +19,144 @@ import org.apache.vysper.xmpp.server.SessionContext; import org.apache.vysper.xmpp.uuid.JVMBuiltinUUIDGenerator; import org.apache.vysper.xmpp.uuid.UUIDGenerator; +import org.apache.vysper.xmpp.addressing.Entity; +import org.apache.vysper.xmpp.addressing.EntityImpl; import java.util.List; import java.util.ArrayList; import java.util.Iterator; import java.util.Collections; +import java.util.Map; +import java.util.HashMap; /** - * assigns and holds resource ids + * assigns and holds resource ids and their related session */ public class ResourceRegistry { private UUIDGenerator resourceIdGenerator = new JVMBuiltinUUIDGenerator(); - protected final List<String> boundResources = new ArrayList<String>(); + + protected final Map<String, SessionContext> boundResources = new HashMap<String, SessionContext>(); + protected final Map<Entity, List<String>> entityResources = new HashMap<Entity, List<String>>(); public String bindSession(SessionContext sessionContext) { + if (sessionContext == null) throw new IllegalArgumentException("session context cannot be NULL"); + if (sessionContext.getInitiatingEntity() == null) throw new IllegalStateException("session context must have a initiating entity set"); String resourceId = resourceIdGenerator.create(); - boundResources.add(resourceId); + + synchronized (boundResources) { + synchronized (entityResources) { + boundResources.put(resourceId, sessionContext); + + Entity initiatingEntity = sessionContext.getInitiatingEntity(); + List<String> resourceList = getResourceList(initiatingEntity); + if (resourceList == null) { + resourceList = new ArrayList<String>(); + entityResources.put(getBareEntity(initiatingEntity), resourceList); + } + resourceList.add(resourceId); + } + } + return resourceId; } public Iterator<String> boundResources() { - return Collections.unmodifiableList(boundResources).iterator(); + return Collections.unmodifiableSet(boundResources.keySet()).iterator(); + } + + public void unbindResource(String resourceId) { + boundResources.remove(resourceId); + } + + public void unbindSession(SessionContext unbindingSessionContext) { + if (unbindingSessionContext == null) return; + + synchronized (boundResources) { + synchronized (entityResources) { + // collect all remove candidates + List<String> removeResourceIds = getResourcesForSession(unbindingSessionContext); + + // actually remove from bound resources + for (String removeResourceId : removeResourceIds) { + unbindResource(removeResourceId); + } + + // actually remove from entity map + List<String> resourceList = getResourceList(unbindingSessionContext.getInitiatingEntity()); + if (resourceList != null) { + resourceList.remove(removeResourceIds); + } + } + } + } + + protected List<String> getResourcesForSession(SessionContext sessionContext) { + if (sessionContext == null) return null; + + List<String> resourceIds = new ArrayList<String>(); + for (String resourceId : boundResources.keySet()) { + SessionContext visitedSessionContext = boundResources.get(resourceId); + if (visitedSessionContext != null && visitedSessionContext.getSessionId().equals(sessionContext.getSessionId())) { + resourceIds.add(resourceId); + // indeed continue iteration, session might have more than one resource bound. + } + } + return resourceIds; + } + + public SessionContext getSessionContext(String resourceId) { + return boundResources.get(resourceId); + } + + private Entity getBareEntity(Entity entity) { + if (entity.getResource() == null) return entity; // bare already + return new EntityImpl(entity.getNode(), entity.getDomain(), null); + } + + /** + * @param entity + * @return all resources bound to this entity modulo the entity's resource (if given) + */ + private List<String> getResourceList(Entity entity) { + return entityResources.get(getBareEntity(entity)); + } + + /** + * retrieve IDs of all bound resources for this entity + */ + public List<String> getBoundResources(Entity entity) { + return getBoundResources(entity, true); + } + + /** + * retrieve IDs of all bound resources for this entity + */ + public List<String> getBoundResources(Entity entity, boolean considerBareID) { + // all resources for the entity + List<String> resourceList = Collections.unmodifiableList(getResourceList(entity)); + + // if resource should not be considered, return all resources + if (considerBareID || entity.getResource() == null) return resourceList; + // resource not contained, result is empty + if (!resourceList.contains(entity.getResource())) { + return Collections.emptyList(); + } + // do we have a bound entity and want only their resource returned? + List<String> singleResult = new ArrayList<String>(); + singleResult.add(entity.getResource()); + return singleResult; + } + + + public List<SessionContext> getSessions(Entity entity) { + List<SessionContext> sessionContexts = new ArrayList<SessionContext>(); + + List<String> boundResources = getBoundResources(entity, false); + for (String resourceId : boundResources) { + sessionContexts.add(getSessionContext(resourceId)); + } + + return sessionContexts; } } Added: labs/vysper/src/test/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistryTestCase.java URL: http://svn.apache.org/viewvc/labs/vysper/src/test/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistryTestCase.java?rev=645987&view=auto ============================================================================== --- labs/vysper/src/test/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistryTestCase.java (added) +++ labs/vysper/src/test/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistryTestCase.java Tue Apr 8 09:16:24 2008 @@ -0,0 +1,151 @@ +/*********************************************************************** + * 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.resourcebinding; + +import junit.framework.TestCase; +import org.apache.vysper.xmpp.server.TestSessionContext; +import org.apache.vysper.xmpp.server.SessionContext; +import org.apache.vysper.xmpp.protocol.SessionStateHolder; +import org.apache.vysper.xmpp.addressing.Entity; +import org.apache.vysper.xmpp.addressing.EntityImpl; +import org.apache.vysper.xmpp.addressing.EntityFormatException; + +import java.util.List; + +/** + */ +public class ResourceRegistryTestCase extends TestCase { + + protected ResourceRegistry resourceRegistry = new ResourceRegistry(); + + private TestSessionContext createSessionContext(Entity entity) { + SessionStateHolder sessionStateHolder = new SessionStateHolder(); + TestSessionContext sessionContext = new TestSessionContext(sessionStateHolder); + sessionContext.setInitiatingEntity(entity); + return sessionContext; + } + + public void testSessionNotWellDefinedForResourceBinding() { + TestSessionContext sessionContext = createSessionContext(null); + assertNull(sessionContext.getInitiatingEntity()); + try { + resourceRegistry.bindSession(sessionContext); + fail("do not accept sessions with no initiating entity"); + } catch (IllegalStateException _) { + // test succeeded + } + } + + public void testAddSession() throws EntityFormatException { + TestSessionContext sessionContext = createSessionContext(EntityImpl.parse("me@test")); + String resourceId = resourceRegistry.bindSession(sessionContext); + assertNotNull(resourceId); + List<String> resourceList = resourceRegistry.getResourcesForSession(sessionContext); + assertEquals(1, resourceList.size()); + assertTrue(resourceList.contains(resourceId)); + } + + public void testAddMultipleSession() throws EntityFormatException { + TestSessionContext sessionContext1 = createSessionContext(EntityImpl.parse("me1@test")); + String resourceId1 = resourceRegistry.bindSession(sessionContext1); + TestSessionContext sessionContext2 = createSessionContext(EntityImpl.parse("me2@test")); + String resourceId2 = resourceRegistry.bindSession(sessionContext2); + assertNotNull(resourceId2); + List<String> resourceList = resourceRegistry.getResourcesForSession(sessionContext1); + assertEquals(1, resourceList.size()); + assertTrue(resourceList.contains(resourceId1)); + resourceList = resourceRegistry.getResourcesForSession(sessionContext2); + assertEquals(1, resourceList.size()); + assertTrue(resourceList.contains(resourceId2)); + + assertEquals(resourceRegistry.getSessionContext(resourceId1), sessionContext1); + assertEquals(resourceRegistry.getSessionContext(resourceId2), sessionContext2); + } + + public void testAddOneEntityMultipleResources() throws EntityFormatException { + EntityImpl entity = EntityImpl.parse("me@test"); + + TestSessionContext sessionContext1 = createSessionContext(entity); + String resourceId1 = resourceRegistry.bindSession(sessionContext1); + + TestSessionContext sessionContext2 = createSessionContext(entity); + String resourceId2 = resourceRegistry.bindSession(sessionContext2); + + assertNotNull(resourceId1); + assertNotNull(resourceId2); + + List<String> resourceList = resourceRegistry.getBoundResources(entity); + assertEquals(2, resourceList.size()); + assertTrue(resourceList.contains(resourceId1)); + assertTrue(resourceList.contains(resourceId2)); + + List<SessionContext> sessionList = resourceRegistry.getSessions(entity); + assertEquals(2, resourceList.size()); + assertTrue(sessionList.contains(sessionContext1)); + assertTrue(sessionList.contains(sessionContext2)); + } + + public void testAddOneEntityMultipleResources_TolerateResourceIds() throws EntityFormatException { + EntityImpl entity = EntityImpl.parse("me@test"); + + TestSessionContext sessionContext1 = createSessionContext(EntityImpl.parse("me@test/xy")); + String resourceId1 = resourceRegistry.bindSession(sessionContext1); + + TestSessionContext sessionContext2 = createSessionContext(EntityImpl.parse("me@test/ab")); + String resourceId2 = resourceRegistry.bindSession(sessionContext2); + + assertNotNull(resourceId1); + assertNotNull(resourceId2); + + List<String> resourceList = resourceRegistry.getBoundResources(entity); + assertEquals(2, resourceList.size()); + assertTrue(resourceList.contains(resourceId1)); + assertTrue(resourceList.contains(resourceId2)); + + List<SessionContext> sessionList = resourceRegistry.getSessions(entity); + assertEquals(2, resourceList.size()); + assertTrue(sessionList.contains(sessionContext1)); + assertTrue(sessionList.contains(sessionContext2)); + } + + public void testSameEntityMultipleResources() throws EntityFormatException { + EntityImpl entity = EntityImpl.parse("me@test"); + + TestSessionContext sessionContext1 = createSessionContext(entity); + String resourceId1 = resourceRegistry.bindSession(sessionContext1); + + TestSessionContext sessionContext2 = createSessionContext(entity); + String resourceId2 = resourceRegistry.bindSession(sessionContext2); + + // resource ids are different + assertFalse(resourceId1.equals(resourceId2)); + } + + public void testUnbindSimple() throws EntityFormatException { + EntityImpl entity = EntityImpl.parse("me@test"); + + TestSessionContext sessionContext1 = createSessionContext(entity); + String resourceId1 = resourceRegistry.bindSession(sessionContext1); + assertEquals(sessionContext1, resourceRegistry.getSessionContext(resourceId1)); + + resourceRegistry.unbindResource(resourceId1); + + assertNull(resourceRegistry.getSessionContext(resourceId1)); + assertEquals(0, resourceRegistry.getBoundResources(entity).size()); + } + +} --------------------------------------------------------------------- To unsubscribe, e-mail: simpsonnathan@example.org For additional commands, e-mail: simpsonnathan@example.org From simpsonnathan@example.org Wed Apr 09 07:28:22 2008 Return-Path: <simpsonnathan@example.org> Delivered-To: simpsonnathan@example.org Received: (qmail 49846 invoked from network); 9 Apr 2008 07:28:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 9 Apr 2008 07:28:21 -0000 Received: (qmail 24506 invoked by uid 500); 9 Apr 2008 07:28:21 -0000 Delivered-To: simpsonnathan@example.org Received: (qmail 24397 invoked by uid 500); 9 Apr 2008 07:28:21 -0000 Mailing-List: contact simpsonnathan@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:simpsonnathan@example.org> List-Unsubscribe: <mailto:simpsonnathan@example.org> List-Post: <mailto:simpsonnathan@example.org> List-Id: <commits.labs.apache.org> Reply-To: simpsonnathan@example.org Delivered-To: mailing list simpsonnathan@example.org Received: (qmail 24386 invoked by uid 99); 9 Apr 2008 07:28:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Apr 2008 00:28:21 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Apr 2008 07:27:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 93F711A9832; Wed, 9 Apr 2008 00:27:59 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r646210 - in /labs/vysper/src: main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java test/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistryTestCase.java Date: Wed, 09 Apr 2008 07:27:55 -0000 To: simpsonnathan@example.org From: simpsonnathan@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <simpsonnathan@example.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: berndf Date: Wed Apr 9 00:27:52 2008 New Revision: 646210 URL: http://svn.apache.org/viewvc?rev=646210&view=rev Log: [vysper] fix resource unbinding (LABS-111) Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java labs/vysper/src/test/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistryTestCase.java Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java?rev=646210&r1=646209&r2=646210&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistry.java Wed Apr 9 00:27:52 2008 @@ -66,7 +66,14 @@ } public void unbindResource(String resourceId) { - boundResources.remove(resourceId); + synchronized (boundResources) { + synchronized (entityResources) { + SessionContext sessionContext = boundResources.get(resourceId); + List<String> resourceListForSession = getResourceList(sessionContext.getInitiatingEntity()); + resourceListForSession.remove(resourceId); + boundResources.remove(resourceId); + } + } } public void unbindSession(SessionContext unbindingSessionContext) { @@ -79,13 +86,13 @@ // actually remove from bound resources for (String removeResourceId : removeResourceIds) { - unbindResource(removeResourceId); + boundResources.remove(removeResourceId); } // actually remove from entity map List<String> resourceList = getResourceList(unbindingSessionContext.getInitiatingEntity()); if (resourceList != null) { - resourceList.remove(removeResourceIds); + resourceList.removeAll(removeResourceIds); } } } Modified: labs/vysper/src/test/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistryTestCase.java URL: http://svn.apache.org/viewvc/labs/vysper/src/test/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistryTestCase.java?rev=646210&r1=646209&r2=646210&view=diff ============================================================================== --- labs/vysper/src/test/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistryTestCase.java (original) +++ labs/vysper/src/test/java/org/apache/vysper/xmpp/resourcebinding/ResourceRegistryTestCase.java Wed Apr 9 00:27:52 2008 @@ -135,7 +135,7 @@ assertFalse(resourceId1.equals(resourceId2)); } - public void testUnbindSimple() throws EntityFormatException { + public void testUnbindResourceSimple() throws EntityFormatException { EntityImpl entity = EntityImpl.parse("me@test"); TestSessionContext sessionContext1 = createSessionContext(entity); @@ -143,6 +143,19 @@ assertEquals(sessionContext1, resourceRegistry.getSessionContext(resourceId1)); resourceRegistry.unbindResource(resourceId1); + + assertNull(resourceRegistry.getSessionContext(resourceId1)); + assertEquals(0, resourceRegistry.getBoundResources(entity).size()); + } + + public void testUnbindSessionSimple() throws EntityFormatException { + EntityImpl entity = EntityImpl.parse("me@test"); + + TestSessionContext sessionContext1 = createSessionContext(entity); + String resourceId1 = resourceRegistry.bindSession(sessionContext1); + assertEquals(sessionContext1, resourceRegistry.getSessionContext(resourceId1)); + + resourceRegistry.unbindSession(sessionContext1); assertNull(resourceRegistry.getSessionContext(resourceId1)); assertEquals(0, resourceRegistry.getBoundResources(entity).size()); --------------------------------------------------------------------- To unsubscribe, e-mail: simpsonnathan@example.org For additional commands, e-mail: simpsonnathan@example.org From simpsonnathan@example.org Wed Apr 09 13:43:47 2008 Return-Path: <simpsonnathan@example.org> Delivered-To: simpsonnathan@example.org Received: (qmail 86583 invoked from network); 9 Apr 2008 13:43:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 9 Apr 2008 13:43:46 -0000 Received: (qmail 80190 invoked by uid 500); 9 Apr 2008 13:43:46 -0000 Delivered-To: simpsonnathan@example.org Received: (qmail 80094 invoked by uid 500); 9 Apr 2008 13:43:46 -0000 Mailing-List: contact simpsonnathan@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:simpsonnathan@example.org> List-Unsubscribe: <mailto:simpsonnathan@example.org> List-Post: <mailto:simpsonnathan@example.org> List-Id: <commits.labs.apache.org> Reply-To: simpsonnathan@example.org Delivered-To: mailing list simpsonnathan@example.org Received: (qmail 80083 invoked by uid 99); 9 Apr 2008 13:43:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Apr 2008 06:43:46 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Apr 2008 13:43:02 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4FE1D1A9838; Wed, 9 Apr 2008 06:43:21 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r646344 - in /labs/vysper/src/main/java/org/apache/vysper/xmpp/modules: Module.java ModuleRegistry.java ServerRuntimeContextService.java ServiceDiscoveryInfo.java Date: Wed, 09 Apr 2008 13:43:20 -0000 To: simpsonnathan@example.org From: simpsonnathan@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <simpsonnathan@example.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: berndf Date: Wed Apr 9 06:43:19 2008 New Revision: 646344 URL: http://svn.apache.org/viewvc?rev=646344&view=rev Log: [vysper] first take of module interfaces (LABS-100) Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/Module.java labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ModuleRegistry.java labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServerRuntimeContextService.java labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServiceDiscoveryInfo.java Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/Module.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/Module.java?rev=646344&view=auto ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/Module.java (added) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/Module.java Wed Apr 9 06:43:19 2008 @@ -0,0 +1,48 @@ +/*********************************************************************** + * 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.modules; + +import org.apache.vysper.xmpp.protocol.HandlerDictionary; + +import java.util.List; + +/** + * a plug-in which adds a certain feature to the server like Messaging, Presence or + * any of the XMPP extension protocols. + */ +public interface Module { + + String getName(); + + String getVersion(); + + /** + * all dictionaries to be added to the server + */ + List<HandlerDictionary> getHandlerDictionaries(); + + /** + * all objects to be added to the server runtime context + */ + List<ServerRuntimeContextService> getServerServices(); + + /** + * all info needed to add to service discovery (XEP-0030) + */ + List<ServiceDiscoveryInfo> getServiceDiscoveryInfos(); + +} Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ModuleRegistry.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ModuleRegistry.java?rev=646344&view=auto ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ModuleRegistry.java (added) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ModuleRegistry.java Wed Apr 9 06:43:19 2008 @@ -0,0 +1,9 @@ +package org.apache.vysper.xmpp.modules; + +/** + */ +public interface ModuleRegistry { + + void addModule(Module module); + +} Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServerRuntimeContextService.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServerRuntimeContextService.java?rev=646344&view=auto ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServerRuntimeContextService.java (added) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServerRuntimeContextService.java Wed Apr 9 06:43:19 2008 @@ -0,0 +1,8 @@ +package org.apache.vysper.xmpp.modules; + +/** + * a service which is managed and retrievable through the server runtime context + */ +public interface ServerRuntimeContextService { + String getName(); +} Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServiceDiscoveryInfo.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServiceDiscoveryInfo.java?rev=646344&view=auto ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServiceDiscoveryInfo.java (added) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServiceDiscoveryInfo.java Wed Apr 9 06:43:19 2008 @@ -0,0 +1,7 @@ +package org.apache.vysper.xmpp.modules; + +/** + * information about what to add to the service discovery + */ +public interface ServiceDiscoveryInfo { +} --------------------------------------------------------------------- To unsubscribe, e-mail: simpsonnathan@example.org For additional commands, e-mail: simpsonnathan@example.org From simpsonnathan@example.org Wed Apr 09 13:52:01 2008 Return-Path: <simpsonnathan@example.org> Delivered-To: simpsonnathan@example.org Received: (qmail 89571 invoked from network); 9 Apr 2008 13:52:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 9 Apr 2008 13:52:00 -0000 Received: (qmail 96315 invoked by uid 500); 9 Apr 2008 13:52:00 -0000 Delivered-To: simpsonnathan@example.org Received: (qmail 96216 invoked by uid 500); 9 Apr 2008 13:52:00 -0000 Mailing-List: contact simpsonnathan@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:simpsonnathan@example.org> List-Unsubscribe: <mailto:simpsonnathan@example.org> List-Post: <mailto:simpsonnathan@example.org> List-Id: <commits.labs.apache.org> Reply-To: simpsonnathan@example.org Delivered-To: mailing list simpsonnathan@example.org Received: (qmail 96205 invoked by uid 99); 9 Apr 2008 13:52:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Apr 2008 06:52:00 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Apr 2008 13:51:26 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CAF361A9832; Wed, 9 Apr 2008 06:51:38 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r646348 - in /labs/vysper/src/main: config/ java/org/apache/vysper/xmpp/delivery/ java/org/apache/vysper/xmpp/modules/ java/org/apache/vysper/xmpp/protocol/ java/org/apache/vysper/xmpp/server/ Date: Wed, 09 Apr 2008 13:51:36 -0000 To: simpsonnathan@example.org From: simpsonnathan@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <simpsonnathan@example.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: berndf Date: Wed Apr 9 06:51:34 2008 New Revision: 646348 URL: http://svn.apache.org/viewvc?rev=646348&view=rev Log: [vysper] make resource registry available on the ServerRuntimeContext level (LABS-94) add license header to modules package files (LABS-115) handle messages (LABS-100) Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/MasterStanzaRelay.java Modified: labs/vysper/src/main/config/spring-config.xml labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ModuleRegistry.java labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServerRuntimeContextService.java labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServiceDiscoveryInfo.java labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/SessionStateHolder.java labs/vysper/src/main/java/org/apache/vysper/xmpp/server/AbstractSessionContext.java labs/vysper/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java labs/vysper/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java Modified: labs/vysper/src/main/config/spring-config.xml URL: http://svn.apache.org/viewvc/labs/vysper/src/main/config/spring-config.xml?rev=646348&r1=646347&r2=646348&view=diff ============================================================================== --- labs/vysper/src/main/config/spring-config.xml (original) +++ labs/vysper/src/main/config/spring-config.xml Wed Apr 9 06:51:34 2008 @@ -33,7 +33,11 @@ <!-- Vysper Server singletons --> - <bean id="stanzaRelay" class="org.apache.vysper.xmpp.delivery.RecordingStanzaRelay" /> + <bean name="resourceRegistry" class="org.apache.vysper.xmpp.resourcebinding.ResourceRegistry" /> + + <bean id="stanzaRelay" class="org.apache.vysper.xmpp.delivery.MasterStanzaRelay" > + <constructor-arg ref="resourceRegistry"/> + </bean> <bean id="serverFeatures" class="org.apache.vysper.xmpp.server.ServerFeatures"> <constructor-arg value="true" /> @@ -65,13 +69,13 @@ <bean class="org.apache.vysper.xmpp.modules.core.compatibility.jabber_iq_auth.JabberIQAuthDictionary"/> </list> </constructor-arg> + <constructor-arg ref="resourceRegistry"/> <property name="tlsContextFactory" ref="tlsContextFactory" /> <property name="userAuthorization" > <bean class="org.apache.vysper.xmpp.authorization.SimpleUserAuthorization"> <constructor-arg index="0"> <map> <entry key="simpsonnathan@example.org" value="password1" /> - <entry key="user1@localhost" value="password1" /> </map> </constructor-arg> </bean> Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/MasterStanzaRelay.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/MasterStanzaRelay.java?rev=646348&view=auto ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/MasterStanzaRelay.java (added) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/delivery/MasterStanzaRelay.java Wed Apr 9 06:51:34 2008 @@ -0,0 +1,79 @@ +/*********************************************************************** + * 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.resourcebinding.ResourceRegistry; +import org.apache.vysper.xmpp.stanza.Stanza; +import org.apache.vysper.xmpp.server.SessionContext; +import org.apache.vysper.xmpp.writer.StanzaWriter; + +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.List; + +/** + * relays stanzas to internal or external servers + * TODO: but right now, it only delivers to internal sessions + */ +public class MasterStanzaRelay implements StanzaRelay { + + protected ResourceRegistry resourceRegistry; + protected final ExecutorService executor = Executors.newSingleThreadExecutor(); + + public MasterStanzaRelay(ResourceRegistry resourceRegistry) { + this.resourceRegistry = resourceRegistry; + } + + public void relay(Entity receiver, Stanza stanza) throws DeliveryException { + executor.submit(new Relay(receiver, stanza)); + } + + public boolean receiverExists(Entity receiver) { + // TODO this is a temp solution, since we only check for 'online' users yet + return !resourceRegistry.getSessions(receiver).isEmpty(); + } + + private class Relay implements Callable<Boolean> { + private Entity receiver; + private Stanza stanza; + + Relay(Entity receiver, Stanza stanza) { + this.receiver = receiver; + this.stanza = stanza; + } + + public Entity getReceiver() { + return receiver; + } + + public Stanza getStanza() { + return stanza; + } + + public Boolean call() throws Exception { + List<SessionContext> receivingSessions = resourceRegistry.getSessions(receiver); + for (SessionContext sessionContext : receivingSessions) { + StanzaWriter stanzaWriter = sessionContext.getResponseWriter(); + stanzaWriter.write(stanza); + } + return Boolean.TRUE; + } + } + +} Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ModuleRegistry.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ModuleRegistry.java?rev=646348&r1=646347&r2=646348&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ModuleRegistry.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ModuleRegistry.java Wed Apr 9 06:51:34 2008 @@ -1,3 +1,19 @@ +/*********************************************************************** + * 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.modules; /** Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServerRuntimeContextService.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServerRuntimeContextService.java?rev=646348&r1=646347&r2=646348&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServerRuntimeContextService.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServerRuntimeContextService.java Wed Apr 9 06:51:34 2008 @@ -1,3 +1,19 @@ +/*********************************************************************** + * 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.modules; /** Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServiceDiscoveryInfo.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServiceDiscoveryInfo.java?rev=646348&r1=646347&r2=646348&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServiceDiscoveryInfo.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/ServiceDiscoveryInfo.java Wed Apr 9 06:51:34 2008 @@ -1,3 +1,19 @@ +/*********************************************************************** + * 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.modules; /** Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/SessionStateHolder.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/SessionStateHolder.java?rev=646348&r1=646347&r2=646348&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/SessionStateHolder.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/SessionStateHolder.java Wed Apr 9 06:51:34 2008 @@ -33,5 +33,9 @@ public void setState(SessionState newState) { currentState = newState; System.err.println("session state changed to = " + newState); +if (currentState == SessionState.CLOSED) { + currentState = SessionState.AUTHENTICATED; +} + System.err.println("session state changed to = " + newState); } } Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/server/AbstractSessionContext.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/server/AbstractSessionContext.java?rev=646348&r1=646347&r2=646348&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/server/AbstractSessionContext.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/server/AbstractSessionContext.java Wed Apr 9 06:51:34 2008 @@ -36,7 +36,6 @@ protected String xmlLang; protected SessionStateHolder sessionStateHolder; protected Entity serverEntity; - protected ResourceRegistry registry = new ResourceRegistry(); private Entity initiatingEntity; private boolean serverToServer = false; @@ -108,6 +107,6 @@ // TODO we should impose a hard limit on the number of bound resources per session (in ServerConfiguration) // TODO to avoid DoS attacks based on resource binding and to shield against clients running berserk - return registry.bindSession(this); + return getServerRuntimeContext().getResourceRegistry().bindSession(this); } } Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java?rev=646348&r1=646347&r2=646348&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java Wed Apr 9 06:51:34 2008 @@ -22,19 +22,26 @@ import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary; import org.apache.vysper.xmpp.protocol.StanzaHandler; import org.apache.vysper.xmpp.protocol.StanzaHandlerLookup; +import org.apache.vysper.xmpp.protocol.HandlerDictionary; import org.apache.vysper.xmpp.security.TLSContextFactory; import org.apache.vysper.xmpp.stanza.Stanza; import org.apache.vysper.xmpp.uuid.JVMBuiltinUUIDGenerator; import org.apache.vysper.xmpp.uuid.UUIDGenerator; import org.apache.vysper.xmpp.authorization.UserAuthorization; import org.apache.vysper.xmpp.authorization.SimpleUserAuthorization; +import org.apache.vysper.xmpp.modules.ModuleRegistry; +import org.apache.vysper.xmpp.modules.Module; +import org.apache.vysper.xmpp.modules.ServerRuntimeContextService; +import org.apache.vysper.xmpp.resourcebinding.ResourceRegistry; import javax.net.ssl.SSLContext; import java.util.List; +import java.util.Map; +import java.util.HashMap; /** */ -public class DefaultServerRuntimeContext implements ServerRuntimeContext { +public class DefaultServerRuntimeContext implements ServerRuntimeContext, ModuleRegistry { private StanzaHandlerLookup stanzaHandlerLookup = new StanzaHandlerLookup(); private Entity serverEntity; @@ -43,6 +50,8 @@ private SSLContext sslContext = null; private UUIDGenerator resourceIdGenerator = new JVMBuiltinUUIDGenerator(); private UserAuthorization userAuthorization = new SimpleUserAuthorization(); + private ResourceRegistry resourceRegistry; + final private Map<String, ServerRuntimeContextService> serverRuntimeContextServiceMap = new HashMap<String, ServerRuntimeContextService>(); public DefaultServerRuntimeContext(Entity serverEntity, StanzaRelay stanzaRelay) { @@ -53,9 +62,11 @@ public DefaultServerRuntimeContext(Entity serverEntity, StanzaRelay stanzaRelay, ServerFeatures serverFeatures, - List<NamespaceHandlerDictionary> dictionaries) { + List<NamespaceHandlerDictionary> dictionaries, + ResourceRegistry resourceRegistry) { this(serverEntity, stanzaRelay); this.serverFeatures = serverFeatures; + this.resourceRegistry = resourceRegistry; addDictionaries(dictionaries); } @@ -110,7 +121,53 @@ return userAuthorization; } + public ResourceRegistry getResourceRegistry() { + return resourceRegistry; + } + public void setUserAuthorization(UserAuthorization userAuthorization) { this.userAuthorization = userAuthorization; + } + + public void registerServerRuntimeContextService(ServerRuntimeContextService service) { + if (service == null) throw new IllegalStateException("service must not be null"); + if (serverRuntimeContextServiceMap.get(service.getName()) == null) { + throw new IllegalStateException("service already registered: " + service.getName()); + } + serverRuntimeContextServiceMap.put(service.getName(), service); + } + + public ServerRuntimeContextService getServerRuntimeContextService(String name) { + return serverRuntimeContextServiceMap.get(name); + } + + public void setModules(List<Module> modules) { + for (Module module : modules) { + addModule(module); + } + } + + public void addModule(Module module) { + + List<ServerRuntimeContextService> serviceList = module.getServerServices(); + if (serviceList != null) { + for (ServerRuntimeContextService serverRuntimeContextService : serviceList) { + registerServerRuntimeContextService(serverRuntimeContextService); + } + } + + // TODO not yet implemented: use module.getServiceDiscoveryInfos() + + List<HandlerDictionary> handlerDictionaryList = module.getHandlerDictionaries(); + if (handlerDictionaryList != null) { + for (HandlerDictionary handlerDictionary : handlerDictionaryList) { + if (handlerDictionary instanceof NamespaceHandlerDictionary) { + addDictionary((NamespaceHandlerDictionary) handlerDictionary); + } else { + throw new RuntimeException("arbitrary HandlerDictionary implementations not supported yet, only NamespaceHandlerDictionary."); + } + } + } + } } Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java?rev=646348&r1=646347&r2=646348&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java Wed Apr 9 06:51:34 2008 @@ -22,6 +22,8 @@ import org.apache.vysper.xmpp.protocol.StanzaHandler; import org.apache.vysper.xmpp.stanza.Stanza; import org.apache.vysper.xmpp.authorization.UserAuthorization; +import org.apache.vysper.xmpp.modules.ServerRuntimeContextService; +import org.apache.vysper.xmpp.resourcebinding.ResourceRegistry; import javax.net.ssl.SSLContext; @@ -44,4 +46,10 @@ SSLContext getSslContext(); UserAuthorization getUserAuthorization(); + + ResourceRegistry getResourceRegistry(); + + void registerServerRuntimeContextService(ServerRuntimeContextService service); + + ServerRuntimeContextService getServerRuntimeContextService(String name); } --------------------------------------------------------------------- To unsubscribe, e-mail: simpsonnathan@example.org For additional commands, e-mail: simpsonnathan@example.org From simpsonnathan@example.org Fri Apr 11 07:04:15 2008 Return-Path: <simpsonnathan@example.org> Delivered-To: simpsonnathan@example.org Received: (qmail 61459 invoked from network); 11 Apr 2008 07:04:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 11 Apr 2008 07:04:14 -0000 Received: (qmail 72375 invoked by uid 500); 11 Apr 2008 07:04:15 -0000 Delivered-To: simpsonnathan@example.org Received: (qmail 72272 invoked by uid 500); 11 Apr 2008 07:04:14 -0000 Mailing-List: contact simpsonnathan@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:simpsonnathan@example.org> List-Unsubscribe: <mailto:simpsonnathan@example.org> List-Post: <mailto:simpsonnathan@example.org> List-Id: <commits.labs.apache.org> Reply-To: simpsonnathan@example.org Delivered-To: mailing list simpsonnathan@example.org Received: (qmail 72261 invoked by uid 99); 11 Apr 2008 07:04:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2008 00:04:14 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2008 07:03:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B97F61A9838; Fri, 11 Apr 2008 00:03:53 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r647069 - in /labs/vysper/src/main/java/org/apache/vysper/xmpp: modules/roster/ modules/roster/RosterDictionary.java modules/roster/handler/ modules/roster/handler/IQRosterHandler.java protocol/NamespaceURIs.java Date: Fri, 11 Apr 2008 07:03:53 -0000 To: simpsonnathan@example.org From: simpsonnathan@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <simpsonnathan@example.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: berndf Date: Fri Apr 11 00:03:36 2008 New Revision: 647069 URL: http://svn.apache.org/viewvc?rev=647069&view=rev Log: [vysper] add very basic (empty) roster retrieval (LABS-119) Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/RosterDictionary.java - copied, changed from r628539, labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/session/SessionStanzaDictionary.java labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/handler/ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/handler/IQRosterHandler.java - copied, changed from r628539, labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/bind/handler/IQBindHandler.java Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/NamespaceURIs.java Copied: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/RosterDictionary.java (from r628539, labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/session/SessionStanzaDictionary.java) URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/RosterDictionary.java?p2=labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/RosterDictionary.java&p1=labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/session/SessionStanzaDictionary.java&r1=628539&r2=647069&rev=647069&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/session/SessionStanzaDictionary.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/RosterDictionary.java Fri Apr 11 00:03:36 2008 @@ -15,20 +15,20 @@ * permissions and limitations under the License. * ***********************************************************************/ -package org.apache.vysper.xmpp.modules.core.session; +package org.apache.vysper.xmpp.modules.roster; -import org.apache.vysper.xmpp.modules.core.session.handler.IQSessionHandler; +import org.apache.vysper.xmpp.modules.roster.handler.IQRosterHandler; import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary; import org.apache.vysper.xmpp.protocol.NamespaceURIs; /** - * handler for session establishment (RFC3921). this logic is planned to be removed in revisions of RFC3921. + * handler for roster retrieval (RFC3921#7.3) */ -public class SessionStanzaDictionary extends NamespaceHandlerDictionary { +public class RosterDictionary extends NamespaceHandlerDictionary { - public SessionStanzaDictionary() { - super(NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_SESSION); - register(new IQSessionHandler()); + public RosterDictionary() { + super(NamespaceURIs.JABBER_IQ_ROSTER); + register(new IQRosterHandler()); seal(); } } Copied: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/handler/IQRosterHandler.java (from r628539, labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/bind/handler/IQBindHandler.java) URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/handler/IQRosterHandler.java?p2=labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/handler/IQRosterHandler.java&p1=labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/bind/handler/IQBindHandler.java&r1=628539&r2=647069&rev=647069&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/bind/handler/IQBindHandler.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/roster/handler/IQRosterHandler.java Fri Apr 11 00:03:36 2008 @@ -15,26 +15,23 @@ * permissions and limitations under the License. * ***********************************************************************/ -package org.apache.vysper.xmpp.modules.core.bind.handler; +package org.apache.vysper.xmpp.modules.roster.handler; import org.apache.vysper.xmpp.modules.core.base.handler.IQHandler; import org.apache.vysper.xmpp.protocol.NamespaceURIs; import org.apache.vysper.xmpp.server.SessionContext; 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.StanzaBuilder; -import org.apache.vysper.xmpp.stanza.IQStanzaType; -import org.apache.vysper.xmpp.resourcebinding.BindException; -import org.apache.vysper.xmpp.addressing.Entity; -import org.apache.vysper.xmpp.addressing.EntityImpl; /** * handles bind requests */ -public class IQBindHandler extends IQHandler { +public class IQRosterHandler extends IQHandler { protected boolean verifyNamespace(Stanza stanza) { - return verifyInnerNamespace(stanza, NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_BIND); + return verifyInnerNamespace(stanza, NamespaceURIs.JABBER_IQ_ROSTER); } protected Stanza executeIQLogic(IQStanza stanza, SessionContext sessionContext) { @@ -44,13 +41,13 @@ case ERROR: new RuntimeException("iq stanza type ERROR not yet handled"); case GET: - new RuntimeException("iq stanza type GET not yet handled"); - break; + return retrieveRoster(stanza, sessionContext); case RESULT: new RuntimeException("iq stanza type RESULT not yet handled"); break; case SET: - return bindNewResource(stanza, sessionContext); + new RuntimeException("iq stanza type GET not yet handled"); + break; default: new RuntimeException("iq stanza type not supported: " + stanza.getIQType()); } @@ -58,45 +55,15 @@ return null; } - private Stanza bindNewResource(IQStanza stanza, SessionContext sessionContext) { - - // As per RFC3920.7, the client may propose a resource id to the server: - // - // <iq type='set' id='bind_2'> - // <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'> - // <resource>someresource</resource> - // </bind> - // </iq> - // - // The client's proposed resource id is ignored by this server. + private Stanza retrieveRoster(IQStanza stanza, SessionContext sessionContext) { - String resourceId = null; - try { - resourceId = sessionContext.bindResource(); - } catch (BindException e) { - return bindError(stanza, sessionContext); - } - - Entity entity = new EntityImpl(sessionContext.getInitiatingEntity(), resourceId); - StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(IQStanzaType.RESULT, stanza.getID()). - startInnerElement("bind"). - addNamespaceAttribute(NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_BIND). - startInnerElement("jid").addText(entity.getFullQualifiedName()).endInnerElement(). - endInnerElement(); + startInnerElement("query", NamespaceURIs.JABBER_IQ_ROSTER); + // TODO add roster items + stanzaBuilder.endInnerElement(); return stanzaBuilder.getFinalStanza(); } - private Stanza bindError(IQStanza stanza, SessionContext sessionContext) { - StanzaBuilder stanzaBuilder = - StanzaBuilder.createIQStanza(IQStanzaType.ERROR, stanza.getID()). - startInnerElement("error"). - addAttribute("type", "cancel"). - startInnerElement("not-allowed", NamespaceURIs.URN_IETF_PARAMS_XML_NS_XMPP_STANZAS). - endInnerElement(); - - return stanzaBuilder.getFinalStanza(); - } } Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/NamespaceURIs.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/NamespaceURIs.java?rev=647069&r1=647068&r2=647069&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/NamespaceURIs.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/NamespaceURIs.java Fri Apr 11 00:03:36 2008 @@ -31,6 +31,7 @@ public static final String JABBER_CLIENT = "jabber:client"; public static final String JABBER_SERVER = "jabber:server"; public static final String JABBER_SERVER_DIALBACK = "jabber:server:dialback"; + public static final String JABBER_IQ_ROSTER = "jabber:iq:roster"; // compatibility namespaces public static final String JABBER_IQ_AUTH_COMPATIBILITY = "jabber:iq:auth"; --------------------------------------------------------------------- To unsubscribe, e-mail: simpsonnathan@example.org For additional commands, e-mail: simpsonnathan@example.org From simpsonnathan@example.org Fri Apr 11 07:16:03 2008 Return-Path: <simpsonnathan@example.org> Delivered-To: simpsonnathan@example.org Received: (qmail 66076 invoked from network); 11 Apr 2008 07:16:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 11 Apr 2008 07:16:02 -0000 Received: (qmail 88567 invoked by uid 500); 11 Apr 2008 07:16:03 -0000 Delivered-To: simpsonnathan@example.org Received: (qmail 88458 invoked by uid 500); 11 Apr 2008 07:16:02 -0000 Mailing-List: contact simpsonnathan@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:simpsonnathan@example.org> List-Unsubscribe: <mailto:simpsonnathan@example.org> List-Post: <mailto:simpsonnathan@example.org> List-Id: <commits.labs.apache.org> Reply-To: simpsonnathan@example.org Delivered-To: mailing list simpsonnathan@example.org Received: (qmail 88447 invoked by uid 99); 11 Apr 2008 07:16:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2008 00:16:02 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2008 07:15:19 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BDC3A1A9832; Fri, 11 Apr 2008 00:15:27 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r647070 - in /labs/vysper/src: main/config/ main/java/org/apache/vysper/xmpp/modules/core/base/handler/ main/java/org/apache/vysper/xmpp/modules/core/compatibility/jabber_iq_auth/handler/ main/java/org/apache/vysper/xmpp/protocol/ main/java... Date: Fri, 11 Apr 2008 07:15:24 -0000 To: simpsonnathan@example.org From: simpsonnathan@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <simpsonnathan@example.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: berndf Date: Fri Apr 11 00:15:22 2008 New Revision: 647070 URL: http://svn.apache.org/viewvc?rev=647070&view=rev Log: [vysper] for the error response class make distinction between stanza and stream errors clear (LABS-119) improve message stanza handling (LABS-100) make IQ stanza handler return service-unavailable for unknown IQs (LABS-99) Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ServiceUnavailableStanzaErrorHandler.java Modified: labs/vysper/src/main/config/spring-config.xml labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/IQHandler.java labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/MessageHandler.java labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/StreamStartHandler.java labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/XMPPCoreStanzaHandler.java labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/compatibility/jabber_iq_auth/handler/IQAuthCompatibilityHandler.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/StanzaHandlerLookup.java labs/vysper/src/main/java/org/apache/vysper/xmpp/server/response/ServerErrorResponses.java labs/vysper/src/main/java/org/apache/vysper/xmpp/writer/DenseStanzaLogRenderer.java labs/vysper/src/test/java/org/apache/vysper/smack/BasicClient.java Modified: labs/vysper/src/main/config/spring-config.xml URL: http://svn.apache.org/viewvc/labs/vysper/src/main/config/spring-config.xml?rev=647070&r1=647069&r2=647070&view=diff ============================================================================== --- labs/vysper/src/main/config/spring-config.xml (original) +++ labs/vysper/src/main/config/spring-config.xml Fri Apr 11 00:15:22 2008 @@ -67,6 +67,7 @@ <bean class="org.apache.vysper.xmpp.modules.core.bind.BindResourceDictionary"/> <bean class="org.apache.vysper.xmpp.modules.core.session.SessionStanzaDictionary"/> <bean class="org.apache.vysper.xmpp.modules.core.compatibility.jabber_iq_auth.JabberIQAuthDictionary"/> + <bean class="org.apache.vysper.xmpp.modules.roster.RosterDictionary"/> </list> </constructor-arg> <constructor-arg ref="resourceRegistry"/> @@ -76,6 +77,7 @@ <constructor-arg index="0"> <map> <entry key="simpsonnathan@example.org" value="password1" /> + <entry key="simpsonnathan@example.org" value="password1" /> </map> </constructor-arg> </bean> Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/IQHandler.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/IQHandler.java?rev=647070&r1=647069&r2=647070&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/IQHandler.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/IQHandler.java Fri Apr 11 00:15:22 2008 @@ -59,8 +59,8 @@ // rfc3920/9.2.3/1. String id = stanza.getID(); if (id == null) { - return ServerErrorResponses.getInstance().getErrorResponse(stanza, - StanzaErrorType.MODIFY, StanzaErrorCondition.BAD_REQUEST, + return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.BAD_REQUEST, stanza, + StanzaErrorType.MODIFY, "iq-stanza requires 'id' attribute to be present", sessionContext.getXMLLang(), null); } @@ -69,8 +69,8 @@ IQStanzaType iqType = stanza.getIQType(); if (iqType == null) { // missing or unknown type - return ServerErrorResponses.getInstance().getErrorResponse(stanza, - StanzaErrorType.MODIFY, StanzaErrorCondition.BAD_REQUEST, + return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.BAD_REQUEST, stanza, + StanzaErrorType.MODIFY, "iq-stanza requires a valid 'type' attribute to be present", sessionContext.getXMLLang(), null); } @@ -79,8 +79,8 @@ // 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, + return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.BAD_REQUEST, stanza, + StanzaErrorType.MODIFY, "iq stanza of type get or set require exactly one child", sessionContext.getXMLLang(), null); } @@ -88,8 +88,8 @@ // 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, + return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.BAD_REQUEST, stanza, + StanzaErrorType.MODIFY, "iq stanza of type result may not have more than one child", sessionContext.getXMLLang(), null); } @@ -107,8 +107,8 @@ */ 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, + return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.FEATURE_NOT_IMPLEMENTED, stanza, + StanzaErrorType.CANCEL, null, null, null); } Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/MessageHandler.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/MessageHandler.java?rev=647070&r1=647069&r2=647070&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/MessageHandler.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/MessageHandler.java Fri Apr 11 00:15:22 2008 @@ -23,6 +23,9 @@ import org.apache.vysper.xmpp.stanza.MessageStanza; import org.apache.vysper.xmpp.stanza.Stanza; import org.apache.vysper.xmpp.stanza.XMPPCoreStanza; +import org.apache.vysper.xmpp.stanza.XMPPCoreStanzaVerifier; +import org.apache.vysper.xmpp.xmlfragment.XMLElement; +import org.apache.vysper.xmpp.xmlfragment.XMLSemanticError; /** * handling message stanzas @@ -38,7 +41,45 @@ protected Stanza executeCore(XMPPCoreStanza stanza, SessionContext sessionContext) { + + XMPPCoreStanzaVerifier stanzaVerifier = stanza.getCoreVerifier(); + + // (try to) read thread id + String threadId = null; + XMLElement threadElement = null; + try { + threadElement = stanza.getSingleInnerElementsNamed("thread"); + try { + threadId = threadElement.getSingleInnerText().getText(); + } catch (Exception _) { + threadId = null; + } + } catch (XMLSemanticError _) { + threadId = null; + } + + // (try to) read subject id + String subject = null; + XMLElement subjectElement = null; + try { + subjectElement = stanza.getSingleInnerElementsNamed("subject"); + try { + subject = subjectElement.getSingleInnerText().getText(); + } catch (Exception _) { + subject = null; + } + } catch (XMLSemanticError _) { + subject = null; + } + + // TODO inspect all BODY elements and make sure they conform to the spec + Entity to = stanza.getTo(); + + // TODO check if to is empty. + + // TODO check if the user should be on this server. relay if not. + StanzaRelay stanzaRelay = sessionContext.getServerRuntimeContext().getStanzaRelay(); if (!stanzaRelay.receiverExists(to)) { // TODO return error stanza Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/StreamStartHandler.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/StreamStartHandler.java?rev=647070&r1=647069&r2=647070&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/StreamStartHandler.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/StreamStartHandler.java Fri Apr 11 00:15:22 2008 @@ -116,7 +116,7 @@ toEntity = EntityImpl.parse(stanza.getAttribute("to").getValue()); } catch (EntityFormatException e) { return new ResponseStanzaContainerImpl( - ServerErrorResponses.getInstance().getError(StreamErrorCondition.IMPROPER_ADDRESSING, + ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.IMPROPER_ADDRESSING, sessionContext.getXMLLang(), "could not parse incoming stanza's TO attribute", null)); @@ -140,7 +140,7 @@ entity = EntityImpl.parse(stanza.getAttribute("from").getValue()); } catch (EntityFormatException e) { return new ResponseStanzaContainerImpl( - ServerErrorResponses.getInstance().getError(StreamErrorCondition.INVALID_FROM, + ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.INVALID_FROM, sessionContext.getXMLLang(), "could not parse incoming stanza's FROM attribute", null)); @@ -175,7 +175,7 @@ private ResponseStanzaContainer respondIllegalNamespaceError(String descriptiveText) { return new ResponseStanzaContainerImpl( - ServerErrorResponses.getInstance().getError(StreamErrorCondition.INVALID_NAMESPACE, + ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.INVALID_NAMESPACE, null, descriptiveText, null)); @@ -183,7 +183,7 @@ private ResponseStanzaContainer respondUnsupportedStanzaType(String descriptiveText) { return new ResponseStanzaContainerImpl( - ServerErrorResponses.getInstance().getError(StreamErrorCondition.UNSUPPORTED_STANZA_TYPE, + ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.UNSUPPORTED_STANZA_TYPE, null, descriptiveText, null)); @@ -191,7 +191,7 @@ private ResponseStanzaContainer respondUnsupportedVersionError(String xmlLang, String versionAttributeValue, String errorMessage) { if (xmlLang == null) xmlLang = "en_US"; - Stanza error = ServerErrorResponses.getInstance().getError(StreamErrorCondition.UNSUPPORTED_VERSION, xmlLang, + Stanza error = ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.UNSUPPORTED_VERSION, xmlLang, errorMessage + versionAttributeValue, null); return new ResponseStanzaContainerImpl(error); } Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/XMPPCoreStanzaHandler.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/XMPPCoreStanzaHandler.java?rev=647070&r1=647069&r2=647070&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/XMPPCoreStanzaHandler.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/base/handler/XMPPCoreStanzaHandler.java Fri Apr 11 00:15:22 2008 @@ -88,7 +88,7 @@ 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)); + return new ResponseStanzaContainerImpl(ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.IMPROPER_ADDRESSING, stanza.getXMLLang(), "missing to attribute", null)); } if (to != null) { Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/compatibility/jabber_iq_auth/handler/IQAuthCompatibilityHandler.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/compatibility/jabber_iq_auth/handler/IQAuthCompatibilityHandler.java?rev=647070&r1=647069&r2=647070&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/compatibility/jabber_iq_auth/handler/IQAuthCompatibilityHandler.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/modules/core/compatibility/jabber_iq_auth/handler/IQAuthCompatibilityHandler.java Fri Apr 11 00:15:22 2008 @@ -20,17 +20,11 @@ import org.apache.vysper.xmpp.modules.core.base.handler.IQHandler; import org.apache.vysper.xmpp.protocol.NamespaceURIs; import org.apache.vysper.xmpp.server.SessionContext; -import org.apache.vysper.xmpp.server.SessionState; import org.apache.vysper.xmpp.server.response.ServerErrorResponses; import org.apache.vysper.xmpp.stanza.IQStanza; import org.apache.vysper.xmpp.stanza.Stanza; -import org.apache.vysper.xmpp.stanza.StanzaBuilder; -import org.apache.vysper.xmpp.stanza.IQStanzaType; import org.apache.vysper.xmpp.stanza.StanzaErrorType; import org.apache.vysper.xmpp.stanza.StanzaErrorCondition; -import org.apache.vysper.xmpp.resourcebinding.BindException; -import org.apache.vysper.xmpp.addressing.Entity; -import org.apache.vysper.xmpp.addressing.EntityImpl; /** * handles bind requests @@ -53,9 +47,9 @@ case GET: case SET: - return ServerErrorResponses.getInstance().getErrorResponse(stanza, - StanzaErrorType.CANCEL, StanzaErrorCondition.SERVICE_UNAVAILABLE, - "jabber:iq:auth not supported", "en", + return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.SERVICE_UNAVAILABLE, stanza, + StanzaErrorType.CANCEL, + "jabber:iq:auth not supported", "en", null); case ERROR: Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ResponseWriter.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ResponseWriter.java?rev=647070&r1=647069&r2=647070&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ResponseWriter.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ResponseWriter.java Fri Apr 11 00:15:22 2008 @@ -32,7 +32,7 @@ public void writeStreamNotOpenedError(SessionContext sessionContext) { - Stanza errorStanza = ServerErrorResponses.getInstance().getError(StreamErrorCondition.BAD_FORMAT, + Stanza errorStanza = ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.BAD_FORMAT, sessionContext.getXMLLang(), "could not parse incoming stanza", null); @@ -65,7 +65,7 @@ if (protocolException != null) errorStanza = protocolException.getErrorStanza(); if (errorStanza == null) { - errorStanza = ServerErrorResponses.getInstance().getError(StreamErrorCondition.BAD_FORMAT, + errorStanza = ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.BAD_FORMAT, sessionContext.getXMLLang(), "could not process incoming stanza", receivedStanza); @@ -74,7 +74,7 @@ } public void handleUnsupportedStanzaType(SessionContext sessionContext, Stanza receivedStanza) { - Stanza errorStanza = ServerErrorResponses.getInstance().getError(StreamErrorCondition.UNSUPPORTED_STANZA_TYPE, + Stanza errorStanza = ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.UNSUPPORTED_STANZA_TYPE, sessionContext.getXMLLang(), "could not process incoming stanza", receivedStanza); @@ -82,7 +82,7 @@ } public void handleNotAuthorized(SessionContext sessionContext, Stanza receivedStanza) { - Stanza errorStanza = ServerErrorResponses.getInstance().getError(StreamErrorCondition.NOT_AUTHORIZED, + Stanza errorStanza = ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.NOT_AUTHORIZED, sessionContext.getXMLLang(), "could not process incoming stanza", receivedStanza); @@ -92,7 +92,7 @@ public void handleParsingException(SessionContext sessionContext, ParsingException e) { //TODO write the __right__ error response, not bad-format default only if (e.getErrorCondition() != ParsingErrorCondition.BAD_FORMAT) throw new RuntimeException("cannot handle this error condition yet"); - Stanza errorStanza = ServerErrorResponses.getInstance().getError(StreamErrorCondition.BAD_FORMAT, + Stanza errorStanza = ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.BAD_FORMAT, sessionContext.getXMLLang(), "could not parse incoming stanza", null); Added: labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ServiceUnavailableStanzaErrorHandler.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ServiceUnavailableStanzaErrorHandler.java?rev=647070&view=auto ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ServiceUnavailableStanzaErrorHandler.java (added) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/ServiceUnavailableStanzaErrorHandler.java Fri Apr 11 00:15:22 2008 @@ -0,0 +1,45 @@ +/*********************************************************************** + * 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.protocol; + +import org.apache.vysper.xmpp.server.SessionContext; +import org.apache.vysper.xmpp.server.response.ServerErrorResponses; +import org.apache.vysper.xmpp.stanza.Stanza; +import org.apache.vysper.xmpp.stanza.StanzaErrorCondition; +import org.apache.vysper.xmpp.stanza.StanzaErrorType; +import org.apache.vysper.xmpp.stanza.XMPPCoreStanza; + +/** + */ +public class ServiceUnavailableStanzaErrorHandler implements StanzaHandler { + public String getName() { + return "stanza_not_supported_error"; + } + + public boolean verify(Stanza stanza) { + return true; + } + + public ResponseStanzaContainer execute(Stanza stanza, SessionContext sessionContext, SessionStateHolder sessionStateHolder) throws ProtocolException { + if (!(stanza instanceof XMPPCoreStanza)) { + stanza = XMPPCoreStanza.getWrapper(stanza); + } + XMPPCoreStanza coreStanza = (XMPPCoreStanza) stanza; + Stanza errorStanza = ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.SERVICE_UNAVAILABLE, coreStanza, StanzaErrorType.CANCEL, "namespace not supported", null, null); + return new ResponseStanzaContainerImpl(errorStanza); + } +} Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/SessionStateHolder.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/SessionStateHolder.java?rev=647070&r1=647069&r2=647070&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/SessionStateHolder.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/SessionStateHolder.java Fri Apr 11 00:15:22 2008 @@ -33,9 +33,5 @@ public void setState(SessionState newState) { currentState = newState; System.err.println("session state changed to = " + newState); -if (currentState == SessionState.CLOSED) { - currentState = SessionState.AUTHENTICATED; -} - System.err.println("session state changed to = " + newState); } } Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java?rev=647070&r1=647069&r2=647070&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java Fri Apr 11 00:15:22 2008 @@ -39,6 +39,7 @@ private IQHandler iqHandler = new IQHandler(); private MessageHandler messageHandler = new MessageHandler(); private PresenceHandler presenceHandler = new PresenceHandler(); + private static final ServiceUnavailableStanzaErrorHandler SERVICE_UNAVAILABLE_STANZA_ERROR_HANDLER = new ServiceUnavailableStanzaErrorHandler(); public void addDictionary(NamespaceHandlerDictionary namespaceHandlerDictionary) { String namespace = namespaceHandlerDictionary.getNamespaceURI(); @@ -101,13 +102,14 @@ String namespace = xmlElement.getVerifier().getUniqueXMLNSValue(); NamespaceHandlerDictionary namespaceHandlerDictionary = dictionaries.get(namespace); + // another try to get a dictionary if (namespaceHandlerDictionary == null) { namespace = xmlElement.getNamespace(); namespaceHandlerDictionary = dictionaries.get(namespace); } if (namespaceHandlerDictionary != null) return namespaceHandlerDictionary.get(stanza); - return null; + return SERVICE_UNAVAILABLE_STANZA_ERROR_HANDLER; } } Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/server/response/ServerErrorResponses.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/server/response/ServerErrorResponses.java?rev=647070&r1=647069&r2=647070&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/server/response/ServerErrorResponses.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/server/response/ServerErrorResponses.java Fri Apr 11 00:15:22 2008 @@ -44,7 +44,7 @@ // empty } - public Stanza getError(StreamErrorCondition definedErrorCondition, String languageCode, String descriptiveText, XMLElement applicationSpecificError) { + public Stanza getStreamError(StreamErrorCondition definedErrorCondition, String languageCode, String descriptiveText, XMLElement applicationSpecificError) { /* <stream:jabber> @@ -81,20 +81,20 @@ /** * TODO move to a more general error handling + * @param errorCondition - corresponds to one of the defined stanza error conditions * @param stanza * @param type - * @param errorCondition - corresponds to one of the defined stanza error conditions * @param errorText - is optional together with errorLang, both together might be NULL * @param errorLang - must be present, if errorText is not NULL * @param errorConditionElement - optional application specific error condition element * @return error response stanza */ - public Stanza getErrorResponse(XMPPCoreStanza stanza, StanzaErrorType type, StanzaErrorCondition errorCondition, - String errorText, String errorLang, - XMLElement errorConditionElement) { + public Stanza getStanzaError(StanzaErrorCondition errorCondition, XMPPCoreStanza stanza, StanzaErrorType type, + String errorText, String errorLang, + XMLElement errorConditionElement) { if ("error".equals(stanza.getType())) { - return ServerErrorResponses.getInstance().getError(StreamErrorCondition.UNSUPPORTED_STANZA_TYPE, errorLang, + return ServerErrorResponses.getInstance().getStreamError(StreamErrorCondition.UNSUPPORTED_STANZA_TYPE, errorLang, "cannot respond to IQ stanza of type error with the same", null); } Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/writer/DenseStanzaLogRenderer.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/writer/DenseStanzaLogRenderer.java?rev=647070&r1=647069&r2=647070&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/writer/DenseStanzaLogRenderer.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/writer/DenseStanzaLogRenderer.java Fri Apr 11 00:15:22 2008 @@ -66,7 +66,10 @@ IQStanza iq = (IQStanza) XMPPCoreStanza.getWrapper((Stanza) stanza); renderAttribute(stringBuilder, iq, "id"); renderAttribute(stringBuilder, iq, "type"); - if (firstInnerElement != null) stringBuilder.append(ELEMENT_SEPARATOR).append(firstInnerElement.getName()); + if (firstInnerElement != null) { + stringBuilder.append(ELEMENT_SEPARATOR).append(firstInnerElement.getName()); + renderAttribute(stringBuilder, firstInnerElement, "xmlns"); + } } private static void renderAuth(StringBuilder stringBuilder, XMLElement stanza, XMLElement firstInnerElement) { Modified: labs/vysper/src/test/java/org/apache/vysper/smack/BasicClient.java URL: http://svn.apache.org/viewvc/labs/vysper/src/test/java/org/apache/vysper/smack/BasicClient.java?rev=647070&r1=647069&r2=647070&view=diff ============================================================================== --- labs/vysper/src/test/java/org/apache/vysper/smack/BasicClient.java (original) +++ labs/vysper/src/test/java/org/apache/vysper/smack/BasicClient.java Fri Apr 11 00:15:22 2008 @@ -16,19 +16,25 @@ ***********************************************************************/ package org.apache.vysper.smack; +import org.jivesoftware.smack.Chat; import org.jivesoftware.smack.ConnectionConfiguration; +import org.jivesoftware.smack.MessageListener; import org.jivesoftware.smack.SASLAuthentication; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.MessageListener; -import org.jivesoftware.smack.Chat; import org.jivesoftware.smack.packet.Message; +import java.util.Date; +import java.util.Random; + /** */ public class BasicClient { public static void main(String[] args) throws XMPPException { + String me = args[0]; + String to = args[1]; + try { ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration("localhost"); // ConnectionConfiguration connectionConfiguration = new ConnectionConfiguration("xmpp.eu"); @@ -48,15 +54,18 @@ // if (!saslAuthentication.isAuthenticated()) return; - connection.login("simpsonnathan@example.org", "password1"); -/* - Chat chat = connection.getChatManager().createChat("simpsonnathan@example.org", new MessageListener() { + connection.login(me + "@vysper.org", "password1"); + + Chat chat = connection.getChatManager().createChat(to + "@vysper.org", new MessageListener() { public void processMessage(Chat chat, Message message) { - System.out.println("log received message: " + message); } - }); - chat.sendMessage("Hello Vysper!"); -*/ - connection.disconnect(); + System.out.println("log received message: " + message.getBody()); } + }); + while (true) { + chat.sendMessage("Hello " + to + " at " + new Date()); + try { Thread.sleep((new Random().nextInt(9)+1)*1000 ); } catch (InterruptedException e) { ; } + } + + //connection.disconnect(); } catch (Throwable e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } --------------------------------------------------------------------- To unsubscribe, e-mail: simpsonnathan@example.org For additional commands, e-mail: simpsonnathan@example.org From simpsonnathan@example.org Thu Apr 17 15:34:30 2008 Return-Path: <simpsonnathan@example.org> Delivered-To: simpsonnathan@example.org Received: (qmail 54428 invoked from network); 17 Apr 2008 15:34:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 17 Apr 2008 15:34:29 -0000 Received: (qmail 61544 invoked by uid 500); 17 Apr 2008 15:34:30 -0000 Delivered-To: simpsonnathan@example.org Received: (qmail 61452 invoked by uid 500); 17 Apr 2008 15:34:30 -0000 Mailing-List: contact simpsonnathan@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:simpsonnathan@example.org> List-Unsubscribe: <mailto:simpsonnathan@example.org> List-Post: <mailto:simpsonnathan@example.org> List-Id: <commits.labs.apache.org> Reply-To: simpsonnathan@example.org Delivered-To: mailing list simpsonnathan@example.org Delivered-To: moderator for simpsonnathan@example.org Received: (qmail 5851 invoked by uid 99); 17 Apr 2008 09:48:09 -0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r649028 - in /labs/vysper/src/main/java/org/apache/vysper/util: ./ annotations/ annotations/RfcCompliant.java Date: Thu, 17 Apr 2008 09:47:45 -0000 To: simpsonnathan@example.org From: simpsonnathan@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <simpsonnathan@example.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gseitz Date: Thu Apr 17 02:47:44 2008 New Revision: 649028 URL: http://svn.apache.org/viewvc?rev=649028&view=rev Log: LABS-123 Added: labs/vysper/src/main/java/org/apache/vysper/util/ labs/vysper/src/main/java/org/apache/vysper/util/annotations/ labs/vysper/src/main/java/org/apache/vysper/util/annotations/RfcCompliant.java (with props) Added: labs/vysper/src/main/java/org/apache/vysper/util/annotations/RfcCompliant.java URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/util/annotations/RfcCompliant.java?rev=649028&view=auto ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/util/annotations/RfcCompliant.java (added) +++ labs/vysper/src/main/java/org/apache/vysper/util/annotations/RfcCompliant.java Thu Apr 17 02:47:44 2008 @@ -0,0 +1,46 @@ +package org.apache.vysper.util.annotations; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * This annotation is used to mark methods, types or packages that implement a + * specific RFC or a section of an RFC. Use the <code>status</code> parameter + * to specify the compliance level. + * + * @author Gerolf Seitz (simpsonnathan@example.org) + * + */ +@Documented +@Target( { ElementType.METHOD, ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface RfcCompliant { + public enum ComplianceStatus { + NOT_STARTED, PARTIAL, FINISHED + } + + /** + * Specifies the RFC the target implements. + * + * @return the RFC number + */ + String rfc(); + + /** + * Specifies the section the target implements. + * + * @return the section/appendix number or an empty {@link String} in case + * the entire RFC is implemented by the target + */ + String section() default ""; + + /** + * Specifies the status of the RFC compliance. + * + * @return the compliance status + */ + ComplianceStatus status(); +} Propchange: labs/vysper/src/main/java/org/apache/vysper/util/annotations/RfcCompliant.java ------------------------------------------------------------------------------ svn:mime-type = text/plain --------------------------------------------------------------------- To unsubscribe, e-mail: simpsonnathan@example.org For additional commands, e-mail: simpsonnathan@example.org From simpsonnathan@example.org Thu Apr 17 15:34:34 2008 Return-Path: <simpsonnathan@example.org> Delivered-To: simpsonnathan@example.org Received: (qmail 54700 invoked from network); 17 Apr 2008 15:34:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 17 Apr 2008 15:34:33 -0000 Received: (qmail 62030 invoked by uid 500); 17 Apr 2008 15:34:34 -0000 Delivered-To: simpsonnathan@example.org Received: (qmail 61938 invoked by uid 500); 17 Apr 2008 15:34:34 -0000 Mailing-List: contact simpsonnathan@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:simpsonnathan@example.org> List-Unsubscribe: <mailto:simpsonnathan@example.org> List-Post: <mailto:simpsonnathan@example.org> List-Id: <commits.labs.apache.org> Reply-To: simpsonnathan@example.org Delivered-To: mailing list simpsonnathan@example.org Delivered-To: moderator for simpsonnathan@example.org Received: (qmail 14269 invoked by uid 99); 17 Apr 2008 09:56:09 -0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r649031 - in /labs/vysper: build.xml src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java src/test/java/org/apache/vysper/xmpp/addressing/ src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java Date: Thu, 17 Apr 2008 09:55:43 -0000 To: simpsonnathan@example.org From: simpsonnathan@example.org X-Mailer: svnmailer-1.0.8 Message-Id: <simpsonnathan@example.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gseitz Date: Thu Apr 17 02:55:35 2008 New Revision: 649031 URL: http://svn.apache.org/viewvc?rev=649031&view=rev Log: added docs target to build.xml fixed EntityConformance check and added TestCase Added: labs/vysper/src/test/java/org/apache/vysper/xmpp/addressing/ labs/vysper/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java (with props) Modified: labs/vysper/build.xml labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java Modified: labs/vysper/build.xml URL: http://svn.apache.org/viewvc/labs/vysper/build.xml?rev=649031&r1=649030&r2=649031&view=diff ============================================================================== --- labs/vysper/build.xml (original) +++ labs/vysper/build.xml Thu Apr 17 02:55:35 2008 @@ -57,7 +57,8 @@ <property name="compiler.args.vysper" value="${compiler.args}"/> - <property name="vysper.output.dir" value="${basedir}/build/ant/classes"/> + <property name="vysper.output.dir" value="${basedir}/build/ant/classes"/> + <property name="vysper.docs.dir" value="${basedir}/build/ant/apidocs"/> <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"/> @@ -190,5 +191,10 @@ <target name="clean" depends="clean.vysper" description="cleanup all"/> - <target name="all" depends="init, clean, compile.vysper" description="build all"/> + <target name="all" depends="init, clean, compile.vysper" description="build all"/> + + <target name="docs" description="generate javadocs"> + <javadoc sourcepathref="sourcepath" destdir="${vysper.docs.dir}"> + </javadoc> + </target> </project> Modified: 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?rev=649031&r1=649030&r2=649031&view=diff ============================================================================== --- labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java (original) +++ labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java Thu Apr 17 02:55:35 2008 @@ -17,8 +17,12 @@ package org.apache.vysper.xmpp.addressing; +import org.apache.vysper.util.annotations.RfcCompliant; +import org.apache.vysper.util.annotations.RfcCompliant.ComplianceStatus; + /** */ +@RfcCompliant(rfc="3290", section="3.1", status=ComplianceStatus.PARTIAL) public class EntityConformance { public static boolean checkRFC3920Conformance(Entity entity) { @@ -31,7 +35,7 @@ } private static boolean checkPartConformity(String part) { - return part != null && part.getBytes().length > 1023; + return part == null || part.getBytes().length < 1023; } private static boolean checkPartIsEmpty(String part) { Added: labs/vysper/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java URL: http://svn.apache.org/viewvc/labs/vysper/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java?rev=649031&view=auto ============================================================================== --- labs/vysper/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java (added) +++ labs/vysper/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java Thu Apr 17 02:55:35 2008 @@ -0,0 +1,39 @@ +package org.apache.vysper.xmpp.addressing; + +import java.util.Arrays; + +import junit.framework.TestCase; + +public class EntityConformanceTestCase extends TestCase { + + public void testCheckRFC3920Conformance() { + String error = buildLargeString(); + String ok = "x"; + + assertFalse(doCheck(error, ok, ok)); + assertFalse(doCheck(ok, error, ok)); + assertFalse(doCheck(ok, ok, error)); + assertFalse(doCheck(ok, null, ok)); + assertFalse(doCheck(ok, "", ok)); + + assertTrue(doCheck(ok, ok, ok)); + assertTrue(doCheck(null, ok, null)); + assertTrue(doCheck(ok, ok, null)); + assertTrue(doCheck(null, ok, ok)); + assertTrue(doCheck("", ok, "")); + assertTrue(doCheck(ok, ok, "")); + assertTrue(doCheck("", ok, ok)); + + } + + private boolean doCheck(String node, String domain, String resource) { + return EntityConformance.checkRFC3920Conformance(new EntityImpl( + node, domain, resource)); + } + + private String buildLargeString() { + char[] chars = new char[1024]; + Arrays.fill(chars, 'x'); + return new String(chars); + } +} Propchange: labs/vysper/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java ------------------------------------------------------------------------------ svn:mime-type = text/plain --------------------------------------------------------------------- To unsubscribe, e-mail: simpsonnathan@example.org For additional commands, e-mail: simpsonnathan@example.org From simpsonnathan@example.org Thu Apr 17 17:23:18 2008 Return-Path:
{'source': 'Apache Software Foundation Public Mail Archives'}