de.novanic.eventservice.service.registry.user
Class UserActivityScheduler

java.lang.Object
  extended by de.novanic.eventservice.service.registry.user.UserActivityScheduler

public class UserActivityScheduler
extends java.lang.Object

UserActivityScheduler observes the activities of the users/clients and can report timeouts. To observe the users/clients, the UserActivityScheduler must be started with the start method (start(boolean)).

Author:
sstrohschein
Date: 20.01.2009
Time: 23:30:47

Constructor Summary
protected UserActivityScheduler(java.util.Collection<UserInfo> aUserInfoCollection, long aTimeoutInterval)
          Creates a new UserActivityScheduler with a reference to a Collection of UserInfo.
 
Method Summary
 void addTimeoutListener(UserTimeoutListener aTimeoutListener)
          Adds a UserTimeoutListener to the UserActivityScheduler.
 long getTimeoutInterval()
          Returns the configured timeout time/interval.
 boolean isActive()
          Returns the state of the UserActivityScheduler.
 void removeTimeoutListener(UserTimeoutListener aTimeoutListener)
          Removes a UserTimeoutListener from the UserActivityScheduler.
 void removeTimeoutListeners()
          Removes all UserTimeoutListener from the UserActivityScheduler.
 void reportUserActivity(UserInfo aUserInfo)
          That method must be called to report a user activity and protects the user from a timeout for the time of the timeout interval (EventServiceConfiguration.getTimeoutTime()).
 void start(boolean isAutoClean)
          That method starts the UserActivityScheduler to observe the users/clients.
 void stop()
          Stops the UserActivityScheduler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserActivityScheduler

protected UserActivityScheduler(java.util.Collection<UserInfo> aUserInfoCollection,
                                long aTimeoutInterval)
Creates a new UserActivityScheduler with a reference to a Collection of UserInfo.

Parameters:
aUserInfoCollection - all UserInfo instances to observe
aTimeoutInterval - milliseconds to the timeout
Method Detail

addTimeoutListener

public void addTimeoutListener(UserTimeoutListener aTimeoutListener)
Adds a UserTimeoutListener to the UserActivityScheduler.

Parameters:
aTimeoutListener - listener to get reported timeouts

removeTimeoutListener

public void removeTimeoutListener(UserTimeoutListener aTimeoutListener)
Removes a UserTimeoutListener from the UserActivityScheduler.

Parameters:
aTimeoutListener - listener to get reported timeouts

removeTimeoutListeners

public void removeTimeoutListeners()
Removes all UserTimeoutListener from the UserActivityScheduler.


start

public void start(boolean isAutoClean)
That method starts the UserActivityScheduler to observe the users/clients. The activities will be checked like the timeout interval is configured (EventServiceConfiguration.getTimeoutTime()).

Parameters:
isAutoClean - when set to true, the users/clients are removed automatically on timeout

stop

public void stop()
Stops the UserActivityScheduler. At that point, the users/clients won't be observed anymore.


isActive

public boolean isActive()
Returns the state of the UserActivityScheduler. Returns true when the UserActivityScheduler is started (start(boolean)) and false when the UserActivityScheduler isn't started or stopped (stop()).

Returns:
true when running/started, false when running (not started or stopped)

getTimeoutInterval

public long getTimeoutInterval()
Returns the configured timeout time/interval. The user activity is checked in that interval.

Returns:
timeout time/interval

reportUserActivity

public void reportUserActivity(UserInfo aUserInfo)
That method must be called to report a user activity and protects the user from a timeout for the time of the timeout interval (EventServiceConfiguration.getTimeoutTime()).

Parameters:
aUserInfo - user/client to refresh