org.openorb.orb.net
Class AbstractSocketStreamDecorationStrategy

java.lang.Object
  extended by org.openorb.orb.net.AbstractSocketStreamDecorationStrategy
All Implemented Interfaces:
SocketStreamDecorationStrategy

public abstract class AbstractSocketStreamDecorationStrategy
extends java.lang.Object
implements SocketStreamDecorationStrategy

A abstract base class that provides exception checking and autoclosing of streams.

Version:
$Revision: 1.1 $ $Date: 2004/05/14 00:36:25 $
Author:
Richard G Clark

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.openorb.orb.net.SocketStreamDecorationStrategy
SocketStreamDecorationStrategy.Factory
 
Constructor Summary
protected AbstractSocketStreamDecorationStrategy()
           
 
Method Summary
protected  void closeStream(java.io.InputStream stream)
          Closes the stream.
protected  void closeStream(java.io.OutputStream stream)
          Closes the stream.
 java.io.InputStream decorate(java.net.Socket socket, java.io.InputStream stream)
          Creates a decorated InputStream.
 java.io.OutputStream decorate(java.net.Socket socket, java.io.OutputStream stream)
          Creates a decorated OutputStream.
protected  void exceptionDuringStreamClose(java.io.InputStream stream, java.lang.Exception e)
          Called when an exception is thrown during a call to closeStream.
protected  void exceptionDuringStreamClose(java.io.OutputStream stream, java.lang.Exception e)
          Called when an exception is thrown during a call to closeStream.
protected  java.io.InputStream uncheckedDecorate(java.net.Socket socket, java.io.InputStream stream)
          Creates a decorated InputStream.
protected  java.io.OutputStream uncheckedDecorate(java.net.Socket socket, java.io.OutputStream stream)
          Creates a decorated OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSocketStreamDecorationStrategy

protected AbstractSocketStreamDecorationStrategy()
Method Detail

decorate

public final java.io.InputStream decorate(java.net.Socket socket,
                                          java.io.InputStream stream)
                                   throws java.io.IOException
Creates a decorated InputStream.

Specified by:
decorate in interface SocketStreamDecorationStrategy
Parameters:
socket - the source of the original stream
stream - the stream to be decorated
Returns:
a decorated InputStream.
Throws:
java.io.IOException - if an I/O error occurs while creating the socket.

decorate

public final java.io.OutputStream decorate(java.net.Socket socket,
                                           java.io.OutputStream stream)
                                    throws java.io.IOException
Creates a decorated OutputStream.

Specified by:
decorate in interface SocketStreamDecorationStrategy
Parameters:
socket - the source of the original stream
stream - the stream to be decorated
Returns:
a decorated OutputStream.
Throws:
java.io.IOException - if an I/O error occurs while creating the socket.

uncheckedDecorate

protected java.io.InputStream uncheckedDecorate(java.net.Socket socket,
                                                java.io.InputStream stream)
                                         throws java.io.IOException
Creates a decorated InputStream.

Parameters:
socket - the source of the original stream
stream - the stream to be decorated
Returns:
a decorated InputStream.
Throws:
java.io.IOException - if an I/O error occurs while creating the socket.

uncheckedDecorate

protected java.io.OutputStream uncheckedDecorate(java.net.Socket socket,
                                                 java.io.OutputStream stream)
                                          throws java.io.IOException
Creates a decorated OutputStream.

Parameters:
socket - the source of the original stream
stream - the stream to be decorated
Returns:
a decorated OutputStream.
Throws:
java.io.IOException - if an I/O error occurs while creating the socket.

closeStream

protected void closeStream(java.io.InputStream stream)
Closes the stream. If an exception is thrown while closing the stream the exceptionDuringStreamClose is called.

Parameters:
stream - the stream to be closed

closeStream

protected void closeStream(java.io.OutputStream stream)
Closes the stream. If an exception is thrown while closing the stream the exceptionDuringStreamClose is called.

Parameters:
stream - the stream to be closed

exceptionDuringStreamClose

protected void exceptionDuringStreamClose(java.io.InputStream stream,
                                          java.lang.Exception e)
Called when an exception is thrown during a call to closeStream.

Parameters:
stream - the stream the threw the exception
e - the exception thrown

exceptionDuringStreamClose

protected void exceptionDuringStreamClose(java.io.OutputStream stream,
                                          java.lang.Exception e)
Called when an exception is thrown during a call to closeStream.

Parameters:
stream - the stream the threw the exception
e - the exception thrown