|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader
public class PluginResourceLoader
The default implementation of the IPluginResourceLoader
. Obtains resources
by searching the root directory of a PluginClassLoader
.
PluginResourceLoader
will search the following places for plugin classes:
PluginResourceLoader
will search for non-class resources in several locations:
PentahoSystem.getSystemSetting(String, String)
and ISystemSettings
. System
settings are expected in a file named settings.xml in the root of the plugin directory.
Constructor Summary | |
---|---|
PluginResourceLoader()
|
Method Summary | |
---|---|
List<URL> |
findResources(Class<?> clazz,
String namePattern)
A searching method, yielding a list of plugin-related resources as URLs. |
List<URL> |
findResources(ClassLoader classLoader,
String namePattern)
|
String |
getPluginSetting(Class<?> pluginClass,
String key)
Searches for the plugin setting with the specified key. |
String |
getPluginSetting(Class<?> pluginClass,
String key,
String defaultVal)
Searches for the plugin setting with the specified key. |
String |
getPluginSetting(ClassLoader classLoader,
String key,
String defaultVal)
Searches for the plugin setting with the specified key. |
byte[] |
getResourceAsBytes(Class<? extends Object> clazz,
String resourcePath)
Gets a plugin-related resource in the form of an array of bytes. |
InputStream |
getResourceAsStream(Class<?> clazz,
String resourcePath)
Gets a plugin-related resource in the form of an InputStream. |
InputStream |
getResourceAsStream(ClassLoader classLoader,
String resourcePath)
Gets a plugin-related resource in the form of an InputStream. |
String |
getResourceAsString(Class<? extends Object> clazz,
String resourcePath)
Gets a plugin-related resource in the form of a String. |
String |
getResourceAsString(Class<? extends Object> clazz,
String resourcePath,
String charsetName)
Gets a plugin-related resource in the form of a String. |
ResourceBundle |
getResourceBundle(Class<?> clazz,
String resourcePath)
Retrieves a localized resource bundle for the plugin represented by pluginClass. |
String |
getSystemRelativePluginPath(ClassLoader classLoader)
|
void |
setOverrideClassloader(PluginClassLoader pluginClassloader)
Deprecated. |
void |
setRootDir(File rootDir)
Deprecated. instead of setting the root dir, have your application use a subclass of PluginResourceLoader that returns an appropriately pathed PluginClassLoader from an overridden getClassLoader(Class) . |
void |
setSettingsPath(String settingsPath)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PluginResourceLoader()
Method Detail |
---|
public void setSettingsPath(String settingsPath)
@Deprecated public void setOverrideClassloader(PluginClassLoader pluginClassloader)
public void setRootDir(File rootDir)
getClassLoader(Class)
.
PluginClassLoader
for the root directory.
rootDir
- the root directory in which to search for resourcespublic byte[] getResourceAsBytes(Class<? extends Object> clazz, String resourcePath)
IPluginResourceLoader
IPluginResourceLoader
is able to resolve
relative paths as it knows where to look for plugin classes and resources.
getResourceAsBytes
in interface IPluginResourceLoader
clazz
- a class that is part of the plugin package, used to identify the pluginresourcePath
- the (relative) path to a resource
public String getResourceAsString(Class<? extends Object> clazz, String resourcePath) throws UnsupportedEncodingException
IPluginResourceLoader
IPluginResourceLoader
is able to resolve
relative paths as it knows where to look for plugin classes and resources.
This method defaults the character encoding (how this default is chosen is up to the implementor).
getResourceAsString
in interface IPluginResourceLoader
clazz
- a class that is part of the plugin package, used to identify the pluginresourcePath
- the (relative) path to a resource
String
or null if the resource is not found
UnsupportedEncodingException
- if there is a problem encoding the stringpublic String getResourceAsString(Class<? extends Object> clazz, String resourcePath, String charsetName) throws UnsupportedEncodingException
IPluginResourceLoader
IPluginResourceLoader
is able to resolve
relative paths as it knows where to look for plugin classes and resources.
getResourceAsString
in interface IPluginResourceLoader
clazz
- a class that is part of the plugin package, used to identify the pluginresourcePath
- the (relative) path to a resourcecharsetName
- the character set to encode the string
String
or null if the resource is not found
UnsupportedEncodingException
- if there is a problem encoding the stringpublic String getSystemRelativePluginPath(ClassLoader classLoader)
public InputStream getResourceAsStream(Class<?> clazz, String resourcePath)
IPluginResourceLoader
IPluginResourceLoader
is able to resolve
relative paths as it knows where to look for plugin classes and resources.
getResourceAsStream
in interface IPluginResourceLoader
clazz
- a class that is part of the plugin package, used to identify the pluginresourcePath
- the (relative) path to a resource
InputStream
or null if the resource is not foundpublic InputStream getResourceAsStream(ClassLoader classLoader, String resourcePath)
IPluginResourceLoader
IPluginResourceLoader
is able to resolve
relative paths as it knows where to look for plugin classes and resources.
getResourceAsStream
in interface IPluginResourceLoader
classLoader
- the ClassLoader which was used to load a pluginresourcePath
- the (relative) path to a resource
InputStream
or null if the resource is not foundpublic List<URL> findResources(Class<?> clazz, String namePattern)
IPluginResourceLoader
findResources
in interface IPluginResourceLoader
namePattern
- a resource name pattern supporting wildcards
public List<URL> findResources(ClassLoader classLoader, String namePattern)
findResources
in interface IPluginResourceLoader
IPluginResourceLoader.findResources(Class, String)
public ResourceBundle getResourceBundle(Class<?> clazz, String resourcePath)
IPluginResourceLoader
IPluginResourceLoader.getResourceBundle(Class, String)
should behave similar to ResourceBundle.getBundle(String)
getResourceBundle
in interface IPluginResourceLoader
clazz
- a class that is part of the plugin package, used to identify the pluginresourcePath
- points to a particular resource bundle
ResourceBundle
ResourceBundle
public String getPluginSetting(Class<?> pluginClass, String key)
IPluginResourceLoader
null
if the setting is not found.
getPluginSetting
in interface IPluginResourceLoader
pluginClass
- a class that is part of the plugin package, used to identify the pluginkey
- the setting key
public String getPluginSetting(Class<?> pluginClass, String key, String defaultVal)
IPluginResourceLoader
getPluginSetting
in interface IPluginResourceLoader
pluginClass
- a class that is part of the plugin package, used to identify the pluginkey
- the setting keydefaultVal
- the value to return if no value is found for the setting key
public String getPluginSetting(ClassLoader classLoader, String key, String defaultVal)
IPluginResourceLoader
getPluginSetting
in interface IPluginResourceLoader
classLoader
- the classloader that was used to load the plugin, must be a PluginClassLoaderkey
- the setting keydefaultVal
- the value to return if no value is found for the setting key
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |