org.jacorb.orb.etf
Class StreamConnectionBase

java.lang.Object
  extended by org.omg.CORBA.LocalObject
      extended by org.omg.ETF._ConnectionLocalBase
          extended by org.jacorb.orb.etf.ConnectionBase
              extended by org.jacorb.orb.etf.StreamConnectionBase
All Implemented Interfaces:
java.io.Serializable, org.jacorb.config.Configurable, LocalInterface, Object, IDLEntity, Connection, ConnectionOperations
Direct Known Subclasses:
IIOPConnection, IIOPLoopbackConnection

public abstract class StreamConnectionBase
extends ConnectionBase

This an abstract base implementation of the ETF::Connection interface.

Version:
$Id: StreamConnectionBase.java,v 1.9 2009-05-25 02:08:03 andre.spiegel Exp $
Author:
Nicolas Noffke, Andre Spiegel
See Also:
Serialized Form

Field Summary
protected  java.io.InputStream in_stream
          Reads performed on this stream.
protected  java.io.OutputStream out_stream
          Writes performed on this stream.
 
Fields inherited from class org.jacorb.orb.etf.ConnectionBase
b_out, configuration, connected, connection_info, finalTimeout, logger, orb, profile
 
Constructor Summary
protected StreamConnectionBase()
           
protected StreamConnectionBase(StreamConnectionBase other)
          Initialise this instance as a copy of another.
 
Method Summary
 void flush()
          Causes any buffered data to be actually written to the Connection.
 boolean is_data_available()
          Simply return true if calling a read on this instance would find data in the connection.
 int read(BufferHolder data, int offset, int min_length, int max_length, long time_out)
          Reads bytes from the connection.
 void write(boolean is_first, boolean is_last, byte[] data, int offset, int length, long time_out)
          Writes bytes to this Connection.
 
Methods inherited from class org.jacorb.orb.etf.ConnectionBase
configure, get_server_profile, getLocalhost, getTimeout, handleCommFailure, is_connected, setTimeout, supports_callback, to_COMM_FAILURE, turnOnFinalTimeout, use_handle_time_out, wait_next_data
 
Methods inherited from class org.omg.ETF._ConnectionLocalBase
_ids
 
Methods inherited from class org.omg.CORBA.LocalObject
_create_request, _create_request, _duplicate, _get_component, _get_domain_managers, _get_interface_def, _get_interface, _get_policy, _hash, _invoke, _is_a, _is_equivalent, _is_local, _non_existent, _orb, _release, _releaseReply, _request, _request, _servant_postinvoke, _servant_preinvoke, _set_policy_override, validate_connection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.omg.ETF.ConnectionOperations
close, connect
 
Methods inherited from interface org.omg.CORBA.Object
_create_request, _create_request, _duplicate, _get_component, _get_domain_managers, _get_interface_def, _get_interface, _get_policy, _hash, _is_a, _is_equivalent, _non_existent, _release, _request, _set_policy_override
 

Field Detail

in_stream

protected java.io.InputStream in_stream
Reads performed on this stream.


out_stream

protected java.io.OutputStream out_stream
Writes performed on this stream.

Constructor Detail

StreamConnectionBase

protected StreamConnectionBase()

StreamConnectionBase

protected StreamConnectionBase(StreamConnectionBase other)
Initialise this instance as a copy of another. Intended for use within subclass constructors.

Method Detail

read

public int read(BufferHolder data,
                int offset,
                int min_length,
                int max_length,
                long time_out)
Reads bytes from the connection.

Parameters:
data - holds a byte array to which the bytes will be written. The field data.value must be initialized with a valid byte array already, it cannot be null.
offset - the index in data.value at which the first byte will be written.
min_length - the minimum number of bytes that shall be read from the Connection. The method will block until at least this many bytes have been read. If min_length is 0, the method will always return immediately without reading any data.
max_length - the maximum number of bytes that shall be read from the Connection. If max_length is greater than min_length, then the transport is free to read (max_length - min_length) additional bytes beyond min_length.
time_out - timeout for this particular read operation. Currently ignored in JacORB; we use socket-level timeouts.
Returns:
the number of bytes actually read. The last byte written to data.value is at the index offset + this return value. This return type is a change to the ETF draft spec in JacORB. It is needed because the mechanism suggested in the draft does not work in Java.
Throws:
TIMEOUT - if the socket-level timeout expires before the read operation completes.
TRANSIENT - if the I/O is interrupted.
COMM_FAILURE - if the read operation fails, for example because the connection has been closed.

write

public void write(boolean is_first,
                  boolean is_last,
                  byte[] data,
                  int offset,
                  int length,
                  long time_out)
Writes bytes to this Connection.

Parameters:
is_first - Currently not used in JacORB.
is_last - Currently not used in JacORB.
data - the buffer that holds the data that is to be written.
offset - index of the first byte in data that shall be written to the Connection.
length - the number of bytes in data that shall be written. The last byte in data that is written is at the index offset + length.
time_out - timeout for this particular write operation. Currently ignored in JacORB.
Throws:
COMM_FAILURE - if anything goes wrong during the write operation.

flush

public void flush()
Causes any buffered data to be actually written to the Connection.


is_data_available

public boolean is_data_available()
Simply return true if calling a read on this instance would find data in the connection. Otherwise, the function shall return false.