org.ceryle.wiki.plugin.chat
Class WikiChatManager

java.lang.Object
  extended by java.lang.Thread
      extended by org.ceryle.wiki.plugin.chat.WikiChatManager
All Implemented Interfaces:
Runnable

public class WikiChatManager
extends Thread

Provides a manager for chat events occurring on any wiki pages within a single WikiEngine. These are generated by the WikiChatPlugin, with this manager providing the page-specific filtering so that a single manager currently handles all chat activity for the WikiEngine.

Note that prior to firing an WikiChatEvent meant to be managed by this class, one should call active() so that it doesn't kill itself prior to processing the event.

See the notes regarding the per-WikiEngine or per-WikiPage decision on WikiChatManagerFactory.

See Also:
WikiEvent, WikiEventListener, WikiChatEvent

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static int default_lifespan
          The default value for the delay before the WikiChatManager dies.
protected static org.apache.log4j.Logger log
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected WikiChatManager(WikiChatManagerFactory factory, WikiEngine engine)
          Create an WikiChatManager for the provided WikiEngine.
 
Method Summary
 void active()
          Called to indicate activity and keep this WikiChatManager alive.
 String getColorForUser(Principal user)
          Returns a color specification for the given user.
static List getColors()
          Returns a List of color specifications.
 WikiChatRecord getRecordForPage(String pagename)
          Returns the List of chat events associated with the wiki page identified by pagename.
 String getTimeString(long timestamp)
          Returns a formatted String representing the timestamp.
 boolean hasWikiChatListener(WikiEventListener listener)
          Returns true if the WikiEventManager is already listening with this WikiChatManager's WikiEventListener.
 void interrupt()
          Overrides the superclass to disable this being called externally.
 boolean isListenerEnabled()
          Returns the enabled state of this WikiChatManager's WikiEventListener.
protected  void kill()
          A synonym method that just calls Thread.interrupt().
 void run()
          Once started, will kill itself after time delay if no activity.
protected  void setLifespan(int seconds)
          Sets the lifespan to the number of seconds.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Logger log

default_lifespan

public static final int default_lifespan
The default value for the delay before the WikiChatManager dies.

See Also:
Constant Field Values
Constructor Detail

WikiChatManager

protected WikiChatManager(WikiChatManagerFactory factory,
                          WikiEngine engine)
Create an WikiChatManager for the provided WikiEngine.

Parameters:
engine - the WikiEngine backing the event handling.
Method Detail

run

public void run()
Once started, will kill itself after time delay if no activity.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

interrupt

public void interrupt()
Overrides the superclass to disable this being called externally. Use kill() instead.

Overrides:
interrupt in class Thread

kill

protected void kill()
A synonym method that just calls Thread.interrupt().


getRecordForPage

public WikiChatRecord getRecordForPage(String pagename)
Returns the List of chat events associated with the wiki page identified by pagename.


hasWikiChatListener

public boolean hasWikiChatListener(WikiEventListener listener)
Returns true if the WikiEventManager is already listening with this WikiChatManager's WikiEventListener.


isListenerEnabled

public boolean isListenerEnabled()
Returns the enabled state of this WikiChatManager's WikiEventListener. If the listener is disabled, the internal registry should be considered invalid.


setLifespan

protected void setLifespan(int seconds)
Sets the lifespan to the number of seconds. Permitted values are -1 (for an infinite lifespan), or 30 to 86400 (24 hours). A zero value is ignored. If not set the default value is 60 seconds.


active

public void active()
Called to indicate activity and keep this WikiChatManager alive.

This creates a timer that if permitted to complete will kill the manager. Calling this method resets the Timer.


getColorForUser

public String getColorForUser(Principal user)
Returns a color specification for the given user. This is assigned upon first encounter and recycles after reaching the end of the list.


getTimeString

public String getTimeString(long timestamp)
Returns a formatted String representing the timestamp.


getColors

public static List getColors()
Returns a List of color specifications.



The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.