Whack

org.jivesoftware.whack
Class ExternalComponent

java.lang.Object
  extended by org.jivesoftware.whack.ExternalComponent
All Implemented Interfaces:
org.xmpp.component.Component

public class ExternalComponent
extends Object
implements org.xmpp.component.Component

ExternalComponents are responsible for connecting and authenticating with a remote server and for sending and processing received packets. In fact, an ExternalComponent is a wrapper on a Component that provides remote connection capabilities. The actual processing of the packets is done by the wrapped Component.

Author:
Gaston Dombiak

Constructor Summary
ExternalComponent(org.xmpp.component.Component component, ExternalComponentManager manager)
           
ExternalComponent(org.xmpp.component.Component component, ExternalComponentManager manager, int maxThreads)
           
 
Method Summary
 void connect(String host, int port, String subdomain)
          Generates a connection with the server and tries to authenticate.
 void connectionLost()
          Notification message that the connection with the server was lost unexpectedly.
 org.xmpp.component.Component getComponent()
           
 String getDescription()
          Returns the description of this component.
 String getDomain()
          Returns the domain provided by this component in the connected server.
 String getName()
          Returns the name of this component.
 String getSubdomain()
          Returns the subdomain provided by this component in the connected server.
 void initialize(org.xmpp.packet.JID jid, org.xmpp.component.ComponentManager componentManager)
          Initializes this component with a ComponentManager and the JID that this component is available at (e.g.
 void processPacket(org.xmpp.packet.Packet packet)
          Processes a packet sent to this Component.
 void send(org.xmpp.packet.Packet packet)
           
 void shutdown()
          Notification message indicating that the component will stop receiving incoming packets.
 void start()
          Notification message indicating that the component will start receiving incoming packets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExternalComponent

public ExternalComponent(org.xmpp.component.Component component,
                         ExternalComponentManager manager)

ExternalComponent

public ExternalComponent(org.xmpp.component.Component component,
                         ExternalComponentManager manager,
                         int maxThreads)
Method Detail

connect

public void connect(String host,
                    int port,
                    String subdomain)
             throws org.xmpp.component.ComponentException
Generates a connection with the server and tries to authenticate. If an error occurs in any of the steps then a ComponentException is thrown.

Parameters:
host - the host to connect with.
port - the port to use.
subdomain - the subdomain that this component will be handling.
Throws:
org.xmpp.component.ComponentException - if an error happens during the connection and authentication steps.

getComponent

public org.xmpp.component.Component getComponent()

getName

public String getName()
Description copied from interface: org.xmpp.component.Component
Returns the name of this component.

Specified by:
getName in interface org.xmpp.component.Component
Returns:
the name of this component.

getDescription

public String getDescription()
Description copied from interface: org.xmpp.component.Component
Returns the description of this component.

Specified by:
getDescription in interface org.xmpp.component.Component
Returns:
the description of this component.

getDomain

public String getDomain()
Returns the domain provided by this component in the connected server. The domain is composed by the subdomain plus the domain of the server. E.g. conference.jivesoftware.com. The domain may change after a connection has been established with the server.

Returns:
the domain provided by this component in the connected server.

getSubdomain

public String getSubdomain()
Returns the subdomain provided by this component in the connected server. E.g. conference.

Returns:
the subdomain provided by this component in the connected server.

processPacket

public void processPacket(org.xmpp.packet.Packet packet)
Description copied from interface: org.xmpp.component.Component
Processes a packet sent to this Component.

Specified by:
processPacket in interface org.xmpp.component.Component
Parameters:
packet - the packet.
See Also:
ComponentManager.sendPacket(Component, Packet)

send

public void send(org.xmpp.packet.Packet packet)

initialize

public void initialize(org.xmpp.packet.JID jid,
                       org.xmpp.component.ComponentManager componentManager)
                throws org.xmpp.component.ComponentException
Description copied from interface: org.xmpp.component.Component
Initializes this component with a ComponentManager and the JID that this component is available at (e.g. service.example.com). If a ComponentException is thrown then the component will not be loaded.

The initialization code must not rely on receiving packets from the server since the component has not been fully initialized yet. This means that at this point the component must not rely on information that is obtained from the server such us discovered items.

Specified by:
initialize in interface org.xmpp.component.Component
Parameters:
jid - the XMPP address that this component is available at.
componentManager - the component manager.
Throws:
org.xmpp.component.ComponentException - if an error occured while initializing the component.

start

public void start()
Description copied from interface: org.xmpp.component.Component
Notification message indicating that the component will start receiving incoming packets. At this time the component may finish pending initialization issues that require information obtained from the server.

It is likely that most of the component will leave this method empty.

Specified by:
start in interface org.xmpp.component.Component

shutdown

public void shutdown()
Description copied from interface: org.xmpp.component.Component
Notification message indicating that the component will stop receiving incoming packets. All component resources must be released as part of shutdown. This could happen when the component is unregistered or when running as an external component when the connection to the server is lost.

In the case of connection to the server was lost, the External Component will keep trying to reconnect to the server. When reconnection is successful the Component.start() event will be sent to the component.

Specified by:
shutdown in interface org.xmpp.component.Component

connectionLost

public void connectionLost()
Notification message that the connection with the server was lost unexpectedly. We will try to reestablish the connection for ever until the connection has been reestablished or this thread has been stopped.


Whack

Copyright © 2003-2008 Jive Software.