protected String getPluginConfigEditorClass(String pluginClass) { if (pluginClass == null) { return null; } try { Class<?> clazz = Class.forName(pluginClass); if (AbstractFieldPlugin.class.isAssignableFrom(clazz)) { return FieldPluginEditorPlugin.class.getName(); } else if (MixinLoaderPlugin.class.isAssignableFrom(clazz)) { return MixinLoaderPluginEditorPlugin.class.getName(); } else if (ListViewPlugin.class.isAssignableFrom(clazz)) { return ListViewPluginEditorPlugin.class.getName(); } else if (RenderPlugin.class.isAssignableFrom(clazz)) { return RenderPluginEditorPlugin.class.getName(); } } catch (ClassNotFoundException ex) { IResourceSettings resourceSettings = Application.get().getResourceSettings(); IResourceStreamLocator locator = resourceSettings.getResourceStreamLocator(); IResourceStream stream = locator.locate(null, pluginClass.replace('.', '/') + ".html"); if (stream == null) { String message = ex.getClass().getName() + ": " + ex.getMessage(); log.error(message, ex); } else { return LayoutPluginEditorPlugin.class.getName(); } } return null; }
private static String readResourceNoCache(Class scope, String file) { InputStream inputStream = null; try { final String path = Packages.absolutePath(scope, file); final IResourceStream resourceStream = Application.get().getResourceSettings().getResourceStreamLocator() .locate(scope, path); inputStream = resourceStream.getInputStream(); return Streams.readString(inputStream, "utf-8"); } catch (ResourceStreamNotFoundException e) { throw new RuntimeException(String.format("Can't find resource \"%s.%s\"", scope.getName(), file), e); } catch (IOException e) { throw new RuntimeException(String.format("Can't read resource \"%s.%s\"", scope.getName(), file), e); } finally { Closeables.closeQuietly(inputStream); } }
.getResourceStreamLocator() .locate(clazz, path); if (stream != null)
/** * Get the XSL resource stream * * @param component * * @return The XSLT file resource stream */ private IResourceStream getResourceStream(final Component component) { final IResourceStream resourceStream; String filePath = xslFile; if (filePath == null) { filePath = component.findParentWithAssociatedMarkup() .getClass() .getPackage() .getName() .replace('.', '/') + "/" + component.getId(); } resourceStream = Application.get().getResourceSettings().getResourceStreamLocator().locate( getClass(), filePath, component.getStyle(), component.getLocale(), XsltTransformer.extension); return resourceStream; } }
/** * Get the XSL resource stream * * @param component * * @return The XSLT file resource stream */ private IResourceStream getResourceStream(final Component component) { final IResourceStream resourceStream; String filePath = this.xslFile; if (filePath == null) { filePath = component.findParentWithAssociatedMarkup().getClass().getPackage().getName() .replace('.', '/') + "/" + component.getId(); } resourceStream = Application.get().getResourceSettings().getResourceStreamLocator().locate( getClass(), filePath, component.getStyle(), component.getLocale(), XsltTransformer.extension); return resourceStream; } }
IResourceStreamLocator locator = resourceSettings.getResourceStreamLocator(); IResourceStream stream = locator.locate(null, className.replace('.', '/') + ".html"); if (stream != null) {
/** * Gets whether a resource for a given set of criteria exists. * * @param scope * This argument will be used to get the class loader for loading the package * resource, and to determine what package it is in. Typically this is the class in * which you call this method * @param path * The path to the resource * @param locale * The locale of the resource * @param style * The style of the resource (see {@link org.apache.wicket.Session}) * @return true if a resource could be loaded, false otherwise */ public static boolean exists(final Class<?> scope, final String path, final Locale locale, final String style) { String absolutePath = Packages.absolutePath(scope, path); return Application.get() .getResourceSettings() .getResourceStreamLocator() .locate(scope, absolutePath, style, locale, null) != null; }
/** * Obtains an {@link IResourceStream} from the application's * {@link IResourceStreamLocator#locate(Class, String)} * * @param scope * This argument will be used to get the class loader for loading the package * resource, and to determine what package it is in. * @param path * The path to the resource */ public PackageResourceStream(Class<?> scope, String path) { String absolutePath = Packages.absolutePath(scope, path); resourceStream = Application.get().getResourceSettings().getResourceStreamLocator().locate( scope, absolutePath, null, null, null); if (resourceStream == null) { throw new WicketRuntimeException("Cannot find resource with " + scope.getName() + " and path " + path); } }
/** * Obtains an {@link IResourceStream} from the application's * {@link IResourceStreamLocator#locate(Class, String)} * * @param scope * This argument will be used to get the class loader for loading the package * resource, and to determine what package it is in. * @param path * The path to the resource */ public PackageResourceStream(Class scope, String path) { String absolutePath = Packages.absolutePath(scope, path); resourceStream = Application.get().getResourceSettings().getResourceStreamLocator().locate( scope, absolutePath, null, null, null); if (resourceStream == null) { throw new WicketRuntimeException("Cannot find resource with " + scope.getName() + " and path " + path); } }
/** * Gets whether a resource for a given set of criteria exists. * * @param scope * This argument will be used to get the class loader for loading the package * resource, and to determine what package it is in. Typically this is the class in * which you call this method * @param path * The path to the resource * @param locale * The locale of the resource * @param style * The style of the resource (see {@link org.apache.wicket.Session}) * @return true if a resource could be loaded, false otherwise */ public static boolean exists(final Class scope, final String path, final Locale locale, final String style) { String absolutePath = Packages.absolutePath(scope, path); return Application.get().getResourceSettings().getResourceStreamLocator().locate(scope, absolutePath, style, locale, null) != null; }
.getResourceStreamLocator() .locate(clazz, fullPath);
IResourceStream stream = app.getResourceSettings().getResourceStreamLocator().locate(clazz, path);
.getResourceStreamLocator() .locate(getScope(), absolutePath, style, locale, null);
.getResourceStreamLocator() .locate(getScope(), absolutePath, style, locale, null);
final IResourceStreamLocator resourceStreamLocator = resourceSettings.getResourceStreamLocator(); resourceSettings.setResourceStreamLocator(new IResourceStreamLocator() { @Override