@Override public String loadStringResource(final Component component, String key, final Locale locale, final String style, final String variation) { if (key.contains(",")) { key = key.substring(0, key.lastIndexOf(',')); return resourceSettings.getLocalizer().getStringIgnoreSettings(key, component, null, locale, style, variation); } return null; } });
/** * In case you want to provide your own list of string resource loaders * * @return Iterator */ protected Iterator<IStringResourceLoader> getStringResourceLoaders() { Iterator<IStringResourceLoader> iter = Application.get() .getResourceSettings() .getStringResourceLoaders() .iterator(); return iter; }
/** * If true, than throw an exception if a property key is not found. If false, just a warning is * issued in the logged. * * @return throwExceptionIfPropertyNotFound */ private static boolean isThrowExceptionIfPropertyNotFound() { return Application.get().getResourceSettings().getThrowExceptionOnMissingResource(); }
IResourceSettings resourceSettings = getResourceSettings(); resourceSettings.addResourceFolder("pages"); //the full path to your folder, relative to the context root resourceSettings.setResourceStreamLocator((IResourceStreamLocator) new PathStripperLocator());
/** * Clears all the wicket caches so that resources and localization files will be re-read */ public void clearWicketCaches() { getResourceSettings().getPropertiesFactory().clearCache(); getResourceSettings().getLocalizer().clearCache(); }
List<IStringResourceLoader> loaders = resourceSettings.getStringResourceLoaders(); loaders.add(new ClassFromKeyStringResourceLoader()); loaders.add(new IStringResourceLoader() { resourceSettings.setCachingStrategy(new QueryStringWithVersionResourceCachingStrategy(new LastModifiedResourceVersion())); } else { resourceSettings.setCachingStrategy(new FilenameWithVersionResourceCachingStrategy(new LastModifiedResourceVersion())); final IResourceStreamLocator resourceStreamLocator = resourceSettings.getResourceStreamLocator(); resourceSettings.setResourceStreamLocator(new IResourceStreamLocator() { @Override public IResourceStream locate(Class<?> clazz, final String path) { resourceSettings.getLocalizer().setEnableCache(false); resourceSettings.setThrowExceptionOnMissingResource(false); resourceSettings.setPackageResourceGuard(resourceGuard);
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; }
Iterator iter = resourceSettings.getStringResourceLoaders().iterator(); while (iter.hasNext()) if (resourceSettings.getUseDefaultOnMissingResource()) if (resourceSettings.getThrowExceptionOnMissingResource())
/** * Get the properties file factory which loads the properties based on locale and style from * *.properties and *.xml files * * @return properties factory */ protected IPropertiesFactory getPropertiesFactory() { return Application.get().getResourceSettings().getPropertiesFactory(); }
if (resourceSettings.getUseDefaultOnMissingResource()) if (resourceSettings.getThrowExceptionOnMissingResource())
/** * @see org.apache.wicket.markup.html.IPackageResourceGuard#accept(java.lang.Class, * java.lang.String) */ public boolean accept(Class<?> scope, String path) { IPackageResourceGuard guard = Application.get() .getResourceSettings() .getPackageResourceGuard(); return guard.accept(scope, path); }
.getResourceStreamLocator() .locate(clazz, fullPath); .getResourceWatcher(true); if (watcher != null)
getResourceSettings().setResourceFinder(getResourceFinder()); if (resourceFolder != null) getResourceSettings().addResourceFolder(resourceFolder);
if (this.application.getResourceFinder() == null) this.application.getResourceSettings().setResourceFinder( new WebApplicationPath(context)); this.application.getResourceSettings().setResourcePollFrequency(null);
getResourceSettings().setResourceStreamLocator(new GeoServerResourceStreamLocator()); for (IStringResourceLoader loader : alternateResourceLoaders) { LOGGER.info("Registering alternate resource loader: " + loader); getResourceSettings().addStringResourceLoader(loader); getResourceSettings().addStringResourceLoader(0, new GeoServerStringResourceLoader()); getResourceSettings().setDisableGZipCompression(true);
getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND); getDebugSettings().setComponentUseCheck(true); getMarkupSettings().setStripWicketTags(false); IExceptionSettings.SHOW_EXCEPTION_PAGE); getDebugSettings().setAjaxDebugModeEnabled(true); getResourceSettings().setStripJavascriptCommentsAndWhitespace(false); getResourceSettings().setResourcePollFrequency(null); getDebugSettings().setComponentUseCheck(false); getMarkupSettings().setStripWicketTags(true); IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE); getDebugSettings().setAjaxDebugModeEnabled(false); getResourceSettings().setStripJavascriptCommentsAndWhitespace(true);
public void init(final Application application) { // disable ModificationWatcher application.getResourceSettings().setResourcePollFrequency(null); // use plain JDK Object(Input|Output)Stream ISerializer serializer = new GaeObjectSerializer(application.getApplicationKey()); application.getFrameworkSettings().setSerializer(serializer); // save older version of pages in the HttpSession final DataStoreEvictionStrategy evictionStrategy; if (application instanceof GaeApplication) { evictionStrategy = ((GaeApplication)application).getEvictionStrategy(); } else { evictionStrategy = new PageNumberEvictionStrategy(10); } application .setPageManagerProvider(new GaePageManagerProvider(application, evictionStrategy)); // disable file cleaning because it starts a new thread application.getResourceSettings().setFileUploadCleaner(null); }
getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND); getDebugSettings().setComponentUseCheck(true); getMarkupSettings().setStripWicketTags(false); getDebugSettings().setDevelopmentUtilitiesEnabled(true); getResourceSettings().setJavascriptCompressor(null); getRequestCycleSettings().addResponseFilter(EmptySrcAttributeCheckFilter.INSTANCE); getResourceSettings().setResourcePollFrequency(null); getDebugSettings().setComponentUseCheck(false); getMarkupSettings().setStripWicketTags(true); getDebugSettings().setAjaxDebugModeEnabled(false); getDebugSettings().setDevelopmentUtilitiesEnabled(false); getResourceSettings().setJavascriptCompressor(new DefaultJavascriptCompressor());
/** * Installs given settings for given application * * @param app The current application * @param settings The settings to use */ public static void install(final Application app, final IBootstrapSettings settings) { app.setMetaData(BOOTSTRAP_SETTINGS_METADATA_KEY, settings); if (settings.getBootstrapLessCompilerSettings().useLessCompiler()) { app.getResourceSettings().setResourceStreamLocator(new CachingResourceStreamLocator(new LessResourceStreamLocator())); } if (settings.updateSecurityManger()) { updateSecurityManager(app, settings); } }
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); } }