public class AdHocCommandHandler extends IQHandler implements ServerFeaturesProvider, DiscoInfoProvider, DiscoItemsProvider
Ad-hoc commands that require user interaction will have one or more stages. For each stage the
user will complete a data form and send it back to the server. The data entered by the user is
kept in a SessionData. Instances of AdHocCommand
are stateless. In order to prevent
"bad" users from consuming all system memory there exists a limit of simultaneous commands that
a user might perform. Configure the system property "xmpp.command.limit" to control
this limit. User sessions will also timeout and their data destroyed if they have not been
executed within a time limit since the session was created. The default timeout value is 10
minutes. The timeout value can be modified by setting the system property
"xmpp.command.timeout".
New commands can be added dynamically by sending the message addCommand(AdHocCommand)
.
The command will immediatelly appear in the disco#items list and might be executed by those
users with enough execution permissions.
deliverer, sessionManager
Constructor and Description |
---|
AdHocCommandHandler() |
Modifier and Type | Method and Description |
---|---|
void |
addCommand(AdHocCommand command)
Adds a new command to the list of supported ad-hoc commands by this server.
|
org.xmpp.forms.DataForm |
getExtendedInfo(String name,
String node,
org.xmpp.packet.JID senderJID)
Returns an XDataForm with the extended information about the entity or null if none.
|
Iterator<String> |
getFeatures()
Returns an Iterator (of String) with the supported features by the server.
|
Iterator<String> |
getFeatures(String name,
String node,
org.xmpp.packet.JID senderJID)
Returns an Iterator (of String) with the supported features.
|
Iterator<org.dom4j.Element> |
getIdentities(String name,
String node,
org.xmpp.packet.JID senderJID)
Returns an Iterator (of Element) with the target entity's identities.
|
IQHandlerInfo |
getInfo()
Returns the handler information to help generically handle IQ packets.
|
Iterator<DiscoItem> |
getItems(String name,
String node,
org.xmpp.packet.JID senderJID)
Returns an Iterator (of DiscoItem) with the target entity's items or null if none.
|
org.xmpp.packet.IQ |
handleIQ(org.xmpp.packet.IQ packet)
Handles the received IQ packet.
|
boolean |
hasInfo(String name,
String node,
org.xmpp.packet.JID senderJID)
Returns true if we can provide information related to the requested name and node.
|
void |
initialize(XMPPServer server)
Initializes the basic module.
|
void |
removeCommand(AdHocCommand command)
Removes the command from the list of ad-hoc commands supported by this server.
|
void |
start()
Starts the basic module.
|
void |
stop()
Stops the basic module.
|
destroy, getName
public org.xmpp.packet.IQ handleIQ(org.xmpp.packet.IQ packet) throws UnauthorizedException
IQHandler
handleIQ
in class IQHandler
packet
- the IQ packet to handle.UnauthorizedException
- if the user that sent the packet is not
authorized to request the given operation.public IQHandlerInfo getInfo()
IQHandler
public Iterator<String> getFeatures()
ServerFeaturesProvider
getFeatures
in interface ServerFeaturesProvider
public Iterator<org.dom4j.Element> getIdentities(String name, String node, org.xmpp.packet.JID senderJID)
DiscoInfoProvider
getIdentities
in interface DiscoInfoProvider
name
- the recipient JID's name.node
- the requested disco node.senderJID
- the XMPPAddress of user that sent the disco info request.public Iterator<String> getFeatures(String name, String node, org.xmpp.packet.JID senderJID)
DiscoInfoProvider
getFeatures
in interface DiscoInfoProvider
name
- the recipient JID's name.node
- the requested disco node.senderJID
- the XMPPAddress of user that sent the disco info request.public org.xmpp.forms.DataForm getExtendedInfo(String name, String node, org.xmpp.packet.JID senderJID)
DiscoInfoProvider
getExtendedInfo
in interface DiscoInfoProvider
name
- the recipient JID's name.node
- the requested disco node.senderJID
- the XMPPAddress of user that sent the disco info request.public boolean hasInfo(String name, String node, org.xmpp.packet.JID senderJID)
DiscoInfoProvider
hasInfo
in interface DiscoInfoProvider
name
- the recipient JID's name.node
- the requested disco node.senderJID
- the XMPPAddress of user that sent the disco info request.public Iterator<DiscoItem> getItems(String name, String node, org.xmpp.packet.JID senderJID)
DiscoItemsProvider
getItems
in interface DiscoItemsProvider
name
- the recipient JID's name.node
- the requested disco node.senderJID
- the XMPPAddress of user that sent the disco items request.public void initialize(XMPPServer server)
BasicModule
Initializes the basic module.
Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.
initialize
in interface Module
initialize
in class IQHandler
server
- the server hosting this module.public void start() throws IllegalStateException
BasicModule
Starts the basic module.
Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.
start
in interface Module
start
in class BasicModule
IllegalStateException
- If start is called before initialize
successfully returnspublic void stop()
BasicModule
Stops the basic module.
Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.
stop
in interface Module
stop
in class BasicModule
public void addCommand(AdHocCommand command)
command
- the new ad-hoc command to add.public void removeCommand(AdHocCommand command)
command
- the ad-hoc command to remove.Copyright © 2003-2008 Jive Software.