private void initModules() {
        for (Module module : modules.values()) {
            try {
                module.initialize(this);
            }
            catch (Exception e) {
                e.printStackTrace();
                // Remove the failed initialized module
                this.modules.remove(module.getClass());
                module.stop();
                module.destroy();
                logger.error(LocaleUtils.getLocalizedString("admin.error"), e);
            }
        }

        // Register modules with service discovery provides where applicable.
        for (Module module : modules.values() )
        {
            // Service discovery info
            if (module instanceof ServerFeaturesProvider) {
                getIQDiscoInfoHandler().addServerFeaturesProvider( (ServerFeaturesProvider) module );
            }

            if (module instanceof ServerIdentitiesProvider) {
                getIQDiscoInfoHandler().addServerIdentitiesProvider( (ServerIdentitiesProvider) module );
            }

            if (module instanceof UserIdentitiesProvider) {
                getIQDiscoInfoHandler().addUserIdentitiesProvider( (UserIdentitiesProvider) module );
            }

            if (module instanceof UserFeaturesProvider ) {
                getIQDiscoInfoHandler().addUserFeaturesProvider( (UserFeaturesProvider) module );
            }

            // Service discovery items
            if (module instanceof ServerItemsProvider) {
                getIQDiscoItemsHandler().addServerItemsProvider( (ServerItemsProvider) module );
            }

            if (module instanceof UserItemsProvider) {
                getIQDiscoItemsHandler().addUserItemsProvider( (UserItemsProvider) module);
            }
        }

    }
Loads a module.

@param module the name of the class that implements the Module interface.
xmppserver/src/main/java/org/jivesoftware/openfire/XMPPServer.java