org.sakaiproject.component.legacy.presence
Class BasePresenceService

java.lang.Object
  extended byorg.sakaiproject.component.legacy.presence.BasePresenceService
All Implemented Interfaces:
PresenceService
Direct Known Subclasses:
ClusterPresenceService

public abstract class BasePresenceService
extends Object
implements PresenceService

Implements the PresenceService, all but a Storage model.

Version:
$Revision: 2433 $
Author:
University of Michigan, Sakai Software Development Team

Nested Class Summary
protected  class BasePresenceService.Presence
          Presence
protected static interface BasePresenceService.Storage
          Storage
 
Field Summary
protected  EventTrackingService m_eventTrackingService
          Dependency: EventTrackingService
protected  Logger m_logger
          Dependency: logging service
protected  BasePresenceService.Storage m_storage
          Storage.
protected  int m_timeout
          Configuration: milliseconds till a non-refreshed presence entry times out.
protected  UsageSessionService m_usageSessionService
          Dependency: UsageSessionService
protected  UserDirectoryService m_userDirectoryService
          Dependency: UserDirectoryService
protected static String SESSION_KEY
          SessionState key.
 
Fields inherited from interface org.sakaiproject.service.legacy.presence.PresenceService
EVENT_ABSENCE, EVENT_PRESENCE, REFERENCE_ROOT
 
Constructor Summary
BasePresenceService()
           
 
Method Summary
protected  boolean checkPresence(String locationId, boolean refresh)
          Check if the current session is present at the location - optionally refreshing it
protected  void checkPresenceForExpiration()
          Check current session presences and remove any expired ones
 void destroy()
          Returns to uninitialized state.
 String getLocationDescription(String location)
          Form a description for the location.
 List getLocations()
          Access a List of all location ids (String).
 List getPresence(String locationId)
          Access a List of sessions (UsageSession) now present in a location.
 List getPresentUsers(String locationId)
          Access a List of users (User) now present in a location.
 int getTimeout()
          Access the time (in seconds) after which a presence will timeout.
 void init()
          Final initialization, once all dependencies are set.
 String locationId(String site, String page, String tool)
          Construct a location id from site, page, and tool.
protected abstract  BasePresenceService.Storage newStorage()
          Allocate a new storage object.
protected  String presenceId(String ref)
          {@inheritDoc}
 String presenceReference(String id)
          Form a presence reference from a location id
 void removePresence(String locationId)
          Remove the presence of the current session from a location.
 void setEventTrackingService(EventTrackingService service)
          Dependency: EventTrackingService.
 void setLogger(Logger service)
          Dependency: logging service.
 void setPresence(String locationId)
          Establish or refresh the presence of the current session in a location.
 void setTimeoutSeconds(String value)
          Configuration: SECONDS till a non-refreshed presence entry times out.
 void setUsageSessionService(UsageSessionService service)
          Dependency: UsageSessionService.
 void setUserDirectoryService(UserDirectoryService service)
          Dependency: UserDirectoryService.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_KEY

protected static final String SESSION_KEY
SessionState key.

See Also:
Constant Field Values

m_storage

protected BasePresenceService.Storage m_storage
Storage.


m_logger

protected Logger m_logger
Dependency: logging service


m_usageSessionService

protected UsageSessionService m_usageSessionService
Dependency: UsageSessionService


m_userDirectoryService

protected UserDirectoryService m_userDirectoryService
Dependency: UserDirectoryService


m_eventTrackingService

protected EventTrackingService m_eventTrackingService
Dependency: EventTrackingService


m_timeout

protected int m_timeout
Configuration: milliseconds till a non-refreshed presence entry times out.

Constructor Detail

BasePresenceService

public BasePresenceService()
Method Detail

newStorage

protected abstract BasePresenceService.Storage newStorage()
Allocate a new storage object.

Returns:
A new storage object.

setLogger

public void setLogger(Logger service)
Dependency: logging service.

Parameters:
service - The logging service.

setUsageSessionService

public void setUsageSessionService(UsageSessionService service)
Dependency: UsageSessionService.

Parameters:
service - The UsageSessionService.

setUserDirectoryService

public void setUserDirectoryService(UserDirectoryService service)
Dependency: UserDirectoryService.

Parameters:
service - The UserDirectoryService.

setEventTrackingService

public void setEventTrackingService(EventTrackingService service)
Dependency: EventTrackingService.

Parameters:
service - The EventTrackingService.

setTimeoutSeconds

public void setTimeoutSeconds(String value)
Configuration: SECONDS till a non-refreshed presence entry times out.

Parameters:
value - timeout seconds.

init

public void init()
Final initialization, once all dependencies are set.


destroy

public void destroy()
Returns to uninitialized state.


presenceReference

public String presenceReference(String id)
Form a presence reference from a location id

Specified by:
presenceReference in interface PresenceService
Parameters:
id - the location id.
Returns:
A presence reference based on a location id.

presenceId

protected String presenceId(String ref)
{@inheritDoc}


setPresence

public void setPresence(String locationId)
Establish or refresh the presence of the current session in a location.

Specified by:
setPresence in interface PresenceService
Parameters:
locationId - A presence location id.

removePresence

public void removePresence(String locationId)
Remove the presence of the current session from a location.

Specified by:
removePresence in interface PresenceService
Parameters:
locationId - A presence location id.

getPresence

public List getPresence(String locationId)
Access a List of sessions (UsageSession) now present in a location.

Specified by:
getPresence in interface PresenceService
Parameters:
locationId - A presence location id.
Returns:
The a List of sessions (UsageSession) now present in the location (may be empty).

getPresentUsers

public List getPresentUsers(String locationId)
Access a List of users (User) now present in a location.

Specified by:
getPresentUsers in interface PresenceService
Parameters:
locationId - A presence location id.
Returns:
The a List of users (User) now present in the location (may be empty).

getLocations

public List getLocations()
Access a List of all location ids (String).

Specified by:
getLocations in interface PresenceService
Returns:
The List of all location ids (Strings) (may be empty).

locationId

public String locationId(String site,
                         String page,
                         String tool)
Construct a location id from site, page, and tool.

Specified by:
locationId in interface PresenceService
Parameters:
site - The site id.
page - The page id (optional).
tool - The tool id (optional).
Returns:
a Location Id.

getLocationDescription

public String getLocationDescription(String location)
Form a description for the location.

Specified by:
getLocationDescription in interface PresenceService
Parameters:
location - The presence location.
Returns:
A description for the location.

getTimeout

public int getTimeout()
Access the time (in seconds) after which a presence will timeout.

Specified by:
getTimeout in interface PresenceService
Returns:
The time (seconds) after which a presence will timeout.

checkPresence

protected boolean checkPresence(String locationId,
                                boolean refresh)
Check if the current session is present at the location - optionally refreshing it

Parameters:
locationId - The location to check.
refresh - If true, refresh the timeout on the presence if found
Returns:
True if the current session is present at that location, false if not.

checkPresenceForExpiration

protected void checkPresenceForExpiration()
Check current session presences and remove any expired ones