@Override public IResourceCachingStrategy get() { return app.getResourceSettings().getCachingStrategy(); } };
@Override public String get() { return app.getResourceSettings().getParentFolderPlaceholder(); } };
@Provides public Localizer getLocalizer(WebApplication application) { return application.getResourceSettings().getLocalizer(); }
/** * Adds the given resourcePath to the resource finder from the given application. * * @param application * the application * @param resourcePath * the resource path * @see org.apache.wicket.settings.ResourceSettings#getResourceFinders() */ public static void addResourceFinder(final WebApplication application, final String resourcePath) { application.getResourceSettings().getResourceFinders() .add(new WebApplicationPath(application.getServletContext(), resourcePath)); }
public static void reindex(final WebApplication application) { final List<IResourceFinder> resourceFinders = application.getResourceSettings().getResourceFinders(); for (IResourceFinder resourceFinder : resourceFinders) { if (resourceFinder instanceof WebjarsResourceFinder) { WebjarsVersion.reset(); WebjarsResourceFinder webjarsResourceFinder = (WebjarsResourceFinder) resourceFinder; webjarsResourceFinder.reindex(); break; } } }
public static void reindex(final WebApplication application) { final List<IResourceFinder> resourceFinders = application.getResourceSettings().getResourceFinders(); for (IResourceFinder resourceFinder : resourceFinders) { if (resourceFinder instanceof WebjarsResourceFinder) { WebjarsVersion.reset(); WebjarsResourceFinder webjarsResourceFinder = (WebjarsResourceFinder) resourceFinder; webjarsResourceFinder.reindex(); break; } } }
/** * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT. */ @Override public void internalDestroy() { // destroy the resource watcher IModificationWatcher resourceWatcher = getResourceSettings().getResourceWatcher(false); if (resourceWatcher != null) { resourceWatcher.destroy(); } IFileCleaner fileCleaner = getResourceSettings().getFileCleaner(); if (fileCleaner != null) { fileCleaner.destroy(); } super.internalDestroy(); }
/** * mounts a special resource reference mapper that transform webjars resource urls into a cdn url. * * @param app current web app * @param cdnUrl the cdn url to use */ private static void mountCDNMapper(final WebApplication app, String cdnUrl) { Supplier<String> parentFolderPlaceholderProvider = () -> app.getResourceSettings().getParentFolderPlaceholder(); Supplier<IResourceCachingStrategy> cachingStrategyProvider = () -> app.getResourceSettings().getCachingStrategy(); LOG.info("use cdn resources from {}", cdnUrl); IRequestMapper delegate = new ResourceReferenceMapper(new PageParametersEncoder(), parentFolderPlaceholderProvider, cachingStrategyProvider); app.mount(new WebjarsCDNRequestMapper(delegate, cdnUrl, cachingStrategyProvider)); }
/** * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT. */ @Override public void internalDestroy() { // destroy the resource watcher IModificationWatcher resourceWatcher = getResourceSettings().getResourceWatcher(false); if (resourceWatcher != null) { resourceWatcher.destroy(); } IFileCleaner fileCleaner = getResourceSettings().getFileCleaner(); if (fileCleaner != null) { fileCleaner.destroy(); } super.internalDestroy(); }
/** * Use this method to enable hot deploy of your html templates on development. Works only with * jetty. Only for * * @param application * the new html hot deploy */ public static void setHtmlHotDeploy(final WebApplication application) { application.getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND); final String slash = "/"; String realPath = application.getServletContext().getRealPath(slash); if ((realPath != null) && !realPath.endsWith(slash)) { realPath += slash; } final String javaSourcePath = realPath + "../java"; final String resourcesPath = realPath + "../resources"; addResourceFinder(application, javaSourcePath); addResourceFinder(application, resourcesPath); }
/** * Sets a set of default development settings for development mode for the given application. * * @param application * the new debug settings for development */ public static void setDefaultDebugSettingsForDevelopment(final WebApplication application) { ApplicationExtensions.setHtmlHotDeploy(application); ApplicationExtensions.setDebugSettingsForDevelopment(application); ApplicationExtensions.setExceptionSettingsForDevelopment(application); // set the behavior if an missing resource is found... application.getResourceSettings().setThrowExceptionOnMissingResource(true); }
/** * Asserts that there is a feedback message provided by a given component * * @param component * the component that provided the expected feedback message. Optional. * @param key * the resource key for the feedback message. Mandatory. * @param model * the model used for interpolating the feedback message. Optional. * @param filter * the filter that decides in which messages to look in. E.g. with a specific * level, rendered or not, etc. */ public void assertComponentFeedbackMessage(Component component, String key, IModel<?> model, IFeedbackMessageFilter filter) { Args.notNull(key, "key"); String expectedMessage = getApplication().getResourceSettings().getLocalizer().getString(key, component, model); List<FeedbackMessage> feedbackMessages = getFeedbackMessages(filter); List<Serializable> actualMessages = getActualFeedbackMessages(feedbackMessages); assertTrue(String.format("Feedback message with key '%s' cannot be found in %s", key, actualMessages), actualMessages.contains(expectedMessage)); }
/** * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT. */ protected void internalDestroy() { // destroy the resource watcher ModificationWatcher resourceWatcher = getResourceSettings().getResourceWatcher(false); if (resourceWatcher != null) { resourceWatcher.destroy(); } super.internalDestroy(); bufferedResponses.clear(); getSessionStore().destroy(); FileCleaner.destroy(); }
/** * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT. */ @Override protected void internalDestroy() { // destroy the resource watcher IModificationWatcher resourceWatcher = getResourceSettings().getResourceWatcher(false); if (resourceWatcher != null) { resourceWatcher.destroy(); } super.internalDestroy(); bufferedResponses.clear(); getSessionStore().destroy(); FileCleaner.destroy(); }
@Override public void init(WebApplication webApplication) { IPackageResourceGuard packageResourceGuard = webApplication.getResourceSettings().getPackageResourceGuard(); if (packageResourceGuard instanceof SecurePackageResourceGuard) { SecurePackageResourceGuard guard = (SecurePackageResourceGuard) packageResourceGuard; for(String pattern : props.getPattern()){ guard.addPattern(pattern); } } wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass()) .withDetail("properties", props) .build()); }
@Override public void init(WebApplication webApplication) { IPackageResourceGuard packageResourceGuard = webApplication.getResourceSettings().getPackageResourceGuard(); if (packageResourceGuard instanceof SecurePackageResourceGuard) { SecurePackageResourceGuard guard = (SecurePackageResourceGuard) packageResourceGuard; for(String pattern : props.getPattern()){ guard.addPattern(pattern); } } wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass()) .withDetail("properties", props) .build()); }
/** * installs the webjars resource finder * * @param app the wicket application * @param settings the settings to use */ public static void install(WebApplication app, IWebjarsSettings settings) { final IWebjarsSettings existingSettings = settings(app); if (existingSettings == null) { if (settings == null) { settings = new WebjarsSettings(); } app.setMetaData(WEBJARS_SETTINGS_METADATA_KEY, settings); if (settings.useCdnResources()) { mountCDNMapper(app, settings.cdnUrl()); } final List<IResourceFinder> finders = app.getResourceSettings().getResourceFinders(); final WebjarsResourceFinder finder = new WebjarsResourceFinder(settings); if (!finders.contains(finder)) { finders.add(finder); } LOG.info("initialize wicket webjars with given settings: {}", settings); } }
/** * installs the webjars resource finder * * @param app the wicket application * @param settings the settings to use */ public static void install(WebApplication app, IWebjarsSettings settings) { final IWebjarsSettings existingSettings = settings(app); if (existingSettings == null) { if (settings == null) { settings = new WebjarsSettings(); } app.setMetaData(WEBJARS_SETTINGS_METADATA_KEY, settings); if (settings.useCdnResources()) { mountCDNMapper(app, settings.cdnUrl()); } final List<IResourceFinder> finders = app.getResourceSettings().getResourceFinders(); final WebjarsResourceFinder finder = new WebjarsResourceFinder(settings); if (!finders.contains(finder)) { finders.add(finder); } LOG.info("initialize wicket webjars with given settings: {}", settings); } }
/** * Asserts that there is a feedback message provided by a given component * * @param component * the component that provided the expected feedback message. Optional. * @param key * the resource key for the feedback message. Mandatory. * @param model * the model used for interpolating the feedback message. Optional. * @param filter * the filter that decides in which messages to look in. E.g. with a specific level, * rendered or not, etc. */ public void assertComponentFeedbackMessage(Component component, String key, IModel<?> model, IFeedbackMessageFilter filter) { Args.notNull(key, "key"); String expectedMessage = getApplication().getResourceSettings().getLocalizer().getString( key, component, model); List<FeedbackMessage> feedbackMessages = getFeedbackMessages(filter); List<Serializable> actualMessages = getActualFeedbackMessages(feedbackMessages); assertTrue(actualMessages.contains(expectedMessage), String .format("Feedback message with key '%s' cannot be found in %s", key, actualMessages)); }
application.getResourceSettings().getStringResourceLoaders().add(loader); config.getRegistry().register(loader, true);