本文整理汇总了Java中org.xmpp.component.Component类的典型用法代码示例。如果您正苦于以下问题:Java Component类的具体用法?Java Component怎么用?Java Component使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Component类属于org.xmpp.component包,在下文中一共展示了Component类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unloadComponent
import org.xmpp.component.Component; //导入依赖的package包/类
/**
* Unloads a component. The {@link ComponentManager#removeComponent(String)} method will be
* called and then any resources will be released. The name should be the name of the component
* directory and not the name as given by the component meta-data. This method only removes
* the component but does not delete the component JAR file. Therefore, if the component JAR
* still exists after this method is called, the component will be started again the next
* time the component monitor process runs. This is useful for "restarting" components.<p>
*
* This method is called automatically when a component's JAR file is deleted.
*
* @param componentName the name of the component to unload.
*/
public void unloadComponent(String componentName) {
manager.getLog().debug("Unloading component " + componentName);
Component component = components.get(componentName);
if (component == null) {
return;
}
File webXML = new File(componentDirectory + File.separator + componentName +
File.separator + "web" + File.separator + "web.xml");
if (webXML.exists()) {
//AdminConsole.removeModel(componentName);
ComponentServlet.unregisterServlets(webXML);
}
ComponentClassLoader classLoader = classloaders.get(component);
try {
manager.removeComponent(componentDomains.get(component));
} catch (ComponentException e) {
manager.getLog().error("Error shutting down component", e);
}
classLoader.destroy();
components.remove(componentName);
componentDirs.remove(component);
classloaders.remove(component);
componentDomains.remove(component);
}
示例2: getElementValue
import org.xmpp.component.Component; //导入依赖的package包/类
/**
* Returns the value of an element selected via an xpath expression from
* a component's component.xml file.
*
* @param component the component.
* @param xpath the xpath expression.
* @return the value of the element selected by the xpath expression.
*/
private String getElementValue(Component component, String xpath) {
File componentDir = componentDirs.get(component);
if (componentDir == null) {
return null;
}
try {
File componentConfig = new File(componentDir, "component.xml");
if (componentConfig.exists()) {
SAXReader saxReader = new SAXReader();
Document componentXML = saxReader.read(componentConfig);
Element element = (Element)componentXML.selectSingleNode(xpath);
if (element != null) {
return element.getTextTrim();
}
}
}
catch (Exception e) {
manager.getLog().error(e);
}
return null;
}
示例3: getComponents
import org.xmpp.component.Component; //导入依赖的package包/类
/**
* Retrieves the <code>Component</code> which is mapped to the specified JID. The
* look up will only be done on components that were registered with this JVM. That
* means that components registered in other cluster nodes are not going to be
* considered.
*
* @param componentJID the jid mapped to the component.
* @return the list of components with the specified id.
*/
private List<Component> getComponents(JID componentJID) {
synchronized (routables) {
if (componentJID.getNode() != null) {
return Collections.emptyList();
}
RoutableComponents routable = routables.get(componentJID.getDomain());
if (routable != null) {
return routable.getComponents();
}
else {
// Search again for those JIDs whose domain include the server name but this
// time remove the server name from the JID's domain
String serverName = componentJID.getDomain();
int index = serverName.lastIndexOf("." + serverDomain);
if (index > -1) {
routable = routables.get(serverName.substring(0, index));
if (routable != null) {
return routable.getComponents();
}
}
}
return Collections.emptyList();
}
}
示例4: addComponent
import org.xmpp.component.Component; //导入依赖的package包/类
public void addComponent(String subdomain, Component component, Integer port) throws ComponentException {
if (componentsByDomain.containsKey(subdomain)) {
if (componentsByDomain.get(subdomain).getComponent() == component) {
// Do nothing since the component has already been registered
return;
}
else {
throw new IllegalArgumentException("Subdomain already in use by another component");
}
}
// Create a wrapping ExternalComponent on the component
ExternalComponent externalComponent = new ExternalComponent(component, this);
try {
// Register the new component
componentsByDomain.put(subdomain, externalComponent);
components.put(component, externalComponent);
// Ask the ExternalComponent to connect with the remote server
externalComponent.connect(host, port, subdomain, startEncrypted);
// Initialize the component
JID componentJID = new JID(null, externalComponent.getDomain(), null);
externalComponent.initialize(componentJID, this);
}
catch (ComponentException e) {
// Unregister the new component
componentsByDomain.remove(subdomain);
components.remove(component);
// Re-throw the exception
throw e;
}
// Ask the external component to start processing incoming packets
externalComponent.start();
}
示例5: ComponentFinder
import org.xmpp.component.Component; //导入依赖的package包/类
/**
* Constructs a new component manager.
*
* @param componentDir the component directory.
*/
public ComponentFinder(ServerContainer server, File componentDir) {
this.componentDirectory = componentDir;
components = new HashMap<String,Component>();
componentDirs = new HashMap<Component,File>();
classloaders = new HashMap<Component,ComponentClassLoader>();
componentDomains = new HashMap<Component,String>();
manager = (ExternalComponentManager) server.getManager();
setupMode = server.isSetupMode();
}
示例6: getName
import org.xmpp.component.Component; //导入依赖的package包/类
/**
* Returns the name of a component. The value is retrieved from the component.xml file
* of the component. If the value could not be found, <tt>null</tt> will be returned.
* Note that this value is distinct from the name of the component directory.
*
* @param component the component.
* @return the component's name.
*/
public String getName(Component component) {
String name = getElementValue(component, "/component/name");
if (name != null) {
return name;
}
else {
return componentDirs.get(component).getName();
}
}
示例7: ExternalComponent
import org.xmpp.component.Component; //导入依赖的package包/类
public ExternalComponent(Component component, ExternalComponentManager manager, int maxThreads) {
this.component = component;
this.manager = manager;
// Create a pool of threads that will process requests received by this component. If more
// threads are required then the command will be executed on the SocketReadThread process
threadPool = new ThreadPoolExecutor(maxThreads, maxThreads, 15, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(), new ThreadPoolExecutor.CallerRunsPolicy());
}
示例8: removeComponent
import org.xmpp.component.Component; //导入依赖的package包/类
/**
* Removes a component. The {@link Component#shutdown} method will be called on the
* component. Note that if the component was an external component that was connected
* several times then all its connections will be terminated.
*
* @param subdomain the subdomain of the component's address.
*/
@Override
public void removeComponent(String subdomain) {
RoutableComponents components = null;
if (routables == null || (components = routables.get(subdomain)) == null) {
return;
}
List<Component> componentsToRemove = new ArrayList<>(components.getComponents());
for (Component component : componentsToRemove) {
removeComponent(subdomain, component);
}
}
示例9: sendPacket
import org.xmpp.component.Component; //导入依赖的package包/类
@Override
public void sendPacket(Component component, Packet packet) {
if (packet != null && packet.getFrom() == null) {
throw new IllegalArgumentException("Packet with no FROM address was received from component.");
}
PacketRouter router = XMPPServer.getInstance().getPacketRouter();
if (router != null) {
router.route(packet);
}
}
示例10: checkDiscoSupport
import org.xmpp.component.Component; //导入依赖的package包/类
/**
* 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.
*
* @param component the new component that was added to this manager.
* @param componentJID the XMPP address of the new component.
*/
private void checkDiscoSupport(Component component, JID componentJID) {
// Build a disco#info request that will be sent to the component
IQ iq = new IQ(IQ.Type.get);
iq.setFrom(getAddress());
iq.setTo(componentJID);
iq.setChildElement("query", "http://jabber.org/protocol/disco#info");
// Send the disco#info request to the component. The reply (if any) will be processed in
// #process(Packet)
// sendPacket(component, iq);
component.processPacket(iq);
}
示例11: getNextComponent
import org.xmpp.component.Component; //导入依赖的package包/类
private Component getNextComponent() {
Component component;
synchronized (components) {
component = components.get(0);
Collections.rotate(components, 1);
}
return component;
}
示例12: removeComponent
import org.xmpp.component.Component; //导入依赖的package包/类
/**
* Removes a given component. Unlike {@link #removeComponent(String)} this method will just
* remove a single component instead of all components associated to the subdomain. External
* components may connect several times and register for the same subdomain. This method
* just removes a singled connection not all of them.
*
* @param subdomain the subdomain of the component's address.
* @param component specific component to remove.
*/
public void removeComponent(String subdomain, Component component) {
if (component == null) {
return;
}
synchronized (routables) {
Log.debug("InternalComponentManager: Unregistering component for domain: " + subdomain);
RoutableComponents routable = routables.get(subdomain);
routable.removeComponent(component);
if (routable.numberOfComponents() == 0) {
routables.remove(subdomain);
JID componentJID = new JID(subdomain + "." + serverDomain);
// Remove the route for the service provided by the component
routingTable.removeComponentRoute(componentJID);
// Ask the component to shutdown
component.shutdown();
if (!routingTable.hasComponentRoute(componentJID)) {
// Remove the disco item from the server for the component that is being removed
IQDiscoItemsHandler iqDiscoItemsHandler = XMPPServer.getInstance().getIQDiscoItemsHandler();
if (iqDiscoItemsHandler != null) {
iqDiscoItemsHandler.removeComponentItem(componentJID.toBareJID());
}
removeComponentInfo(componentJID);
// Notify listeners that an existing component has been unregistered
notifyComponentUnregistered(componentJID);
// Alert other nodes of component removed event
CacheFactory.doClusterTask(new NotifyComponentUnregistered(componentJID));
}
Log.debug("InternalComponentManager: Component unregistered for domain: " + subdomain);
}
else {
Log.debug("InternalComponentManager: Other components still tied to domain: " + subdomain);
}
}
}
示例13: sendPacket
import org.xmpp.component.Component; //导入依赖的package包/类
public void sendPacket(Component component, Packet packet) {
if (packet != null && packet.getFrom() == null) {
throw new IllegalArgumentException("Packet with no FROM address was received from component.");
}
PacketRouter router = XMPPServer.getInstance().getPacketRouter();
if (router != null) {
router.route(packet);
}
}
示例14: addComponent
import org.xmpp.component.Component; //导入依赖的package包/类
public void addComponent(String subdomain, Component component, Integer port)
throws ComponentException {
if (componentsByDomain.containsKey(subdomain)) {
if (componentsByDomain.get(subdomain).getComponent() == component) {
// Do nothing since the component has already been registered
return;
} else {
throw new IllegalArgumentException(
"Subdomain already in use by another component");
}
}
// Create a wrapping ExternalComponent on the component
ExternalComponent externalComponent = new ExternalComponent(component,
this);
try {
// Register the new component
componentsByDomain.put(subdomain, externalComponent);
components.put(component, externalComponent);
// Ask the ExternalComponent to connect with the remote server
externalComponent.connect(host, port, subdomain);
// Initialize the component
JID componentJID = new JID(null, externalComponent.getDomain(),
null);
externalComponent.initialize(componentJID, this);
} catch (ComponentException e) {
// Unregister the new component
componentsByDomain.remove(subdomain);
components.remove(component);
// Re-throw the exception
throw e;
}
// Ask the external component to start processing incoming packets
externalComponent.start();
}
示例15: query
import org.xmpp.component.Component; //导入依赖的package包/类
public void query(Component component, IQ packet, IQResultListener listener)
throws ComponentException {
ExternalComponent externalComponent = components.get(component);
// Add listenet with a timeout of 5 minutes to prevent memory leaks
externalComponent.addIQResultListener(packet.getID(), listener, 300000);
sendPacket(component, packet);
}