Class ConnectorUtilities

java.lang.Object
org.scictrl.csshell.ConnectorUtilities

public final class ConnectorUtilities extends Object
Helper class which helps manage different plug implementations.

This class expects specifc keywords in configuration properties, which define which plugs are present and which instances can be used for particular plug.

Author:
igor@scictrl.com
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Optional system configuration property which tells to plug implementations what is expected timeout for remote operations in milliseconds.
    static final String
    Keyword used in System properties to configure DAL logging.
    static final long
    DAL default connection timeout value in milliseconds.
    static final long
    DAL default initial connection timeout value in milliseconds.
    static final String
    Optional system configuration property, which defines the timeout for establishing or initializing the connections in milliseconds.
  • Method Summary

    Modifier and Type
    Method
    Description
    static final String
    formatConnectionMessage.
    static final String
    formatConnectionMessage.
    static final long
    Convenience method which tries to get connection timeout first from provided properties, then from system properties and if both fails returns DAL default value.
    static final long
    Convenience method which tries to get connection timeout first from provided properties, then from system properties and if both fails returns provided default value.
    static final org.apache.logging.log4j.Logger
    Returns logger for particular DAL plug, this logger shuld be used for general messages about plug activity.
    static final long
    Convenience method which tries to get initial connection timeout first from provided properties, then from system properties and if both fails returns DAL default value.
    static final long
    Convenience method which tries to get initial connection timeout first from provided properties, then from system properties and if both fails returns provided default value.
    static final org.apache.logging.log4j.Logger
    Return logger, which is parent for all DAL plug loggers.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CSSHELL_LOGGING

      public static final String CSSHELL_LOGGING
      Keyword used in System properties to configure DAL logging. Valie values are:
      • true - DAL will call basic log4j configuration, which enables logging to console.
      • false - DAL will not configure logging to console.
      By default true is assumed and logging will be configured.

      Regardless of this setting an application can configure own appenders for DAL logging. See getLogger() for details.

      See Also:
    • CONNECTION_TIMEOUT

      public static final String CONNECTION_TIMEOUT
      Optional system configuration property which tells to plug implementations what is expected timeout for remote operations in milliseconds.
      See Also:
    • INITIAL_CONNECTION_TIMEOUT

      public static final String INITIAL_CONNECTION_TIMEOUT
      Optional system configuration property, which defines the timeout for establishing or initializing the connections in milliseconds.
      See Also:
    • DEFAULT_CONNECTION_TIMEOUT

      public static final long DEFAULT_CONNECTION_TIMEOUT
      DAL default connection timeout value in milliseconds. Used if CONNECTION_TIMEOUT is not defined.
      See Also:
    • DEFAULT_INITIAL_CONNECTION_TIMEOUT

      public static final long DEFAULT_INITIAL_CONNECTION_TIMEOUT
      DAL default initial connection timeout value in milliseconds. Used if INITIAL_CONNECTION_TIMEOUT is not defined.
      See Also:
  • Method Details

    • getConnectionTimeout

      public static final long getConnectionTimeout(Properties p, long def)
      Convenience method which tries to get connection timeout first from provided properties, then from system properties and if both fails returns provided default value.
      Parameters:
      p - properties, may be null
      def - default fallback values
      Returns:
      connection timeout propety value
    • getConnectionTimeout

      public static final long getConnectionTimeout(Properties p)
      Convenience method which tries to get connection timeout first from provided properties, then from system properties and if both fails returns DAL default value.
      Parameters:
      p - properties, may be null
      Returns:
      connection timeout propety value
    • getInitialConnectionTimeout

      public static final long getInitialConnectionTimeout(Properties p, long def)
      Convenience method which tries to get initial connection timeout first from provided properties, then from system properties and if both fails returns provided default value.
      Parameters:
      p - properties, may be null
      def - default fallback values
      Returns:
      connection timeout property value
    • getInitialConnectionTimeout

      public static final long getInitialConnectionTimeout(Properties p)
      Convenience method which tries to get initial connection timeout first from provided properties, then from system properties and if both fails returns DAL default value.
      Parameters:
      p - properties, may be null
      Returns:
      initial connection timeout property value
    • getLogger

      public static final org.apache.logging.log4j.Logger getLogger()
      Return logger, which is parent for all DAL plug loggers.

      DAL Plug loggers collect and distribute messages, which are intended for general plublic. E.g. application which is not interested in internal structure, but wants to display progress when some channel was connected or some user initiated action failed.

      Parent DAL logger name is 'DAL'. Names of plug loggers are 'DAL.PLUG_NAME', for example 'DAL.EPICS'.

      Default configuration of appenders is controlled with System parameter CSSHELL_LOGGING.

      Returns:
      parent logger for all DAL plug loggers.
      See Also:
    • getConnectorLogger

      public static final org.apache.logging.log4j.Logger getConnectorLogger(String type)
      Returns logger for particular DAL plug, this logger shuld be used for general messages about plug activity.
      Parameters:
      type - a String object
      Returns:
      logger for DAL plug
    • formatConnectionMessage

      public static final String formatConnectionMessage(Connection<?,?,?> conn, String message, Throwable t)

      formatConnectionMessage.

      Parameters:
      conn - a Connection object
      message - a String object
      t - a Throwable object
      Returns:
      a String object
    • formatConnectionMessage

      public static final String formatConnectionMessage(String conn, String message, Throwable t)

      formatConnectionMessage.

      Parameters:
      conn - a String object
      message - a String object
      t - a Throwable object
      Returns:
      a String object