Package org.jivesoftware.smackx.commands
Class AdHocCommandManager
- java.lang.Object
-
- org.jivesoftware.smack.Manager
-
- org.jivesoftware.smackx.commands.AdHocCommandManager
-
public final class AdHocCommandManager extends Manager
An AdHocCommandManager is responsible for keeping the list of available commands offered by a service and for processing commands requests. Pass in an XMPPConnection instance togetAddHocCommandsManager(XMPPConnection)
in order to get an instance of this class.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DiscoverItems
discoverCommands(Jid jid)
Discover the commands of an specific JID.static AdHocCommandManager
getAddHocCommandsManager(XMPPConnection connection)
Deprecated.usegetInstance(XMPPConnection)
instead.static AdHocCommandManager
getInstance(XMPPConnection connection)
Returns theAdHocCommandManager
related to theconnection
.AdHocCommand
getRemoteCommand(Jid jid, String node)
Returns a command that represents an instance of a command in a remote host.void
registerCommand(String node, String name, Class<? extends AdHocCommandHandler> clazz)
Registers a new command with this command manager, which is related to a connection.void
registerCommand(String node, String name, AdHocCommandHandlerFactory factory)
Registers a new command with this command manager, which is related to a connection.static void
setDefaultSessionTimeoutSecs(int seconds)
void
setSessionTimeoutSecs(int seconds)
boolean
unregisterCommand(String node)
-
Methods inherited from class org.jivesoftware.smack.Manager
connection, getAuthenticatedConnectionOrThrow, schedule, schedule, scheduleBlocking
-
-
-
-
Field Detail
-
NAMESPACE
public static final String NAMESPACE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getAddHocCommandsManager
@Deprecated public static AdHocCommandManager getAddHocCommandsManager(XMPPConnection connection)
Deprecated.usegetInstance(XMPPConnection)
instead.Returns theAdHocCommandManager
related to theconnection
.- Parameters:
connection
- the XMPP connection.- Returns:
- the AdHocCommandManager associated with the connection.
-
getInstance
public static AdHocCommandManager getInstance(XMPPConnection connection)
Returns theAdHocCommandManager
related to theconnection
.- Parameters:
connection
- the XMPP connection.- Returns:
- the AdHocCommandManager associated with the connection.
-
registerCommand
public void registerCommand(String node, String name, Class<? extends AdHocCommandHandler> clazz) throws NoSuchMethodException, SecurityException
Registers a new command with this command manager, which is related to a connection. Thenode
is an unique identifier of that command for the connection related to this command manager. Thename
is the human readable name of the command. Theclass
is the class of the command, which must extendAdHocCommandHandler
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 extendAdHocCommandHandler
.- Throws:
SecurityException
- if there was a security violation.NoSuchMethodException
- if no such method is declared.
-
registerCommand
public void registerCommand(String node, String name, AdHocCommandHandlerFactory factory)
Registers a new command with this command manager, which is related to a connection. Thenode
is an unique identifier of that command for the connection related to this command manager. Thename
is the human readable name of the command. Thefactory
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.
-
unregisterCommand
public boolean unregisterCommand(String node)
-
discoverCommands
public DiscoverItems discoverCommands(Jid jid) throws XMPPException, SmackException, InterruptedException
Discover the commands of an specific JID. Thejid
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.SmackException
- if there was no response from the server.InterruptedException
- if the calling thread was interrupted.
-
getRemoteCommand
public AdHocCommand getRemoteCommand(Jid 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 commandnode
- the identifier of the command- Returns:
- a local instance equivalent to the remote command.
-
setDefaultSessionTimeoutSecs
public static void setDefaultSessionTimeoutSecs(int seconds)
-
setSessionTimeoutSecs
public void setSessionTimeoutSecs(int seconds)
-
-