com.mindtree.techworks.insight.receiver
Class AbstractReceiver

java.lang.Object
  extended by java.lang.Thread
      extended by com.mindtree.techworks.insight.receiver.AbstractReceiver
All Implemented Interfaces:
ILogEventModelMutator, ReceiverInterpreter, java.lang.Runnable
Direct Known Subclasses:
FileStreamReceiver, RemoteProtocolStreamReceiver

public abstract class AbstractReceiver
extends java.lang.Thread
implements ReceiverInterpreter, ILogEventModelMutator

The AbstractReceiver class is an abstraction of functionality common to all Insight receiver implementations. This class doesnot notify registered Log4j Appender instances. Instead it notifies those appenders that have been registered directly with this class using

#addAppender(Appender appender)

The appenders are notified for every LoggingEvent successfully parsed/received by this receiver. This AbstractReceiver processes events in an asynchronous manner using callback methods on derived implementations for events and their availability.

Version:
1.0, 05/07/05
Author:
Regunath B

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  long interpretedEventCount
          Count of events interpreted by this Receiver
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface com.mindtree.techworks.insight.receiver.ReceiverInterpreter
FAILURE, SUCCESS
 
Fields inherited from interface com.mindtree.techworks.insight.model.ILogEventModelMutator
FAILURE, NON_TAILING_MUTATOR, SUCCESS, TAILING_MUTATOR
 
Constructor Summary
AbstractReceiver()
           
 
Method Summary
 void addAppender(org.apache.log4j.Appender appender)
          Adds the specified Appender for notification when a LoggingEvent has been parsed
 void addMutatorListener(IMutatorListener mutatorListener)
          Adds the specified MutatorListener
 void addReceiverListener(ReceiverListener receiverListener)
          Adds the specified ReceiverListener for notification when a ReceiverSpecifc Events will occur.
protected abstract  void deInitialize()
          Informs this AbstractReceiver to reset itself.
abstract  LogNamespace[] getNamespaces()
          Returns the LogNamespace that this AbstractReceiver was initialized with
protected abstract  LogEvent[] getNextEvents()
          Gets null or the next LoggingEvent(s) processed by this receiver
protected abstract  boolean hasMoreEvents()
          Determines if this receiver has any more events to process
protected abstract  void initialize(LogNamespace namespace, boolean isTailing)
          Informs this AbstractReceiver to initialize itself.
abstract  boolean isTailing()
          Returns true if this AbstractReceiver tails the LogNamespace
 void removeAppender(org.apache.log4j.Appender appender)
          Removes the specified Appender for notification when a LoggingEvent has been parsed
 void removeMutatorListener(IMutatorListener mutatorListener)
          Removes the specified MutatorListener
 void removeReceiverListener(ReceiverListener receiverListener)
          Removes the specified ReceiverListener for notification when a ReceiverSpecifc Events will occur.
 void run()
          Overriden Thread super class method
 void shutdown()
          Informs this receiver to stop processing events from the log namespace.
 void startup()
          Informs this receiver to start processing events from the log namespace.
 
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
 

Field Detail

interpretedEventCount

protected long interpretedEventCount
Count of events interpreted by this Receiver

Constructor Detail

AbstractReceiver

public AbstractReceiver()
Method Detail

addAppender

public void addAppender(org.apache.log4j.Appender appender)
Adds the specified Appender for notification when a LoggingEvent has been parsed

Parameters:
appender - the Appender instance to be added to the appender list

removeAppender

public void removeAppender(org.apache.log4j.Appender appender)
Removes the specified Appender for notification when a LoggingEvent has been parsed

Parameters:
appender - the Appender instance to be added to the appender list

addReceiverListener

public void addReceiverListener(ReceiverListener receiverListener)
Adds the specified ReceiverListener for notification when a ReceiverSpecifc Events will occur.

Specified by:
addReceiverListener in interface ReceiverInterpreter
Parameters:
receiverListener - the ReceiverListener instance to be added to the receiverListener list

removeReceiverListener

public void removeReceiverListener(ReceiverListener receiverListener)
Removes the specified ReceiverListener for notification when a ReceiverSpecifc Events will occur.

Specified by:
removeReceiverListener in interface ReceiverInterpreter
Parameters:
receiverListener - the ReceiverListener instance to be added to the receiverListener list

addMutatorListener

public void addMutatorListener(IMutatorListener mutatorListener)
Adds the specified MutatorListener

Specified by:
addMutatorListener in interface ILogEventModelMutator
Parameters:
mutatorListener - the IMutatorListener to add

removeMutatorListener

public void removeMutatorListener(IMutatorListener mutatorListener)
Removes the specified MutatorListener

Specified by:
removeMutatorListener in interface ILogEventModelMutator
Parameters:
mutatorListener - the MutatorListener to remove

startup

public void startup()
Informs this receiver to start processing events from the log namespace.


run

public void run()
Overriden Thread super class method

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread
See Also:
Thread.run()

shutdown

public void shutdown()
Informs this receiver to stop processing events from the log namespace.


getNamespaces

public abstract LogNamespace[] getNamespaces()
Returns the LogNamespace that this AbstractReceiver was initialized with

Returns:
Returns the namespace.

isTailing

public abstract boolean isTailing()
Returns true if this AbstractReceiver tails the LogNamespace

Returns:
the isTailing value specified during initialization
See Also:
initialize(LogNamespace, boolean)

initialize

protected abstract void initialize(LogNamespace namespace,
                                   boolean isTailing)
                            throws ReceiverInitializationException
Informs this AbstractReceiver to initialize itself. This method is called after the no args constructor of the specific derived instance has been called. Tailing receivers require an explicit call to shutdown() to stop receiving events from the specified LogNamespace.

Parameters:
namespace - the LogNamespace that this AbstractReceiver will process events from
isTailing - determines if this AbstractReceiver tails the specified LogNamespace
Throws:
ReceiverInitializationException - if any problems occurs during the initialization of receiver.
See Also:
shutdown()

deInitialize

protected abstract void deInitialize()
Informs this AbstractReceiver to reset itself. This method is called post shutdown to let this class cleanup and release resources such socket connections, input streams e.t.c.


getNextEvents

protected abstract LogEvent[] getNextEvents()
Gets null or the next LoggingEvent(s) processed by this receiver

Returns:
null or the LoggingEvent instance

hasMoreEvents

protected abstract boolean hasMoreEvents()
Determines if this receiver has any more events to process

Returns:
true if events exist in the log namespace for processing


Copyright © 2003-2008 MindTree Consulting Ltd.. All Rights Reserved.