com.ibm.jtopenlite
Class HostServerConnection
- java.lang.Object
-
- com.ibm.jtopenlite.HostServerConnection
-
- All Implemented Interfaces:
- Connection
- Direct Known Subclasses:
- CommandConnection, DatabaseConnection, DDMConnection, FileConnection, SignonConnection
public abstract class HostServerConnection extends java.lang.Object implements Connection
Represents a TCP/IP socket connection to an IBM i Host Server job. All HostServerConnections have associated system information provided via the SystemInfo class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description protected static class
HostServerConnection.HostInputStream
protected static class
HostServerConnection.HostOutputStream
-
Field Summary
Fields Modifier and Type Field and Description protected HostServerConnection.HostInputStream
in_
protected HostServerConnection.HostOutputStream
out_
-
Constructor Summary
Constructors Modifier Constructor and Description protected
HostServerConnection(SystemInfo info, java.lang.String user, java.lang.String jobName, java.net.Socket socket, HostServerConnection.HostInputStream in, HostServerConnection.HostOutputStream out)
-
Method Summary
Methods Modifier and Type Method and Description void
close()
Sends an "end job" datastream (if supported) and closes the underlying socket.protected static java.lang.String
connect(SystemInfo info, HostServerConnection.HostOutputStream dout, HostServerConnection.HostInputStream din, int serverID, java.lang.String user, java.lang.String password)
protected void
finalize()
long
getBytesReceived()
Returns the total number of bytes this connection has read since it was opened.long
getBytesSent()
Returns the total number of bytes this connection has written since it was opened.protected static byte[]
getEncryptedPassword(byte[] userBytes, byte[] passwordBytes, byte[] clientSeed, byte[] serverSeed, int passwordLevel)
SystemInfo
getInfo()
Returns the system information associated with this connection.java.lang.String
getJobName()
Returns the host server job string for the job that is connected to this connection.java.lang.String
getUser()
Returns the currently authenticated user of this connection.boolean
isClosed()
Returns true if close() has been called on this connection.boolean
isDatastreamDebug()
Returns true if datastream debugging is currently enabled.static boolean
isDefaultDatastreamDebug()
Returns true if debugging is enabled by default for all HostServerConnection datastreams.protected abstract void
sendEndJobRequest()
void
setDatastreamDebug(boolean debug)
If debug is true, enables datastream debugging for this connection.static void
setDefaultDatastreamDebug(boolean debug)
If debug is true, enables by default debugging on all HostServerConnection datastreams created after the call to this method.protected static void
writePadEBCDIC(java.lang.String s, int len, HostServerConnection.HostOutputStream out)
protected static void
writePadEBCDIC10(java.lang.String s, HostServerConnection.HostOutputStream out)
protected static void
writeStringToUnicodeBytes(java.lang.String s, HostServerConnection.HostOutputStream out)
-
-
-
Field Detail
-
in_
protected final HostServerConnection.HostInputStream in_
-
out_
protected final HostServerConnection.HostOutputStream out_
-
-
Constructor Detail
-
HostServerConnection
protected HostServerConnection(SystemInfo info, java.lang.String user, java.lang.String jobName, java.net.Socket socket, HostServerConnection.HostInputStream in, HostServerConnection.HostOutputStream out)
-
-
Method Detail
-
isDefaultDatastreamDebug
public static boolean isDefaultDatastreamDebug()
Returns true if debugging is enabled by default for all HostServerConnection datastreams.
-
setDefaultDatastreamDebug
public static void setDefaultDatastreamDebug(boolean debug)
If debug is true, enables by default debugging on all HostServerConnection datastreams created after the call to this method.
-
getBytesReceived
public long getBytesReceived()
Returns the total number of bytes this connection has read since it was opened. If an I/O exception has occurred with this stream, the number returned by this method may not reflect any partial datastream bytes that may have actually been read before the exception took place.
-
getBytesSent
public long getBytesSent()
Returns the total number of bytes this connection has written since it was opened. If an I/O exception has occurred with this stream, the number returned by this method may not reflect any partial datastream bytes that may have actually been written before the exception took place. Additionally, the number of bytes written over the TCP socket may be less, if the underlying stream has not yet been flushed.
-
isDatastreamDebug
public boolean isDatastreamDebug()
Returns true if datastream debugging is currently enabled.
-
setDatastreamDebug
public void setDatastreamDebug(boolean debug)
If debug is true, enables datastream debugging for this connection.
-
close
public final void close() throws java.io.IOException
Sends an "end job" datastream (if supported) and closes the underlying socket.- Specified by:
close
in interfaceConnection
- Throws:
java.io.IOException
-
sendEndJobRequest
protected abstract void sendEndJobRequest() throws java.io.IOException
- Throws:
java.io.IOException
-
finalize
protected final void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
isClosed
public final boolean isClosed()
Returns true if close() has been called on this connection.- Specified by:
isClosed
in interfaceConnection
-
getInfo
public final SystemInfo getInfo()
Returns the system information associated with this connection.
-
getUser
public final java.lang.String getUser()
Returns the currently authenticated user of this connection.- Specified by:
getUser
in interfaceConnection
-
getJobName
public final java.lang.String getJobName()
Returns the host server job string for the job that is connected to this connection.- Specified by:
getJobName
in interfaceConnection
-
getEncryptedPassword
protected static byte[] getEncryptedPassword(byte[] userBytes, byte[] passwordBytes, byte[] clientSeed, byte[] serverSeed, int passwordLevel) throws java.io.IOException
- Throws:
java.io.IOException
-
connect
protected static java.lang.String connect(SystemInfo info, HostServerConnection.HostOutputStream dout, HostServerConnection.HostInputStream din, int serverID, java.lang.String user, java.lang.String password) throws java.io.IOException
- Throws:
java.io.IOException
-
writePadEBCDIC10
protected static void writePadEBCDIC10(java.lang.String s, HostServerConnection.HostOutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
writePadEBCDIC
protected static void writePadEBCDIC(java.lang.String s, int len, HostServerConnection.HostOutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
writeStringToUnicodeBytes
protected static void writeStringToUnicodeBytes(java.lang.String s, HostServerConnection.HostOutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
-