Smack

org.jivesoftware.smackx.commands
Class AdHocCommandManager

java.lang.Object
  extended by org.jivesoftware.smackx.commands.AdHocCommandManager

public class AdHocCommandManager
extends Object

An AdHocCommandManager is responsible for keeping the list of available commands offered by a service and for processing commands requests. Pass in a Connection instance to getAddHocCommandsManager(org.jivesoftware.smack.Connection) in order to get an instance of this class.

Author:
Gabriel Guardincerri

Method Summary
 DiscoverItems discoverCommands(String jid)
          Discover the commands of an specific JID.
static AdHocCommandManager getAddHocCommandsManager(Connection connection)
          Returns the AdHocCommandManager related to the connection.
 RemoteCommand getRemoteCommand(String jid, String node)
          Returns a command that represents an instance of a command in a remote host.
 void publishCommands(String jid)
          Publish the commands to an specific JID.
 void registerCommand(String node, String name, Class<? extends LocalCommand> clazz)
          Registers a new command with this command manager, which is related to a connection.
 void registerCommand(String node, String name, LocalCommandFactory factory)
          Registers a new command with this command manager, which is related to a connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAddHocCommandsManager

public static AdHocCommandManager getAddHocCommandsManager(Connection connection)
Returns the AdHocCommandManager related to the connection.

Parameters:
connection - the XMPP connection.
Returns:
the AdHocCommandManager associated with the connection.

registerCommand

public void registerCommand(String node,
                            String name,
                            Class<? extends LocalCommand> clazz)
Registers a new command with this command manager, which is related to a connection. The node is an unique identifier of that command for the connection related to this command manager. The name is the human readable name of the command. The class is the class of the command, which must extend LocalCommand and have a default constructor.

Parameters:
node - the unique identifier of the command.
name - the human readable name of the command.
clazz - the class of the command, which must extend LocalCommand.

registerCommand

public void registerCommand(String node,
                            String name,
                            LocalCommandFactory factory)
Registers a new command with this command manager, which is related to a connection. The node is an unique identifier of that command for the connection related to this command manager. The name is the human readeale name of the command. The factory generates new instances of the command.

Parameters:
node - the unique identifier of the command.
name - the human readable name of the command.
factory - a factory to create new instances of the command.

discoverCommands

public DiscoverItems discoverCommands(String jid)
                               throws XMPPException
Discover the commands of an specific JID. The jid is a full JID.

Parameters:
jid - the full JID to retrieve the commands for.
Returns:
the discovered items.
Throws:
XMPPException - if the operation failed for some reason.

publishCommands

public void publishCommands(String jid)
                     throws XMPPException
Publish the commands to an specific JID.

Parameters:
jid - the full JID to publish the commands to.
Throws:
XMPPException - if the operation failed for some reason.

getRemoteCommand

public RemoteCommand getRemoteCommand(String jid,
                                      String node)
Returns a command that represents an instance of a command in a remote host. It is used to execute remote commands. The concept is similar to RMI. Every invocation on this command is equivalent to an invocation in the remote command.

Parameters:
jid - the full JID of the host of the remote command
node - the identifier of the command
Returns:
a local instance equivalent to the remote command.

Smack

Copyright © 2003-2007 Jive Software.