You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Niklas Gustavsson <ng...@apache.org> on 2010/12/27 13:29:32 UTC

Re: svn commit: r1053051 - in /mina/vysper/branches/s2s/server/core/src: main/java/org/apache/vysper/spring/ main/java/org/apache/vysper/xmpp/modules/extension/xep0119_xmppping/ main/java/org/apache/vysper/xmpp/protocol/ main/java/org/apache/vysper/x

Bernd, this is the patch we spoke about yesterday about changing the
StanzaHandler lookup. Please review. It currently passes all unit
tests and I've done some basic manual testing. It also contains a demo
of how it could be used for catching XMPP Ping responses.

/niklas

On Mon, Dec 27, 2010 at 1:14 PM,  <ng...@apache.org> wrote:
> Author: ngn
> Date: Mon Dec 27 12:14:33 2010
> New Revision: 1053051
>
> URL: http://svn.apache.org/viewvc?rev=1053051&view=rev
> Log:
> Allowing for generic HanderDictionaries
> Letting extensions override standard StanzaHandlers
> Prototype of more flexible handling of StanzaHandler lookup with ping responses
>
> Added:
>    mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/DefaultHandlerDictionary.java
>      - copied, changed from r1050959, mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/AbstractHandlerDictionary.java
> Removed:
>    mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/AbstractHandlerDictionary.java
> Modified:
>    mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/spring/SpringCompatibleDefaultServerRuntimeContext.java
>    mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0119_xmppping/XmppPingIQHandler.java
>    mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0119_xmppping/XmppPingModule.java
>    mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/AbstractStanzaHandlerLookup.java
>    mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/NamespaceHandlerDictionary.java
>    mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java
>    mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java
>    mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java
>    mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/components/ComponentStanzaHandlerLookup.java
>    mina/vysper/branches/s2s/server/core/src/test/java/org/apache/vysper/stanzasession/StanzaSessionTestCase.java
>    mina/vysper/branches/s2s/server/core/src/test/java/org/apache/vysper/xmpp/server/s2s/Server2Server.java
>
> Modified: mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/spring/SpringCompatibleDefaultServerRuntimeContext.java
> URL: http://svn.apache.org/viewvc/mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/spring/SpringCompatibleDefaultServerRuntimeContext.java?rev=1053051&r1=1053050&r2=1053051&view=diff
> ==============================================================================
> --- mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/spring/SpringCompatibleDefaultServerRuntimeContext.java (original)
> +++ mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/spring/SpringCompatibleDefaultServerRuntimeContext.java Mon Dec 27 12:14:33 2010
> @@ -26,7 +26,7 @@ import org.apache.vysper.xmpp.delivery.S
>  import org.apache.vysper.xmpp.delivery.failure.DeliveryException;
>  import org.apache.vysper.xmpp.delivery.failure.DeliveryFailureStrategy;
>  import org.apache.vysper.xmpp.modules.Module;
> -import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary;
> +import org.apache.vysper.xmpp.protocol.HandlerDictionary;
>  import org.apache.vysper.xmpp.server.DefaultServerRuntimeContext;
>  import org.apache.vysper.xmpp.server.ServerFeatures;
>  import org.apache.vysper.xmpp.stanza.Stanza;
> @@ -51,7 +51,7 @@ public class SpringCompatibleDefaultServ
>     }
>
>     public SpringCompatibleDefaultServerRuntimeContext(Entity serverEntity, ServerFeatures serverFeatures,
> -            List<NamespaceHandlerDictionary> dictionaries, ResourceRegistry resourceRegistry) {
> +            List<HandlerDictionary> dictionaries, ResourceRegistry resourceRegistry) {
>         super(serverEntity, new StanzaRelayHull(), serverFeatures, dictionaries, resourceRegistry);
>     }
>
>
> Modified: mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0119_xmppping/XmppPingIQHandler.java
> URL: http://svn.apache.org/viewvc/mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0119_xmppping/XmppPingIQHandler.java?rev=1053051&r1=1053050&r2=1053051&view=diff
> ==============================================================================
> --- mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0119_xmppping/XmppPingIQHandler.java (original)
> +++ mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0119_xmppping/XmppPingIQHandler.java Mon Dec 27 12:14:33 2010
> @@ -51,6 +51,21 @@ public class XmppPingIQHandler extends D
>     }
>
>     @Override
> +    public boolean verify(Stanza stanza) {
> +        boolean extension = super.verify(stanza);
> +        if(extension) {
> +            return true;
> +        } else {
> +            String id = stanza.getAttributeValue("id");
> +            if(id != null && id.equals("123")) {
> +                return true;
> +            }
> +        }
> +
> +        return false;
> +    }
> +
> +    @Override
>     protected boolean verifyNamespace(Stanza stanza) {
>         return verifyInnerNamespace(stanza, NamespaceURIs.URN_XMPP_PING);
>     }
> @@ -68,4 +83,13 @@ public class XmppPingIQHandler extends D
>
>         return stanzaBuilder.build();
>     }
> +
> +    @Override
> +    protected Stanza handleResult(IQStanza stanza, ServerRuntimeContext serverRuntimeContext,
> +            SessionContext sessionContext) {
> +        System.out.println("Got Pong");
> +        return null;
> +    }
> +
> +
>  }
>
> Modified: mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0119_xmppping/XmppPingModule.java
> URL: http://svn.apache.org/viewvc/mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0119_xmppping/XmppPingModule.java?rev=1053051&r1=1053050&r2=1053051&view=diff
> ==============================================================================
> --- mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0119_xmppping/XmppPingModule.java (original)
> +++ mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0119_xmppping/XmppPingModule.java Mon Dec 27 12:14:33 2010
> @@ -27,8 +27,8 @@ import org.apache.vysper.xmpp.modules.se
>  import org.apache.vysper.xmpp.modules.servicediscovery.management.InfoElement;
>  import org.apache.vysper.xmpp.modules.servicediscovery.management.InfoRequest;
>  import org.apache.vysper.xmpp.modules.servicediscovery.management.ServerInfoRequestListener;
> +import org.apache.vysper.xmpp.protocol.DefaultHandlerDictionary;
>  import org.apache.vysper.xmpp.protocol.HandlerDictionary;
> -import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary;
>  import org.apache.vysper.xmpp.protocol.NamespaceURIs;
>
>  /**
> @@ -61,6 +61,6 @@ public class XmppPingModule extends Defa
>
>     @Override
>     protected void addHandlerDictionaries(List<HandlerDictionary> dictionary) {
> -        dictionary.add(new NamespaceHandlerDictionary(NamespaceURIs.URN_XMPP_PING, new XmppPingIQHandler()));
> +        dictionary.add(new DefaultHandlerDictionary(new XmppPingIQHandler()));
>     }
>  }
>
> Modified: mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/AbstractStanzaHandlerLookup.java
> URL: http://svn.apache.org/viewvc/mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/AbstractStanzaHandlerLookup.java?rev=1053051&r1=1053050&r2=1053051&view=diff
> ==============================================================================
> --- mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/AbstractStanzaHandlerLookup.java (original)
> +++ mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/AbstractStanzaHandlerLookup.java Mon Dec 27 12:14:33 2010
> @@ -19,8 +19,9 @@
>  */
>  package org.apache.vysper.xmpp.protocol;
>
> +import java.util.ArrayList;
>  import java.util.LinkedHashMap;
> -import java.util.Map;
> +import java.util.List;
>
>  import org.apache.vysper.xml.fragment.XMLElement;
>  import org.apache.vysper.xmpp.stanza.Stanza;
> @@ -29,13 +30,10 @@ import org.apache.vysper.xmpp.stanza.Sta
>  * basic facility to collect and query a set of namespace-based handlers
>  */
>  public abstract class AbstractStanzaHandlerLookup {
> -    protected Map<String, NamespaceHandlerDictionary> namespaceDictionaries = new LinkedHashMap<String, NamespaceHandlerDictionary>();
> +    protected List<HandlerDictionary> namespaceDictionaries = new ArrayList<HandlerDictionary>();
>
> -    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(HandlerDictionary namespaceHandlerDictionary) {
> +        namespaceDictionaries.add(namespaceHandlerDictionary);
>     }
>
>     public abstract StanzaHandler getHandler(Stanza stanza);
> @@ -46,18 +44,10 @@ public abstract class AbstractStanzaHand
>      * 2. xmlElements namespace, if the element name has a namespace prefix
>      */
>     protected StanzaHandler getHandlerForElement(Stanza stanza, XMLElement xmlElement) {
> -
> -        String namespace = xmlElement.getNamespaceURI();
> -        NamespaceHandlerDictionary namespaceHandlerDictionary = namespaceDictionaries.get(namespace);
> -
> -        // another try to get a dictionary
> -        if (namespaceHandlerDictionary == null) {
> -            namespace = xmlElement.getNamespacePrefix();
> -            namespaceHandlerDictionary = namespaceDictionaries.get(namespace);
> +        for(HandlerDictionary dictionary : namespaceDictionaries) {
> +            StanzaHandler stanzaHandler = dictionary.get(stanza);
> +            if(stanzaHandler != null) return stanzaHandler;
>         }
> -        if (namespaceHandlerDictionary != null)
> -            return namespaceHandlerDictionary.get(stanza);
> -
>         return null;
>     }
>  }
>
> Copied: mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/DefaultHandlerDictionary.java (from r1050959, mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/AbstractHandlerDictionary.java)
> URL: http://svn.apache.org/viewvc/mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/DefaultHandlerDictionary.java?p2=mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/DefaultHandlerDictionary.java&p1=mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/AbstractHandlerDictionary.java&r1=1050959&r2=1053051&rev=1053051&view=diff
> ==============================================================================
> --- mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/AbstractHandlerDictionary.java (original)
> +++ mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/DefaultHandlerDictionary.java Mon Dec 27 12:14:33 2010
> @@ -25,20 +25,20 @@ import java.util.List;
>  import org.apache.vysper.xmpp.stanza.Stanza;
>
>  /**
> - * Abstract class for implementations of {@link HandlerDictionary}
> + * Default implementation of {@link HandlerDictionary}. Will simple check all handlers
>  *
>  * @author The Apache MINA Project (dev@mina.apache.org)
>  */
> -public abstract class AbstractHandlerDictionary implements HandlerDictionary {
> +public class DefaultHandlerDictionary implements HandlerDictionary {
>
>     private List<StanzaHandler> handlerList = new ArrayList<StanzaHandler>();
>
>     private boolean sealed = false;
>
> -    public AbstractHandlerDictionary() {
> +    public DefaultHandlerDictionary() {
>     }
>
> -    public AbstractHandlerDictionary(List<StanzaHandler> handlerList) {
> +    public DefaultHandlerDictionary(List<StanzaHandler> handlerList) {
>         if (handlerList != null) {
>             for (StanzaHandler stanzaHandler : handlerList) {
>                 register(stanzaHandler);
> @@ -47,7 +47,7 @@ public abstract class AbstractHandlerDic
>         seal();
>     }
>
> -    public AbstractHandlerDictionary(StanzaHandler stanzaHandler) {
> +    public DefaultHandlerDictionary(StanzaHandler stanzaHandler) {
>         register(stanzaHandler);
>         seal();
>     }
>
> Modified: mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/NamespaceHandlerDictionary.java
> URL: http://svn.apache.org/viewvc/mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/NamespaceHandlerDictionary.java?rev=1053051&r1=1053050&r2=1053051&view=diff
> ==============================================================================
> --- mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/NamespaceHandlerDictionary.java (original)
> +++ mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/NamespaceHandlerDictionary.java Mon Dec 27 12:14:33 2010
> @@ -21,12 +21,14 @@ package org.apache.vysper.xmpp.protocol;
>
>  import java.util.List;
>
> +import org.apache.vysper.xmpp.stanza.Stanza;
> +
>  /**
>  * holds all stanza handlers for a distinct namespace
>  *
>  * @author The Apache MINA Project (dev@mina.apache.org)
>  */
> -public class NamespaceHandlerDictionary extends AbstractHandlerDictionary {
> +public class NamespaceHandlerDictionary extends DefaultHandlerDictionary {
>
>     private String namespaceURI;
>
> @@ -47,4 +49,20 @@ public class NamespaceHandlerDictionary
>     public String getNamespaceURI() {
>         return namespaceURI;
>     }
> +
> +    @Override
> +    public StanzaHandler get(Stanza stanza) {
> +        String namespace;
> +        if(stanza.getVerifier().subElementsPresentExact(1)) {
> +            namespace = stanza.getFirstInnerElement().getNamespaceURI();
> +        } else {
> +            namespace = stanza.getNamespaceURI();
> +        }
> +
> +        if(namespace != null && namespace.equals(namespaceURI)) {
> +            return super.get(stanza);
> +        } else {
> +            return null;
> +        }
> +    }
>  }
>
> Modified: mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java
> URL: http://svn.apache.org/viewvc/mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java?rev=1053051&r1=1053050&r2=1053051&view=diff
> ==============================================================================
> --- mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java (original)
> +++ mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/protocol/StanzaHandlerLookup.java Mon Dec 27 12:14:33 2010
> @@ -68,36 +68,33 @@ public class StanzaHandlerLookup extends
>         if (stanza == null)
>             return null;
>
> -        String name = stanza.getName();
> -
> -        if ("xml".equals(name)) {
> -            return new XMLPrologHandler();
> -        } else if ("stream".equals(name)) {
> -            return new StreamStartHandler();
> -        } else if ("verify".equals(name)) {
> -            return new DbVerifyHandler();
> -        } else if ("result".equals(name)) {
> -            return new DbResultHandler();
> -        } else if (iqHandler.verify(stanza)) {
> -            return getIQHandler(stanza);
> -        } else if (messageHandler.verify(stanza)) {
> -            return getMessageHandler(stanza);
> -        } else if (presenceHandler.verify(stanza)) {
> -            return getPresenceHandler(stanza);
> -        } else {
> -            // this is not a core stanza (RFC3920), but something like the following
> -            // (in descending-probability order):
> -            // a. a custom extension of iq, message, presence
> -            // b. some handshake stanza other than iq, message, presence
> -            // c. an arbitrary test stanza
> -            // d. an evil forged stanza
> -            // e. some extension we don't know yet
> -            // ...so we delegate:
> -            StanzaHandler stanzaHandler = getHandlerForElement(stanza, stanza);
> -            // ... and if we could not resolve and it's a core stanza, we can safely return an error
> -            if (stanzaHandler == null && XMPPCoreStanza.getWrapper(stanza) != null)
> -                return SERVICE_UNAVAILABLE_STANZA_ERROR_HANDLER;
> +        // allow extensions to override default handling
> +        StanzaHandler stanzaHandler = getHandlerForElement(stanza, stanza);
> +
> +        if(stanzaHandler != null) {
>             return stanzaHandler;
> +        } else {
> +            String name = stanza.getName();
> +
> +            if ("xml".equals(name)) {
> +                return new XMLPrologHandler();
> +            } else if ("stream".equals(name)) {
> +                return new StreamStartHandler();
> +            } else if ("verify".equals(name)) {
> +                return new DbVerifyHandler();
> +            } else if ("result".equals(name)) {
> +                return new DbResultHandler();
> +            } else if (iqHandler.verify(stanza)) {
> +                return getIQHandler(stanza);
> +            } else if (messageHandler.verify(stanza)) {
> +                return getMessageHandler(stanza);
> +            } else if (presenceHandler.verify(stanza)) {
> +                return getPresenceHandler(stanza);
> +            } else {
> +                // ... and if we could not resolve and it's a core stanza, we can safely return an error
> +                if (XMPPCoreStanza.getWrapper(stanza) != null) return SERVICE_UNAVAILABLE_STANZA_ERROR_HANDLER;
> +                else return null;
> +            }
>         }
>     }
>
>
> Modified: mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java
> URL: http://svn.apache.org/viewvc/mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java?rev=1053051&r1=1053050&r2=1053051&view=diff
> ==============================================================================
> --- mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java (original)
> +++ mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java Mon Dec 27 12:14:33 2010
> @@ -143,7 +143,7 @@ public class DefaultServerRuntimeContext
>     }
>
>     public DefaultServerRuntimeContext(Entity serverEntity, StanzaRelay stanzaRelay, ServerFeatures serverFeatures,
> -            List<NamespaceHandlerDictionary> dictionaries, ResourceRegistry resourceRegistry) {
> +            List<HandlerDictionary> dictionaries, ResourceRegistry resourceRegistry) {
>         this(serverEntity, stanzaRelay);
>         this.serverFeatures = serverFeatures;
>         this.resourceRegistry = resourceRegistry;
> @@ -193,12 +193,12 @@ public class DefaultServerRuntimeContext
>         return serverConnectorRegistry;
>     }
>
> -    public void addDictionary(NamespaceHandlerDictionary namespaceHandlerDictionary) {
> +    public void addDictionary(HandlerDictionary namespaceHandlerDictionary) {
>         stanzaHandlerLookup.addDictionary(namespaceHandlerDictionary);
>     }
>
> -    protected void addDictionaries(List<NamespaceHandlerDictionary> dictionaries) {
> -        for (NamespaceHandlerDictionary dictionary : dictionaries) {
> +    protected void addDictionaries(List<HandlerDictionary> dictionaries) {
> +        for (HandlerDictionary dictionary : dictionaries) {
>             addDictionary(dictionary);
>         }
>     }
> @@ -328,12 +328,7 @@ public class DefaultServerRuntimeContext
>         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.");
> -                }
> +                addDictionary(handlerDictionary);
>             }
>
>         }
>
> Modified: mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java
> URL: http://svn.apache.org/viewvc/mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java?rev=1053051&r1=1053050&r2=1053051&view=diff
> ==============================================================================
> --- mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java (original)
> +++ mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java Mon Dec 27 12:14:33 2010
> @@ -39,7 +39,7 @@ import org.apache.vysper.xmpp.delivery.i
>  import org.apache.vysper.xmpp.modules.Module;
>  import org.apache.vysper.xmpp.modules.roster.RosterModule;
>  import org.apache.vysper.xmpp.modules.servicediscovery.ServiceDiscoveryModule;
> -import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary;
> +import org.apache.vysper.xmpp.protocol.HandlerDictionary;
>  import org.apache.vysper.xmpp.state.resourcebinding.ResourceRegistry;
>
>  /**
> @@ -108,7 +108,7 @@ public class XMPPServer {
>         tlsContextFactory.setPassword(tlsCertificatePassword);
>         tlsContextFactory.setTrustManagerFactory(bogusTrustManagerFactory);
>
> -        List<NamespaceHandlerDictionary> dictionaries = new ArrayList<NamespaceHandlerDictionary>();
> +        List<HandlerDictionary> dictionaries = new ArrayList<HandlerDictionary>();
>         addCoreDictionaries(dictionaries);
>
>         ResourceRegistry resourceRegistry = new ResourceRegistry();
> @@ -157,7 +157,7 @@ public class XMPPServer {
>         serverRuntimeContext.addModule(module);
>     }
>
> -    private void addCoreDictionaries(List<NamespaceHandlerDictionary> dictionaries) {
> +    private void addCoreDictionaries(List<HandlerDictionary> dictionaries) {
>         dictionaries.add(new org.apache.vysper.xmpp.modules.core.base.BaseStreamStanzaDictionary());
>         dictionaries.add(new org.apache.vysper.xmpp.modules.core.starttls.StartTLSStanzaDictionary());
>         dictionaries.add(new org.apache.vysper.xmpp.modules.core.sasl.SASLStanzaDictionary());
>
> Modified: mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/components/ComponentStanzaHandlerLookup.java
> URL: http://svn.apache.org/viewvc/mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/components/ComponentStanzaHandlerLookup.java?rev=1053051&r1=1053050&r2=1053051&view=diff
> ==============================================================================
> --- mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/components/ComponentStanzaHandlerLookup.java (original)
> +++ mina/vysper/branches/s2s/server/core/src/main/java/org/apache/vysper/xmpp/server/components/ComponentStanzaHandlerLookup.java Mon Dec 27 12:14:33 2010
> @@ -20,7 +20,7 @@
>  package org.apache.vysper.xmpp.server.components;
>
>  import org.apache.vysper.xml.fragment.XMLElement;
> -import org.apache.vysper.xmpp.protocol.AbstractHandlerDictionary;
> +import org.apache.vysper.xmpp.protocol.DefaultHandlerDictionary;
>  import org.apache.vysper.xmpp.protocol.AbstractStanzaHandlerLookup;
>  import org.apache.vysper.xmpp.protocol.StanzaHandler;
>  import org.apache.vysper.xmpp.stanza.Stanza;
> @@ -30,7 +30,7 @@ import org.apache.vysper.xmpp.stanza.Sta
>  */
>  public class ComponentStanzaHandlerLookup extends AbstractStanzaHandlerLookup {
>
> -    private static class ComponentHandlerDictionary extends AbstractHandlerDictionary {
> +    private static class ComponentHandlerDictionary extends DefaultHandlerDictionary {
>
>         public ComponentHandlerDictionary() {
>             super();
>
> Modified: mina/vysper/branches/s2s/server/core/src/test/java/org/apache/vysper/stanzasession/StanzaSessionTestCase.java
> URL: http://svn.apache.org/viewvc/mina/vysper/branches/s2s/server/core/src/test/java/org/apache/vysper/stanzasession/StanzaSessionTestCase.java?rev=1053051&r1=1053050&r2=1053051&view=diff
> ==============================================================================
> --- mina/vysper/branches/s2s/server/core/src/test/java/org/apache/vysper/stanzasession/StanzaSessionTestCase.java (original)
> +++ mina/vysper/branches/s2s/server/core/src/test/java/org/apache/vysper/stanzasession/StanzaSessionTestCase.java Mon Dec 27 12:14:33 2010
> @@ -26,7 +26,7 @@ import junit.framework.TestCase;
>
>  import org.apache.vysper.xmpp.addressing.EntityImpl;
>  import org.apache.vysper.xmpp.delivery.StanzaRelayBroker;
> -import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary;
> +import org.apache.vysper.xmpp.protocol.HandlerDictionary;
>  import org.apache.vysper.xmpp.server.DefaultServerRuntimeContext;
>  import org.apache.vysper.xmpp.server.ServerFeatures;
>  import org.apache.vysper.xmpp.stanza.Stanza;
> @@ -44,7 +44,7 @@ public class StanzaSessionTestCase exten
>     protected void setUp() throws Exception {
>         StanzaRelayBroker relay = new StanzaRelayBroker();
>
> -        List<NamespaceHandlerDictionary> dictionaries = new ArrayList<NamespaceHandlerDictionary>();
> +        List<HandlerDictionary> dictionaries = new ArrayList<HandlerDictionary>();
>         dictionaries.add(new org.apache.vysper.xmpp.modules.core.base.BaseStreamStanzaDictionary());
>         dictionaries.add(new org.apache.vysper.xmpp.modules.core.starttls.StartTLSStanzaDictionary());
>         dictionaries.add(new org.apache.vysper.xmpp.modules.core.sasl.SASLStanzaDictionary());
>
> Modified: mina/vysper/branches/s2s/server/core/src/test/java/org/apache/vysper/xmpp/server/s2s/Server2Server.java
> URL: http://svn.apache.org/viewvc/mina/vysper/branches/s2s/server/core/src/test/java/org/apache/vysper/xmpp/server/s2s/Server2Server.java?rev=1053051&r1=1053050&r2=1053051&view=diff
> ==============================================================================
> --- mina/vysper/branches/s2s/server/core/src/test/java/org/apache/vysper/xmpp/server/s2s/Server2Server.java (original)
> +++ mina/vysper/branches/s2s/server/core/src/test/java/org/apache/vysper/xmpp/server/s2s/Server2Server.java Mon Dec 27 12:14:33 2010
> @@ -7,6 +7,7 @@ import org.apache.vysper.storage.inmemor
>  import org.apache.vysper.xmpp.addressing.Entity;
>  import org.apache.vysper.xmpp.addressing.EntityImpl;
>  import org.apache.vysper.xmpp.authorization.AccountManagement;
> +import org.apache.vysper.xmpp.modules.extension.xep0119_xmppping.XmppPingModule;
>  import org.apache.vysper.xmpp.protocol.NamespaceURIs;
>  import org.apache.vysper.xmpp.server.ServerRuntimeContext;
>  import org.apache.vysper.xmpp.server.XMPPServer;
> @@ -44,7 +45,10 @@ public class Server2Server {
>         server.addEndpoint(new TCPEndpoint());
>         server.setStorageProviderRegistry(providerRegistry);
>         server.setTLSCertificateInfo(new File("src/main/config/bogus_mina_tls.cert"), "boguspw");
> +
>         server.start();
> +        server.addModule(new XmppPingModule());
> +
>         ServerRuntimeContext serverRuntimeContext = server.getServerRuntimeContext();
>
>         Thread.sleep(2000);
>
>
>

Re: svn commit: r1053051 - in /mina/vysper/branches/s2s/server/core/src: main/java/org/apache/vysper/spring/ main/java/org/apache/vysper/xmpp/modules/extension/xep0119_xmppping/ main/java/org/apache/vysper/xmpp/protocol/ main/java/org/apache/vysper/x

Posted by Niklas Gustavsson <ni...@protocol7.com>.
On Wed, Dec 29, 2010 at 10:53 AM, Bernd Fondermann
<bf...@brainlounge.de> wrote:
> On 27.12.10 13:29, Niklas Gustavsson wrote:
>>
>> Bernd, this is the patch we spoke about yesterday about changing the
>> StanzaHandler lookup. Please review. It currently passes all unit
>> tests and I've done some basic manual testing. It also contains a demo
>> of how it could be used for catching XMPP Ping responses.
>
> +1, patch works well on trunk, I don't detect any collateral damage.

Great!

> For IQ responses, I think we'd need more supporting infrastructure.
> I'd like to see some kind of continuation/future mechanism:
> 1. server sends IQ request + records a continuation in case the IQ
> result/error arrives
> 2.1. IQ result arrives: 'regular' continuation is invoked.
> 2.2. IQ error arrives: depending on the error case indicated in the
> response, IQ request might been retried, or connections is canceled.
> 2.3. IQ response doesn't arrive in time: some fallback is invoked, for
> example sending another IQ, or setting a status.

Agreed. I did a one-of hack of this based on event listeners for XMPP
Ping. But having something more generic would be good.

/niklas

Re: svn commit: r1053051 - in /mina/vysper/branches/s2s/server/core/src: main/java/org/apache/vysper/spring/ main/java/org/apache/vysper/xmpp/modules/extension/xep0119_xmppping/ main/java/org/apache/vysper/xmpp/protocol/ main/java/org/apache/vysper/x

Posted by Bernd Fondermann <bf...@brainlounge.de>.
On 27.12.10 13:29, Niklas Gustavsson wrote:
> Bernd, this is the patch we spoke about yesterday about changing the
> StanzaHandler lookup. Please review. It currently passes all unit
> tests and I've done some basic manual testing. It also contains a demo
> of how it could be used for catching XMPP Ping responses.
>

+1, patch works well on trunk, I don't detect any collateral damage.

For IQ responses, I think we'd need more supporting infrastructure.
I'd like to see some kind of continuation/future mechanism:
1. server sends IQ request + records a continuation in case the IQ 
result/error arrives
2.1. IQ result arrives: 'regular' continuation is invoked.
2.2. IQ error arrives: depending on the error case indicated in the 
response, IQ request might been retried, or connections is canceled.
2.3. IQ response doesn't arrive in time: some fallback is invoked, for 
example sending another IQ, or setting a status.

   Bernd