org.log4jfugue
Class MessageReceiver

java.lang.Object
  extended by java.lang.Thread
      extended by org.log4jfugue.MessageReceiver
All Implemented Interfaces:
java.lang.Runnable

public class MessageReceiver
extends java.lang.Thread

Listens for log messages to process. This is the class that does the string searches to determine that a particular message of interest has been seen. When this happens the count of the associated instrument is incremented. The message can arrive from a variety of sources such as a live feed or a replay of an existing log file. The actual source does not matter to this class. A recent change to this class has been to replace the native java string search with an MIT based BoyerMoorHorspool string search that is up to 10x faster.

Author:
btarbox

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MessageReceiver()
           
 
Method Summary
 java.util.Set<java.lang.String> getInstrumentList()
          Let other classes, like the RhythmSoundBuilder get our list of instruments
 void run()
          Build the music string to send to JFugue
 void setMessages(java.util.Properties messages)
          Injected by Spring, after music is set.
 void setMusic(Music music)
          Used by Spring DI to tell class what the main Music object is
 void setReader(java.io.Reader reader)
          Used by Spring DI to tell class where to get the message Reader
 void setStatistics(org.log4jfugue.Statistics statistics)
           
 void swapCounters()
          There are two message accumulators, one is being added to and the other is being played from.
 
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, interrupt, 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
 

Constructor Detail

MessageReceiver

public MessageReceiver()
Method Detail

setReader

public void setReader(java.io.Reader reader)
Used by Spring DI to tell class where to get the message Reader

Parameters:
reader -

setStatistics

public void setStatistics(org.log4jfugue.Statistics statistics)

setMusic

public void setMusic(Music music)
Used by Spring DI to tell class what the main Music object is

Parameters:
music -

setMessages

public void setMessages(java.util.Properties messages)
Injected by Spring, after music is set. The properties object contains the definitions of the strings to look for and the instruments to associate with them

Parameters:
messages -

getInstrumentList

public java.util.Set<java.lang.String> getInstrumentList()
Let other classes, like the RhythmSoundBuilder get our list of instruments


swapCounters

public void swapCounters()
There are two message accumulators, one is being added to and the other is being played from. This method allows the player to swap the accumulators


run

public void run()
Build the music string to send to JFugue

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread