com.sap.mdm.net
Class ConnectionPoolFactory

java.lang.Object
  extended bycom.sap.mdm.net.ConnectionPoolFactory

public class ConnectionPoolFactory
extends Object

This class manages the creation and the access to all connection pools. Each connection pool is tied to a particular MDM server and is identified by a connection tag which encodes its host name and port number.

The factory's static properties are used to set defaults for the connection pools. These defaults may be overridden by modifying each connection pool instance's settings.

The factory maintains a list of connection pool instances. A call to getInstance for the same connection tag will return a previous instance unless isShared is false.

Examples of connection tags:
localhost
The MDM server is on the local machine and the default port number of 59950.

MyMachine;40000
The MDM server is on the "MyMachine" and the port number is 40000.

See Also:
ConnectionPool, SimpleConnectionFactory

Field Summary
static int DEFAULT_MAX_CONNECTIONS
          The default maximum number of connections for the connection pool.
static int DEFAULT_MIN_CONNECTIONS
          The default minimum number of connections for the connection pool.
static int NO_TIMEOUT
          A constant for specifying no timeout.
 
Method Summary
static int getConnectionCreationTimeout()
          Returns the SO_TIMEOUT used when establishing a new connection.
static ConnectionPool getInstance(String connectionTag)
          Returns a connection pool instance associated with the MDM server specified by the connection tag.
static ConnectionPool getInstance(String connectionTag, boolean isShared)
          Returns a connection pool instance associated with the MDM server specified by the connection tag.
static ConnectionPool getInstance(String connectionTag, boolean isShared, boolean isCheckConnections)
          Returns a connection pool instance associated with the MDM server specified by the connection tag.
static ConnectionPool getInstance(String connectionTag, boolean isShared, boolean isCheckConnections, SocketFactory socketFactory)
          Returns a connection pool instance for SSL connections associated with the MDM server specified by the connection tag.
static ConnectionPool getInstance(String connectionTag, String connectionSource)
          Deprecated. there is really no way to make use of connection source
static ConnectionPool getInstance(String connectionTag, String connectionSource, boolean isShared, boolean isCheckConnections, SocketFactory socketFactory)
          Returns a connection pool instance for SSL and non-SSL connections associated with the MDM server specified by the connection tag.
static int getMaxConnections()
          Returns the default value for the maximum number of connections that connection pools may open.
static int getMinConnections()
          Returns the default value for the minimum number of connections that connection pools will open upon initialization.
static ConnectionPool[] getSharedInstances()
          Returns all shared instances of connection pool that are cached in this factory
static int getTimeout()
          Returns the SO_TIMEOUT used during normal communication with the MDM server.
static void setConnectionCreationTimeout(int timeout)
          Sets the SO_TIMEOUT used when establishing a new connection.
static void setMaxConnections(int maxConnections)
          Sets the default value for the maximum number of connections that connection pools may open.
static void setMinConnections(int minConnections)
          Sets the default value for the minimum number of connections that connection pools will open upon initialization.
static void setTimeout(int timeout)
          Sets the SO_TIMEOUT used during normal communication with the MDM server.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_TIMEOUT

public static final int NO_TIMEOUT
A constant for specifying no timeout.

See Also:
Constant Field Values

DEFAULT_MIN_CONNECTIONS

public static final int DEFAULT_MIN_CONNECTIONS
The default minimum number of connections for the connection pool.

See Also:
Constant Field Values

DEFAULT_MAX_CONNECTIONS

public static final int DEFAULT_MAX_CONNECTIONS
The default maximum number of connections for the connection pool.

See Also:
Constant Field Values
Method Detail

getInstance

public static ConnectionPool getInstance(String connectionTag)
                                  throws ConnectionException
Returns a connection pool instance associated with the MDM server specified by the connection tag.

Parameters:
connectionTag - the connection tag encoding the host name and the port number
Returns:
the connection pool
Throws:
ConnectionException - if not able to create a connection to the MDM server

getInstance

public static ConnectionPool getInstance(String connectionTag,
                                         boolean isShared)
                                  throws ConnectionException
Returns a connection pool instance associated with the MDM server specified by the connection tag.

Parameters:
connectionTag - the connection tag encoding the host name and the port number
isShared - indicates if the instance can be shared
Returns:
the connection pool
Throws:
ConnectionException - if not able to create a connection to the MDM server
Since:
5.5 SP6 Patch 04

getInstance

public static ConnectionPool getInstance(String connectionTag,
                                         String connectionSource)
                                  throws ConnectionException
Deprecated. there is really no way to make use of connection source

Returns a connection pool instance associated with the MDM server specified by the connection tag. A set of connections can be logically grouped by giving it the same connect source identifier.

Parameters:
connectionTag - the connection tag encoding the host name and the port number
connectionSource - the connection source identifier
Returns:
the connection pool
Throws:
ConnectionException - if not able to create a connection to the MDM server

getInstance

public static ConnectionPool getInstance(String connectionTag,
                                         boolean isShared,
                                         boolean isCheckConnections)
                                  throws ConnectionException
Returns a connection pool instance associated with the MDM server specified by the connection tag. A set of connections can be logically grouped by giving it the same connect source identifier.

Parameters:
connectionTag - the connection tag encoding the host name and the port number
isShared - indicates if the instance can be shared
isCheckConnections - indicates if connections are checked periodically, requiring a background thread
Returns:
the connection pool
Throws:
ConnectionException - if not able to create a connection to the MDM server
Since:
5.5 SP6 Patch 04

getInstance

public static ConnectionPool getInstance(String connectionTag,
                                         boolean isShared,
                                         boolean isCheckConnections,
                                         SocketFactory socketFactory)
                                  throws ConnectionException
Returns a connection pool instance for SSL connections associated with the MDM server specified by the connection tag.

Parameters:
connectionTag - the connection tag encoding the host name and the port number
isShared - indicates if the instance can be shared
isCheckConnections - indicates if connections are checked periodically, requiring a background thread
socketFactory - the socket factory, if null, a plain socket is used
Returns:
the connection pool
Throws:
ConnectionException - if not able to create a connection to the MDM server
Since:
7.1 SP07

getMinConnections

public static int getMinConnections()
Returns the default value for the minimum number of connections that connection pools will open upon initialization.

Returns:
the minimum number of connections

setMinConnections

public static void setMinConnections(int minConnections)
Sets the default value for the minimum number of connections that connection pools will open upon initialization. This setting may be overridden on the connection pool itself. The default is one.

Parameters:
minConnections - the minimum number of connections

getMaxConnections

public static int getMaxConnections()
Returns the default value for the maximum number of connections that connection pools may open.

Returns:
the maximum number of connections

setMaxConnections

public static void setMaxConnections(int maxConnections)
Sets the default value for the maximum number of connections that connection pools may open. The default is ten.

Parameters:
maxConnections - the maximum number of connections

setTimeout

public static void setTimeout(int timeout)
Sets the SO_TIMEOUT used during normal communication with the MDM server. The default is forever.

Parameters:
timeout - a timeout in milliseconds
See Also:
Socket.setSoTimeout(int)

getTimeout

public static int getTimeout()
Returns the SO_TIMEOUT used during normal communication with the MDM server.

Returns:
a timeout in milliseconds

getConnectionCreationTimeout

public static int getConnectionCreationTimeout()
Returns the SO_TIMEOUT used when establishing a new connection.

Returns:
a timeout in milliseconds
Since:
7.1

setConnectionCreationTimeout

public static void setConnectionCreationTimeout(int timeout)
Sets the SO_TIMEOUT used when establishing a new connection. If a new connection cannot be established within the specified timeout, an exception will be thrown. The default is one minute.

Parameters:
timeout - a timeout in milliseconds
Since:
7.1
See Also:
Socket.setSoTimeout(int)

getSharedInstances

public static ConnectionPool[] getSharedInstances()
Returns all shared instances of connection pool that are cached in this factory

Returns:
the array of connection pool instances
Throws:
ConnectionException - if not able to create a connection to the MDM server

getInstance

public static ConnectionPool getInstance(String connectionTag,
                                         String connectionSource,
                                         boolean isShared,
                                         boolean isCheckConnections,
                                         SocketFactory socketFactory)
                                  throws ConnectionException
Returns a connection pool instance for SSL and non-SSL connections associated with the MDM server specified by the connection tag.

Parameters:
connectionTag - the connection tag encoding the host name and the port number
connectionSource - the connection source identifier
isShared - indicates if the instance can be shared
isCheckConnections - indicates if connections are checked periodically, requiring a background thread
socketFactory - the socket factory, if null, a plain socket is used
Returns:
the connection pool
Throws:
ConnectionException - if not able to create a connection to the MDM server
Since:
7.1 SP08


Copyright 2004-2007 by SAP AG. All Rights Reserved.

SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies (SAP Group) for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.