anon.client
Class AbstractDataChain

java.lang.Object
  extended by anon.client.AbstractDataChain
All Implemented Interfaces:
AnonChannel, java.lang.Runnable, java.util.Observer
Direct Known Subclasses:
SequentialChannelDataChain, SingleChannelDataChain

public abstract class AbstractDataChain
extends java.lang.Object
implements AnonChannel, java.util.Observer, java.lang.Runnable

Author:
Stefan Lieske

Nested Class Summary
private  class AbstractDataChain.DataChainInputStreamImplementation
           
private  class AbstractDataChain.DataChainOutputStreamImplementation
           
 
Field Summary
private  boolean m_chainClosed
           
private  IDataChannelCreator m_channelCreator
           
private  java.lang.Thread m_downstreamThread
           
private  DataChainErrorListener m_errorListener
           
private  AbstractDataChain.DataChainInputStreamImplementation m_inputStream
           
private  java.util.Vector m_messageQueuesNotifications
           
private  AbstractDataChain.DataChainOutputStreamImplementation m_outputStream
           
 
Fields inherited from interface anon.AnonChannel
HTTP, SMTP, SOCKS
 
Constructor Summary
AbstractDataChain(IDataChannelCreator a_channelCreator, DataChainErrorListener a_errorListener)
           
 
Method Summary
protected  void addInputStreamQueueEntry(DataChainInputStreamQueueEntry a_entry)
           
 void close()
          Closes the channel and releases all resources used.
protected abstract  void closeDataChain()
           
protected  AbstractDataChannel createDataChannel()
           
abstract  void createPacketPayload(DataChainSendOrderStructure a_order)
           
 java.io.InputStream getInputStream()
          The returned InputStream could be used to receive data.
protected  java.util.Vector getMessageQueuesNotificationsList()
           
abstract  int getOutputBlockSize()
          Returns a value that indicates the current optimum size of data to write..
 java.io.OutputStream getOutputStream()
          The returned OutputStream could be used to send data.
protected  void interruptDownstreamThread()
           
protected abstract  void orderPacket(DataChainSendOrderStructure a_order)
           
protected abstract  void outputStreamClosed()
           
protected  void propagateConnectionError()
           
abstract  void run()
           
 void update(java.util.Observable a_observedObject, java.lang.Object a_message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_inputStream

private AbstractDataChain.DataChainInputStreamImplementation m_inputStream

m_outputStream

private AbstractDataChain.DataChainOutputStreamImplementation m_outputStream

m_messageQueuesNotifications

private java.util.Vector m_messageQueuesNotifications

m_channelCreator

private IDataChannelCreator m_channelCreator

m_errorListener

private DataChainErrorListener m_errorListener

m_chainClosed

private boolean m_chainClosed

m_downstreamThread

private java.lang.Thread m_downstreamThread
Constructor Detail

AbstractDataChain

public AbstractDataChain(IDataChannelCreator a_channelCreator,
                         DataChainErrorListener a_errorListener)
Method Detail

getInputStream

public java.io.InputStream getInputStream()
Description copied from interface: AnonChannel
The returned InputStream could be used to receive data.

Specified by:
getInputStream in interface AnonChannel
Returns:
InputStream, useful for receiving data

getOutputStream

public java.io.OutputStream getOutputStream()
Description copied from interface: AnonChannel
The returned OutputStream could be used to send data.

Specified by:
getOutputStream in interface AnonChannel
Returns:
OutputStream, useful for sending data

close

public void close()
Description copied from interface: AnonChannel
Closes the channel and releases all resources used.

Specified by:
close in interface AnonChannel

update

public void update(java.util.Observable a_observedObject,
                   java.lang.Object a_message)
Specified by:
update in interface java.util.Observer

getMessageQueuesNotificationsList

protected java.util.Vector getMessageQueuesNotificationsList()

addInputStreamQueueEntry

protected void addInputStreamQueueEntry(DataChainInputStreamQueueEntry a_entry)

createDataChannel

protected AbstractDataChannel createDataChannel()

interruptDownstreamThread

protected void interruptDownstreamThread()

propagateConnectionError

protected void propagateConnectionError()

getOutputBlockSize

public abstract int getOutputBlockSize()
Description copied from interface: AnonChannel
Returns a value that indicates the current optimum size of data to write.. Because often anon services transport the data splited into packets for optimum performance it may be good to send data according to the packet size to avoid unneccessary overheads.

Specified by:
getOutputBlockSize in interface AnonChannel
Returns:
the current optimum size for output data. If 1 is returned the size does not matter.

createPacketPayload

public abstract void createPacketPayload(DataChainSendOrderStructure a_order)

run

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

orderPacket

protected abstract void orderPacket(DataChainSendOrderStructure a_order)

outputStreamClosed

protected abstract void outputStreamClosed()
                                    throws java.io.IOException
Throws:
java.io.IOException

closeDataChain

protected abstract void closeDataChain()