org.xmpp.component
Interface ComponentManager


public interface ComponentManager

Manages components.

Author:
Matt Tucker
See Also:
Component

Method Summary
 void addComponent(java.lang.String subdomain, Component component)
          Adds a component.
 java.lang.String getProperty(java.lang.String name)
          Returns a property value specified by name.
 java.lang.String getServerName()
          Returns the domain of the XMPP server.
 boolean isExternalMode()
          Returns true if components managed by this component manager are external components connected to the server over a network connection.
 void query(Component component, IQ packet, IQResultListener listener)
          Sends an IQ packet to the server and returns immediately.
 IQ query(Component component, IQ packet, long timeout)
          Sends an IQ packet to the XMPP server and waits to get an IQ of type result or error.
 void removeComponent(java.lang.String subdomain)
          Removes a component.
 void sendPacket(Component component, Packet packet)
          Sends a packet to the XMPP server.
 void setProperty(java.lang.String name, java.lang.String value)
          Sets a property value.
 

Method Detail

addComponent

void addComponent(java.lang.String subdomain,
                  Component component)
                  throws ComponentException
Adds a component. The Component.initialize(org.xmpp.packet.JID, ComponentManager) method will be called on the component. The subdomain specifies the address of the component on a server. For example, if the subdomain is "test" and the XMPP server is at "example.com", then the component's address would be "test.example.com".

Parameters:
subdomain - the subdomain of the component's address.
component - the component.
Throws:
ComponentException - if the component connection is lost and the component cannot be added.

removeComponent

void removeComponent(java.lang.String subdomain)
                     throws ComponentException
Removes a component. The Component.shutdown() method will be called on the component.

Parameters:
subdomain - the subdomain of the component's address.
Throws:
ComponentException - if the component connection is lost and the component cannot be removed.

sendPacket

void sendPacket(Component component,
                Packet packet)
                throws ComponentException
Sends a packet to the XMPP server. The "from" value of the packet must not be null. An IllegalArgumentException will be thrown when the "from" value is null.

Components are trusted by the server and may use any value in from address. Usually the from address uses the component's address as the domain but this is not required.

Parameters:
component - the component sending the packet.
packet - the packet to send.
Throws:
ComponentException - if the component connection is lost or unavialble during the time of sending and recieving packets.

query

IQ query(Component component,
         IQ packet,
         long timeout)
         throws ComponentException
Sends an IQ packet to the XMPP server and waits to get an IQ of type result or error. The "from" value of the packet must not be null. An IllegalArgumentException will be thrown when the "from" value is null.

If no answer is received from the server before the specified timeout then null will be returned. Components are trusted by the server and may use any value in from address. Usually the from address uses the component's address as the domain but this is not required.

Parameters:
component - the component sending the packet.
packet - the IQ packet to send.
timeout - the number of milliseconds to wait before returning an IQ error.
Returns:
the answer sent by the server. The answer could be an IQ of type result or error. null will be returned if there is no response from the server.
Throws:
ComponentException - if the component connection is lost or unavialble during the time of sending and recieving packets.

query

void query(Component component,
           IQ packet,
           IQResultListener listener)
           throws ComponentException
Sends an IQ packet to the server and returns immediately. The specified IQResultListener will be invoked when an answer is received.

Parameters:
component - the component sending the packet.
packet - the IQ packet to send.
listener - the listener that will be invoked when an answer is received.
Throws:
ComponentException - if the component connection is lost or unavialble during the time of sending and recieving packets.

getProperty

java.lang.String getProperty(java.lang.String name)
Returns a property value specified by name. Properties can be used by components to store configuration data. It is recommended that each component qualify property names to prevent overlap. For example a component that broadcasts messages to groups of users, might prepend all property names it uses with "broadcast.".

Parameters:
name - the property name.
Returns:
the property value.

setProperty

void setProperty(java.lang.String name,
                 java.lang.String value)
Sets a property value. Properties can be used by components to store configuration data. It is recommended that each component qualify property names to prevent overlap. For example a component that broadcasts messages to groups of users, might prepend all property names it uses with "broadcast.".

Parameters:
name - the property name.
value - the property value.

getServerName

java.lang.String getServerName()
Returns the domain of the XMPP server. The domain name may be the IP address or the host name.

Returns:
the domain of the XMPP server.

isExternalMode

boolean isExternalMode()
Returns true if components managed by this component manager are external components connected to the server over a network connection. Otherwise, the components are internal to the server.

Returns:
true if the managed components are external components.


Copyright © 2009-2010 Ignite Realtime. All Rights Reserved.