|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.anneck.jcast.core.AbstractThread | +--de.anneck.jcast.channels.AbstractChannelThread
AbstractChannelThread the abstract implementation of the "bus" for Sources and Listeners. The Channel implements the "Bus" of a Producer-Bus-Consumer pattern.
Field Summary | |
protected int |
m_dist_timeout
Timeout between each packet distribution |
protected java.lang.String |
m_Identifying_Name
The identifying name of this channel. |
protected java.lang.String |
m_listener_response
The listener respones header |
protected java.util.List |
m_Listeners
All listeners subscribed to this channel. |
protected java.lang.String |
m_source_response
The source response header |
protected java.util.List |
m_Sources
All sources feeding this channel. |
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 |
Constructor Summary | |
AbstractChannelThread()
Creates new Channel |
Method Summary | |
void |
add(IListener listener)
Adds a listener into the Channel. |
void |
add(IListener listener,
ISource source)
Adds a listener into the Channel listening to the specified source only. |
void |
add(ISource source)
Adds a source into the Channel. |
void |
configure(org.apache.avalon.framework.configuration.Configuration configuration)
Configures a SimpleChannel. |
java.lang.String |
getIdentifyingName()
Returns the unique name for the Channel |
java.lang.String |
getListenerResponseHeader()
Returns the current ListenerResponseHeader |
java.util.List |
getListeners()
Returns a list of all listeners. |
java.util.List |
getListeners(ISource source)
Returns a list of all listeners, subscribed to source. |
java.lang.String |
getSourceResponseHeader()
Returns the current SourceResponseHeader |
java.util.List |
getSources()
Returns a list of all sources. |
java.lang.String |
getStats()
Returns some statistiks infos, for debugging mainly. |
void |
remove(IListener listener)
Removes a IListner from the Channel. |
void |
remove(IListener listener,
ISource source)
Removes the IListener from the specified ISource in the Channel. |
void |
remove(ISource source)
Removes a ISource from the Channel. |
void |
send(byte[] b)
Sends the specified byteArray to all listeners in the channel |
void |
send(byte[] b,
ISource source)
Sends the specified byteArray to all subscribed listeners. |
void |
setIdentifyingName(java.lang.String idName)
Sets a unique name for a channel. |
void |
setListenerResponseHeader(java.lang.String resHeader)
Sets the response header to be send to listeners connecting to this channel |
void |
setSourceResponseHeader(java.lang.String resHeader)
Sets the response header to be send to sources connecting to this channel |
java.lang.String |
toString()
Returns a meaningfull string of the ChannelThread. |
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, equals, finalize, getClass, hashCode, 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 |
protected java.util.List m_Listeners
protected java.util.List m_Sources
protected java.lang.String m_Identifying_Name
protected java.lang.String m_listener_response
protected java.lang.String m_source_response
protected int m_dist_timeout
Constructor Detail |
public AbstractChannelThread()
Method Detail |
public final void add(ISource source) throws ChannelException
add
in interface IChannel
source
- The source to be added. Must implement ISource
.public final void remove(ISource source) throws ChannelException
remove
in interface IChannel
source
- A valid ISourceA
- Channel excpetionpublic final void add(IListener listener) throws ChannelException
add
in interface IChannel
listener
- The listener to be added. Must implement IListener
.ChannelException
- only if an otherwise successfull attempt to add
the listener into the channel failed for an internal reason. If you try
to add a listener that is already listening to this channel a warning is
logged but no exception is throw.public final void remove(IListener listener) throws ChannelException
ISingleSource
type of Channel than the listener is also removed from the source.remove
in interface IChannel
listener
- The IListener to be removed.ChannelException
- if the specified listener is not inside of this
channel or if an otherwise successfull attempt to remove the specified
listener fails.public final void add(IListener listener, ISource source) throws ChannelException
add
in interface IChannel
listener
- The listener to be added. Must implement IListener
.source
- The source to listen to. Must implement ISource
.ChannelException
- if the specified ISource
is not registered within
this IChannel
. Also if the ISource
exists but fails to subscribe the IListener
to the specified ISource
.public final void remove(IListener listener, ISource source) throws ChannelException
remove
in interface IChannel
listener
- The IListener to be removed.source
- The ISource to which the specified IListener is subscribed.public final void send(byte[] b, ISource source)
send
in interface IChannel
b
- The byte[] array.source
- The sending ISourcepublic final void send(byte[] b)
b
- The byteArray to be send.public final java.lang.String getIdentifyingName()
getIdentifyingName
in interface IChannel
public final void setIdentifyingName(java.lang.String idName)
setIdentifyingName
in interface IChannel
idName
- The unique name for the IChannelpublic final void setListenerResponseHeader(java.lang.String resHeader)
setListenerResponseHeader
in interface IChannel
resHeader
- The response header.public final java.lang.String getListenerResponseHeader()
getListenerResponseHeader
in interface IChannel
public final void setSourceResponseHeader(java.lang.String resHeader)
setSourceResponseHeader
in interface IChannel
resHeader
- The response header.public final java.lang.String getSourceResponseHeader()
getSourceResponseHeader
in interface IChannel
public java.lang.String getStats()
public java.lang.String toString()
toString
in class java.lang.Object
public void configure(org.apache.avalon.framework.configuration.Configuration configuration) throws org.apache.avalon.framework.configuration.ConfigurationException
configure
in interface org.apache.avalon.framework.configuration.Configurable
configuration
- The configuration object.org.apache.avalon.framework.configuration.ConfigurationException
- Error during configuration.public final java.util.List getSources()
getSources
in interface IChannel
public final java.util.List getListeners()
getListeners
in interface IChannel
public final java.util.List getListeners(ISource source)
getListeners
in interface IChannel
source
- The target source.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |