Author: berndf
Date: Fri Aug 28 08:03:03 2009
New Revision: 808801

URL: http://svn.apache.org/viewvc?rev=808801&view=rev
Log:
this is a complex commit - and it will have follow ups:
in general, it routes directed presence stanzas through the client into stanza 
relay back to clients (as before) and (new!) to registered components. MUC acts 
as such a component.
VYSPER-172: removes the previous subdomain handling and introduces a different 
approach, which does not hook into the sending clients session. Modules can now 
register as a component for a subdomain, retrieving all stanzas for this 
subdomain.
VYSPER-176: improve internal routing to a component
VYSPER-6: naive and preliminary implementation of outbound directed presence

Added:
    
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/components/
    
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/components/Component.java
Removed:
    
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/protocol/SubdomainHandlerDictionary.java
Modified:
    mina/sandbox/vysper/trunk/server/core/src/main/config/spring-config.xml
    
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelayBroker.java
    
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringInboundStanzaRelay.java
    
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java
    
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java
    
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java
    
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java
    
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/StanzaBuilder.java
    
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookupTestCase.java
    
mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/MUCModule.java

Modified: 
mina/sandbox/vysper/trunk/server/core/src/main/config/spring-config.xml
URL: 
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/main/config/spring-config.xml?rev=808801&r1=808800&r2=808801&view=diff
==============================================================================
--- mina/sandbox/vysper/trunk/server/core/src/main/config/spring-config.xml 
(original)
+++ mina/sandbox/vysper/trunk/server/core/src/main/config/spring-config.xml Fri 
Aug 28 08:03:03 2009
@@ -21,6 +21,13 @@
 
 <beans>
 
+    <!-- Domain -->
+    <bean id="domain" class="org.apache.vysper.xmpp.addressing.EntityImpl" >
+        <constructor-arg value=""/>
+        <constructor-arg value="vysper.org"/>
+        <constructor-arg value=""/>
+    </bean>
+    
     <!-- The SSL configuration -->
 
      <bean id="bogusTrustManagerFactory" 
class="org.apache.vysper.xmpp.cryptography.BogusTrustManagerFactory"/>
@@ -43,6 +50,7 @@
     <alias name="jcrStorageRegistry" alias="storageRegistry" />
     
     <bean id="internalOutboundRelay" 
class="org.apache.vysper.xmpp.delivery.inbound.DeliveringInboundStanzaRelay" >
+        <constructor-arg ref="domain" />
         <constructor-arg ref="resourceRegistry"/>
         <constructor-arg ref="storageRegistry"/>
     </bean>
@@ -77,13 +85,7 @@
     </bean>
     
     <bean id="server" 
class="org.apache.vysper.spring.SpringCompatibleDefaultServerRuntimeContext" >
-        <constructor-arg >
-            <bean class="org.apache.vysper.xmpp.addressing.EntityImpl" >
-                <constructor-arg value=""/>
-                <constructor-arg value="vysper.org"/>
-                <constructor-arg value=""/>
-            </bean>
-        </constructor-arg>
+        <constructor-arg ref="domain" />
         <constructor-arg ref="stanzaRelay"/>
         <constructor-arg ref="serverFeatures"/>
         <constructor-arg>

Modified: 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelayBroker.java
URL: 
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelayBroker.java?rev=808801&r1=808800&r2=808801&view=diff
==============================================================================
--- 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelayBroker.java
 (original)
+++ 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/delivery/StanzaRelayBroker.java
 Fri Aug 28 08:03:03 2009
@@ -64,7 +64,7 @@
 
         boolean relayToExternal = 
serverRuntimeContext.getServerFeatures().isRelayingToFederationServers();
 
-        if 
(domain.equals(serverRuntimeContext.getServerEnitity().getDomain())) {
+        if 
(domain.endsWith(serverRuntimeContext.getServerEnitity().getDomain())) {
             internalRelay.relay(receiver, stanza, deliveryFailureStrategy);
         } else {
             if (!relayToExternal) throw new IllegalStateException("this server 
is not relaying to external currently");

Modified: 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringInboundStanzaRelay.java
URL: 
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringInboundStanzaRelay.java?rev=808801&r1=808800&r2=808801&view=diff
==============================================================================
--- 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringInboundStanzaRelay.java
 (original)
+++ 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/delivery/inbound/DeliveringInboundStanzaRelay.java
 Fri Aug 28 08:03:03 2009
@@ -20,6 +20,7 @@
 package org.apache.vysper.xmpp.delivery.inbound;
 
 import org.apache.vysper.storage.StorageProviderRegistry;
+import org.apache.vysper.storage.jcr.JcrStorageProviderRegistry;
 import org.apache.vysper.xmpp.addressing.Entity;
 import org.apache.vysper.xmpp.addressing.EntityImpl;
 import org.apache.vysper.xmpp.authorization.AccountManagement;
@@ -82,7 +83,7 @@
         this(serverEntity, resourceRegistry, 
(AccountManagement)storageProviderRegistry.retrieve(AccountManagement.class));
     }
     
-    public DeliveringInboundStanzaRelay(Entity serverEntity, ResourceRegistry 
resourceRegistry, AccountManagement accountManagement) {
+    public DeliveringInboundStanzaRelay(Entity serverEntity, ResourceRegistry 
resourceRegistry, AccountManagement accountVerification) {
         this.serverEntity = serverEntity;
         this.resourceRegistry = resourceRegistry;
         this.accountVerification = accountVerification;

Modified: 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java
URL: 
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java?rev=808801&r1=808800&r2=808801&view=diff
==============================================================================
--- 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java
 (original)
+++ 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/modules/core/im/handler/PresenceAvailabilityHandler.java
 Fri Aug 28 08:03:03 2009
@@ -47,6 +47,8 @@
 import org.apache.vysper.xmpp.state.resourcebinding.ResourceRegistry;
 import org.apache.vysper.xmpp.state.resourcebinding.ResourceState;
 import org.apache.vysper.xmpp.xmlfragment.Attribute;
+import org.apache.vysper.xmpp.delivery.failure.IgnoreFailureStrategy;
+import org.apache.vysper.xmpp.delivery.failure.DeliveryException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -280,6 +282,20 @@
                                                           RosterManager 
rosterManager, 
                                                           Entity user, 
                                                           ResourceRegistry 
registry) {
+        PresenceStanza redirectDirectedStanza = presenceStanza;
+        if (presenceStanza.getFrom() == null) {
+            StanzaBuilder builder = StanzaBuilder.createClone(presenceStanza, 
true, null);
+            EntityImpl from = new 
EntityImpl(sessionContext.getInitiatingEntity(), 
registry.getUniqueResourceForSession(sessionContext));
+            builder.addAttribute("from", from.getFullQualifiedName());
+            redirectDirectedStanza = 
(PresenceStanza)XMPPCoreStanza.getWrapper(builder.getFinalStanza());
+        }
+
+        try {
+            
serverRuntimeContext.getStanzaRelay().relay(presenceStanza.getTo(), 
redirectDirectedStanza, new IgnoreFailureStrategy());
+        } catch (DeliveryException e) {
+            e.printStackTrace();  //To change body of catch statement use File 
| Settings | File Templates.
+        }
+
         logger.warn("directed presence is not yet implemented");
         return null;
     }

Modified: 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java
URL: 
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java?rev=808801&r1=808800&r2=808801&view=diff
==============================================================================
--- 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java
 (original)
+++ 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java
 Fri Aug 28 08:03:03 2009
@@ -43,7 +43,6 @@
  */
 public class StanzaHandlerLookup {
 
-    private Map<String, SubdomainHandlerDictionary> subdomainDictionaries = 
new LinkedHashMap<String, SubdomainHandlerDictionary>();
     private Map<String, NamespaceHandlerDictionary> namespaceDictionaries = 
new LinkedHashMap<String, NamespaceHandlerDictionary>();
 
     private IQHandler iqHandler = new IQHandler();
@@ -51,40 +50,12 @@
     private PresenceHandler presenceHandler = new PresenceHandler();
     private static final ServiceUnavailableStanzaErrorHandler 
SERVICE_UNAVAILABLE_STANZA_ERROR_HANDLER = new 
ServiceUnavailableStanzaErrorHandler();
 
-    private Entity serverEntity;
-    
-    public StanzaHandlerLookup(Entity serverEntity) {
-        this.serverEntity = serverEntity;
-    }
-    
     public void addDictionary(NamespaceHandlerDictionary 
namespaceHandlerDictionary) {
         String namespace = namespaceHandlerDictionary.getNamespaceURI();
         if (namespaceDictionaries.containsKey(namespace)) throw new 
IllegalArgumentException("dictionary already exists covering namespace " + 
namespace);
         namespaceDictionaries.put(namespace, namespaceHandlerDictionary);
     }
 
-    public void addDictionary(SubdomainHandlerDictionary 
subdomainHandlerDictionary) {
-        Entity domain = subdomainHandlerDictionary.getDomain();
-        if(domain == null || domain.getDomain() == null) throw new 
IllegalArgumentException("subdomain dictionary can not be added with null 
domain");
-        if(domain.getDomain().equals(serverEntity.getDomain())) throw new 
IllegalArgumentException("a module can not register for the server domain " + 
domain);
-        if (subdomainDictionaries.containsKey(domain)) throw new 
IllegalArgumentException("dictionary already exists covering the domain " + 
domain);
-        subdomainDictionaries.put(domain.getDomain(), 
subdomainHandlerDictionary);
-    }
-    
-    private boolean forSubDomain(Stanza stanza) {
-        Entity to = stanza.getTo();
-
-        if(to != null) {
-            String stanzaDomain = to.getDomain();
-            String serverDomain = serverEntity.getDomain();
-            
-            return stanzaDomain.endsWith(serverDomain) && 
!serverDomain.equals(stanzaDomain);
-        } else {
-            // no "to" attribute
-            return false;
-        }
-    }
-    
     /**
      * looks into the stanza to see which handler is responsible, if any
      * @param stanza
@@ -94,13 +65,6 @@
         if (stanza == null) return null;
 
         String name = stanza.getName();
-        
-        // check if this stanza is for a subdomain, and if so, if we got a 
module for it
-        if(forSubDomain(stanza)) {
-            StanzaHandler handler = getHandlerForSubdomain(stanza);
-            if(handler != null) return handler;
-        }
-        
         if      ("xml".equals(name)) return new XMLPrologHandler();
         else if ("stream".equals(name)) return new StreamStartHandler();
         else if (iqHandler.verify(stanza)) return getIQHandler(stanza);
@@ -119,26 +83,6 @@
         }
     }
 
-    private StanzaHandler getHandlerForSubdomain(Stanza stanza) {
-        // check if we got a handler for this subdomain
-        HandlerDictionary handlerDic = 
subdomainDictionaries.get(stanza.getTo().getDomain());
-        if(handlerDic != null) {
-            // a module has registered for this domain
-            StanzaHandler handler = handlerDic.get(stanza);
-            if(handler != null) {
-                // found a handler, return
-                return handler;
-            } else {
-                // all messages for a subdomain must be handled by the module 
which has 
-                // registered for the domain, or we return unsupported stanza
-                return SERVICE_UNAVAILABLE_STANZA_ERROR_HANDLER;
-            }
-        } else {
-            // no module has registered for this subdomain 
-            return null;
-        }
-    }
-    
     private StanzaHandler getPresenceHandler(Stanza stanza) {
         return presenceHandler;
     }

Modified: 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java
URL: 
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java?rev=808801&r1=808800&r2=808801&view=diff
==============================================================================
--- 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java
 (original)
+++ 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java
 Fri Aug 28 08:03:03 2009
@@ -42,13 +42,13 @@
 import org.apache.vysper.xmpp.protocol.StanzaHandler;
 import org.apache.vysper.xmpp.protocol.StanzaHandlerLookup;
 import org.apache.vysper.xmpp.protocol.StanzaProcessor;
-import org.apache.vysper.xmpp.protocol.SubdomainHandlerDictionary;
 import org.apache.vysper.xmpp.stanza.Stanza;
 import org.apache.vysper.xmpp.state.presence.LatestPresenceCache;
 import org.apache.vysper.xmpp.state.presence.SimplePresenceCache;
 import org.apache.vysper.xmpp.state.resourcebinding.ResourceRegistry;
 import org.apache.vysper.xmpp.uuid.JVMBuiltinUUIDGenerator;
 import org.apache.vysper.xmpp.uuid.UUIDGenerator;
+import org.apache.vysper.xmpp.server.components.Component;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -118,12 +118,13 @@
      * collection of all other services, which are mostly add-ons to the 
minimal setup
      */
     final private Map<String, ServerRuntimeContextService> 
serverRuntimeContextServiceMap = new HashMap<String, 
ServerRuntimeContextService>();
+    protected final Map<String, Component> componentMap = new HashMap<String, 
Component>();
 
     public DefaultServerRuntimeContext(Entity serverEntity, StanzaRelay 
stanzaRelay) {
         this.serverEntity = serverEntity;
         this.stanzaRelay = stanzaRelay;
         this.resourceRegistry = new ResourceRegistry();
-        this.stanzaHandlerLookup = new StanzaHandlerLookup(serverEntity);
+        this.stanzaHandlerLookup = new StanzaHandlerLookup();
     }
 
     public DefaultServerRuntimeContext(Entity serverEntity, StanzaRelay 
stanzaRelay, StorageProviderRegistry storageProviderRegistry) {
@@ -185,10 +186,6 @@
         stanzaHandlerLookup.addDictionary(namespaceHandlerDictionary);
     }
 
-    public void addDictionary(SubdomainHandlerDictionary 
subdomainHandlerDictionary) {
-        stanzaHandlerLookup.addDictionary(subdomainHandlerDictionary);
-    }
-    
     protected void addDictionaries(List<NamespaceHandlerDictionary> 
dictionaries) {
         for (NamespaceHandlerDictionary dictionary : dictionaries) {
             addDictionary(dictionary);
@@ -316,29 +313,36 @@
 
         List<HandlerDictionary> handlerDictionaryList = 
module.getHandlerDictionaries();
         if (handlerDictionaryList != null) {
-            boolean addedNamespaceHandler = false;
-            boolean addedSubdomainHandler = false;
 
             for (HandlerDictionary handlerDictionary : handlerDictionaryList) {
                 if (handlerDictionary instanceof NamespaceHandlerDictionary) {
                     addDictionary((NamespaceHandlerDictionary) 
handlerDictionary);
-                    addedNamespaceHandler = true;
-                } else if (handlerDictionary instanceof 
SubdomainHandlerDictionary) {
-                    addDictionary((SubdomainHandlerDictionary) 
handlerDictionary);
-                    addedSubdomainHandler = true;
                 } else {
                     throw new RuntimeException("arbitrary HandlerDictionary 
implementations not supported yet, " +
-                               "only NamespaceHandlerDictionary and 
SubdomainHandlerDictionary.");
+                               "only NamespaceHandlerDictionary.");
                 }
             }
             
-            // make sure that a module does not add both namespace and 
subdomain handlers 
-            if(addedNamespaceHandler && addedSubdomainHandler) {
-                throw new RuntimeException("Module adding both " +
-                    " NamespaceHandlerDictionary and 
SubdomainHandlerDictionary. Only one type is" +
-                    "allowed per module");
- 
-            }
+        }
+
+        if (module instanceof Component) {
+            registerComponent((Component)module);
         }
     }
+    
+    public void registerComponent(Component component) {
+        componentMap.put(component.getSubdomain(), component);
+    }                          
+
+    public SessionContext getComponentSession(String domain) {
+        String serverDomain = getServerEnitity().getDomain();
+        if (!domain.endsWith(serverDomain)) {
+            return null;
+        }
+        String subdomain = domain.replace("." + domain, "");
+        Component component = componentMap.get(subdomain);
+        if (component == null) return null;
+        return component.getSessionContext();
+    }
+
 }

Modified: 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java
URL: 
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java?rev=808801&r1=808800&r2=808801&view=diff
==============================================================================
--- 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java
 (original)
+++ 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java
 Fri Aug 28 08:03:03 2009
@@ -30,6 +30,7 @@
 import org.apache.vysper.xmpp.stanza.Stanza;
 import org.apache.vysper.xmpp.state.presence.LatestPresenceCache;
 import org.apache.vysper.xmpp.state.resourcebinding.ResourceRegistry;
+import org.apache.vysper.xmpp.server.components.Component;
 
 import javax.net.ssl.SSLContext;
 
@@ -66,4 +67,8 @@
     ServerRuntimeContextService getServerRuntimeContextService(String name);
     
     StorageProvider getStorageProvider(Class<? extends StorageProvider> clazz);
+
+    void registerComponent(Component component);
+
+    SessionContext getComponentSession(String domain);
 }

Added: 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/components/Component.java
URL: 
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/components/Component.java?rev=808801&view=auto
==============================================================================
--- 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/components/Component.java
 (added)
+++ 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/server/components/Component.java
 Fri Aug 28 08:03:03 2009
@@ -0,0 +1,15 @@
+package org.apache.vysper.xmpp.server.components;
+
+import org.apache.vysper.xmpp.server.SessionContext;
+
+/**
+ * a component is a server subsystem providing a dedicated extension.
+ * components operate on their own subdomain, e.g. conference.vysper.org for 
MUC.
+ * components have a dedicated context in which they receive stanzas 
+ */
+public interface Component {
+    
+    String getSubdomain();
+    
+    SessionContext getSessionContext();
+}

Modified: 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/StanzaBuilder.java
URL: 
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/StanzaBuilder.java?rev=808801&r1=808800&r2=808801&view=diff
==============================================================================
--- 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/StanzaBuilder.java
 (original)
+++ 
mina/sandbox/vysper/trunk/server/core/src/main/java/org/apache/vysper/xmpp/stanza/StanzaBuilder.java
 Fri Aug 28 08:03:03 2009
@@ -112,7 +112,8 @@
     public static StanzaBuilder createClone(XMLElement original, boolean deep, 
List<Attribute> replacingAttributes) {
         StanzaBuilder stanzaBuilder = new StanzaBuilder(original.getName(), 
original.getNamespacePrefix());
 
-        List<Attribute> replacingAttributesCopy = new 
ArrayList<Attribute>(replacingAttributes);
+        List<Attribute> replacingAttributesCopy = new ArrayList<Attribute>();
+        if (replacingAttributes != null) 
replacingAttributesCopy.addAll(replacingAttributes);
 
         List<Attribute> originalAttributes = original.getAttributes();
         for (Attribute originalAttribute : originalAttributes) {

Modified: 
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookupTestCase.java
URL: 
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookupTestCase.java?rev=808801&r1=808800&r2=808801&view=diff
==============================================================================
--- 
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookupTestCase.java
 (original)
+++ 
mina/sandbox/vysper/trunk/server/core/src/test/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookupTestCase.java
 Fri Aug 28 08:03:03 2009
@@ -50,7 +50,7 @@
         lowerNamespaceHandlerDictionary.register(lowerStanzaHandler);
 
 
-        StanzaHandlerLookup stanzaHandlerLookup = new 
StanzaHandlerLookup(SERVER_ENTITY);
+        StanzaHandlerLookup stanzaHandlerLookup = initStanzaHandlerLookup();
         stanzaHandlerLookup.addDictionary(upperNamespaceHandlerDictionary);
         stanzaHandlerLookup.addDictionary(lowerNamespaceHandlerDictionary);
 
@@ -75,7 +75,7 @@
     }
 
     public void testLookupCoreHandlerClientNS() {
-        StanzaHandlerLookup stanzaHandlerLookup = new 
StanzaHandlerLookup(SERVER_ENTITY);
+        StanzaHandlerLookup stanzaHandlerLookup = initStanzaHandlerLookup();
         stanzaHandlerLookup.addDictionary(new BaseStreamStanzaDictionary());
 
         Stanza stanza = new StanzaBuilder("iq", 
NamespaceURIs.JABBER_CLIENT).getFinalStanza();
@@ -86,8 +86,12 @@
 
     }
 
+    private StanzaHandlerLookup initStanzaHandlerLookup() {
+        return new StanzaHandlerLookup();
+    }
+
     public void testLookupCoreHandlerServerNS() {
-        StanzaHandlerLookup stanzaHandlerLookup = new 
StanzaHandlerLookup(SERVER_ENTITY);
+        StanzaHandlerLookup stanzaHandlerLookup = initStanzaHandlerLookup();
         stanzaHandlerLookup.addDictionary(new BaseStreamStanzaDictionary());
 
         Stanza stanza = new StanzaBuilder("iq", 
NamespaceURIs.JABBER_SERVER).getFinalStanza();
@@ -99,7 +103,7 @@
     }
 
     public void testLookupCoreHandlerWrongNamespace() {
-        StanzaHandlerLookup stanzaHandlerLookup = new 
StanzaHandlerLookup(SERVER_ENTITY);
+        StanzaHandlerLookup stanzaHandlerLookup = initStanzaHandlerLookup();
         stanzaHandlerLookup.addDictionary(new BaseStreamStanzaDictionary());
 
         Stanza stanza = new StanzaBuilder("iq", 
"arbitraryNamespace").getFinalStanza();
@@ -109,7 +113,7 @@
     }
 
     public void testLookupPresenceHandler() {
-        StanzaHandlerLookup stanzaHandlerLookup = new 
StanzaHandlerLookup(SERVER_ENTITY);
+        StanzaHandlerLookup stanzaHandlerLookup = initStanzaHandlerLookup();
         stanzaHandlerLookup.addDictionary(new BaseStreamStanzaDictionary());
 
         Stanza stanza = new StanzaBuilder("presence", 
NamespaceURIs.JABBER_CLIENT).getFinalStanza();
@@ -120,7 +124,7 @@
     }
 
     public void testLookupMessageHandler() {
-        StanzaHandlerLookup stanzaHandlerLookup = new 
StanzaHandlerLookup(SERVER_ENTITY);
+        StanzaHandlerLookup stanzaHandlerLookup = initStanzaHandlerLookup();
         stanzaHandlerLookup.addDictionary(new BaseStreamStanzaDictionary());
 
         Stanza stanza = new StanzaBuilder("message", 
NamespaceURIs.JABBER_CLIENT).getFinalStanza();
@@ -131,7 +135,7 @@
     }
 
     public void testLookupSpecializedIQHandler() {
-        StanzaHandlerLookup stanzaHandlerLookup = new 
StanzaHandlerLookup(SERVER_ENTITY);
+        StanzaHandlerLookup stanzaHandlerLookup = initStanzaHandlerLookup();
         stanzaHandlerLookup.addDictionary(new BaseStreamStanzaDictionary());
 
         NamespaceHandlerDictionary testDictionary = new 
NamespaceHandlerDictionary("test:namespace:OK");
@@ -152,21 +156,6 @@
         assertTrue("test handler", 
TestIQHandler.class.equals(handler.getClass()));
     }
     
-    public void testLookupSubdomain() {
-        StanzaHandlerLookup stanzaHandlerLookup = new 
StanzaHandlerLookup(SERVER_ENTITY);
-
-        SubdomainHandlerDictionary testDictionary = new 
SubdomainHandlerDictionary(SUBDOMAIN_ENTITY);
-        testDictionary.register(new TestIQHandler("test", "test:namespace"));
-        stanzaHandlerLookup.addDictionary(testDictionary);
-
-        Stanza stanza = buildStanza("test", "test:namespace", 
"[email protected]");
-
-        StanzaHandler handler = stanzaHandlerLookup.getHandler(stanza);
-
-        assertNotNull("handler found", handler);
-        assertTrue("test handler", 
TestIQHandler.class.equals(handler.getClass()));
-    }
-
     private Stanza buildStanza(String name, String namespaceURI) {
         return buildStanza(name, namespaceURI, null);
     }

Modified: 
mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/MUCModule.java
URL: 
http://svn.apache.org/viewvc/mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/MUCModule.java?rev=808801&r1=808800&r2=808801&view=diff
==============================================================================
--- 
mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/MUCModule.java
 (original)
+++ 
mina/sandbox/vysper/trunk/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/MUCModule.java
 Fri Aug 28 08:03:03 2009
@@ -43,8 +43,10 @@
 import 
org.apache.vysper.xmpp.modules.servicediscovery.management.ServiceDiscoveryRequestException;
 import org.apache.vysper.xmpp.protocol.HandlerDictionary;
 import org.apache.vysper.xmpp.protocol.NamespaceURIs;
-import org.apache.vysper.xmpp.protocol.SubdomainHandlerDictionary;
+import org.apache.vysper.xmpp.protocol.AbstractHandlerDictionary;
 import org.apache.vysper.xmpp.server.ServerRuntimeContext;
+import org.apache.vysper.xmpp.server.SessionContext;
+import org.apache.vysper.xmpp.server.components.Component;
 import org.apache.vysper.xmpp.stanza.IQStanzaType;
 import org.apache.vysper.xmpp.stanza.StanzaBuilder;
 import org.slf4j.Logger;
@@ -55,7 +57,7 @@
  *
  * @author The Apache MINA Project ([email protected])
  */
-public class MUCModule extends DefaultDiscoAwareModule implements 
ServerInfoRequestListener, InfoRequestListener, ItemRequestListener {
+public class MUCModule extends DefaultDiscoAwareModule implements 
ServerInfoRequestListener, InfoRequestListener, ItemRequestListener, Component {
 
     private Conference conference;
     private Entity domain;
@@ -164,12 +166,16 @@
     @Override
     protected void addHandlerDictionaries(List<HandlerDictionary> 
dictionaries) {
         // MUC is only supported for running on a subdomain
+
+        
+        AbstractHandlerDictionary dictionary = new AbstractHandlerDictionary() 
{
+            
+        };
         
-        SubdomainHandlerDictionary dictionary = new 
SubdomainHandlerDictionary(domain);
         dictionary.register(new MUCPresenceHandler(conference));
         dictionary.register(new MUCMessageHandler(conference, domain));
         
-        dictionaries.add(dictionary);
+// TODO        dictionaries.add(dictionary);
     }
 
     /**
@@ -215,4 +221,12 @@
         }
         return null;
     }
+
+    public String getSubdomain() {
+        return domain.getDomain();
+    }
+
+    public SessionContext getSessionContext() {
+        return null;
+    }
 }


Reply via email to