Interface ILocationProvider

All Known Implementing Classes:
DefaultLocationProvider

public interface ILocationProvider

Provides a mechanism of obtaining a file path of given class path, resource or bundle for application running in OSGi context. This interface is used to provide a classpath of additional classes for IProcessManager. This interface implementation is used in IProcessManager and you can also use this interface to obtain a classpath of your classes. To do that, inject an instance of this interface. To change this mechanism, bind your implementation by Google Guice module and get an IProcessManager instance by that module.

  • Method Summary

    Modifier and Type
    Method
    Description
    getBundleLocation(org.osgi.framework.Bundle bundle)
    Returns a location of given bundle if you run your application and call this method within OSGi context.
    Returns the root class path location where given class is located.
    getClassPathLocation(org.osgi.framework.Bundle bundle)
    Returns given bundle's class root path location.
    getResourcePath(org.osgi.framework.Bundle bundle, String resource)
    Returns a file path to resource which is located within given bundle.
  • Method Details

    • getClassPathLocation

      String getClassPathLocation(Class<?> clazz) throws IOException

      Returns the root class path location where given class is located.

      Parameters:
      clazz - given class (not null)s
      Returns:
      class path location of the given class's bundle (not null)
      Throws:
      IOException - if an error occurred during reading given class's root location
    • getClassPathLocation

      String getClassPathLocation(org.osgi.framework.Bundle bundle) throws IOException

      Returns given bundle's class root path location. Given bundle must not be a fragment.

      This method works only if it called within OSGi context. Otherwise, NullPointerException is thrown.

      Parameters:
      bundle - given bundle (not null)
      Returns:
      given bundle's class path location (not null)
      Throws:
      IOException - if an error occurred during reading given bundle
    • getBundleLocation

      String getBundleLocation(org.osgi.framework.Bundle bundle) throws IOException

      Returns a location of given bundle if you run your application and call this method within OSGi context. Otherwise NullPointerException will be thrown.

      Parameters:
      bundle - given bundle (not null)
      Returns:
      a location of the jar of given bundle (may be null)
      Throws:
      IOException - if an error occurred during reading given bundle
    • getResourcePath

      String getResourcePath(org.osgi.framework.Bundle bundle, String resource) throws IOException

      Returns a file path to resource which is located within given bundle. If bundle is archived, then resource is extracted from archive to temporary directory, and path to it is returned.

      Parameters:
      bundle - given bundle (not null)
      resource - given location of resource within given bundle (not null)
      Returns:
      file path to resource which is located within given bundle (not null)
      Throws:
      IOException - if an error occurred during reading given bundle