All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.access.ProxyServer

java.lang.Object
   |
   +----com.ibm.as400.access.ProxyServer

public class ProxyServer
extends Object

The ProxyServer class is used to fulfill 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:

-balanceThreshold balanceThreshold
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.
-configuration configuration
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.
-jdbcDrivers jdbcDriver1[;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 AS/400 Toolbox for Java JDBC driver.
-maxConnections maxConnections
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.
-peers hostname1[: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.
-port port
Specifies the port to use for accepting connections from clients. This option may be abbreviated -po. The default port is 3470.
-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 -h or -?. 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 Index

 o ProxyServer()
Constructs a ProxyServer object.

Method Index

 o getActiveConnections()
Returns the number of active connections.
 o getBalanceThreshold()
Returns the balance threshold.
 o getConfiguration()
Returns the name of the configuration properties.
 o getMaxConnections()
Returns the maximum number of connections which can be active at any particular time.
 o getPeers()
Returns a list of peer proxy servers for use in load balancing.
 o getPort()
Returns the port to use for accepting connections from clients.
 o isStarted()
Indicates if the proxy server has been started.
 o isVerbose()
Indicates whether to print status and connection information to System.out.
 o main(String[])
Runs the proxy server as an application.
 o setBalanceThreshold(int)
Sets the number of connections that must be active before the peer server starts load balancing by dispatching requests to peer proxy servers.
 o setConfiguration(String)
Sets and loads the properties file which lists configuration properties.
 o setMaxConnections(int)
Sets the maximum number of connections which can be active at any particular time.
 o setPeers(String[])
Sets the list of peer proxy servers for use in load balancing.
 o setPort(int)
Sets the port to use for accepting connections from clients.
 o setVerbose(boolean)
Sets whether to print status and connection information to System.out.
 o start()
Starts the proxy server.
 o stop()
Stops the proxy server.

Constructors

 o ProxyServer
 public ProxyServer()
Constructs a ProxyServer object.

Methods

 o getActiveConnections
 public int getActiveConnections()
Returns the number of active connections.

Returns:
The number of active connections.
 o 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.
 o getConfiguration
 public String getConfiguration()
Returns the name of the configuration properties.

Returns:
The name of the configuration properties, or null if not set.
 o 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.
 o getPeers
 public 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.
 o getPort
 public int getPort()
Returns the port to use for accepting connections from clients.

Returns:
The port to use for accepting connections from clients.
 o isStarted
 public boolean isStarted()
Indicates if the proxy server has been started.

Returns:
true if the proxy server has been started, false otherwise.
 o 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.
 o main
 public static void main(String args[])
Runs the proxy server as an application.

Parameters:
args - The command line arguments.
 o 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.
 o setConfiguration
 public void setConfiguration(String configuration) throws IOException
Sets 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: IOException
If the configuration can not be loaded.
 o 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.
 o setPeers
 public void setPeers(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.
 o 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.
 o 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.
 o 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.

 o stop
 public void stop()
Stops the proxy server. This stops all threads relating to this proxy server.


All Packages  Class Hierarchy  This Package  Previous  Next  Index