首页 > 代码库 > OPENFIRE 启动流程
OPENFIRE 启动流程
在java>org>jivesoftware>openfire>starter,该类中的main方法启动,有图为证:
在start中方法分别调用unpackArchives和findParentClassLoader方法,确定openfire目录,并解压相关jia包,并创建一个org.jivesoftware.openfire.XMPPServer类的实例,有图为证:
在XMPPServer类中,依次执行start>initialize>locateOpenfire加载相关的配置文件,初始化缓存工厂设置相关的缓存大小,然后接着保存设置,在start方法中有一句判断: if (!setupMode) ,这里的setupMode是从openfire文件夹下的config文件夹下面的openfire.xml配置文件获取,有图为证:
如果想重置openfire或者设置数据库连接把setup设置为false就可以重新配置openfire了;如果已经设置为true了,则会执行verifyDataSource进行数据库验证,loadModules加载模块,initModules初始化模块,startModules启动模块,启动插件管理器 pluginManager.start();最后设置监听。
1 private void loadModules() { 2 // Load boot modules 3 loadModule(RoutingTableImpl.class.getName()); 4 loadModule(AuditManagerImpl.class.getName()); 5 loadModule(RosterManager.class.getName()); 6 loadModule(PrivateStorage.class.getName()); 7 // Load core modules 8 loadModule(PresenceManagerImpl.class.getName()); 9 loadModule(SessionManager.class.getName());10 loadModule(PacketRouterImpl.class.getName());11 loadModule(IQRouter.class.getName());12 loadModule(MessageRouter.class.getName());13 loadModule(PresenceRouter.class.getName());14 loadModule(MulticastRouter.class.getName());15 loadModule(PacketTransporterImpl.class.getName());16 loadModule(PacketDelivererImpl.class.getName());17 loadModule(TransportHandler.class.getName());18 loadModule(OfflineMessageStrategy.class.getName());19 loadModule(OfflineMessageStore.class.getName());20 loadModule(VCardManager.class.getName());21 // Load standard modules22 loadModule(IQBindHandler.class.getName());23 loadModule(IQSessionEstablishmentHandler.class.getName());24 loadModule(IQAuthHandler.class.getName());25 loadModule(IQPingHandler.class.getName());26 loadModule(IQPrivateHandler.class.getName());27 loadModule(IQRegisterHandler.class.getName());28 loadModule(IQRosterHandler.class.getName());29 loadModule(IQTimeHandler.class.getName());30 loadModule(IQEntityTimeHandler.class.getName());31 loadModule(IQvCardHandler.class.getName());32 loadModule(IQVersionHandler.class.getName());33 loadModule(IQLastActivityHandler.class.getName());34 loadModule(PresenceSubscribeHandler.class.getName());35 loadModule(PresenceUpdateHandler.class.getName());36 loadModule(IQOfflineMessagesHandler.class.getName());37 loadModule(IQPEPHandler.class.getName());38 loadModule(IQPEPOwnerHandler.class.getName());39 loadModule(MulticastDNSService.class.getName());40 loadModule(IQSharedGroupHandler.class.getName());41 loadModule(AdHocCommandHandler.class.getName());42 loadModule(IQPrivacyHandler.class.getName());43 loadModule(DefaultFileTransferManager.class.getName());44 loadModule(FileTransferProxy.class.getName());45 loadModule(MediaProxyService.class.getName());46 loadModule(PubSubModule.class.getName());47 loadModule(IQDiscoInfoHandler.class.getName());48 loadModule(IQDiscoItemsHandler.class.getName());49 loadModule(UpdateManager.class.getName());50 loadModule(FlashCrossDomainHandler.class.getName());51 loadModule(InternalComponentManager.class.getName());52 loadModule(MultiUserChatManager.class.getName());53 loadModule(ClearspaceManager.class.getName());54 loadModule(IQMessageCarbonsHandler.class.getName());55 56 // Load this module always last since we don‘t want to start listening for clients57 // before the rest of the modules have been started58 loadModule(ConnectionManagerImpl.class.getName());59 // Keep a reference to the internal component manager60 componentManager = getComponentManager();61 }
在启动加载模块的过程中会依次加载这些模块。这些模块全部直接继承或间接继承BasicModule类,BasicModule类继承Module接口,Module接口定义五个方法,有图为证:
执行完loadModules这个方法之后所有的模块都保存在 private Map<Class, Module> modules = new LinkedHashMap<Class, Module>(); 这个LinkedHashMap中,执行startModules()时回按顺序执行LinkedHashMap中键值的start方法.
public class RoutingTableImpl extends BasicModule implements RoutingTable, ClusterEventListener
public class AuditManagerImpl extends BasicModule implements AuditManager
public class RosterManager extends BasicModule implements GroupEventListener, UserEventListener
public class PrivateStorage extends BasicModule implements UserEventListener
public class PresenceManagerImpl extends BasicModule implements PresenceManager, UserEventListener, XMPPServerListener
public class SessionManager extends BasicModule implements ClusterEventListener
public class PacketRouterImpl extends BasicModule implements PacketRouter
public class IQRouter extends BasicModule
public class MessageRouter extends BasicModule
public class PresenceRouter extends BasicModule
public class MulticastRouter extends BasicModule implements ServerFeaturesProvider, IQResultListener
public class PacketTransporterImpl extends BasicModule
public class PacketDelivererImpl extends BasicModule implements PacketDeliverer
public class TransportHandler extends BasicModule implements ChannelHandler
public class OfflineMessageStrategy extends BasicModule
public class OfflineMessageStore extends BasicModule implements UserEventListener
public class VCardManager extends BasicModule implements ServerFeaturesProvider
public class IQBindHandler extends IQHandler
public class IQSessionEstablishmentHandler extends IQHandler
public class IQAuthHandler extends IQHandler implements IQAuthInfo
public class IQPingHandler extends IQHandler implements ServerFeaturesProvider
public class IQPrivateHandler extends IQHandler implements ServerFeaturesProvider
public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvider
public class IQRosterHandler extends IQHandler implements ServerFeaturesProvider
public class IQTimeHandler extends IQHandler implements ServerFeaturesProvider
public final class IQEntityTimeHandler extends IQHandler implements ServerFeaturesProvider
public class IQvCardHandler extends IQHandler
public class IQVersionHandler extends IQHandler implements ServerFeaturesProvider
public class IQLastActivityHandler extends IQHandler implements ServerFeaturesProvider
public class PresenceSubscribeHandler extends BasicModule implements ChannelHandler<Presence>
public class PresenceUpdateHandler extends BasicModule implements ChannelHandler, ClusterEventListener
public class IQOfflineMessagesHandler extends IQHandler implements ServerFeaturesProvider, DiscoInfoProvider, DiscoItemsProvider
public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ServerFeaturesProvider, UserIdentitiesProvider, UserItemsProvider, PresenceEventListener, RosterEventListener, UserEventListener
public class IQPEPOwnerHandler extends IQHandler
public class MulticastDNSService extends BasicModule
public class IQSharedGroupHandler extends IQHandler
public class AdHocCommandHandler extends IQHandler implements ServerFeaturesProvider, DiscoInfoProvider, DiscoItemsProvider
public class IQPrivacyHandler extends IQHandler implements ServerFeaturesProvider, UserEventListener
public class DefaultFileTransferManager extends BasicModule implements FileTransferManager
public class FileTransferProxy extends BasicModule implements ServerItemsProvider, DiscoInfoProvider, DiscoItemsProvider, RoutableChannelHandler
public class MediaProxyService extends BasicModule implements ServerItemsProvider, RoutableChannelHandler, DiscoInfoProvider, DiscoItemsProvider
public class PubSubModule extends BasicModule implements ServerItemsProvider, DiscoInfoProvider, DiscoItemsProvider, RoutableChannelHandler, PubSubService, PropertyEventListener
public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListener
public class IQDiscoItemsHandler extends IQHandler implements ServerFeaturesProvider, ClusterEventListener, UserItemsProvider
public class UpdateManager extends BasicModule
public class FlashCrossDomainHandler extends BasicModule
public class InternalComponentManager extends BasicModule implements ComponentManager, RoutableChannelHandler
public class MultiUserChatManager extends BasicModule implements ClusterEventListener, MUCServicePropertyEventListener, UserEventListener
public class ClearspaceManager extends BasicModule implements ExternalComponentManagerListener, ComponentEventListener, PropertyEventListener, CertificateEventListener
public final class IQMessageCarbonsHandler extends IQHandler implements ServerFeaturesProvider
public class ConnectionManagerImpl extends BasicModule implements ConnectionManager, CertificateEventListener
先做个记录吧。
OPENFIRE 启动流程