BEA Systems, Inc.

com.connecterra.ale.reader
Class ByteStreamDeviceChannel

java.lang.Object
  extended by com.connecterra.ale.reader.DeviceChannel
      extended by com.connecterra.ale.reader.SocketDeviceChannel
          extended by com.connecterra.ale.reader.ByteStreamDeviceChannel

public class ByteStreamDeviceChannel
extends com.connecterra.ale.reader.SocketDeviceChannel

A DeviceChannel implemented by a TCP connection initiated by the device driver. It extends the SocketDeviceChannel to provide buffering on the input and output streams.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.connecterra.ale.reader.SocketDeviceChannel
com.connecterra.ale.reader.SocketDeviceChannel.BlockingSocketInputListener, com.connecterra.ale.reader.SocketDeviceChannel.SocketInputListener
 
Nested classes/interfaces inherited from class com.connecterra.ale.reader.DeviceChannel
DeviceChannel.AbstractOpenChannel, DeviceChannel.MarkingInputStream
 
Constructor Summary
ByteStreamDeviceChannel(PluginConfig rc, String portName)
          Creates a new ByteStreamDeviceChannel instance where the remote host is read from the hostname parameter and the remote port is read from the parameter named by the portName argument in the given PluginConfig.
 
Method Summary
 BufferedInputStream getInputStream()
          Returns a BufferedInputStream for reading from an open channel.
 BufferedOutputStream getOutputStream()
           
 
Methods inherited from class com.connecterra.ale.reader.SocketDeviceChannel
addDeviceAttributes, addToPluginMeta, addToPluginMeta, close, getHostname, getPort, getSocket, open, ready, setBlockingListener, setListener, toString
 
Methods inherited from class com.connecterra.ale.reader.DeviceChannel
getLogger, getReactor, markUsed, reactivateChannels
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ByteStreamDeviceChannel

public ByteStreamDeviceChannel(PluginConfig rc,
                               String portName)
                        throws com.connecterra.ale.resources.PluginLoadException
Creates a new ByteStreamDeviceChannel instance where the remote host is read from the hostname parameter and the remote port is read from the parameter named by the portName argument in the given PluginConfig. The timeout for socket operations is read from the socketTimeout parameter in the PluginConfig.

Parameters:
portName - the String key name of the remote port parameter
Throws:
com.connecterra.ale.resources.PluginLoadException - if a configuration error occurs
Method Detail

getInputStream

public BufferedInputStream getInputStream()
                                   throws IOException
Returns a BufferedInputStream for reading from an open channel.

If this method is used by a driver which expects to receive data asynchronously, and this method is used to read a synchronous result from a command, then there is a pitfall to avoid: if the device sent asynchronous data before the synchronous command was received and processed, then the command "response" may actually be the asynchronous data. The reader should be aware of this, and be prepared to handle the asynchronous data, either immediately or by queueing it for later processing.

Overrides:
getInputStream in class com.connecterra.ale.reader.SocketDeviceChannel
Returns:
a BufferedInputStream for reading from an open channel.
Throws:
IOException - if the channel is not open

getOutputStream

public BufferedOutputStream getOutputStream()
                                     throws IOException
Overrides:
getOutputStream in class com.connecterra.ale.reader.SocketDeviceChannel
Returns:
a BufferedOutputStream for writing to an open channel.
Throws:
IOException - if the channel is not open

Documentation is available at
${DOCSWEBROOT}
Copyright 2007 BEA Systems Inc.