Class SystemUtilities

  • Direct Known Subclasses:
    ClientSystemUtilities

    public abstract class SystemUtilities
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  SystemUtilities.RequestImpl
      This is the base implementation of the "Result" object of system.util.sendRequestAsync.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static int DEFAULT_REQUEST_TIMEOUT  
      protected static org.slf4j.Logger log  
      protected static java.util.concurrent.atomic.AtomicLong MSGID_GENERATOR  
      protected static org.slf4j.Logger MSGLOG  
    • Constructor Summary

      Constructors 
      Constructor Description
      SystemUtilities()  
    • Field Detail

      • DEFAULT_REQUEST_TIMEOUT

        protected static final int DEFAULT_REQUEST_TIMEOUT
        See Also:
        Constant Field Values
      • log

        protected static final org.slf4j.Logger log
      • MSGLOG

        protected static final org.slf4j.Logger MSGLOG
      • MSGID_GENERATOR

        protected static final java.util.concurrent.atomic.AtomicLong MSGID_GENERATOR
    • Constructor Detail

      • SystemUtilities

        public SystemUtilities()
    • Method Detail

      • execute

        public static void execute​(java.lang.String[] commands)
                            throws java.io.IOException
        Executes a shell command
        Throws:
        java.io.IOException
      • getProperty

        public static java.lang.String getProperty​(java.lang.String name)
        Simply delegates to System.getProperty()
      • beep

        public static void beep()
      • playSoundClip

        public static void playSoundClip​(java.lang.String wavFile)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • threadDump

        public java.lang.String threadDump()
                                    throws java.io.IOException
        Gets a thread dump from the JVM and returns as a string.
        Throws:
        java.io.IOException
      • _getCpuUsageString

        protected java.lang.String _getCpuUsageString​(java.lang.management.ThreadInfo threadInfo)
      • setLoggingLevel

        public static void setLoggingLevel​(java.lang.String loggerName,
                                           java.lang.String loggerLevel)
                                    throws java.io.IOException
        Sets the logging level for the named logger.
        Throws:
        java.io.IOException
      • playSoundClip

        public static void playSoundClip​(java.lang.String wavFile,
                                         double volume,
                                         boolean wait)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • playSoundClip

        public static void playSoundClip​(byte[] soundData)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • playSoundClip

        public static void playSoundClip​(byte[] soundData,
                                         double volume,
                                         boolean wait)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • invokeAsynchronous

        public final java.lang.Thread invokeAsynchronous​(org.python.core.PyObject fun)
      • _invokeAsyncImpl

        protected abstract java.lang.Thread _invokeAsyncImpl​(org.python.core.PyObject fun)
      • logger

        public static org.slf4j.Logger logger​(java.lang.String loggerName)
      • getLogger

        public static LoggerEx getLogger​(java.lang.String name)
      • jsonEncode

        public static java.lang.String jsonEncode​(org.python.core.PyObject pyObj)
                                           throws JSONException
        Encodes a PyObject into a JSON string. The conversion is as follows:
        • None=>null
        • True=>true
        • 42=>42
        • 42L=>42
        • 42.0=>42.0
        • {'hello': 1, 'world': 2}=>{"hello": 1, "world": 2}
        • (1, 42, 'Hello world!')=>[1, 42, "Hello world!"] .
        Returns:
        String
        Throws:
        JSONException
      • jsonEncode

        public static java.lang.String jsonEncode​(org.python.core.PyObject pyObj,
                                                  int indentFactor)
                                           throws JSONException
        Encodes a prettyprinted PyObject into a JSON string.
        Parameters:
        indentFactor - indentation per line
        Returns:
        String result from the encode
        Throws:
        JSONException
      • jsonDecode

        public static org.python.core.PyObject jsonDecode​(java.lang.String jsonString)
                                                   throws JSONException
        Decodes a JSON String into a PyObject. The mapping of the JSON strings to PyObjects is the inverse of jsonEncode except that json Arrays get mapped to PyList only( no way to map back to python tuple). Also, JSON integers get mapped to PyIntegers unless they are greater than the maximum value of PyInteger, in which case they get mapped to PyLong. Floating point values are mapped to PyFloat.
        Parameters:
        jsonString - the JSON to decode.
        Returns:
        a PyObject, the structure of which reflects the decoded JSON.
        Throws:
        JSONException - if any errors occur decoding the provided JSON.
      • getSessionInfo

        public DatasetUtilities.PyDataSet getSessionInfo​(java.lang.String unameFilter,
                                                         java.lang.String projectFilter)
      • getSessionInfo

        public DatasetUtilities.PyDataSet getSessionInfo​(org.python.core.PyObject[] values,
                                                         java.lang.String[] keywords)
      • _getSessionInfo

        public abstract DatasetUtilities.PyDataSet _getSessionInfo​(java.lang.String unameFilter,
                                                                   java.lang.String projectFilter)
      • sendMessage

        public java.util.List<java.lang.String> sendMessage​(org.python.core.PyObject[] values,
                                                            java.lang.String[] keywords)
                                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendMessageInternal

        public abstract java.util.List<java.lang.String> sendMessageInternal​(java.lang.String project,
                                                                             java.lang.String messageHandler,
                                                                             org.python.core.PyDictionary payload,
                                                                             java.util.Properties filterParams)
                                                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendRequest

        public java.lang.Object sendRequest​(org.python.core.PyObject[] values,
                                            java.lang.String[] keywords)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendRequestAsync

        public Request sendRequestAsync​(org.python.core.PyObject[] values,
                                        java.lang.String[] keywords)
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendRequestInternal

        protected Request sendRequestInternal​(org.python.core.PyObject[] values,
                                              java.lang.String[] keywords,
                                              boolean async)
      • sendRequestInternal

        protected abstract Request sendRequestInternal​(java.lang.String project,
                                                       java.lang.String messageHandler,
                                                       org.python.core.PyDictionary payload,
                                                       java.util.Properties params,
                                                       boolean async)
      • getGatewayStatus

        public java.lang.String getGatewayStatus​(org.python.core.PyObject[] values,
                                                 java.lang.String[] keywords)