Class JavaTool


  • public class JavaTool
    extends java.lang.Object
    Java toolbox
    This class only provides static variables and methods
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String buildJar​(java.lang.String binDir, java.lang.String jarPath, java.lang.String version)
      Build a single jar with all source in bin directory
      static java.lang.String buildJar​(java.lang.String binDir, java.util.List<java.lang.String> paths, java.lang.String jarPath, java.lang.String version)
      Build a single jar with specified sources in the bin directory
      static boolean cleanSrcAndBinDirs()
      Clean default sources and binaries directories
      static java.lang.String compile​(java.lang.String srcDir, java.lang.String binDir, java.lang.String file)
      Compile Java files
      static java.lang.String compile​(java.lang.String srcDir, java.lang.String binDir, java.lang.String[] files)
      Compile Java file(s)
      static java.lang.String compile​(java.lang.String srcDir, java.lang.String binDir, java.lang.String cn, byte[] src, boolean force)
      Compile class from source
      static java.lang.String compileAdapterAndLoadClass​(ObjectDB adp, boolean force)
      Compile and load class for adapter
      static java.util.List<java.lang.String> compileAndGetClassFiles​(java.lang.String srcDir, java.lang.String binDir, boolean force)
      Compile files and get class
      static java.lang.String compileAndLoadClass​(Grant g, java.lang.String cn, java.lang.String docId, boolean force)
      Compile and load class from document ID
      static java.lang.String compileAndLoadClass​(java.lang.String cn, byte[] src, boolean force)
      Compile and load class from source
      static java.lang.String compileAndLoadClass​(java.lang.String cn, DocumentDB doc, boolean force)
      Compile and load class from document
      static java.lang.String compileAndLoadClass​(java.lang.String srcDir, java.lang.String binDir, java.lang.String cn, byte[] src, boolean force)
      Compile and load class from source
      static java.lang.String compileBusinessObjectAndLoadClass​(ObjectDB obj, boolean force)
      Compile and load class for business object
      static java.lang.String compileDispositionAndLoadClass​(ObjectDB dis, boolean force)
      Compile and load class for disposition
      static java.lang.String compileExternalObjectAndLoadClass​(ObjectDB ext, boolean force)
      Compile and load class for external object
      static java.lang.String compileProcessAndLoadClass​(ObjectDB pcs, boolean force)
      Compile and load class for business process
      static java.lang.String compileSharedCodeAndLoadClass​(ObjectDB scr, boolean force)
      Compile and load class for shared code
      static java.lang.String getAdapterBasePath​(ObjectDB adp)
      Get base relative path for disposition
      static java.lang.String getAdapterBinaryPath​(ObjectDB adp)
      Get binary relative path for business process
      static java.lang.String getAdapterClassName​(ObjectDB adp)
      Get class name for adapter
      static java.lang.String getAdapterClassName​(java.lang.String module, java.lang.String name)
      Get class name for adapter
      static java.lang.String getAdapterSourcePath​(ObjectDB adp)
      Get source relative path for business process
      static java.lang.String getBasePathFromClassName​(java.lang.String className)
      Get base path from class name
      static java.lang.String getBinaryPathFromClassName​(java.lang.String className)
      Get source path from class name
      static java.lang.String getBinDir()
      Get default binaries directory
      static java.lang.String getBuildDir()
      Get default build directory
      static java.lang.String getBusinessObjectBinaryPath​(ObjectDB obj)
      Get binary relative path for business object
      static java.lang.String getBusinessObjectClassName​(ObjectDB obj)
      Get class name for business object
      static java.lang.String getBusinessObjectClassName​(java.lang.String module, java.lang.String name)
      Get class name for business object
      static java.lang.String getBusinessObjectSourcePath​(ObjectDB obj)
      Get source relative path for business object
      static java.lang.String getBusinessProcessClassName​(java.lang.String module, java.lang.String name)
      Get class name for business process
      static java.lang.Class<?> getClass​(java.lang.String name)
      Get a class from name
      static java.lang.String getClassNameFromBinaryPath​(java.lang.String path, java.lang.String dir)
      Get class name from source path
      static java.lang.String getClassNameFromSourcePath​(java.lang.String path, java.lang.String dir)
      Get class name from source path
      static java.lang.String getClassPath​(boolean force)
      Get classpath including J2E libs, JDBC drivers and all third party libs
      static java.net.URL[] getClassPathItems()
      Get classpath items from URL class loader
      static java.lang.String getConfigurationObjectClassName​(java.lang.String pkg, java.lang.String module, java.lang.String name)
      Get class name for configuration object
      static java.lang.String getDispositionBasePath​(ObjectDB dis)
      Get base relative path for disposition
      static java.lang.String getDispositionBinaryPath​(ObjectDB dis)
      Get binary relative path for disposition
      static java.lang.String getDispositionClassName​(ObjectDB dis)
      Get Java class name for disposition
      static java.lang.String getDispositionClassName​(java.lang.String module, java.lang.String name)
      Get class name for disposition
      static java.lang.String getDispositionSourcePath​(ObjectDB dis)
      Get source relative path for disposition
      static java.lang.String getExternalObjectBinaryPath​(ObjectDB ext)
      Get binary relative path for external object
      static java.lang.String getExternalObjectClassName​(ObjectDB ext)
      Get class name for external object
      static java.lang.String getExternalObjectClassName​(java.lang.String module, java.lang.String name)
      Get class name for external object
      static java.lang.String getExternalObjectSourcePath​(ObjectDB ext)
      Get source relative path for external object
      static java.lang.String getJarDir()
      Get default shared lib directory
      static DocumentDB getJavaDocument​(Grant g, java.lang.String docId)
      Get document or null if not a Java source document
      static java.lang.String getProcessBinaryPath​(ObjectDB pcs)
      Get binary relative path for business process
      static java.lang.String getProcessClassName​(ObjectDB pcs)
      Get class name for business process
      static java.lang.String getProcessSourcePath​(ObjectDB pcs)
      Get source relative path for business process
      static java.lang.String getSharedCodeBasePath​(ObjectDB scr)
      Get base relative path for disposition
      static java.lang.String getSharedCodeBinaryPath​(ObjectDB scr)
      Get binary relative path for shared code
      static java.lang.String getSharedCodeClassName​(ObjectDB scr)
      Get class name for shared code
      static java.lang.String getSharedCodeClassName​(java.lang.String module, java.lang.String name)
      Get class name for shared code
      static java.lang.String getSharedCodeSourcePath​(ObjectDB scr)
      Get source relative path for shared code
      static java.lang.String getSourcePathFromClassName​(java.lang.String className)
      Get source path from class name
      static java.lang.String getSrcDir()
      Get default sources directory
      static java.lang.String getWorkflowClassName​(java.lang.String module, java.lang.String name)
      Alias to getBusinessProcessClassName
      static boolean isJavaArchive​(DocumentDB doc)
      Is document a Java archive (JAR)
      static boolean isJavaSource​(DocumentDB doc)
      Is document a Java source
      static boolean isJavaSource​(java.lang.String docId)
      Is document a Java source
      static java.lang.Object run​(java.lang.Class<?> cls, java.lang.String method)
      Run method
      static java.lang.Object run​(java.lang.Class<?> cls, java.lang.String method, java.lang.Object[] args)
      Run method
      static java.lang.Object run​(java.lang.Class<?> cls, java.lang.String method, java.util.List<java.lang.Object> args)
      Run method
      static void runMain​(java.lang.Class<?> cls, java.lang.String method, java.lang.String[] args)
      Run method
      static void runMain​(java.lang.Class<?> cls, java.lang.String method, java.util.List<java.lang.String> args)
      Run method
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getSrcDir

        public static java.lang.String getSrcDir()
        Get default sources directory
      • getBinDir

        public static java.lang.String getBinDir()
        Get default binaries directory
      • getBuildDir

        public static java.lang.String getBuildDir()
        Get default build directory
      • getJarDir

        public static java.lang.String getJarDir()
        Get default shared lib directory
      • cleanSrcAndBinDirs

        public static boolean cleanSrcAndBinDirs()
        Clean default sources and binaries directories
        Returns:
        false if deletion of one of the dirs failed
      • run

        public static java.lang.Object run​(java.lang.Class<?> cls,
                                           java.lang.String method)
                                    throws java.lang.Exception
        Run method
        Parameters:
        cls - Class
        method - Method
        Throws:
        java.lang.Exception
      • run

        public static java.lang.Object run​(java.lang.Class<?> cls,
                                           java.lang.String method,
                                           java.util.List<java.lang.Object> args)
                                    throws java.lang.Exception
        Run method
        Parameters:
        cls - Class
        method - Method
        args - List of object arguments
        Throws:
        java.lang.Exception
      • run

        public static java.lang.Object run​(java.lang.Class<?> cls,
                                           java.lang.String method,
                                           java.lang.Object[] args)
                                    throws java.lang.Exception
        Run method
        Parameters:
        cls - Class
        method - Method
        args - Array of object arguments
        Throws:
        java.lang.Exception
      • runMain

        public static void runMain​(java.lang.Class<?> cls,
                                   java.lang.String method,
                                   java.util.List<java.lang.String> args)
                            throws java.lang.Exception
        Run method
        Parameters:
        cls - Class
        method - Method
        args - List of string arguments
        Throws:
        java.lang.Exception
      • runMain

        public static void runMain​(java.lang.Class<?> cls,
                                   java.lang.String method,
                                   java.lang.String[] args)
                            throws java.lang.Exception
        Run method
        Parameters:
        cls - Class
        method - Method
        args - Array of string arguments
        Throws:
        java.lang.Exception
      • getClassPathItems

        public static java.net.URL[] getClassPathItems()
        Get classpath items from URL class loader
      • getClassPath

        public static java.lang.String getClassPath​(boolean force)
        Get classpath including J2E libs, JDBC drivers and all third party libs
        Parameters:
        force - Force scanning all jar from server and webapp
      • getBasePathFromClassName

        public static java.lang.String getBasePathFromClassName​(java.lang.String className)
        Get base path from class name
      • getSourcePathFromClassName

        public static java.lang.String getSourcePathFromClassName​(java.lang.String className)
        Get source path from class name
      • getBinaryPathFromClassName

        public static java.lang.String getBinaryPathFromClassName​(java.lang.String className)
        Get source path from class name
      • getClassNameFromSourcePath

        public static java.lang.String getClassNameFromSourcePath​(java.lang.String path,
                                                                  java.lang.String dir)
        Get class name from source path
        Parameters:
        path - Source (.java) file path
        dir - Optional dir part of path
      • getClassNameFromBinaryPath

        public static java.lang.String getClassNameFromBinaryPath​(java.lang.String path,
                                                                  java.lang.String dir)
        Get class name from source path
        Parameters:
        path - Binary (.class) file path
        dir - Optional dir part of path
      • getConfigurationObjectClassName

        public static java.lang.String getConfigurationObjectClassName​(java.lang.String pkg,
                                                                       java.lang.String module,
                                                                       java.lang.String name)
        Get class name for configuration object
        Parameters:
        pkg - Package
        module - Module name
        name - Object name
      • getBusinessObjectClassName

        public static java.lang.String getBusinessObjectClassName​(java.lang.String module,
                                                                  java.lang.String name)
        Get class name for business object
        Parameters:
        module - Module name
        name - Business object name
      • getBusinessObjectClassName

        public static java.lang.String getBusinessObjectClassName​(ObjectDB obj)
        Get class name for business object
        Parameters:
        obj - Business object
      • getBusinessObjectSourcePath

        public static java.lang.String getBusinessObjectSourcePath​(ObjectDB obj)
        Get source relative path for business object
        Parameters:
        obj - Business object
      • getBusinessObjectBinaryPath

        public static java.lang.String getBusinessObjectBinaryPath​(ObjectDB obj)
        Get binary relative path for business object
        Parameters:
        obj - Business object
      • compileBusinessObjectAndLoadClass

        public static java.lang.String compileBusinessObjectAndLoadClass​(ObjectDB obj,
                                                                         boolean force)
        Compile and load class for business object
        Parameters:
        obj - Business object
        force - Force?
      • getBusinessProcessClassName

        public static java.lang.String getBusinessProcessClassName​(java.lang.String module,
                                                                   java.lang.String name)
        Get class name for business process
        Parameters:
        module - Module name
        name - Business process name
      • getWorkflowClassName

        public static java.lang.String getWorkflowClassName​(java.lang.String module,
                                                            java.lang.String name)
        Alias to getBusinessProcessClassName
      • getProcessClassName

        public static java.lang.String getProcessClassName​(ObjectDB pcs)
        Get class name for business process
        Parameters:
        pcs - Business process
      • getProcessSourcePath

        public static java.lang.String getProcessSourcePath​(ObjectDB pcs)
        Get source relative path for business process
        Parameters:
        pcs - Business process
      • getProcessBinaryPath

        public static java.lang.String getProcessBinaryPath​(ObjectDB pcs)
        Get binary relative path for business process
        Parameters:
        pcs - Business process
      • compileProcessAndLoadClass

        public static java.lang.String compileProcessAndLoadClass​(ObjectDB pcs,
                                                                  boolean force)
        Compile and load class for business process
        Parameters:
        pcs - Business process
        force - Force?
      • getExternalObjectClassName

        public static java.lang.String getExternalObjectClassName​(java.lang.String module,
                                                                  java.lang.String name)
        Get class name for external object
        Parameters:
        module - Module name
        name - External object name
      • getExternalObjectClassName

        public static java.lang.String getExternalObjectClassName​(ObjectDB ext)
        Get class name for external object
        Parameters:
        ext - External object
      • getExternalObjectSourcePath

        public static java.lang.String getExternalObjectSourcePath​(ObjectDB ext)
        Get source relative path for external object
        Parameters:
        ext - External object
      • getExternalObjectBinaryPath

        public static java.lang.String getExternalObjectBinaryPath​(ObjectDB ext)
        Get binary relative path for external object
        Parameters:
        ext - External object
      • compileExternalObjectAndLoadClass

        public static java.lang.String compileExternalObjectAndLoadClass​(ObjectDB ext,
                                                                         boolean force)
        Compile and load class for external object
        Parameters:
        ext - External object
        force - Force?
      • getDispositionClassName

        public static java.lang.String getDispositionClassName​(java.lang.String module,
                                                               java.lang.String name)
        Get class name for disposition
        Parameters:
        module - Module name
        name - Disposition name
      • getDispositionClassName

        public static java.lang.String getDispositionClassName​(ObjectDB dis)
        Get Java class name for disposition
        Parameters:
        dis - Disposition
      • getDispositionBasePath

        public static java.lang.String getDispositionBasePath​(ObjectDB dis)
        Get base relative path for disposition
        Parameters:
        dis - Disposition
      • getDispositionSourcePath

        public static java.lang.String getDispositionSourcePath​(ObjectDB dis)
        Get source relative path for disposition
        Parameters:
        dis - Disposition
      • getDispositionBinaryPath

        public static java.lang.String getDispositionBinaryPath​(ObjectDB dis)
        Get binary relative path for disposition
        Parameters:
        dis - Disposition
      • compileDispositionAndLoadClass

        public static java.lang.String compileDispositionAndLoadClass​(ObjectDB dis,
                                                                      boolean force)
        Compile and load class for disposition
        Parameters:
        dis - Disposition
        force - Force?
      • getAdapterClassName

        public static java.lang.String getAdapterClassName​(java.lang.String module,
                                                           java.lang.String name)
        Get class name for adapter
        Parameters:
        module - Module name
        name - Adapter name
      • getAdapterClassName

        public static java.lang.String getAdapterClassName​(ObjectDB adp)
        Get class name for adapter
        Parameters:
        adp - Adapter
      • getAdapterBasePath

        public static java.lang.String getAdapterBasePath​(ObjectDB adp)
        Get base relative path for disposition
        Parameters:
        adp - Business process
      • getAdapterSourcePath

        public static java.lang.String getAdapterSourcePath​(ObjectDB adp)
        Get source relative path for business process
        Parameters:
        adp - Business process
      • getAdapterBinaryPath

        public static java.lang.String getAdapterBinaryPath​(ObjectDB adp)
        Get binary relative path for business process
        Parameters:
        adp - Business process
      • compileAdapterAndLoadClass

        public static java.lang.String compileAdapterAndLoadClass​(ObjectDB adp,
                                                                  boolean force)
        Compile and load class for adapter
        Parameters:
        adp - Adapter
        force - Force?
      • getSharedCodeClassName

        public static java.lang.String getSharedCodeClassName​(java.lang.String module,
                                                              java.lang.String name)
        Get class name for shared code
        Parameters:
        module - Module name
        name - Shared code name
      • getSharedCodeClassName

        public static java.lang.String getSharedCodeClassName​(ObjectDB scr)
        Get class name for shared code
        Parameters:
        scr - Shared code
      • getSharedCodeBasePath

        public static java.lang.String getSharedCodeBasePath​(ObjectDB scr)
        Get base relative path for disposition
        Parameters:
        scr - Shared code
      • getSharedCodeSourcePath

        public static java.lang.String getSharedCodeSourcePath​(ObjectDB scr)
        Get source relative path for shared code
        Parameters:
        scr - Shared code
      • getSharedCodeBinaryPath

        public static java.lang.String getSharedCodeBinaryPath​(ObjectDB scr)
        Get binary relative path for shared code
        Parameters:
        scr - Shared code
      • compileSharedCodeAndLoadClass

        public static java.lang.String compileSharedCodeAndLoadClass​(ObjectDB scr,
                                                                     boolean force)
        Compile and load class for shared code
        Parameters:
        scr - Shared code
        force - Force?
      • getJavaDocument

        public static DocumentDB getJavaDocument​(Grant g,
                                                 java.lang.String docId)
                                          throws java.io.IOException
        Get document or null if not a Java source document
        Parameters:
        g - Grant
        docId - Document ID
        Throws:
        java.io.IOException
      • compile

        public static java.lang.String compile​(java.lang.String srcDir,
                                               java.lang.String binDir,
                                               java.lang.String[] files)
                                        throws JavaCompilationException
        Compile Java file(s)
        Parameters:
        srcDir - Sources directory path
        binDir - Binaries directory path
        files - Java source relative file paths
        Returns:
        Compilation logs
        Throws:
        JavaCompilationException
      • compile

        public static java.lang.String compile​(java.lang.String srcDir,
                                               java.lang.String binDir,
                                               java.lang.String file)
                                        throws JavaCompilationException
        Compile Java files
        Parameters:
        srcDir - Sources directory path
        binDir - Binaries directory path
        Returns:
        null if no error occurred
        Throws:
        JavaCompilationException
      • compile

        public static java.lang.String compile​(java.lang.String srcDir,
                                               java.lang.String binDir,
                                               java.lang.String cn,
                                               byte[] src,
                                               boolean force)
        Compile class from source
        Parameters:
        srcDir - Source directory (if null defaults to system source directory)
        binDir - Binary directory (if null defaults to system binary directory)
        cn - Class name
        src - Class source (as byte array)
        force - Force?
        Returns:
        null if no error occurred
      • compileAndLoadClass

        public static java.lang.String compileAndLoadClass​(Grant g,
                                                           java.lang.String cn,
                                                           java.lang.String docId,
                                                           boolean force)
        Compile and load class from document ID
        Parameters:
        g - Grant
        cn - Class name
        docId - Document ID
        force - Force?
      • compileAndLoadClass

        public static java.lang.String compileAndLoadClass​(java.lang.String cn,
                                                           DocumentDB doc,
                                                           boolean force)
        Compile and load class from document
        Parameters:
        cn - Class name
        doc - Document
        force - Force?
      • compileAndLoadClass

        public static java.lang.String compileAndLoadClass​(java.lang.String cn,
                                                           byte[] src,
                                                           boolean force)
        Compile and load class from source
        Parameters:
        cn - Class name
        src - Class source (as byte array)
        force - Force?
      • compileAndLoadClass

        public static java.lang.String compileAndLoadClass​(java.lang.String srcDir,
                                                           java.lang.String binDir,
                                                           java.lang.String cn,
                                                           byte[] src,
                                                           boolean force)
        Compile and load class from source
        Parameters:
        srcDir - Source directory
        binDir - Binary directory
        cn - Class name
        src - Class source (as byte array)
        force - Force?
      • isJavaSource

        public static boolean isJavaSource​(java.lang.String docId)
        Is document a Java source
        Parameters:
        docId - Document ID
      • isJavaSource

        public static boolean isJavaSource​(DocumentDB doc)
        Is document a Java source
        Parameters:
        doc - Document
      • isJavaArchive

        public static boolean isJavaArchive​(DocumentDB doc)
        Is document a Java archive (JAR)
        Parameters:
        doc - Document
      • compileAndGetClassFiles

        public static java.util.List<java.lang.String> compileAndGetClassFiles​(java.lang.String srcDir,
                                                                               java.lang.String binDir,
                                                                               boolean force)
                                                                        throws java.lang.Exception
        Compile files and get class
        Parameters:
        srcDir - Source dir
        binDir - Binary dir
        Returns:
        List of compiled class files
        Throws:
        java.lang.Exception
      • getClass

        public static java.lang.Class<?> getClass​(java.lang.String name)
        Get a class from name
        Parameters:
        name - Class name
        Returns:
        null if not found in class loader
      • buildJar

        public static java.lang.String buildJar​(java.lang.String binDir,
                                                java.lang.String jarPath,
                                                java.lang.String version)
        Build a single jar with all source in bin directory
        Parameters:
        binDir - Binary directory
        jarPath - JAR path
        Returns:
        jar path
      • buildJar

        public static java.lang.String buildJar​(java.lang.String binDir,
                                                java.util.List<java.lang.String> paths,
                                                java.lang.String jarPath,
                                                java.lang.String version)
        Build a single jar with specified sources in the bin directory
        Parameters:
        binDir - Binary directory
        paths - Relative paths to class to add to jar
        jarPath - JAR path
        version - Optional version
        Returns:
        JAR path