de.anneck.jcast.sources
Class AbstractSourceThread

java.lang.Object
  |
  +--de.anneck.jcast.core.AbstractThread
        |
        +--de.anneck.jcast.sources.AbstractSourceThread
All Implemented Interfaces:
org.apache.avalon.framework.configuration.Configurable, ISignal, ISource, ISourceThread, IStartable, IThread, java.lang.Runnable
Direct Known Subclasses:
FileSourceThread, PlaylistSourceThread, SimpleSourceThread

public abstract class AbstractSourceThread
extends AbstractThread
implements ISourceThread

This class implements all methods common to SourceThreads. Extends this class if you need to create a new type of ISourceThread.

Version:
$Revision: 1.13 $
Author:

Field Summary
protected  IChannel m_channel
          A source is alsways with a Channel
protected  boolean m_channel_ready
          Channel state
protected  java.lang.String m_Identifying_Name
          The identifying name of this source.
protected  java.util.List m_listeners
          The listeners of this source
protected  boolean m_waitForListeners
          Option wait for listeners
protected  SimpleTime timer
          Timer
 
Fields inherited from class de.anneck.jcast.core.AbstractThread
m_class, m_log, m_mutex, m_name, m_prio, m_state
 
Fields inherited from interface de.anneck.jcast.core.IThread
RUNNING, STOPPED, WAITING
 
Fields inherited from interface de.anneck.jcast.core.ISignal
BUSY, CHANNEL_IS_BUSY, CHANNEL_IS_READY, CLIENT_DISCONNECTED, HELO, READY, SOURCE_GONE
 
Constructor Summary
AbstractSourceThread()
          Creates new AbstractSourceThread
 
Method Summary
 void addListener(IListener listener)
          Subscribes a IListener into this ISource.
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
          Configures the Source.
 boolean equals(java.lang.Object obj)
          Returns true if 2 sources have the same identifying name.
 IChannel getChannel()
          Returns the channel of this source
 java.lang.String getIdentifyingName()
          Returns the unique name for the Source
 java.util.List getSubscribedListeners()
          Returns all subscribes listeners of this ISource.
 int hashCode()
          Vanialla hashCode().
 void receiveSignal(java.lang.Object source, int signal)
          Receives a signal.
 void removeListener(IListener listener)
          Removes one IListener from my ISources.
 void send()
          Sends the internal byte[] of the source.
 void send(byte[] b)
          Sends the specified byte to the IChannel.
 void setChannel(IChannel channel)
          Sets the channel of this Source
 void setIdentifyingName(java.lang.String idName)
          Sets a unique name for a source
 void signal(java.lang.Object target, int theSignal)
          Sends a signal to target object.
 java.lang.String toString()
          The name of the source.
 
Methods inherited from class de.anneck.jcast.core.AbstractThread
checkState, doKill, doRestart, doStart, doStop, getAllThreads, getThreadClass, getThreadName, getThreadPriority, isRunning, isStopped, isWaiting, run, setState, setThreadPriority
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.anneck.jcast.core.IThread
checkState, doKill, doRestart, doStart, doStop, doWork, getThreadClass, getThreadName, getThreadPriority, isRunning, isStopped, isWaiting, setState, setThreadPriority
 
Methods inherited from interface java.lang.Runnable
run
 

Field Detail

m_Identifying_Name

protected java.lang.String m_Identifying_Name
The identifying name of this source.

m_channel

protected IChannel m_channel
A source is alsways with a Channel

m_listeners

protected java.util.List m_listeners
The listeners of this source

m_channel_ready

protected boolean m_channel_ready
Channel state

timer

protected SimpleTime timer
Timer

m_waitForListeners

protected boolean m_waitForListeners
Option wait for listeners
Constructor Detail

AbstractSourceThread

public AbstractSourceThread()
Creates new AbstractSourceThread
Method Detail

setChannel

public final void setChannel(IChannel channel)
                      throws SourceException
Sets the channel of this Source
Specified by:
setChannel in interface ISource
Parameters:
channel - The IChannel this source is sending to.

getChannel

public final IChannel getChannel()
Returns the channel of this source
Specified by:
getChannel in interface ISource
Returns:
IChannel The current channel.

setIdentifyingName

public final void setIdentifyingName(java.lang.String idName)
Sets a unique name for a source
Specified by:
setIdentifyingName in interface ISource
Parameters:
idName - The unique name.

getIdentifyingName

public final java.lang.String getIdentifyingName()
Returns the unique name for the Source
Specified by:
getIdentifyingName in interface ISource
Returns:
The unique name.

addListener

public final void addListener(IListener listener)
                       throws SourceException
Subscribes a IListener into this ISource.
Specified by:
addListener in interface ISource
Parameters:
listener - The IListener to add.

removeListener

public final void removeListener(IListener listener)
                          throws SourceException,
                                 NoSuchListenerException
Removes one IListener from my ISources.
Specified by:
removeListener in interface ISource
Parameters:
listener - The IListener to remove.

getSubscribedListeners

public final java.util.List getSubscribedListeners()
Returns all subscribes listeners of this ISource.
Specified by:
getSubscribedListeners in interface ISource
Returns:
A list of listeners.

send

public final void send()
Sends the internal byte[] of the source.
Specified by:
send in interface ISource

send

public final void send(byte[] b)
Sends the specified byte to the IChannel.
Specified by:
send in interface ISource
Parameters:
b - The byte to send.

receiveSignal

public final void receiveSignal(java.lang.Object source,
                                int signal)
Receives a signal.
Specified by:
receiveSignal in interface ISignal
Parameters:
source - The sending object.
signal - The signal.

signal

public final void signal(java.lang.Object target,
                         int theSignal)
Sends a signal to target object.
Specified by:
signal in interface ISignal
Parameters:
target - The target object.
theSignal - The signal to send.

toString

public java.lang.String toString()
The name of the source.
Overrides:
toString in class java.lang.Object
Returns:
The name.

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Configures the Source. This is the place where filename, playmode, etc. are set.
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Parameters:
configuration - The configuration object.
Throws:
org.apache.avalon.framework.configuration.ConfigurationException - Error during configuration.

equals

public boolean equals(java.lang.Object obj)
Returns true if 2 sources have the same identifying name.
Overrides:
equals in class java.lang.Object
Parameters:
The - object to compare

hashCode

public int hashCode()
Vanialla hashCode().
Overrides:
hashCode in class java.lang.Object
Returns:
The hashcode of this object.