Package xal.tools

Class ResourceManager

java.lang.Object
xal.tools.ResourceManager

public abstract class ResourceManager extends Object

Provide normalized methods for getting resources There are two separate mechanisms for getting resources (jar based and file based)

- The jar based resource manager is the standard mechanism and it searches for resources in the binary's jar files. This the only option that should be used in production.

- The file based resource manager can be set as the default if the environment variable OPENXAL_FIND_RESOURCES_IN_ROOT is set to true. The OPENXAL_HOME environment variable must be set to the root of the project. The file based resource manager searches for resources directly on the file system relative to the project. This may be useful in development for IDE's that compile code in real time and do not generate the usual jar files. This option should not be used in production.

  • Field Details

  • Constructor Details

    • ResourceManager

      public ResourceManager()
  • Method Details

    • fetchResourceURL

      public URL fetchResourceURL(Class<?> rootClass, String resourcePath)
      Get the URL to the specified resource relative to the specified class
      Parameters:
      rootClass - class at the root of the group (this class must be at the same location as the resources directory in the jar file)
      resourcePath - to the resource relative to the group's resources directory
      Returns:
      URL to the resource
    • fetchResourceURL

      public abstract URL fetchResourceURL(String subdomain, Class<?> rootClass, String resourcePath)
      Get the URL to the specified resource relative to the specified class
      Parameters:
      subdomain - subdomain under which to search (e.g. for "core" with a subdomain of "test" we must search "core/test")
      rootClass - class at the root of the group (this class must be at the same location as the resources directory in the jar file)
      resourcePath - to the resource relative to the group's resources directory
      Returns:
      URL to the resource
    • getResourceURL

      public static URL getResourceURL(Class<?> rootClass, String resourcePath)
      Get the URL to the specified resource relative to the specified class
      Parameters:
      rootClass - class at the root of the group (this class must be at the same location as the resources directory in the jar file)
      resourcePath - to the resource relative to the group's resources directory
      Returns:
      URL to the resource
    • getResourceURL

      public static URL getResourceURL(String subdomain, Class<?> rootClass, String resourcePath)
      Get the URL to the specified resource relative to the specified class
      Parameters:
      subdomain - subdomain under which to search (e.g. for "core" with a subdomain of "test" we must search "core/test")
      rootClass - class at the root of the group (this class must be at the same location as the resources directory in the jar file)
      resourcePath - to the resource relative to the group's resources directory
      Returns:
      URL to the resource
    • getProjectHomePath

      public static String getProjectHomePath()
      get the path to the project home based on the "xal.home" property or corresponding "OPENXAL_HOME" environment variable if necessary