Class RhinoConnectionFactory


  • public class RhinoConnectionFactory
    extends Object
    Factory class to create connections to Rhino.
    • Method Detail

      • setLogWriter

        public static void setLogWriter​(PrintWriter out)
        Sets the logging/tracing PrintWriter object that is used by the RhinoConnectionFactory and all connections. To log debugging information to standard out, use the following: [source,java] ---- RhinoConnectionFactory.setLogWriter(new PrintWriter(System.out, true)); ---- *Note the second parameter to the PrintWriter constructor (`true`) -- if this is not supplied, no output will be displayed until the PrintWriter's buffer is full, which is generally not the desired behaviour.* To log to a Log4J logger, you could do this: [source,java] ---- class LogWriter extends Writer { public void write(char[] cbuf, int off, int len) { String s = new String(cbuf, off, len); if(!lineSep.equals(s)) log.info(s); } public void flush() { } public void close() { } private final String lineSep = System.getProperty("line.separator"); } RhinoConnectionFactory.setLogWriter(new PrintWriter(new LogWriter())); ----
        Parameters:
        out - the new logging/tracing PrintWriter object; null to disable logging and tracing
      • getLogWriter

        public static PrintWriter getLogWriter()
        Retrieves the log writer.
        Returns:
        a java.io.PrintWriter object
      • connect

        public static RhinoConnection connect​(File propertiesFile)
                                       throws ConnectionException
        Create a Rhino client using connection properties in the given properties file. The names of the properties are defined by the link:../../../../constant-values.html#com.opencloud.slee.remote.RhinoConnectionFactory.RHINO_HOST_ATTRIBUTE[constant field values] of this class. If both a server list and a host/port are in the properties, the server list takes precedence. If the target Rhino server requires SSL, the properties file must contain SSL properties if they have not been set as system properties prior to calling this method. The names of the SSL properties are defined by the link:../../../../constant-values.html#com.opencloud.slee.remote.RhinoSsl.JAVAXSSL_KEYSTORE_ATTRIBUTE[constant field values] in the RhinoSsl class.
        Parameters:
        propertiesFile - a file containing server address properties, authentication credential properties, and SSL properties (if not set as system properties)
        Returns:
        a RhinoConnection instance
        Throws:
        ConnectionException - if none of the provided servers could be reached
      • connect

        public static RhinoConnection connect​(Properties properties)
                                       throws ConnectionException
        Create a Rhino client using connection properties in the given properties object. The names of the properties are defined by the link:../../../../constant-values.html#com.opencloud.slee.remote.RhinoConnectionFactory.RHINO_HOST_ATTRIBUTE[constant field values] of this class. If both a server list and a host/port are in the properties, the server list takes precedence. If the target Rhino server requires SSL, the properties object must contain SSL properties if they have not been set as system properties prior to calling this method. The names of the SSL properties are defined by the link:../../../../constant-values.html#com.opencloud.slee.remote.RhinoSsl.JAVAXSSL_KEYSTORE_ATTRIBUTE[constant field values] in the RhinoSsl class.
        Parameters:
        properties - a properties object containing server address properties, authentication credential properties, and SSL properties (if not set as system properties)
        Returns:
        a RhinoConnection instance
        Throws:
        ConnectionException - if none of the provided servers could be reached
      • connect

        public static RhinoConnection connect​(String host,
                                              int port,
                                              String username,
                                              String password)
                                       throws ConnectionException
        Create a Rhino client that will connect to the given host and port, and authenticate using the given username and password. If the target Rhino server requires SSL, the SSL system properties must be set prior to calling this method.
        Parameters:
        host - host to connect to
        port - port to connect to
        username - username to authenticate as
        password - password to authenticate using
        Returns:
        a RhinoConnection instance
        Throws:
        ConnectionException - if none of the provided servers could be reached
      • connect

        public static RhinoConnection connect​(String serverList,
                                              String username,
                                              String password)
                                       throws ConnectionException
        Create a Rhino client that will attempt connections to the given hosts and ports in the order specified, and authenticate using the given username and password. If the target Rhino server requires SSL, the SSL system properties must be set prior to calling this method.
        Parameters:
        serverList - list of servers to connect to in format "host1:port1,host2:port2,host3:port3,..."
        username - username to authenticate as
        password - password to authenticate using
        Returns:
        a RhinoConnection instance
        Throws:
        ConnectionException - if none of the provided servers could be reached
      • connect

        public static RhinoConnection connect​(String[] servers,
                                              String username,
                                              String password)
                                       throws ConnectionException
        Create a Rhino client that will attempt connections to the given servers in the order specified, and authenticate using the given username and password. If the target Rhino server requires SSL, the SSL system properties must be set prior to calling this method.
        Parameters:
        servers - list of servers to connect to in format "host:port" in each array element
        username - username to authenticate as
        password - password to authenticate using
        Returns:
        a RhinoConnection instance
        Throws:
        ConnectionException - if none of the provided servers could be reached
      • connect

        public static RhinoConnection connect​(String host,
                                              int port,
                                              String username,
                                              String password,
                                              Properties sslProps)
                                       throws ConnectionException
        Deprecated.
        Initialise SSL properties by calling setRhinoSslProperties(java.util.Properties) (only once) then use connect methods on this class that do not take SSL properties as an argument. Please note that the setRhinoSslProperties method requires a different set of SSL properties than that used by this method.
        Create a Rhino client that will connect to the given host and port, and authenticate using the given username and password. The `sslProps` properties object can only be used to provide SSL properties, not server addresses or authentication credentials. The names of the SSL properties are defined by the link:../../../../constant-values.html#com.opencloud.slee.remote.RhinoSsl.JAVAXSSL_KEYSTORE_ATTRIBUTE[constant field values] in the RhinoSsl class.
        Parameters:
        host - host to connect to
        port - port to connect to
        username - username to authenticate as
        password - password to authenticate using
        sslProps - properties object containing SSL properties
        Returns:
        a RhinoConnection instance
        Throws:
        ConnectionException - if none of the provided servers could be reached
      • connect

        public static RhinoConnection connect​(String[] servers,
                                              String username,
                                              String password,
                                              Properties sslProps)
                                       throws ConnectionException
        Deprecated.
        Initialise SSL properties by calling setRhinoSslProperties(java.util.Properties) (only once) then use connect methods on this class that do not take SSL properties as an argument. Please note that the setRhinoSslProperties method requires a different set of SSL properties than that used by this method.
        Create a Rhino client that will attempt connections to the given servers in the order specified. The `sslProps` properties object can only be used to provide SSL properties, not server addresses or authentication credentials. The names of the SSL properties are defined by the link:../../../../constant-values.html#com.opencloud.slee.remote.RhinoSsl.JAVAXSSL_KEYSTORE_ATTRIBUTE[constant field values] in the RhinoSsl class.
        Parameters:
        servers - list of servers to connect to in format "host:port" in each array element
        username - username to authenticate as
        password - password to authenticate using
        sslProps - properties object containing SSL properties
        Returns:
        a RhinoConnection instance
        Throws:
        ConnectionException - if none of the provided servers could be reached
      • recreateSslContext

        public static void recreateSslContext()
        Force the SSL context and client socket factory to be recreated. This can used when the trust store or keystore file has changed on disk. The SSL context and socket factory will be recreated the next time a connection is needed.