com.ibm.as400.access

Class ProxyServer

  • java.lang.Object
    • com.ibm.as400.access.ProxyServer


  • public class ProxyServer
    extends java.lang.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. This port is not used if the JVM property javax.net.ssl.keyStore has been set.
    -securePort port
    Specifies the port to use for accepting secure SSL connections from clients. The default port is 3471.

    This will be used only if the JVM property javax.net.ssl.keyStore has been set.

    This used the SSL support provided by JSSE. To use this support the following JVM properties must be set.

    • javax.net.ssl.keyStoreType
    • javax.net.ssl.keyStore
    • javax.net.ssl.keyStorePassword
    -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.
      java.lang.String getConfiguration()
      Returns the name of the configuration properties.
      int getMaxConnections()
      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.
      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(java.lang.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(java.lang.String configuration)
      Sets and loads the properties file which lists configuration properties.
      void setMaxConnections(int maxConnections)
      Sets the maximum number of connections which can be active at any particular time.
      void setPeers(java.lang.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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 java.lang.String getConfiguration()
        Returns the name of the configuration properties.
        Returns:
        The name of the configuration properties, or null if not set.
      • 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.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:
        java.io.IOException - If the configuration can not be loaded.
      • 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. This is implemented JSSE support. To function, the following JVM properties need to be set.
        • javax.net.ssl.keyStoreType
        • javax.net.ssl.keyStore
        • javax.net.ssl.keyStorePassword
        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.