use of org.pentaho.platform.api.engine.IPluginResourceLoader in project pentaho-platform by pentaho.
the class PluginGwtRpc method getSerializationPolicyUrl.
/**
* The request path is broken up for processing like so: Ex: given a request for serialization file at
* '/pentaho/content/data-access/resources/gwt/'
*
* @param serializationPolicyFilename the name of the serialization policy file that GWT is looking for
* @param moduleContextPath according to the example url, this would be
* '/content/data-access/resources/gwt/'
* @return a URL to the serialization policy file, or <code>null</code> if none applies, in which case the default
* serialization policy will apply
*/
@Nullable
private URL getSerializationPolicyUrl(@NonNull String serializationPolicyFilename, String moduleContextPath) {
ClassLoader serviceClassloader = PluginUtil.getClassLoaderForService(moduleContextPath);
if (serviceClassloader == null) {
// if we get here, then the service is not supplied by a plugin and thus we cannot hope to find
// the appropriate serialization policy.
logger.error(Messages.getInstance().getErrorString("GwtRpcPluginProxyServlet.ERROR_0005_FAILED_TO_FIND_PLUGIN", getAppContextPath()));
return null;
}
// We know what plugin is supposed to have the serialization policy file,
// now go find it in the plugin's filesystem.
IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, PentahoSessionHolder.getSession());
List<URL> urls = resLoader.findResources(serviceClassloader, serializationPolicyFilename);
if (urls.size() < 1) {
logger.error(Messages.getInstance().getErrorString("GwtRpcPluginProxyServlet.ERROR_0006_FAILED_TO_FIND_FILE", serializationPolicyFilename));
return null;
}
if (urls.size() > 1) {
logger.warn(Messages.getInstance().getString("GwtRpcPluginProxyServlet.WARN_MULTIPLE_RESOURCES_FOUND", serializationPolicyFilename));
}
return urls.get(0);
}
use of org.pentaho.platform.api.engine.IPluginResourceLoader in project pentaho-platform by pentaho.
the class DefaultPluginManager method getStaticResource.
@Deprecated
public InputStream getStaticResource(String path) {
for (IPlatformPlugin plugin : registeredPlugins.values()) {
Map<String, String> resourceMap = plugin.getStaticResourceMap();
for (String url : resourceMap.keySet()) {
if (isRequested(url, path)) {
IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
ClassLoader classLoader = classLoaderMap.get(plugin.getId());
String resourcePath = path.replace(url, resourceMap.get(url));
return resLoader.getResourceAsStream(classLoader, resourcePath);
}
}
}
return null;
}
use of org.pentaho.platform.api.engine.IPluginResourceLoader in project pentaho-platform by pentaho.
the class DefaultPluginManager method getPluginSetting.
@Override
public Object getPluginSetting(String pluginId, String key, String defaultValue) {
IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
ClassLoader classLoader = classLoaderMap.get(pluginId);
return resLoader.getPluginSetting(classLoader, key, defaultValue);
}
use of org.pentaho.platform.api.engine.IPluginResourceLoader in project pentaho-platform by pentaho.
the class PentahoSystemPluginManager method getStaticResource.
@Override
public InputStream getStaticResource(String path) {
for (IPlatformPlugin plugin : PentahoSystem.getAll(IPlatformPlugin.class)) {
Map<String, String> resourceMap = plugin.getStaticResourceMap();
for (String url : resourceMap.keySet()) {
if (isRequested(url, path)) {
IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
ClassLoader classLoader = PentahoSystem.get(ClassLoader.class, null, Collections.singletonMap(PLUGIN_ID, plugin.getId()));
String resourcePath = path.replace(url, resourceMap.get(url));
return resLoader.getResourceAsStream(classLoader, resourcePath);
}
}
}
return null;
}
Aggregations