FileDocCategorySizeDatePackage
StreamConnectionElement.javaAPI DocphoneME MR2 API (J2ME)5796Wed May 02 18:00:14 BST 2007com.sun.midp.io.j2me.http

StreamConnectionElement

public class StreamConnectionElement extends Object implements javax.microedition.io.StreamConnection
This class implements the necessary functionality for an HTTP connection pool element container. Each element contains appropriate http connection information including a reference to the underlying socket stream connection.
version
1.0

Fields Summary
String
m_protocol
Current protocol.
String
m_host
Current host name.
int
m_port
Http port number.
private javax.microedition.io.StreamConnection
m_stream
Connection stream to http server.
private DataInputStream
m_data_input_stream
Input stream to http server.
private DataOutputStream
m_data_output_stream
Output stream to http server.
boolean
m_in_use
In use flag.
long
m_time
Start time in milliseconds.
boolean
m_removed
Removed from pool flag while in use. (lingered too long)
Constructors Summary
StreamConnectionElement(String p_protocol, String p_host, int p_port, javax.microedition.io.StreamConnection p_sc, DataOutputStream p_dos, DataInputStream p_dis)
Create a new instance of this class.

param
p_protocol protocol for the connection
param
p_host hostname for the connection
param
p_port port number for the connection
param
p_sc stream connection
param
p_dos data output stream from the stream connection
param
p_dis data input stream from the stream connection

        m_protocol = p_protocol;
        m_host = p_host;
        m_port = p_port;
        m_stream = p_sc;
        m_data_output_stream = p_dos;
        m_data_input_stream = p_dis;
        m_time = System.currentTimeMillis();
    
Methods Summary
public voidclose()
Clear the fields of the saved connection and release any system resources. Any open input and output streams are closed as well as the connection itself.

        try {
            if (m_data_output_stream != null) {
                m_data_output_stream.close();
                m_data_output_stream = null;
            }
            if (m_data_input_stream != null) {
                m_data_input_stream.close();
                m_data_input_stream = null;
            }
            if (m_stream != null) {
                m_stream.close();
                m_stream = null;
            }
        } catch (IOException ioe) {
            /*
             * No special processing for errors, since the 
             * the cached connection is no longer in use, and
             * the server may already have shutdown its end
             * of the connection.
             */
            if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                Logging.report(Logging.WARNING, LogChannels.LC_PROTOCOL,
                                    "IOException while close");
            }
        }
    
public javax.microedition.io.StreamConnectiongetBaseConnection()
Get the stream connection for this element.

return
base stream connection

        return m_stream;
    
public java.io.DataInputStreamopenDataInputStream()
Get the current data input stream for the stream connection.

return
data input stream

 
        return m_data_input_stream;
    
public java.io.DataOutputStreamopenDataOutputStream()
Get the current data output stream for the stream connection.

return
data output stream

 
        return m_data_output_stream;
    
public java.io.InputStreamopenInputStream()
Get the current data stream for the stream connection.

return
input stream

 
        return m_data_input_stream;
    
public java.io.OutputStreamopenOutputStream()
Get the current output stream for the stream connection.

return
output stream

        return m_data_output_stream;