com.ibm.as400.access
Class ProxyServer
- java.lang.Object
-
- com.ibm.as400.access.ProxyServer
-
public class ProxyServer extends java.lang.ObjectFulfills requests from programs using the proxy jar file. The proxy server is responsible for creating and invoking methods on Toolbox objects on behalf of the program. The proxy server is intended for use on a middle-tier in a multiple tier environment.If there is already a proxy server active for the specified port, then a new proxy server will not be started. Instead, the existing proxy server's configuration will be updated.
A ProxyServer object can be created and run directly from a program. Alternately, the proxy server can be run as an application, as follows:
java com.ibm.as400.access.ProxyServer [ options ]
Options:
-balanceThresholdbalanceThreshold-
Specifies the number of connections that must be active before
the peer server starts load balancing by dispatching requests to
peer proxy servers. Specify 0 to start load balancing immediately or
-1 to never start load balancing. This option may be abbreviated
-bt. The default is -1. This has no effect unless peer proxy servers are specified. -configurationconfiguration-
Specifies a properties file which lists configuration
properties in the following format:
balanceThreshold=balanceThreshold jdbcDrivers=jdbcDriver1[;jdbcDriver2[;...]] maxConnections=maxConnections peers=hostname1[:port1][;hostname2[:port2][;...]] verbose=true|false
This option may be abbreviated-c. The default is to not load a configuration. If a property is loaded in a configuration and specified in a command line argument, then the command line argument takes precedence. -jdbcDriversjdbcDriver1[;jdbcDriver2;...]-
Specifies a list of JDBC driver class names to register with
the JDBC DriverManager. Use this to register any JDBC drivers
to which clients might need to connect. This option may be abbreviated
-jd. The default is to load only the IBM Toolbox for Java JDBC driver. -maxConnectionsmaxConnections-
Specifies the maximum number of connections which can be active
at any particular time. This refers to connections to the proxy
server, that are initiated by clients. If the maximum number of
connections are active, then any further connection requests will
be rejected and an exception is thrown to the client program.
Specify 0 to not allow any connections, or -1 for no limit.
This option may be abbreviated
-mc. The default is to allow an unlimited number of connections. -peershostname1[:port1][;hostname2[:port2];...]-
Specifies a list of peer proxy servers for use in load balancing.
In some cases, connections to this proxy server will be
reassigned to a peer. This option may be abbreviated
-pe. The default is not to do load balancing. -portport-
Specifies the port to use for accepting connections from clients.
This option may be abbreviated
-po. The default port is 3470. -securePortsecurePort-
Specifies the port to use for accepting Secure Sockets Layer (SSL)
connections from clients. This option may be abbreviated
-sp. The proxy server will only accept SSL connections when the com.ibm.sslight package is in the classpath. The default port is 3471. -keyringNamekeyringName-
Specifies the keyring to use for Secure Sockets Layer (SSL)
communications from clients. This option may be abbreviated
-kn. The keyring specified by this option must be in the classpath for SSL communications to work properly between the proxy server and client. If the com.ibm.sslight package is not the classpath, this option will be ignored. -keyringPasswordkeyringPassword-
Specifies the password to the keyring. This option may be
abbreviated
-kp. This option msut be used in conjunction with the -keyringName option. If the com.ibm.sslight package is not the classpath, this option will be ignored. -verbose[true|false]-
Specifies whether to print status and connection
information to System.out. This option may be abbreviated
-v. The default is not to print status and connection information. -help-
Prints usage information to System.out. This option may be abbreviated
-hor-?. The default is not to print usage information.
Example usage:
To start the proxy server from a program:
ProxyServer proxyServer = new ProxyServer (); proxyServer.setMaxConnections (25); proxyServer.run ();
Alternatively, the above action can be performed directly from the command line as follows:
java com.ibm.as400.access.ProxyServer -maxconnections 25
-
-
Constructor Summary
Constructors Constructor and Description ProxyServer()Constructs a ProxyServer object.
-
Method Summary
Methods Modifier and Type Method and Description intgetActiveConnections()Returns the number of active connections.intgetBalanceThreshold()Returns the balance threshold.java.lang.StringgetConfiguration()Returns the name of the configuration properties.java.lang.StringgetKeyring()Returns the keyring file that the proxy server will use during SSL connections from clients.intgetMaxConnections()Returns the maximum number of connections which can be active at any particular time.java.lang.String[]getPeers()Returns a list of peer proxy servers for use in load balancing.intgetPort()Returns the port to use for accepting connections from clients.intgetSecurePort()Returns the port to use for accepting Secure Sockets Layer (SSL) connections from clients.booleanisStarted()Indicates if the proxy server has been started.booleanisVerbose()Indicates whether to print status and connection information to System.out.static voidmain(java.lang.String[] args)Runs the proxy server as an application.voidsetBalanceThreshold(int balanceThreshold)Sets the number of connections that must be active before the peer server starts load balancing by dispatching requests to peer proxy servers.voidsetConfiguration(java.lang.String configuration)Sets and loads the properties file which lists configuration properties.voidsetKeyringName(java.lang.String keyringName)Sets the name of the keyring the proxy server will use during SSL communications.voidsetKeyringPassword(java.lang.String keyringPassword)Sets the password to the keyring the proxy server will use during SSL communications.voidsetMaxConnections(int maxConnections)Sets the maximum number of connections which can be active at any particular time.voidsetPeers(java.lang.String[] peers)Sets the list of peer proxy servers for use in load balancing.voidsetPort(int port)Sets the port to use for accepting connections from clients.voidsetSecurePort(int securePort)Sets the port to use for accepting Secure Sockets Layer (SSL) connections from clients.voidsetVerbose(boolean verbose)Sets whether to print status and connection information to System.out.voidstart()Starts the proxy server.voidstop()Stops the proxy server.
-
-
-
Method Detail
-
getActiveConnections
public int getActiveConnections()
Returns the number of active connections.- Returns:
- The number of active connections.
-
getBalanceThreshold
public int getBalanceThreshold()
Returns the balance threshold. This is the number of connections that must be active before the peer server starts load balancing by dispatching requests to peer proxy servers. Specify 0 to start load balancing immediately or -1 to never start load balancing.- Returns:
- The balance threshold, or 0 to start load balancing immediately or -1 to never start load balancing.
-
getConfiguration
public java.lang.String getConfiguration()
Returns the name of the configuration properties.- Returns:
- The name of the configuration properties, or null if not set.
-
getKeyring
public java.lang.String getKeyring()
Returns the keyring file that the proxy server will use during SSL connections from clients.- Returns:
- The proxy server keyring file name.
-
getMaxConnections
public int getMaxConnections()
Returns the maximum number of connections which can be active at any particular time.- Returns:
- The maximum number of connections which can be active at any particular time, or -1 for unlimited connections.
-
getPeers
public java.lang.String[] getPeers()
Returns a list of peer proxy servers for use in load balancing. Each peer proxy server is specified in the format hostname[:port]. This returns an empty array if there are no peer proxy servers.- Returns:
- A list of peer proxy servers for use in load balancing.
-
getPort
public int getPort()
Returns the port to use for accepting connections from clients.- Returns:
- The port to use for accepting connections from clients.
-
getSecurePort
public int getSecurePort()
Returns the port to use for accepting Secure Sockets Layer (SSL) connections from clients.- Returns:
- The port to use for accepting Secure Sockets Layer (SSL) connections from clients.
-
isStarted
public boolean isStarted()
Indicates if the proxy server has been started.- Returns:
- true if the proxy server has been started, false otherwise.
-
isVerbose
public boolean isVerbose()
Indicates whether to print status and connection information to System.out.- Returns:
- true to print status and connection information to System.out, false otherwise.
-
main
public static void main(java.lang.String[] args)
Runs the proxy server as an application.- Parameters:
args- The command line arguments.
-
setBalanceThreshold
public void setBalanceThreshold(int balanceThreshold)
Sets the number of connections that must be active before the peer server starts load balancing by dispatching requests to peer proxy servers. The default is -1.- Parameters:
balanceThreshold- The number of connections that must be active before the peer server starts load balancing by dispatching requests to peer proxy servers. Specify 0 to start load balancing immediately or -1 to never start load balancing.
-
setConfiguration
public void setConfiguration(java.lang.String configuration) throws java.io.IOExceptionSets and loads the properties file which lists configuration properties. The default is not to load a configuration.- Parameters:
configuration- The properties file which list configuration properties.- Throws:
java.io.IOException- If the configuration can not be loaded.
-
setKeyringName
public void setKeyringName(java.lang.String keyringName)
Sets the name of the keyring the proxy server will use during SSL communications. The proxy server keyring name can be set only if the proxy server is not running.- Parameters:
keyringName- The proxy server keyring name.
-
setKeyringPassword
public void setKeyringPassword(java.lang.String keyringPassword)
Sets the password to the keyring the proxy server will use during SSL communications. The proxy server keyring password can be set only if the proxy server is not running.- Parameters:
keyringPassword- The proxy server keyring password.
-
setMaxConnections
public void setMaxConnections(int maxConnections)
Sets the maximum number of connections which can be active at any particular time. If the maximum number of connections are active, then any further connection requests will be rejected. The default is to allow an unlimited number of connections.Setting this to a number less than the number of active connections will not drop any active connections. It will simply prevent new connections from being accepted until the number of active connections is less than the limit.
- Parameters:
maxConnections- The maximum number of connections which can be active at any particular time. Specify 0 to not allow any connections or -1 for unlimited connections.
-
setPeers
public void setPeers(java.lang.String[] peers)
Sets the list of peer proxy servers for use in load balancing. In some cases, connections to the proxy server will be reassigned to a peer. The default is not to do load balancing. Specify each peer proxy server in the format hostname[:port].- Parameters:
peers- The list of peer proxy servers for use in load balancing, or an empty array to not do load balancing.
-
setPort
public void setPort(int port)
Sets the port to use for accepting connections from clients. The default is 3470. Specify 0 to indicate that any free port can be used. The port number can be set only if the proxy server is not running.- Parameters:
port- The port to use for accepting connections from clients.
-
setSecurePort
public void setSecurePort(int securePort)
Sets the port to use for accepting Secure Sockets Layer (SSL) connections from clients. The default is 3471. Specify 0 to indicate that any free port can be used. The proxy server will only accept SSL connections when the com.ibm.sslight package is in the classpath. The secure port number can be set only if the proxy server is not running.- Parameters:
securePort- The port to use for accepting Secure Sockets Layer (SSL) connections from clients.
-
setVerbose
public void setVerbose(boolean verbose)
Sets whether to print status and connection information to System.out. The default is false.- Parameters:
verbose- true to print status and connection information to System.out, false otherwise.
-
start
public void start()
Starts the proxy server. This starts several threads which process client requests, and then return immediately. The proxy server is still running after the return. Use stop() to stop all threads for this proxy server.
-
stop
public void stop()
Stops the proxy server. This stops all threads relating to this proxy server.
-
-