Jive Messenger 2.2.2 Javadoc

org.jivesoftware.messenger
Class SessionManager

java.lang.Object
  extended by org.jivesoftware.messenger.container.BasicModule
      extended by org.jivesoftware.messenger.SessionManager
All Implemented Interfaces:
Module

public class SessionManager
extends BasicModule

Manages the sessions associated with an account. The information maintained by the Session manager is entirely transient and does not need to be preserved between server restarts.

Author:
Derek DeMoro

Field Summary
static int NEVER_KICK
           
 
Constructor Summary
SessionManager()
           
 
Method Summary
 void addAnonymousSession(ClientSession session)
           
 boolean addSession(ClientSession session)
          Add a new session to be managed.
 void broadcast(Packet packet)
          Broadcasts the given data to all connected sessions.
 void changePriority(JID sender, int priority)
          Change the priority of a session, that was already available, associated with the sender.
 Session createClientSession(Connection conn)
          Creates a new ClientSession.
 Session createComponentSession(Connection conn)
           
 IncomingServerSession createIncomingServerSession(Connection conn, StreamID id)
          Creates a session for a remote server.
 int getAnonymousSessionCount()
           
 Iterator getAnonymousSessions()
           
 Session getBestRoute(JID recipient)
          Retrieve the best route to deliver packets to this session given the recipient jid.
 ComponentSession getComponentSession(String domain)
          Returns the session of the component whose domain matches the specified domain.
 Collection<ComponentSession> getComponentSessions()
          Returns a collection with the established sessions from external components.
 int getConflictKickLimit()
           
 Collection<String> getIncomingServers()
          Returns a collection with the hostnames of the remote servers that currently have an incoming server connection to this server.
 IncomingServerSession getIncomingServerSession(String hostname)
          Returns a session that was originated by a remote server.
static SessionManager getInstance()
          Returns the instance of SessionManagerImpl being used by the XMPPServer.
 Collection<String> getOutgoingServers()
          Returns a collection with the hostnames of the remote servers that currently may receive packets sent from this server.
 OutgoingServerSession getOutgoingServerSession(String hostname)
          Returns a session that was originated from this server to a remote server.
 Collection<String> getPreAuthenticatedKeys()
          Returns the temporary keys used by the sessions that has not been authenticated yet.
 int getServerSessionIdleTime()
           
 int getServerSessionTimeout()
          Returns the number of milliseconds to elapse between clearing of idle server sessions.
 ClientSession getSession(JID from)
          Returns the session responsible for this JID.
 ClientSession getSession(String username, String domain, String resource)
          Returns the session responsible for this JID data.
 int getSessionCount()
           
 int getSessionCount(String username)
           
 Collection<ClientSession> getSessions()
           
 Collection<ClientSession> getSessions(SessionResultFilter filter)
           
 Collection<ClientSession> getSessions(String username)
           
 Collection<String> getSessionUsers()
           
 int getTotalSessionCount()
           
 void initialize(XMPPServer server)
          Initializes the basic module.
 boolean isActiveRoute(String username, String resource)
           
 StreamID nextStreamID()
          Returns a randomly created ID to be used in a stream element.
 void outgoingServerSessionCreated(OutgoingServerSession session)
          Notification message that a new OutgoingServerSession has been created.
 void registerIncomingServerSession(String hostname, IncomingServerSession session)
          Registers that a server session originated by a remote server is hosting a given hostname.
 void registerOutgoingServerSession(String hostname, OutgoingServerSession session)
          Registers that a server session originated by this server has been established to a remote server named hostname.
 void removeSession(ClientSession session)
          Removes a session.
 void sendServerMessage(JID address, String subject, String body)
          Sends a message with a given subject and body to one or more user sessions related to the specified address.
 void sendServerMessage(String subject, String body)
          Sends a message with a given subject and body to all the active user sessions in the server.
 void sessionAvailable(ClientSession session)
          Notification message sent when a client sent an available presence for the session.
 void sessionUnavailable(ClientSession session)
          Notification message sent when a client sent an unavailable presence for the session.
 void setConflictKickLimit(int limit)
           
 void setServerSessionIdleTime(int idleTime)
           
 void setServerSessionTimeout(int timeout)
          Sets the number of milliseconds to elapse between clearing of idle server sessions.
 void stop()
          Stops the basic module.
 void unregisterIncomingServerSession(String hostname)
          Unregisters that a server session originated by a remote server is hosting a given hostname.
 void unregisterOutgoingServerSession(String hostname)
          Unregisters the server session that was originated by this server to a remote server named hostname.
 void userBroadcast(String username, Packet packet)
          Broadcasts the given data to all connected sessions for a particular user.
 
Methods inherited from class org.jivesoftware.messenger.container.BasicModule
destroy, getName, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEVER_KICK

public static final int NEVER_KICK
See Also:
Constant Field Values
Constructor Detail

SessionManager

public SessionManager()
Method Detail

getInstance

public static SessionManager getInstance()
Returns the instance of SessionManagerImpl being used by the XMPPServer.

Returns:
the instance of SessionManagerImpl being used by the XMPPServer.

nextStreamID

public StreamID nextStreamID()
Returns a randomly created ID to be used in a stream element.

Returns:
a randomly created ID to be used in a stream element.

createClientSession

public Session createClientSession(Connection conn)
                            throws UnauthorizedException
Creates a new ClientSession.

Parameters:
conn - the connection to create the session from.
Returns:
a newly created session.
Throws:
UnauthorizedException

createComponentSession

public Session createComponentSession(Connection conn)
                               throws UnauthorizedException
Throws:
UnauthorizedException

createIncomingServerSession

public IncomingServerSession createIncomingServerSession(Connection conn,
                                                         StreamID id)
                                                  throws UnauthorizedException
Creates a session for a remote server. The session should be created only after the remote server has been authenticated either using "server dialback" or SASL.

Parameters:
conn - the connection to the remote server.
id - the stream ID used in the stream element when authenticating the server.
Returns:
the newly created IncomingServerSession.
Throws:
UnauthorizedException - if the local server has not been initialized yet.

outgoingServerSessionCreated

public void outgoingServerSessionCreated(OutgoingServerSession session)
Notification message that a new OutgoingServerSession has been created. Register a listener that will react when the connection gets closed.

Parameters:
session - the newly created OutgoingServerSession.

registerIncomingServerSession

public void registerIncomingServerSession(String hostname,
                                          IncomingServerSession session)
Registers that a server session originated by a remote server is hosting a given hostname. Notice that the remote server may be hosting several subdomains as well as virtual hosts so the same IncomingServerSession may be associated with many keys.

Parameters:
hostname - the hostname that is being served by the remote server.
session - the incoming server session to the remote server.

unregisterIncomingServerSession

public void unregisterIncomingServerSession(String hostname)
Unregisters that a server session originated by a remote server is hosting a given hostname. Notice that the remote server may be hosting several subdomains as well as virtual hosts so the same IncomingServerSession may be associated with many keys.

Parameters:
hostname - the hostname that is being served by the remote server.

registerOutgoingServerSession

public void registerOutgoingServerSession(String hostname,
                                          OutgoingServerSession session)
Registers that a server session originated by this server has been established to a remote server named hostname. This session will only be used for sending packets to the remote server and cannot receive packets. The OutgoingServerSession may have one or more domains, subdomains or virtual hosts authenticated with the remote server.

Parameters:
hostname - the hostname that is being served by the remote server.
session - the outgoing server session to the remote server.

unregisterOutgoingServerSession

public void unregisterOutgoingServerSession(String hostname)
Unregisters the server session that was originated by this server to a remote server named hostname. This session was only being used for sending packets to the remote server and not for receiving packets. The OutgoingServerSession may have one or more domains, subdomains or virtual hosts authenticated with the remote server.

Parameters:
hostname - the hostname that the session was connected with.

addSession

public boolean addSession(ClientSession session)
Add a new session to be managed.


sessionAvailable

public void sessionAvailable(ClientSession session)
Notification message sent when a client sent an available presence for the session. Making the session available means that the session is now eligible for receiving messages from other clients. Sessions whose presence is not available may only receive packets (IQ packets) from the server. Therefore, an unavailable session remains invisible to other clients.

Parameters:
session - the session that receieved an available presence.

sessionUnavailable

public void sessionUnavailable(ClientSession session)
Notification message sent when a client sent an unavailable presence for the session. Making the session unavailable means that the session is not eligible for receiving messages from other clients.

Parameters:
session - the session that receieved an unavailable presence.

changePriority

public void changePriority(JID sender,
                           int priority)
Change the priority of a session, that was already available, associated with the sender.

Parameters:
sender - The sender who's session just changed priority
priority - The new priority for the session

getBestRoute

public Session getBestRoute(JID recipient)
Retrieve the best route to deliver packets to this session given the recipient jid. If the requested JID does not have a node (i.e. username) then the best route will be looked up in the anonymous sessions list. Otherwise, try to find a root for the exact JID (i.e. including the resource) and if none is found then answer the deafult session if any.

Parameters:
recipient - The recipient ID to deliver packets to
Returns:
The XMPPAddress best suited to use for delivery to the recipient

isActiveRoute

public boolean isActiveRoute(String username,
                             String resource)

getSession

public ClientSession getSession(JID from)
Returns the session responsible for this JID.

Parameters:
from - the sender of the packet.
Returns:
the Session associated with the JID.

getSession

public ClientSession getSession(String username,
                                String domain,
                                String resource)
Returns the session responsible for this JID data. The returned Session may have never sent an available presence (thus not have a route) or could be a Session that hasn't authenticated yet (i.e. preAuthenticatedSessions).

Parameters:
username - the username of the JID.
domain - the username of the JID.
resource - the username of the JID.
Returns:
the Session associated with the JID data.

getSessions

public Collection<ClientSession> getSessions()

getSessions

public Collection<ClientSession> getSessions(SessionResultFilter filter)

getIncomingServerSession

public IncomingServerSession getIncomingServerSession(String hostname)
Returns a session that was originated by a remote server. IncomingServerSession can only receive packets from the remote server but are not capable of sending packets to the remote server.

Parameters:
hostname - the name of the remote server.
Returns:
a session that was originated by a remote server.

getOutgoingServerSession

public OutgoingServerSession getOutgoingServerSession(String hostname)
Returns a session that was originated from this server to a remote server. OutgoingServerSession an only send packets to the remote server but are not capable of receiving packets from the remote server.

Parameters:
hostname - the name of the remote server.
Returns:
a session that was originated from this server to a remote server.

getAnonymousSessions

public Iterator getAnonymousSessions()

getSessions

public Collection<ClientSession> getSessions(String username)

getTotalSessionCount

public int getTotalSessionCount()

getSessionCount

public int getSessionCount()

getAnonymousSessionCount

public int getAnonymousSessionCount()

getSessionCount

public int getSessionCount(String username)

getSessionUsers

public Collection<String> getSessionUsers()

getComponentSessions

public Collection<ComponentSession> getComponentSessions()
Returns a collection with the established sessions from external components.

Returns:
a collection with the established sessions from external components.

getComponentSession

public ComponentSession getComponentSession(String domain)
Returns the session of the component whose domain matches the specified domain.

Parameters:
domain - the domain of the component session to look for.
Returns:
the session of the component whose domain matches the specified domain.

getIncomingServers

public Collection<String> getIncomingServers()
Returns a collection with the hostnames of the remote servers that currently have an incoming server connection to this server.

Returns:
a collection with the hostnames of the remote servers that currently have an incoming server connection to this server.

getOutgoingServers

public Collection<String> getOutgoingServers()
Returns a collection with the hostnames of the remote servers that currently may receive packets sent from this server.

Returns:
a collection with the hostnames of the remote servers that currently may receive packets sent from this server.

broadcast

public void broadcast(Packet packet)
               throws UnauthorizedException
Broadcasts the given data to all connected sessions. Excellent for server administration messages.

Parameters:
packet - The packet to be broadcast
Throws:
UnauthorizedException

userBroadcast

public void userBroadcast(String username,
                          Packet packet)
                   throws UnauthorizedException,
                          PacketException
Broadcasts the given data to all connected sessions for a particular user. Excellent for updating all connected resources for users such as roster pushes.

Parameters:
packet - The packet to be broadcast
Throws:
UnauthorizedException
PacketException

removeSession

public void removeSession(ClientSession session)
Removes a session.

Parameters:
session - the session.

addAnonymousSession

public void addAnonymousSession(ClientSession session)

getConflictKickLimit

public int getConflictKickLimit()

getPreAuthenticatedKeys

public Collection<String> getPreAuthenticatedKeys()
Returns the temporary keys used by the sessions that has not been authenticated yet. This is an utility method useful for debugging situations.

Returns:
the temporary keys used by the sessions that has not been authenticated yet.

setConflictKickLimit

public void setConflictKickLimit(int limit)

initialize

public void initialize(XMPPServer server)
Description copied from class: BasicModule

Initializes the basic module.

Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.

Specified by:
initialize in interface Module
Overrides:
initialize in class BasicModule
Parameters:
server - the server hosting this module.

sendServerMessage

public void sendServerMessage(String subject,
                              String body)
Sends a message with a given subject and body to all the active user sessions in the server.

Parameters:
subject - the subject to broadcast.
body - the body to broadcast.

sendServerMessage

public void sendServerMessage(JID address,
                              String subject,
                              String body)
Sends a message with a given subject and body to one or more user sessions related to the specified address. If address is null or the address's node is null then the message will be sent to all the user sessions. But if the address includes a node but no resource then the message will be sent to all the user sessions of the requeted user (defined by the node). Finally, if the address is a full JID then the message will be sent to the session associated to the full JID. If no session is found then the message is not sent.

Parameters:
address - the address that defines the sessions that will receive the message.
subject - the subject to broadcast.
body - the body to broadcast.

stop

public void stop()
Description copied from class: BasicModule

Stops the basic module.

Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.

Specified by:
stop in interface Module
Overrides:
stop in class BasicModule

setServerSessionTimeout

public void setServerSessionTimeout(int timeout)
Sets the number of milliseconds to elapse between clearing of idle server sessions.

Parameters:
timeout - the number of milliseconds to elapse between clearings.

getServerSessionTimeout

public int getServerSessionTimeout()
Returns the number of milliseconds to elapse between clearing of idle server sessions.

Returns:
the number of milliseconds to elapse between clearing of idle server sessions.

setServerSessionIdleTime

public void setServerSessionIdleTime(int idleTime)

getServerSessionIdleTime

public int getServerSessionIdleTime()

Jive Messenger 2.2.2 Javadoc

Copyright © 1999-2004 Jive Software.