de.infinityloop.util.log
Class LogBroadcasterImpl

java.lang.Object
  extended by de.infinityloop.util.log.LogBroadcasterImpl
All Implemented Interfaces:
LogBroadcaster
Direct Known Subclasses:
LogSource

public class LogBroadcasterImpl
extends java.lang.Object
implements LogBroadcaster

A default implementation of a LogBroadcaster that handles all the housekeeping. It also adds the method broadcast() which sends the passed LogEvent to all subscribers.

Author:
Christian Roth

Field Summary
protected  java.lang.String name
          A name for this logging instance to allow for better debugging.
protected  de.infinityloop.util.WeakSet subscribers
           
 
Constructor Summary
LogBroadcasterImpl()
           
 
Method Summary
 void addLogListener(LogListener ls)
          Register a new listener with us.
 LogEvent broadcast(LogEvent le)
          Broadcast a LogEvent to all attached listeners.
 java.lang.String getName()
           
 void removeAllSubscribers()
          This method unregisters all LogSubscriber from this LogPublisher.
 void removeLogListener(LogListener ls)
          Unregister the specified listener.
 void setName(java.lang.String name)
           
 java.lang.String toString()
          instance info for debugging
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

subscribers

protected de.infinityloop.util.WeakSet subscribers

name

protected java.lang.String name
A name for this logging instance to allow for better debugging.

Constructor Detail

LogBroadcasterImpl

public LogBroadcasterImpl()
Method Detail

addLogListener

public void addLogListener(LogListener ls)
Register a new listener with us.

Specified by:
addLogListener in interface LogBroadcaster
Parameters:
ls -
See Also:
LogBroadcaster.addLogListener(de.infinityloop.util.log.LogListener)

removeLogListener

public void removeLogListener(LogListener ls)
Unregister the specified listener.

Specified by:
removeLogListener in interface LogBroadcaster
Parameters:
ls -
See Also:
LogBroadcaster.removeLogListener(de.infinityloop.util.log.LogListener)

broadcast

public LogEvent broadcast(LogEvent le)
Broadcast a LogEvent to all attached listeners.

Specified by:
broadcast in interface LogBroadcaster
Parameters:
le - the LogEvent to broadcast.
Returns:
the logging event that was supplied as parameter

removeAllSubscribers

public void removeAllSubscribers()
This method unregisters all LogSubscriber from this LogPublisher. Use this to break any links and make this object disposable to the GC.


toString

public java.lang.String toString()
instance info for debugging

Overrides:
toString in class java.lang.Object
Returns:
See Also:
Object.toString()

setName

public final void setName(java.lang.String name)
Parameters:
name - the name to set

getName

public final java.lang.String getName()
Returns:
the name