public void start()

in server/core/src/main/java/org/apache/vysper/xmpp/server/XMPPServer.java [158:239]


    public void start() throws Exception {

        ServerFeatures serverFeatures = createServerFeatures();
        serverFeatures.setAuthenticationMethods(saslMechanisms);

        TrustManagerFactory trustManagerFactory = null; // default, check certificates strictly
        if (!serverFeatures.isCheckingFederationServerCertificates()) {
            // switch to accepting *any* certificate
            trustManagerFactory = new NonCheckingX509TrustManagerFactory();
        }

        if (StringUtils.isNotEmpty(tlsCertificatePassword) && tlsCertificate == null) {
            throw new IllegalStateException("no TLS certificate loaded for the configured password");
        }
        InputStreamBasedTLSContextFactory tlsContextFactory = new InputStreamBasedTLSContextFactory(tlsCertificate);
        tlsContextFactory.setPassword(tlsCertificatePassword);
        tlsContextFactory.setTrustManagerFactory(trustManagerFactory);
        if (tlsKeyStoreType != null) {
            tlsContextFactory.setKeyStoreType(tlsKeyStoreType);
        }

        List<HandlerDictionary> dictionaries = new ArrayList<>();
        addCoreDictionaries(dictionaries);

        InternalResourceRegistry resourceRegistry = new DefaultResourceRegistry();

        EntityImpl serverEntity = new EntityImpl(null, serverDomain, null);

        AccountManagement accountManagement = storageProviderRegistry.retrieve(AccountManagement.class);
        OfflineStanzaReceiver offlineReceiver = storageProviderRegistry.retrieve(OfflineStorageProvider.class);

        AlterableComponentRegistry componentRegistry = new SimpleComponentRegistry(serverEntity);

        DeliveringInternalInboundStanzaRelay internalStanzaRelay = new DeliveringInternalInboundStanzaRelay(
                serverEntity, resourceRegistry, componentRegistry, accountManagement);
        DeliveringExternalInboundStanzaRelay externalStanzaRelay = new DeliveringExternalInboundStanzaRelay();

        if (maxInternalRelayThreads >= 0)
            internalStanzaRelay.setMaxThreadCount(maxInternalRelayThreads);
        if (maxExternalRelayThreads >= 0)
            externalStanzaRelay.setMaxThreadCount(maxExternalRelayThreads);

        stanzaRelayBroker = new StanzaRelayBroker();
        stanzaRelayBroker.setInternalRelay(internalStanzaRelay);
        stanzaRelayBroker.setExternalRelay(externalStanzaRelay);

        StanzaHandlerExecutorFactory stanzaHandlerExecutorFactory = new SimpleStanzaHandlerExecutorFactory(
                stanzaRelayBroker, offlineReceiver);

        stanzaProcessor = new ProtocolWorker(stanzaHandlerExecutorFactory);

        serverRuntimeContext = new DefaultServerRuntimeContext(serverEntity, stanzaRelayBroker, stanzaProcessor,
                componentRegistry, resourceRegistry, serverFeatures, dictionaries, offlineReceiver);
        serverRuntimeContext.setStorageProviderRegistry(storageProviderRegistry);
        serverRuntimeContext.setTlsContextFactory(tlsContextFactory);

        for (Module module : initialModules) {
            serverRuntimeContext.addModule(module);
        }

        stanzaRelayBroker.setServerRuntimeContext(serverRuntimeContext);
        internalStanzaRelay.setServerRuntimeContext(serverRuntimeContext);
        internalStanzaRelay.setStanzaHandlerExecutorFactory(stanzaHandlerExecutorFactory);
        externalStanzaRelay.setServerRuntimeContext(serverRuntimeContext);

        final LogStorageProvider logStorageProvider = this.storageProviderRegistry.retrieve(LogStorageProvider.class);
        if (logStorageProvider != null)
            internalStanzaRelay.setLogStorageProvider(logStorageProvider);

        if (endpoints.isEmpty())
            throw new IllegalStateException("server must have at least one endpoint");

        /*
         * 'input stream': receives stanzas issued by client sessions to be handled by
         * the server
         */
        for (Endpoint endpoint : endpoints) {
            endpoint.setServerRuntimeContext(serverRuntimeContext);
            endpoint.setStanzaProcessor(stanzaProcessor);
            endpoint.start();
        }
    }