com.echomine.jabber
Class JabberServerService

java.lang.Object
  extended by com.echomine.jabber.JabberServerService

public class JabberServerService
extends java.lang.Object

the server service contains the methods that you will use 90% of the time. For the rest, you will need to manually create the individual methods (should be easy) and work with the message object directly.


Constructor Summary
JabberServerService(JabberSession session)
           
 
Method Summary
 JIDType browse(JID jid, java.lang.String type, boolean wait)
          browses to the JID that you specify.
 java.util.List discoverItems(JID jid, java.lang.String node, boolean wait)
          Convenience method to use the service discovery protocol to find service items available for use.
 java.util.List getAgents()
          Deprecated. Replace by new JEP-0030 Service Discovery Protocol
 java.util.HashMap getSearchFields(JID jid)
          Convenience method to retrieve the search fields for a particular service.
 java.lang.String getServerTime()
          retrieves the server's time in a string.
 java.lang.String getServerTimeInLocal()
          retrieves the server's time.
 long getServerUptime()
          retrieves the server uptime synchronously.
 java.lang.String getServerVersion()
          obtains the server version.
 java.util.List search(JID jid, java.util.HashMap searchFields, boolean wait)
          convenience method to submit a search to the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JabberServerService

public JabberServerService(JabberSession session)
Method Detail

getServerTimeInLocal

public java.lang.String getServerTimeInLocal()
                                      throws SendMessageFailedException
retrieves the server's time. The time zone will be your time zone, not the server's. Thus, the time is the server's time in your time zone. If you need to retrieve other information such as the UTF date or timezone, you should submit your own message This method is provided as a convenience and is synchronous.

Returns:
the server's time or null if no server time can be retrieved
Throws:
SendMessageFailedException

getServerTime

public java.lang.String getServerTime()
                               throws SendMessageFailedException
retrieves the server's time in a string. The time zone indicated is the server's time zone, not yours. Thus, the time is the server's local time. If you need to retrieve other information such as the UTF date or timezone, you should submit your own message This method is provided as a convenience and is synchronous.

Returns:
the server's time or null if no server time can be retrieved
Throws:
SendMessageFailedException

getServerVersion

public java.lang.String getServerVersion()
                                  throws SendMessageFailedException
obtains the server version. The version is the jabber version that the server is running on. It will include the Jabber Server plus the version, ie. "jsm 1.4.1". This method is provided as a convenience and is synchronous.

Throws:
SendMessageFailedException

getServerUptime

public long getServerUptime()
                     throws SendMessageFailedException
retrieves the server uptime synchronously. The time will return -1 if there's any problems.

Returns:
the server uptime
Throws:
SendMessageFailedException

getAgents

public java.util.List getAgents()
                         throws SendMessageFailedException
Deprecated. Replace by new JEP-0030 Service Discovery Protocol

Retrieves a list of agents that are available for the server. These agents can include conferencing, gateways/transports, Jabber User Directories, etc. Whatever the server offers is what this list contains. The returned list is simply a list of services provided by the server. This method uses the old style of agent retrieval (by using the jabber:iq:agents namespace) for backwards compatibility. The new way (using browsing) is also supported, but you will have to instantiate your own Browse message for that (or use the generic browse method). This method is synchronous and will not return until a reply or timeout is received. Likely the Agent namespace is still supported by remote servers, but be on the lookout for changes.

Returns:
a list of Agent objects, or null if there are none.
Throws:
SendMessageFailedException
See Also:
ServiceInfoIQMessage, ServiceItemsIQMessage

browse

public JIDType browse(JID jid,
                      java.lang.String type,
                      boolean wait)
               throws JabberMessageException,
                      SendMessageFailedException,
                      ParseException
browses to the JID that you specify. The JID is basically also the entity to send this message to (JID and To are equal). If you need to have them be different, then create your own Browse Message and send it manually. The JID Type is basically the "category/subtype" that you want to query for. This method's synchronicity is changeable and will not return until a reply or error is received. Note that if the message is sent synchronously, the return value will always be null.

Parameters:
jid - the JID of the service/user/resource to browse to
type - the JID Type in the format of "category/subtype"
wait - whether to wait for reply or just simply send and return
Returns:
JIDType if there are any JID Types for the browsed resource, null if wait is false.
Throws:
JabberMessageException - if any error occurred while waiting for reply (ie. timeouts)
ParseException - if the type passed in is not in the proper format
SendMessageFailedException

getSearchFields

public java.util.HashMap getSearchFields(JID jid)
                                  throws SendMessageFailedException,
                                         JabberMessageException
Convenience method to retrieve the search fields for a particular service. Normally used with the JUD (Jabber User Directory). The method is synchronous and will return a hashmap of fields you can use.

Parameters:
jid - the jid to search for
Returns:
a hashmap of field you can search on
Throws:
SendMessageFailedException
JabberMessageException

search

public java.util.List search(JID jid,
                             java.util.HashMap searchFields,
                             boolean wait)
                      throws SendMessageFailedException,
                             JabberMessageException
convenience method to submit a search to the server. If the search is submitted asynchronously, then the return value is null. Otherwise, the return value will be a List of SearchItem objects.

Parameters:
jid - the jid to submit this search to, normally the JUD.
searchFields - hashmap of fields that is filled with the search criteria
wait - whether to send the message synchronously or asynchronously
Returns:
the list of SearchItem objects, or null if wait is false
Throws:
SendMessageFailedException
JabberMessageException

discoverItems

public java.util.List discoverItems(JID jid,
                                    java.lang.String node,
                                    boolean wait)
                             throws SendMessageFailedException,
                                    JabberMessageException
Convenience method to use the service discovery protocol to find service items available for use. Currently, not very many servers support this feature so be careful if you decide to call this method synchronously because likely the call will wait until timeout occurs, in which case, your client may stall. It is recommended that you call this method asynchronously until you know for sure that the remote server supports this feature.

Parameters:
jid - the JID to send the discovery request to
node - an optional node name for discovering further items, or null if none is required
wait - whether to wait for a reply or not
Returns:
a list of ServiceItem objects
Throws:
SendMessageFailedException
JabberMessageException


Copyright © 2001-2005 Echomine. All Rights Reserved.