com.ibm.as400.access

Class ProxyServer



  • public class ProxyServer
    extends Object
    Fulfills 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 IBM 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.
    -securePort securePort
    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.
    -keyringName keyringName
    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.
    -keyringPassword keyringPassword
    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 -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 Summary

      Constructors 
      Constructor and Description
      ProxyServer()
      Constructs a ProxyServer object.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      int getActiveConnections()
      Returns the number of active connections.
      int getBalanceThreshold()
      Returns the balance threshold.
      String getConfiguration()
      Returns the name of the configuration properties.
      String getKeyring()
      Returns the keyring file that the proxy server will use during SSL connections from clients.
      int getMaxConnections()
      Returns the maximum number of connections which can be active at any particular time.
      String[] getPeers()
      Returns a list of peer proxy servers for use in load balancing.
      int getPort()
      Returns the port to use for accepting connections from clients.
      int getSecurePort()
      Returns the port to use for accepting Secure Sockets Layer (SSL) connections from clients.
      boolean isStarted()
      Indicates if the proxy server has been started.
      boolean isVerbose()
      Indicates whether to print status and connection information to System.out.
      static void main(String[] args)
      Runs the proxy server as an application.
      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.
      void setConfiguration(String configuration)
      Sets and loads the properties file which lists configuration properties.
      void setKeyringName(String keyringName)
      Sets the name of the keyring the proxy server will use during SSL communications.
      void setKeyringPassword(String keyringPassword)
      Sets the password to the keyring the proxy server will use during SSL communications.
      void setMaxConnections(int maxConnections)
      Sets the maximum number of connections which can be active at any particular time.
      void setPeers(String[] peers)
      Sets the list of peer proxy servers for use in load balancing.
      void setPort(int port)
      Sets the port to use for accepting connections from clients.
      void setSecurePort(int securePort)
      Sets the port to use for accepting Secure Sockets Layer (SSL) connections from clients.
      void setVerbose(boolean verbose)
      Sets whether to print status and connection information to System.out.
      void start()
      Starts the proxy server.
      void stop()
      Stops the proxy server.
    • Constructor Detail

      • ProxyServer

        public ProxyServer()
        Constructs a ProxyServer object.

    • 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 String getConfiguration()
        Returns the name of the configuration properties.
        Returns:
        The name of the configuration properties, or null if not set.
      • getKeyring

        public 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 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(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(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.
      • setKeyringName

        public void setKeyringName(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(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(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.