cnrg.itx.datax
Class Connection

java.lang.Object
  |
  +--java.util.Observable
        |
        +--cnrg.itx.datax.Connection
Direct Known Subclasses:
AudioConnection

public abstract class Connection
extends java.util.Observable
implements Statistics, java.lang.Runnable, Properties

Abstract class for creating and managing an endpoint of communication. Each Connection has two different "channels" an input channel and an output channel. Both channels collect data from sources and pipe it to destinations. The input channel is intended to "collect" data while the output channel is intended to distribute data. However, it is possible not to follow these conventions with the system still functioning. We distinguish between input and output for naming reasons only -- they have the same functionality.


Field Summary
(package private)  Channel input
           
(package private)  Channel output
           
(package private)  boolean running
           
(package private)  Stats s
           
private static int SLEEPTIME
           
(package private)  java.lang.Thread t
           
 
Fields inherited from class java.util.Observable
changed, obs
 
Constructor Summary
Connection(Channel input, Channel output)
          Creates a connection.
 
Method Summary
 void close()
          Stops sending data in the channel.
 Channel getInputChannel()
          Interface to get the input channel.
 Channel getOutputChannel()
          Interface to get the output channel.
 PropertiesCollection getProperties()
          Gets the properties for this audioConnection
 Stats getStatistics()
          Interface to get the statistics for the connection.
 void open()
          Begins sending data in the channel.
 void run()
          Method to implement the connection thread.
 void setInputChannel(Channel c)
          Sets a new input channel.
 void setOutputChannel(Channel c)
          Sets a new output channel.
 void setPeerProperties(PropertiesCollection pc)
          Interface to set the given properties collection into the device.
 void setProperties(PropertiesCollection pc)
          Sets the properties for this audioConnection
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

SLEEPTIME

private static final int SLEEPTIME

s

Stats s

input

Channel input

output

Channel output

t

java.lang.Thread t

running

boolean running
Constructor Detail

Connection

public Connection(Channel input,
                  Channel output)
Creates a connection.
Parameters:
input - The channel which is inteded to collect data.
output - The channel which distributes data.
Method Detail

getInputChannel

public Channel getInputChannel()
Interface to get the input channel.
Returns:
Channel the input channel

getOutputChannel

public Channel getOutputChannel()
Interface to get the output channel.
Returns:
Channel the output channel

setInputChannel

public void setInputChannel(Channel c)
Sets a new input channel.

The old channel should be closed to free its resources.

Parameters:
c - The new input channel

setOutputChannel

public void setOutputChannel(Channel c)
Sets a new output channel. The old channel should be closed to free its resources.
Parameters:
c - The new output channel

getStatistics

public Stats getStatistics()
Interface to get the statistics for the connection.
Specified by:
getStatistics in interface Statistics
Returns:
Stats the statistics corresponding to the channel

getProperties

public PropertiesCollection getProperties()
Gets the properties for this audioConnection
Specified by:
getProperties in interface Properties
Returns:
the ProertiesCollection

setProperties

public void setProperties(PropertiesCollection pc)
Sets the properties for this audioConnection
Specified by:
setProperties in interface Properties

setPeerProperties

public void setPeerProperties(PropertiesCollection pc)
                       throws DataException
Interface to set the given properties collection into the device. WOrks under the assumption that this is the properties collection of the peer.
Specified by:
setPeerProperties in interface Properties

run

public void run()
Method to implement the connection thread.
Specified by:
run in interface java.lang.Runnable

open

public void open()
          throws DataException
Begins sending data in the channel. Calls open on both channels, which will call open on all devices attached to the channel.
Throws:
DataException - thrown after reopening a device that has already been closed.

close

public void close()
Stops sending data in the channel. Calls close on both channels, which closes all devices attached to the channel. Note: Once a devide has been closed, it cannot be reopened.