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 66bf8b7 Allow to override ServerRuntimeContext creation in XMPPServer (#7) 66bf8b7 is described below commit 66bf8b7ec8659e99721ff5b47f615d053cc4f5b5 Author: Réda Housni Alaoui <rala...@apache.org> AuthorDate: Sat Aug 17 09:15:24 2019 +0200 Allow to override ServerRuntimeContext creation in XMPPServer (#7) --- .../vysper/xmpp/server/ServerRuntimeContext.java | 2 ++ .../org/apache/vysper/xmpp/server/XMPPServer.java | 24 ++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) 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 0a869f4..0972ab4 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 @@ -81,4 +81,6 @@ public interface ServerRuntimeContext { List<Module> getModules(); <T> T getModule(Class<T> clazz); + + void addModule(Module module); } 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 01baafb..f22f66b 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 @@ -34,8 +34,8 @@ import org.apache.vysper.xmpp.addressing.EntityImpl; import org.apache.vysper.xmpp.authentication.AccountManagement; import org.apache.vysper.xmpp.authentication.Plain; import org.apache.vysper.xmpp.authentication.SASLMechanism; -import org.apache.vysper.xmpp.cryptography.NonCheckingX509TrustManagerFactory; import org.apache.vysper.xmpp.cryptography.InputStreamBasedTLSContextFactory; +import org.apache.vysper.xmpp.cryptography.NonCheckingX509TrustManagerFactory; import org.apache.vysper.xmpp.cryptography.TrustManagerFactory; import org.apache.vysper.xmpp.delivery.OfflineStanzaReceiver; import org.apache.vysper.xmpp.delivery.StanzaRelayBroker; @@ -68,7 +68,7 @@ public class XMPPServer { private String serverDomain; - private DefaultServerRuntimeContext serverRuntimeContext; + private ServerRuntimeContext serverRuntimeContext; private StorageProviderRegistry storageProviderRegistry; @@ -187,12 +187,9 @@ public class XMPPServer { stanzaRelayBroker.setInternalRelay(internalStanzaRelay); stanzaRelayBroker.setExternalRelay(externalStanzaRelay); - serverRuntimeContext = new DefaultServerRuntimeContext(serverEntity, stanzaRelayBroker, serverFeatures, - dictionaries, resourceRegistry); - serverRuntimeContext.setStorageProviderRegistry(storageProviderRegistry); - serverRuntimeContext.setTlsContextFactory(tlsContextFactory); - - for(Module module : initialModules) { + serverRuntimeContext = createServerRuntimeContext(serverFeatures, tlsContextFactory, dictionaries, + resourceRegistry, serverEntity); + for (Module module : initialModules) { serverRuntimeContext.addModule(module); } @@ -211,6 +208,17 @@ public class XMPPServer { } } + protected ServerRuntimeContext createServerRuntimeContext(ServerFeatures serverFeatures, + InputStreamBasedTLSContextFactory tlsContextFactory, List<HandlerDictionary> dictionaries, + ResourceRegistry resourceRegistry, EntityImpl serverEntity) { + DefaultServerRuntimeContext serverRuntimeContext = new DefaultServerRuntimeContext(serverEntity, + stanzaRelayBroker, serverFeatures, dictionaries, resourceRegistry); + serverRuntimeContext.setStorageProviderRegistry(storageProviderRegistry); + serverRuntimeContext.setTlsContextFactory(tlsContextFactory); + + return serverRuntimeContext; + } + protected ServerFeatures createServerFeatures() { return new ServerFeatures(); }