jrunx.logger
Class ThreadedLogEventHandler

jrunx.kernel.ServiceAdapter
  |
  +--jrunx.kernel.ServicePartition
        |
        +--jrunx.kernel.ConfigurableServicePartition
              |
              +--jrunx.logger.LogEventHandler
                    |
                    +--jrunx.logger.ThreadedLogEventHandler
All Implemented Interfaces:
ConfigurableServicePartitionMBean, LogEventHandlerMBean, javax.naming.Referenceable, java.lang.Runnable, java.io.Serializable, Service, ServiceMBean, ServicePartitionMBean, ThreadedLogEventHandlerMBean

public class ThreadedLogEventHandler
extends LogEventHandler
implements ThreadedLogEventHandlerMBean, java.lang.Runnable

Maintains a queue of log events and processes them in a background thread (via the Scheduler). This allows callers to post log events and not have to wait for them to be delivered.

Author:
Karl Moss
See Also:
Serialized Form

Field Summary
protected  boolean flushing
           
protected  java.util.ArrayList handlers
           
protected  java.lang.Object lockObject
           
protected  java.util.Vector queue
           
protected  int queuePointer
           
 
Fields inherited from class jrunx.kernel.ServicePartition
sortedServices
 
Fields inherited from class jrunx.kernel.ServiceAdapter
DEFAULT_DEACTIVATED, DEFAULT_DOMAIN, DOMAIN_NAME_SEPARATOR, DOMAIN_NAME_SUFFIX, domainName, jndiBindable, LOGGER_CACHE_TIME, SCHEDULER_SERVICE, SECURITY_MANAGER, server, status, TRANSACTION_MANAGER
 
Fields inherited from interface jrunx.kernel.Service
INITIALIZED, STARTED, STARTING, STOPPED, STOPPING, UNINITIALIZED
 
Constructor Summary
ThreadedLogEventHandler()
           
 
Method Summary
 void addLogEventHandler(LogEventHandler handler)
           
 void flush()
          Flushes all messages to the underlying destination
 boolean logEvent(LogEvent event)
           
protected  boolean processNextInQueue()
          Process the next entry in the queue.
 void run()
           
 void start()
          Every service other than mere data collections should start
 void stop()
          Every service other than mere data collections should stop
 
Methods inherited from class jrunx.logger.LogEventHandler
clearBuffer, getFormat, log, setFormat
 
Methods inherited from class jrunx.kernel.ConfigurableServicePartition
destroy, destroyServices, init, initServices, loadAndInit, loadChildren, setChildElements, startServices, stopServices
 
Methods inherited from class jrunx.kernel.ServicePartition
addService, addService, getServices, invokeChain, iterator, removeService, removeService
 
Methods inherited from class jrunx.kernel.ServiceAdapter
bind, findObjectInstance, findObjectInstance, findObjectInstance, getBindToJNDI, getDeactivated, getDomainName, getDomainSearchPath, getJRunService, getLogger, getName, getParentService, getReference, getResourceManager, getServerName, getServerProperties, getStatus, invokeMethod, isInPartition, isPartition, lookup, postDeregister, postRegister, preDeregister, preRegister, requestServer, scheduleRunnable, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, toString, unbind, unscheduleRunnable, updateStatus
 
Methods inherited from interface jrunx.logger.LogEventHandlerMBean
getFormat, log, setFormat
 
Methods inherited from interface jrunx.kernel.ServiceMBean
bind, getBindToJNDI, getDeactivated, getDomainName, getJRunService, getLogger, getName, getParentService, getServerName, requestServer, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, unbind
 
Methods inherited from interface jrunx.kernel.Service
destroy, getStatus, init, updateStatus
 
Methods inherited from interface jrunx.kernel.ServicePartitionMBean
addService, addService, iterator, removeService, removeService
 

Field Detail

queue

protected java.util.Vector queue

queuePointer

protected int queuePointer

flushing

protected boolean flushing

lockObject

protected java.lang.Object lockObject

handlers

protected java.util.ArrayList handlers
Constructor Detail

ThreadedLogEventHandler

public ThreadedLogEventHandler()
Method Detail

addLogEventHandler

public void addLogEventHandler(LogEventHandler handler)

start

public void start()
Description copied from class: ServiceAdapter
Every service other than mere data collections should start
Specified by:
start in interface Service
Overrides:
start in class ConfigurableServicePartition

stop

public void stop()
          throws java.lang.Exception
Description copied from class: ServiceAdapter
Every service other than mere data collections should stop
Specified by:
stop in interface Service
Overrides:
stop in class ConfigurableServicePartition

flush

public void flush()
Description copied from interface: LogEventHandlerMBean
Flushes all messages to the underlying destination
Specified by:
flush in interface LogEventHandlerMBean
Overrides:
flush in class LogEventHandler

logEvent

public boolean logEvent(LogEvent event)
Overrides:
logEvent in class LogEventHandler

run

public void run()
Specified by:
run in interface java.lang.Runnable

processNextInQueue

protected boolean processNextInQueue()
Process the next entry in the queue.
Returns:
true if there are more entires in the queue


Copyright � 2002 Macromedia Corporation. All Rights Reserved.