Interface ILocationProvider
- All Known Implementing Classes:
DefaultLocationProvider
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 TypeMethodDescriptiongetBundleLocation
(org.osgi.framework.Bundle bundle) Returns a location of given bundle if you run your application and call this method within OSGi context.getClassPathLocation
(Class<?> clazz) 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
Returns the root class path location where given class is located.
- Parameters:
clazz
- given class (notnull
)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
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 (notnull
)- Returns:
- given bundle's class path location (not
null
) - Throws:
IOException
- if an error occurred during reading given bundle
-
getBundleLocation
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 (notnull
)- Returns:
- a location of the jar of given bundle (may be
null
) - Throws:
IOException
- if an error occurred during reading given bundle
-
getResourcePath
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 (notnull
)resource
- given location of resource within given bundle (notnull
)- Returns:
- file path to resource which is located within given bundle (not
null
) - Throws:
IOException
- if an error occurred during reading given bundle
-