Providing JNDI context information  SYBSOCKET_FACTORY connection property

Chapter 2: Programming Information

Implementing custom socket plug-ins

This section discusses how to plug a custom socket implementation into an application to customize the communication between a client and server. javax.net.ssl.SSLSocket is an example of a socket that you could customize to enable encryption.

com.sybase.jdbcx.SybSocketFactory is a Sybase extension interface that contains the createSocket(String, int, Properties) method that returns a java.net.Socket.For a jConnect version 4.1 or later driver to load a custom socket, an application must:

jConnect uses the new socket for its subsequent input/output operations. Classes that implement SybSocketFactory create sockets and provide a general framework for the addition of public socket-level functionality.

/**
 * Returns a socket connected to a ServerSocket on the named host,
 * at the given port.
 * @param host  the server host
 * @param port  the server port
 * @param props  Properties passed in through the connection
 * @returns Socket
 * @exception IOException, UnknownHostException
 */
 public java.net.Socket createSocket(String host, int port, Properties props) throws IOException, UnknownHostException;

Passing in properties allows instances of SybSocketFactory to use connection properties to implement an intelligent socket.

When you implement SybSocketFactory to produce a socket, the same application code can use different kinds of sockets by passing the different kinds of factories or pseudo-factories that create sockets to the application. You can customize factories with parameters used in socket construction. For example, you could customize factories to return sockets with different networking time outs or security parameters already configured. The sockets returned to the application can be subclasses of java.net.Socket to directly expose new APIs for features such as compression, security, record marking, statistics collection, or firewall tunnelling (javax.net.SocketFactory).

NoteSybSocketFactory is intended to be an overly simplified javax.net.SocketFactory, enabling applications to bridge from java.net.* to javax.net.* if desired.

To use a custom socket with jConnect:

  1. Provide a Java class that implements com.sybase.jdbcx.SybSocketFactory. See “Creating and configuring a custom socket”.

  2. Set the SYBSOCKET_FACTORY connection property so that jConnect can use your implementation to obtain a socket.





Copyright © 2003. Sybase Inc. All rights reserved. SYBSOCKET_FACTORY connection property

View this book as PDF