当前位置: 首页>>代码示例>>Java>>正文


Java Component.initialize方法代码示例

本文整理汇总了Java中org.xmpp.component.Component.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java Component.initialize方法的具体用法?Java Component.initialize怎么用?Java Component.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xmpp.component.Component的用法示例。


在下文中一共展示了Component.initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addComponent

import org.xmpp.component.Component; //导入方法依赖的package包/类
@Override
public void addComponent(String subdomain, Component component) throws ComponentException {
    synchronized (routables) {
        RoutableComponents routable = routables.get(subdomain);
        if (routable != null && routable.hasComponent(component)) {
            // This component has already registered with this subdomain.
            // TODO: Is this all we should do?  Should we return an error?
            return;
        }
        Log.debug("InternalComponentManager: Registering component for domain: " + subdomain);
        JID componentJID = new JID(subdomain + "." + serverDomain);
        boolean notifyListeners = false;
        if (routable != null) {
            routable.addComponent(component);
        }
        else {
            routable = new RoutableComponents(componentJID, component);
            routables.put(subdomain, routable);

            if (!routingTable.hasComponentRoute(componentJID)) {
                notifyListeners = true;
            }
            // Add the route to the new service provided by the component
            routingTable.addComponentRoute(componentJID, routable);
        }

        // Initialize the new component
        try {
            component.initialize(componentJID, this);
            component.start();

            if (notifyListeners) {
                // Notify listeners that a new component has been registered
                notifyComponentRegistered(componentJID);
                // Alert other nodes of new registered domain event
                CacheFactory.doClusterTask(new NotifyComponentRegistered(componentJID));
            }

            // Check for potential interested users.
            checkPresences();
            // Send a disco#info request to the new component. If the component provides information
            // then it will be added to the list of discoverable server items.
            checkDiscoSupport(component, componentJID);
            Log.debug("InternalComponentManager: Component registered for domain: " + subdomain);
        }
        catch (Exception e) {
            // Unregister the component's domain
            routable.removeComponent(component);
            if (e instanceof ComponentException) {
                // Rethrow the exception
                throw (ComponentException)e;
            }
            // Rethrow the exception
            throw new ComponentException(e);
        }
        finally {
            if (routable.numberOfComponents() == 0) {
                // If there are no more components associated with this subdomain, remove it.
                routables.remove(subdomain);
                // Remove the route
                XMPPServer.getInstance().getRoutingTable().removeComponentRoute(componentJID);
            }
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:66,代码来源:InternalComponentManager.java

示例2: addComponent

import org.xmpp.component.Component; //导入方法依赖的package包/类
public void addComponent(String subdomain, Component component) throws ComponentException {
    synchronized (routables) {
        RoutableComponents routable = routables.get(subdomain);
        if (routable != null && routable.hasComponent(component)) {
            // This component has already registered with this subdomain.
            // TODO: Is this all we should do?  Should we return an error?
            return;
        }
        Log.debug("InternalComponentManager: Registering component for domain: " + subdomain);
        JID componentJID = new JID(subdomain + "." + serverDomain);
        boolean notifyListeners = false;
        if (routable != null) {
            routable.addComponent(component);
        }
        else {
            routable = new RoutableComponents(componentJID, component);
            routables.put(subdomain, routable);

            if (!routingTable.hasComponentRoute(componentJID)) {
                notifyListeners = true;
            }
            // Add the route to the new service provided by the component
            routingTable.addComponentRoute(componentJID, routable);
        }

        // Initialize the new component
        try {
            component.initialize(componentJID, this);
            component.start();

            if (notifyListeners) {
                // Notify listeners that a new component has been registered
                notifyComponentRegistered(componentJID);
                // Alert other nodes of new registered domain event
                CacheFactory.doClusterTask(new NotifyComponentRegistered(componentJID));
            }

            // Check for potential interested users.
            checkPresences();
            // Send a disco#info request to the new component. If the component provides information
            // then it will be added to the list of discoverable server items.
            checkDiscoSupport(component, componentJID);
            Log.debug("InternalComponentManager: Component registered for domain: " + subdomain);
        }
        catch (Exception e) {
            // Unregister the component's domain
            routable.removeComponent(component);
            if (e instanceof ComponentException) {
                // Rethrow the exception
                throw (ComponentException)e;
            }
            // Rethrow the exception
            throw new ComponentException(e);
        }
        finally {
            if (routable.numberOfComponents() == 0) {
                // If there are no more components associated with this subdomain, remove it.
                routables.remove(subdomain);
                // Remove the route
                XMPPServer.getInstance().getRoutingTable().removeComponentRoute(componentJID);
            }
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:65,代码来源:InternalComponentManager.java


注:本文中的org.xmpp.component.Component.initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。