This is an automated email from the ASF dual-hosted git repository.
ralaoui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-vysper.git
The following commit(s) were added to refs/heads/master by this push:
new 5bcde9d Remove createComponentStanzaProcessor from the
ServerRuntimeContext
5bcde9d is described below
commit 5bcde9dd39e5d088c883e00604786d1626f511fd
Author: Réda Housni Alaoui <[email protected]>
AuthorDate: Sun Aug 25 11:38:11 2019 +0200
Remove createComponentStanzaProcessor from the ServerRuntimeContext
---
.../apache/vysper/xmpp/addressing/EntityUtils.java | 9 +++
.../xmpp/server/AlterableComponentRegistry.java | 3 +-
...y.java => ComponentStanzaProcessorFactory.java} | 16 ++++-
.../xmpp/server/DefaultServerRuntimeContext.java | 11 ++--
.../vysper/xmpp/server/ServerRuntimeContext.java | 2 -
.../xmpp/server/SimpleComponentRegistry.java | 70 ++++++++++++----------
.../org/apache/vysper/xmpp/server/XMPPServer.java | 2 +-
.../vysper/xmpp/server/components/Component.java | 25 ++++----
.../modules/extension/xep0045_muc/MUCModule.java | 27 +++++----
.../xep0060_pubsub/PublishSubscribeModule.java | 53 ++++++++--------
.../xmpp/extension/xep0065_socks/Socks5Module.java | 29 ++++-----
.../extension/xep0065_socks/Socks5ModuleTest.java | 9 ---
12 files changed, 136 insertions(+), 120 deletions(-)
diff --git
a/server/core/src/main/java/org/apache/vysper/xmpp/addressing/EntityUtils.java
b/server/core/src/main/java/org/apache/vysper/xmpp/addressing/EntityUtils.java
index 2401848..0bbc4c1 100644
---
a/server/core/src/main/java/org/apache/vysper/xmpp/addressing/EntityUtils.java
+++
b/server/core/src/main/java/org/apache/vysper/xmpp/addressing/EntityUtils.java
@@ -60,4 +60,13 @@ public class EntityUtils {
throw new RuntimeException("could not create component domain", e);
}
}
+
+ public static Entity createComponentDomain(String subdomain, Entity
serverEntity){
+ try {
+ return EntityImpl.parse(subdomain + "." +
serverEntity.getDomain());
+ } catch (EntityFormatException e) {
+ // only happens when server entity is bad.
+ throw new RuntimeException("could not create component domain", e);
+ }
+ }
}
diff --git
a/server/core/src/main/java/org/apache/vysper/xmpp/server/AlterableComponentRegistry.java
b/server/core/src/main/java/org/apache/vysper/xmpp/server/AlterableComponentRegistry.java
index f4ff214..b38fe0a 100644
---
a/server/core/src/main/java/org/apache/vysper/xmpp/server/AlterableComponentRegistry.java
+++
b/server/core/src/main/java/org/apache/vysper/xmpp/server/AlterableComponentRegistry.java
@@ -19,6 +19,7 @@
*/
package org.apache.vysper.xmpp.server;
+import org.apache.vysper.xmpp.delivery.StanzaRelay;
import org.apache.vysper.xmpp.server.components.Component;
/**
@@ -26,6 +27,6 @@ import org.apache.vysper.xmpp.server.components.Component;
*/
public interface AlterableComponentRegistry extends ComponentRegistry {
- void registerComponent(Component component);
+ void registerComponent(ComponentStanzaProcessorFactory processorFactory,
Component component);
}
diff --git
a/server/core/src/main/java/org/apache/vysper/xmpp/server/AlterableComponentRegistry.java
b/server/core/src/main/java/org/apache/vysper/xmpp/server/ComponentStanzaProcessorFactory.java
similarity index 64%
copy from
server/core/src/main/java/org/apache/vysper/xmpp/server/AlterableComponentRegistry.java
copy to
server/core/src/main/java/org/apache/vysper/xmpp/server/ComponentStanzaProcessorFactory.java
index f4ff214..ef2dc04 100644
---
a/server/core/src/main/java/org/apache/vysper/xmpp/server/AlterableComponentRegistry.java
+++
b/server/core/src/main/java/org/apache/vysper/xmpp/server/ComponentStanzaProcessorFactory.java
@@ -19,13 +19,23 @@
*/
package org.apache.vysper.xmpp.server;
-import org.apache.vysper.xmpp.server.components.Component;
+import static java.util.Objects.requireNonNull;
+
+import org.apache.vysper.xmpp.delivery.StanzaRelay;
+import org.apache.vysper.xmpp.server.components.ComponentStanzaProcessor;
/**
* @author Réda Housni Alaoui
*/
-public interface AlterableComponentRegistry extends ComponentRegistry {
+public class ComponentStanzaProcessorFactory {
+
+ private final StanzaRelay stanzaRelay;
- void registerComponent(Component component);
+ public ComponentStanzaProcessorFactory(StanzaRelay stanzaRelay) {
+ this.stanzaRelay = requireNonNull(stanzaRelay);
+ }
+ public ComponentStanzaProcessor build() {
+ return new ComponentStanzaProcessor(stanzaRelay);
+ }
}
diff --git
a/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java
b/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java
index 83b1edb..87aac14 100644
---
a/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java
+++
b/server/core/src/main/java/org/apache/vysper/xmpp/server/DefaultServerRuntimeContext.java
@@ -48,7 +48,6 @@ 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.server.components.Component;
-import org.apache.vysper.xmpp.server.components.ComponentStanzaProcessor;
import org.apache.vysper.xmpp.server.s2s.DefaultXMPPServerConnectorRegistry;
import org.apache.vysper.xmpp.server.s2s.XMPPServerConnectorRegistry;
import org.apache.vysper.xmpp.stanza.Stanza;
@@ -142,6 +141,8 @@ public class DefaultServerRuntimeContext implements
ServerRuntimeContext, Module
private final AlterableComponentRegistry componentRegistry;
private final SimpleEventBus eventBus;
+
+ private final ComponentStanzaProcessorFactory
componentStanzaProcessorFactory;
public DefaultServerRuntimeContext(Entity serverEntity, StanzaRelay
stanzaRelay,
AlterableComponentRegistry componentRegistry, ResourceRegistry
resourceRegistry,
@@ -155,6 +156,7 @@ public class DefaultServerRuntimeContext implements
ServerRuntimeContext, Module
this.eventBus = new SimpleEventBus();
this.serverFeatures = serverFeatures;
this.resourceRegistry = resourceRegistry;
+ this.componentStanzaProcessorFactory = new
ComponentStanzaProcessorFactory(stanzaRelay);
addDictionaries(dictionaries);
}
@@ -408,7 +410,7 @@ public class DefaultServerRuntimeContext implements
ServerRuntimeContext, Module
@Override
public void registerComponent(Component component) {
- componentRegistry.registerComponent(component);
+ componentRegistry.registerComponent(componentStanzaProcessorFactory,
component);
}
@Override
@@ -416,9 +418,4 @@ public class DefaultServerRuntimeContext implements
ServerRuntimeContext, Module
return componentRegistry.getComponentStanzaProcessor(entity) != null;
}
- @Override
- public ComponentStanzaProcessor createComponentStanzaProcessor() {
- return new ComponentStanzaProcessor(stanzaRelay);
- }
-
}
diff --git
a/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java
b/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java
index 9a1563b..1cebe0d 100644
---
a/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java
+++
b/server/core/src/main/java/org/apache/vysper/xmpp/server/ServerRuntimeContext.java
@@ -76,8 +76,6 @@ public interface ServerRuntimeContext {
boolean hasComponentStanzaProcessor(Entity entity);
- ComponentStanzaProcessor createComponentStanzaProcessor();
-
XMPPServerConnectorRegistry getServerConnectorRegistry();
List<Module> getModules();
diff --git
a/server/core/src/main/java/org/apache/vysper/xmpp/server/SimpleComponentRegistry.java
b/server/core/src/main/java/org/apache/vysper/xmpp/server/SimpleComponentRegistry.java
index d2df521..30b480e 100644
---
a/server/core/src/main/java/org/apache/vysper/xmpp/server/SimpleComponentRegistry.java
+++
b/server/core/src/main/java/org/apache/vysper/xmpp/server/SimpleComponentRegistry.java
@@ -19,48 +19,52 @@
*/
package org.apache.vysper.xmpp.server;
-import org.apache.vysper.xmpp.addressing.Entity;
-import org.apache.vysper.xmpp.addressing.EntityUtils;
-import org.apache.vysper.xmpp.protocol.StanzaProcessor;
-import org.apache.vysper.xmpp.server.components.Component;
+import static java.util.Objects.requireNonNull;
import java.util.HashMap;
import java.util.Map;
-import static java.util.Objects.requireNonNull;
+import org.apache.vysper.xmpp.addressing.Entity;
+import org.apache.vysper.xmpp.addressing.EntityUtils;
+import org.apache.vysper.xmpp.protocol.StanzaProcessor;
+import org.apache.vysper.xmpp.server.components.Component;
+import org.apache.vysper.xmpp.server.components.ComponentStanzaProcessor;
/**
* @author Réda Housni Alaoui
*/
public class SimpleComponentRegistry implements AlterableComponentRegistry {
-
- private final Entity serverEntity;
-
- /**
- * map of all registered components, index by the subdomain they are
registered for
- */
- private final Map<String, Component> componentMap = new HashMap<>();
- public SimpleComponentRegistry(Entity serverEntity) {
- this.serverEntity = requireNonNull(serverEntity);
- }
-
- @Override
- public void registerComponent(Component component){
- componentMap.put(component.getSubdomain(), component);
- }
+ private final Entity serverEntity;
+
+ /**
+ * map of all registered components, index by the subdomain they are
registered
+ * for
+ */
+ private final Map<String, StanzaProcessor> processorBySubdomain = new
HashMap<>();
+
+ public SimpleComponentRegistry(Entity serverEntity) {
+ this.serverEntity = requireNonNull(serverEntity);
+ }
+
+ @Override
+ public void registerComponent(ComponentStanzaProcessorFactory
processorFactory, Component component) {
+ ComponentStanzaProcessor processor = processorFactory.build();
+ Entity fullDomain =
EntityUtils.createComponentDomain(component.getSubdomain(), serverEntity);
+
component.getComponentHandlers(fullDomain).forEach(processor::addHandler);
+
component.getComponentHandlerDictionnaries(fullDomain).forEach(processor::addDictionary);
+ processorBySubdomain.put(component.getSubdomain(), processor);
+ }
+
+ @Override
+ public StanzaProcessor getComponentStanzaProcessor(Entity entity) {
+ String serverDomain = serverEntity.getDomain();
+ if (!EntityUtils.isAddressingServerComponent(entity, serverEntity)) {
+ return null;
+ }
+ String domain = entity.getDomain();
+ String subdomain = domain.replace("." + serverDomain, "");
+ return processorBySubdomain.get(subdomain);
+ }
- @Override
- public StanzaProcessor getComponentStanzaProcessor(Entity entity) {
- String serverDomain = serverEntity.getDomain();
- if (!EntityUtils.isAddressingServerComponent(entity,
serverEntity)) {
- return null;
- }
- String domain = entity.getDomain();
- String subdomain = domain.replace("." + serverDomain, "");
- Component component = componentMap.get(subdomain);
- if (component == null)
- return null;
- return component.getStanzaProcessor();
- }
}
diff --git
a/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java
b/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java
index 5268bc9..0176190 100644
--- a/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java
+++ b/server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java
@@ -168,7 +168,7 @@ public class XMPPServer {
tlsContextFactory.setKeyStoreType(tlsKeyStoreType);
}
- List<HandlerDictionary> dictionaries = new
ArrayList<HandlerDictionary>();
+ List<HandlerDictionary> dictionaries = new ArrayList<>();
addCoreDictionaries(dictionaries);
ResourceRegistry resourceRegistry = new DefaultResourceRegistry();
diff --git
a/server/core/src/main/java/org/apache/vysper/xmpp/server/components/Component.java
b/server/core/src/main/java/org/apache/vysper/xmpp/server/components/Component.java
index d3687b2..a7d2462 100644
---
a/server/core/src/main/java/org/apache/vysper/xmpp/server/components/Component.java
+++
b/server/core/src/main/java/org/apache/vysper/xmpp/server/components/Component.java
@@ -19,25 +19,28 @@
*/
package org.apache.vysper.xmpp.server.components;
-import org.apache.vysper.xmpp.protocol.StanzaProcessor;
+import java.util.List;
+
+import org.apache.vysper.xmpp.addressing.Entity;
+import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary;
+import org.apache.vysper.xmpp.protocol.StanzaHandler;
/**
- * 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
+ * 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 {
/**
- * the subdomain this component should become available under.
- * example: subdomain = 'chat' + server domain = 'vysper.org' =>
'chat.vysper.org'
+ * the subdomain this component should become available under. example:
+ * subdomain = 'chat' + server domain = 'vysper.org' => 'chat.vysper.org'
+ *
* @return
*/
String getSubdomain();
- /**
- * retrieve the stanza processor for the component
- * @return
- */
- StanzaProcessor getStanzaProcessor();
+ List<StanzaHandler> getComponentHandlers(Entity fullDomain);
+
+ List<NamespaceHandlerDictionary> getComponentHandlerDictionnaries(Entity
fullDomain);
}
diff --git
a/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/MUCModule.java
b/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/MUCModule.java
index 540c46a..572e61a 100644
---
a/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/MUCModule.java
+++
b/server/extensions/xep0045-muc/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0045_muc/MUCModule.java
@@ -20,6 +20,7 @@
package org.apache.vysper.xmpp.modules.extension.xep0045_muc;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.apache.vysper.xmpp.addressing.Entity;
@@ -41,12 +42,12 @@ import
org.apache.vysper.xmpp.modules.servicediscovery.management.InfoRequest;
import org.apache.vysper.xmpp.modules.servicediscovery.management.Item;
import
org.apache.vysper.xmpp.modules.servicediscovery.management.ItemRequestListener;
import
org.apache.vysper.xmpp.modules.servicediscovery.management.ServiceDiscoveryRequestException;
+import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary;
import org.apache.vysper.xmpp.protocol.NamespaceURIs;
import org.apache.vysper.xmpp.protocol.StanzaBroker;
-import org.apache.vysper.xmpp.protocol.StanzaProcessor;
+import org.apache.vysper.xmpp.protocol.StanzaHandler;
import org.apache.vysper.xmpp.server.ServerRuntimeContext;
import org.apache.vysper.xmpp.server.components.Component;
-import org.apache.vysper.xmpp.server.components.ComponentStanzaProcessor;
import org.apache.vysper.xmpp.stanza.IQStanzaType;
import org.apache.vysper.xmpp.stanza.StanzaBuilder;
import org.slf4j.Logger;
@@ -73,8 +74,6 @@ public class MUCModule extends DefaultDiscoAwareModule
private ServerRuntimeContext serverRuntimeContext;
- private ComponentStanzaProcessor stanzaProcessor;
-
public MUCModule(String subdomain) {
this(subdomain, null);
}
@@ -103,12 +102,6 @@ public class MUCModule extends DefaultDiscoAwareModule
fullDomain = EntityUtils.createComponentDomain(subdomain,
serverRuntimeContext);
- ComponentStanzaProcessor processor =
serverRuntimeContext.createComponentStanzaProcessor();
- processor.addHandler(new MUCPresenceHandler(conference));
- processor.addHandler(new MUCMessageHandler(conference, fullDomain));
- processor.addHandler(new MUCIqAdminHandler(conference));
- stanzaProcessor = processor;
-
RoomStorageProvider roomStorageProvider =
serverRuntimeContext.getStorageProvider(RoomStorageProvider.class);
OccupantStorageProvider occupantStorageProvider = serverRuntimeContext
.getStorageProvider(OccupantStorageProvider.class);
@@ -245,8 +238,18 @@ public class MUCModule extends DefaultDiscoAwareModule
return subdomain;
}
- public StanzaProcessor getStanzaProcessor() {
- return stanzaProcessor;
+ @Override
+ public List<StanzaHandler> getComponentHandlers(Entity fullDomain) {
+ List<StanzaHandler> handlers = new ArrayList<>();
+ handlers.add(new MUCPresenceHandler(conference));
+ handlers.add(new MUCMessageHandler(conference, fullDomain));
+ handlers.add(new MUCIqAdminHandler(conference));
+ return handlers;
+ }
+
+ @Override
+ public List<NamespaceHandlerDictionary>
getComponentHandlerDictionnaries(Entity fullDomain) {
+ return Collections.emptyList();
}
}
diff --git
a/server/extensions/xep0060-pubsub/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/PublishSubscribeModule.java
b/server/extensions/xep0060-pubsub/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/PublishSubscribeModule.java
index 4ea5607..be965a4 100644
---
a/server/extensions/xep0060-pubsub/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/PublishSubscribeModule.java
+++
b/server/extensions/xep0060-pubsub/src/main/java/org/apache/vysper/xmpp/modules/extension/xep0060_pubsub/PublishSubscribeModule.java
@@ -20,6 +20,7 @@
package org.apache.vysper.xmpp.modules.extension.xep0060_pubsub;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.apache.vysper.compliance.SpecCompliant;
@@ -74,8 +75,6 @@ public class PublishSubscribeModule extends
DefaultDiscoAwareModule implements C
// for debugging
private final Logger logger =
LoggerFactory.getLogger(PublishSubscribeModule.class);
- private ComponentStanzaProcessor stanzaProcessor;
-
private ServerRuntimeContext serverRuntimeContext;
/**
@@ -138,13 +137,6 @@ public class PublishSubscribeModule extends
DefaultDiscoAwareModule implements C
serviceConfiguration.setLeafNodeStorageProvider(leafNodeStorageProvider);
}
- ComponentStanzaProcessor processor =
serverRuntimeContext.createComponentStanzaProcessor();
- addPubsubHandlers(processor);
- addPubsubOwnerHandlers(processor);
- processor
- .addDictionary(new
NamespaceHandlerDictionary(NamespaceURIs.XEP0060_PUBSUB_EVENT, new
MessageHandler()));
- stanzaProcessor = processor;
-
this.serviceConfiguration.setDomainJID(fullDomain);
this.serviceConfiguration.initialize();
}
@@ -232,38 +224,49 @@ public class PublishSubscribeModule extends
DefaultDiscoAwareModule implements C
return items;
}
+ public String getSubdomain() {
+ return subdomain;
+ }
+
+ @Override
+ public List<StanzaHandler> getComponentHandlers(Entity fullDomain) {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public List<NamespaceHandlerDictionary>
getComponentHandlerDictionnaries(Entity fullDomain) {
+ List<NamespaceHandlerDictionary> dictionaries = new ArrayList<>();
+ addPubsubHandlers(dictionaries);
+ addPubsubOwnerHandlers(dictionaries);
+ dictionaries.add(new
NamespaceHandlerDictionary(NamespaceURIs.XEP0060_PUBSUB_EVENT, new
MessageHandler()));
+ return dictionaries;
+ }
+
/**
* Inserts the handlers for the pubsub#owner namespace into the
HandlerDictionary.
- * @param dictionary the list to which the handlers should be appended.
+ * @param dictionaries the list to which the handlers should be appended.
*/
- private void addPubsubOwnerHandlers(ComponentStanzaProcessor dictionary) {
- ArrayList<StanzaHandler> pubsubOwnerHandlers = new
ArrayList<StanzaHandler>();
+ private void addPubsubOwnerHandlers(List<NamespaceHandlerDictionary>
dictionaries) {
+ ArrayList<StanzaHandler> pubsubOwnerHandlers = new ArrayList<>();
pubsubOwnerHandlers.add(new
PubSubOwnerConfigureNodeHandler(serviceConfiguration));
pubsubOwnerHandlers.add(new
PubSubOwnerDeleteNodeHandler(serviceConfiguration));
- dictionary
- .addDictionary(new
NamespaceHandlerDictionary(NamespaceURIs.XEP0060_PUBSUB_OWNER,
pubsubOwnerHandlers));
+ dictionaries
+ .add(new
NamespaceHandlerDictionary(NamespaceURIs.XEP0060_PUBSUB_OWNER,
pubsubOwnerHandlers));
}
/**
* Inserts the handlers for the pubsub namespace into the
HandlerDictionary.
- * @param dictionary the list to which the handlers should be appended.
+ * @param dictionaries the list to which the handlers should be appended.
*/
- private void addPubsubHandlers(ComponentStanzaProcessor dictionary) {
- ArrayList<StanzaHandler> pubsubHandlers = new
ArrayList<StanzaHandler>();
+ private void addPubsubHandlers(List<NamespaceHandlerDictionary>
dictionaries) {
+ ArrayList<StanzaHandler> pubsubHandlers = new ArrayList<>();
pubsubHandlers.add(new PubSubSubscribeHandler(serviceConfiguration));
pubsubHandlers.add(new PubSubUnsubscribeHandler(serviceConfiguration));
pubsubHandlers.add(new PubSubPublishHandler(serviceConfiguration));
pubsubHandlers.add(new PubSubCreateNodeHandler(serviceConfiguration));
pubsubHandlers.add(new
PubSubRetrieveSubscriptionsHandler(serviceConfiguration));
pubsubHandlers.add(new
PubSubRetrieveAffiliationsHandler(serviceConfiguration));
- dictionary.addDictionary(new
NamespaceHandlerDictionary(NamespaceURIs.XEP0060_PUBSUB, pubsubHandlers));
- }
-
- public String getSubdomain() {
- return subdomain;
+ dictionaries.add(new
NamespaceHandlerDictionary(NamespaceURIs.XEP0060_PUBSUB, pubsubHandlers));
}
- public StanzaProcessor getStanzaProcessor() {
- return stanzaProcessor;
- }
}
diff --git
a/server/extensions/xep0065-socks/src/main/java/org/apache/vysper/xmpp/extension/xep0065_socks/Socks5Module.java
b/server/extensions/xep0065-socks/src/main/java/org/apache/vysper/xmpp/extension/xep0065_socks/Socks5Module.java
index a2331bc..24ef2de 100644
---
a/server/extensions/xep0065-socks/src/main/java/org/apache/vysper/xmpp/extension/xep0065_socks/Socks5Module.java
+++
b/server/extensions/xep0065-socks/src/main/java/org/apache/vysper/xmpp/extension/xep0065_socks/Socks5Module.java
@@ -22,6 +22,7 @@ package org.apache.vysper.xmpp.extension.xep0065_socks;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.Validate;
@@ -37,8 +38,10 @@ import
org.apache.vysper.xmpp.modules.servicediscovery.management.InfoRequest;
import org.apache.vysper.xmpp.modules.servicediscovery.management.Item;
import
org.apache.vysper.xmpp.modules.servicediscovery.management.ItemRequestListener;
import
org.apache.vysper.xmpp.modules.servicediscovery.management.ServiceDiscoveryRequestException;
+import org.apache.vysper.xmpp.protocol.NamespaceHandlerDictionary;
import org.apache.vysper.xmpp.protocol.NamespaceURIs;
import org.apache.vysper.xmpp.protocol.StanzaBroker;
+import org.apache.vysper.xmpp.protocol.StanzaHandler;
import org.apache.vysper.xmpp.protocol.StanzaProcessor;
import org.apache.vysper.xmpp.server.ServerRuntimeContext;
import org.apache.vysper.xmpp.server.components.Component;
@@ -67,8 +70,6 @@ public class Socks5Module extends DefaultDiscoAwareModule
implements Component,
private InetSocketAddress proxyAddress = new
InetSocketAddress(DEFAULT_PORT);
private int idleTimeInSeconds = DEFAULT_IDLE_TIME;
- private ComponentStanzaProcessor stanzaProcessor;
-
private Socks5ConnectionsRegistry connectionsRegistry = new
DefaultSocks5ConnectionsRegistry();
/*
@@ -122,9 +123,6 @@ public class Socks5Module extends DefaultDiscoAwareModule
implements Component,
fullDomain = EntityUtils.createComponentDomain(subdomain,
serverRuntimeContext);
- stanzaProcessor =
serverRuntimeContext.createComponentStanzaProcessor();
- stanzaProcessor.addHandler(new Socks5IqHandler(fullDomain,
proxyAddress, connectionsRegistry));
-
try {
startProxy();
} catch (Exception e) {
@@ -165,17 +163,20 @@ public class Socks5Module extends DefaultDiscoAwareModule
implements Component,
/**
* {@inheritDoc}
*/
- public StanzaProcessor getStanzaProcessor() {
- return stanzaProcessor;
- }
-
- /**
- * {@inheritDoc}
- */
public String getSubdomain() {
return subdomain;
}
+ @Override
+ public List<StanzaHandler> getComponentHandlers(Entity fullDomain) {
+ return Collections.singletonList(new Socks5IqHandler(fullDomain,
proxyAddress, connectionsRegistry));
+ }
+
+ @Override
+ public List<NamespaceHandlerDictionary>
getComponentHandlerDictionnaries(Entity fullDomain) {
+ return Collections.emptyList();
+ }
+
/**
* {@inheritDoc}
*/
@@ -208,10 +209,6 @@ public class Socks5Module extends DefaultDiscoAwareModule
implements Component,
return COMPONENT_INFO;
}
- public Socks5ConnectionsRegistry getConnectionsRegistry() {
- return connectionsRegistry;
- }
-
public void setConnectionsRegistry(Socks5ConnectionsRegistry
connectionsRegistry) {
this.connectionsRegistry = connectionsRegistry;
}
diff --git
a/server/extensions/xep0065-socks/src/test/java/org/apache/vysper/xmpp/extension/xep0065_socks/Socks5ModuleTest.java
b/server/extensions/xep0065-socks/src/test/java/org/apache/vysper/xmpp/extension/xep0065_socks/Socks5ModuleTest.java
index f01d701..59df298 100644
---
a/server/extensions/xep0065-socks/src/test/java/org/apache/vysper/xmpp/extension/xep0065_socks/Socks5ModuleTest.java
+++
b/server/extensions/xep0065-socks/src/test/java/org/apache/vysper/xmpp/extension/xep0065_socks/Socks5ModuleTest.java
@@ -67,8 +67,6 @@ public class Socks5ModuleTest extends Mockito {
@Before
public void before() {
when(serverRuntimeContext.getServerEntity()).thenReturn(SERVER);
- ComponentStanzaProcessor componentStanzaProcessor =
mock(ComponentStanzaProcessor.class);
-
when(serverRuntimeContext.createComponentStanzaProcessor()).thenReturn(componentStanzaProcessor);
module.setConnectionsRegistry(connectionsRegistry);
}
@@ -104,13 +102,6 @@ public class Socks5ModuleTest extends Mockito {
}
@Test
- public void getStanzaProcessor() throws Exception {
- module = new Socks5Module("socks");
- module.initialize(serverRuntimeContext);
- Assert.assertTrue(module.getStanzaProcessor() instanceof
ComponentStanzaProcessor);
- }
-
- @Test
public void discoItems() throws Exception {
ServiceCollector collector = new ServiceCollector();