Wildfire 3.1.1 Javadoc

org.jivesoftware.wildfire.component
Class InternalComponentManager

java.lang.Object
  extended by org.jivesoftware.wildfire.component.InternalComponentManager
All Implemented Interfaces:
ChannelHandler, RoutableChannelHandler, ComponentManager

public class InternalComponentManager
extends Object
implements ComponentManager, RoutableChannelHandler

Manages the registration and delegation of Components. The ComponentManager is responsible for managing registration and delegation of Components, as well as offering a facade around basic server functionallity such as sending and receiving of packets.

This component manager will be an internal service whose JID will be component.[domain]. So the component manager will be able to send packets to other internal or external components and also receive packets from other components or even from trusted clients (e.g. ad-hoc commands).

Author:
Derek DeMoro

Nested Class Summary
static class InternalComponentManager.RoutableComponent
          Exposes a Component as a RoutableChannelHandler.
 
Constructor Summary
InternalComponentManager()
           
 
Method Summary
 void addComponent(String subdomain, Component component)
          Adds a component.
 void addListener(ComponentEventListener listener)
          Adds a new listener that will be notified of component events.
 void addPresenceRequest(JID prober, JID probee)
          Registers Probeers who have not yet been serviced.
 JID getAddress()
          Returns the XMPP address.
 Component getComponent(JID componentJID)
          Retrieves the Component which is mapped to the specified JID.
 Component getComponent(String jid)
          Retrieves the Component which is mapped to the specified JID.
 Collection<Component> getComponents()
          Returns the list of components that are currently installed in the server.
 String getHomeDirectory()
           
static InternalComponentManager getInstance()
           
 Log getLog()
          Returns a Log instance, which can be used by components for logging error, warning, info, and debug messages.
 String getProperty(String name)
          Returns a property value specified by name.
 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 process(Packet packet)
          Processes packets that were sent to this service.
 void removeComponent(String subdomain)
          Removes a component.
 void removeListener(ComponentEventListener listener)
          Removes the specified listener from the listeners being notified of component events.
 void sendPacket(Component component, Packet packet)
          Sends a packet to the XMPP server.
 void setProperty(String name, String value)
          Sets a property value.
 void start()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InternalComponentManager

public InternalComponentManager()
Method Detail

getInstance

public static InternalComponentManager getInstance()

start

public void start()

addComponent

public void addComponent(String subdomain,
                         Component component)
                  throws ComponentException
Description copied from interface: ComponentManager
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".

Specified by:
addComponent in interface ComponentManager
Parameters:
subdomain - the subdomain of the component's address.
component - the component.
Throws:
ComponentException

removeComponent

public void removeComponent(String subdomain)
Description copied from interface: ComponentManager
Removes a component. The Component.shutdown() method will be called on the component.

Specified by:
removeComponent in interface ComponentManager
Parameters:
subdomain - the subdomain of the component's address.

sendPacket

public void sendPacket(Component component,
                       Packet packet)
Description copied from interface: ComponentManager
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.

Specified by:
sendPacket in interface ComponentManager
Parameters:
component - the component sending the packet.
packet - the packet to send.

addListener

public void addListener(ComponentEventListener listener)
Adds a new listener that will be notified of component events. Events being notified are: 1) when a component is added to the component manager, 2) when a component is deleted and 3) when disco#info is received from a component.

Parameters:
listener - the new listener to notify of component events.

removeListener

public void removeListener(ComponentEventListener listener)
Removes the specified listener from the listeners being notified of component events.

Parameters:
listener - the listener to remove.

getProperty

public String getProperty(String name)
Description copied from interface: ComponentManager
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.".

Specified by:
getProperty in interface ComponentManager
Parameters:
name - the property name.
Returns:
the property value.

setProperty

public void setProperty(String name,
                        String value)
Description copied from interface: ComponentManager
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.".

Specified by:
setProperty in interface ComponentManager
Parameters:
name - the property name.
value - the property value.

getServerName

public String getServerName()
Description copied from interface: ComponentManager
Returns the domain of the XMPP server. The domain name may be the IP address or the host name.

Specified by:
getServerName in interface ComponentManager
Returns:
the domain of the XMPP server.

getHomeDirectory

public String getHomeDirectory()

isExternalMode

public boolean isExternalMode()
Description copied from interface: ComponentManager
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.

Specified by:
isExternalMode in interface ComponentManager
Returns:
true if the managed components are external components.

getLog

public Log getLog()
Description copied from interface: ComponentManager
Returns a Log instance, which can be used by components for logging error, warning, info, and debug messages.

Specified by:
getLog in interface ComponentManager
Returns:
a Log instance.

getComponents

public Collection<Component> getComponents()
Returns the list of components that are currently installed in the server. This includes internal and external components.

Returns:
the list of installed components.

getComponent

public Component getComponent(JID componentJID)
Retrieves the Component which is mapped to the specified JID.

Parameters:
componentJID - the jid mapped to the component.
Returns:
the component with the specified id.

getComponent

public Component getComponent(String jid)
Retrieves the Component which is mapped to the specified JID.

Parameters:
jid - the jid mapped to the component.
Returns:
the component with the specified id.

addPresenceRequest

public void addPresenceRequest(JID prober,
                               JID probee)
Registers Probeers who have not yet been serviced.

Parameters:
prober - the jid probing.
probee - the presence being probed.

getAddress

public JID getAddress()
Description copied from interface: RoutableChannelHandler
Returns the XMPP address. The address is used by services like the core server packet router to determine if a packet should be sent to the handler. Handlers that are working on behalf of the server should use the generic server hostname address (e.g. server.com).

Specified by:
getAddress in interface RoutableChannelHandler
Returns:
the XMPP address.

process

public void process(Packet packet)
             throws PacketException
Processes packets that were sent to this service. Currently only packets that were sent from registered components are being processed. In the future, we may also process packet of trusted clients. Trusted clients may be able to execute ad-hoc commands such as adding or removing components.

Specified by:
process in interface ChannelHandler
Parameters:
packet - the packet to process.
Throws:
PacketException - thrown if the packet is malformed (results in the sender's session being shutdown).

Wildfire 3.1.1 Javadoc

Copyright © 2003-2006 Jive Software.