List of usage examples for org.apache.wicket.protocol.http WebApplication getApplicationSettings
public final ApplicationSettings getApplicationSettings()
From source file:codetroopers.wicket.web.HotReloadingWicketFilter.java
License:Apache License
/** * Reset the class resolver, it removes stale classes. * Optimization is possible by removing from the map only changed classes * * NOTICE : as long as we don't touch the HomePage, this seems to work *//*from w ww . j a v a 2 s.c o m*/ private void resetClassAndResourcesCaches() { final WebApplication application = getApplication(); if (application != null) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Resetting the Application's ClassResolver and Resource Finders"); } application.getApplicationSettings().setClassResolver(new HotReloadingClassResolver()); //we reset the resourceStreamLocator cache by recreating resource finders List<IResourceFinder> resourceFinders = Lists.newArrayList(); resourceFinders .add(new org.apache.wicket.util.file.Path(compilationManager.getDestination().toString())); resourceFinders.add(new ClassPathResourceFinder("")); application.getResourceSettings().setResourceFinders(resourceFinders); } }
From source file:org.ops4j.pax.wicket.api.PaxWicketApplicationFactory.java
License:Apache License
private WebApplication createWicketApplicationViaCustomFactory() { WebApplication paxWicketApplication; paxWicketApplication = applicationFactory.createWebApplication(new ApplicationLifecycleListener() { private final List<ServiceRegistration> m_serviceRegistrations = new ArrayList<ServiceRegistration>(); private PageMounterTracker mounterTracker; private ComponentInstantiationListenerFacade componentInstanciationListener; public void onInit(WebApplication wicketApplication) { componentInstanciationListener = new ComponentInstantiationListenerFacade( delegatingComponentInstanciationListener); wicketApplication.addComponentInstantiationListener(componentInstanciationListener); IApplicationSettings applicationSettings = wicketApplication.getApplicationSettings(); applicationSettings.setClassResolver(delegatingClassResolver); addWicketService(IApplicationSettings.class, applicationSettings); ISessionSettings sessionSettings = wicketApplication.getSessionSettings(); sessionSettings.setPageFactory(pageFactory); addWicketService(ISessionSettings.class, sessionSettings); addWicketService(IDebugSettings.class, wicketApplication.getDebugSettings()); addWicketService(IExceptionSettings.class, wicketApplication.getExceptionSettings()); addWicketService(IFrameworkSettings.class, wicketApplication.getFrameworkSettings()); addWicketService(IMarkupSettings.class, wicketApplication.getMarkupSettings()); addWicketService(IPageSettings.class, wicketApplication.getPageSettings()); addWicketService(IRequestCycleSettings.class, wicketApplication.getRequestCycleSettings()); addWicketService(IResourceSettings.class, wicketApplication.getResourceSettings()); addWicketService(ISecuritySettings.class, wicketApplication.getSecuritySettings()); if (pageMounter != null) { for (MountPointInfo bookmark : pageMounter.getMountPoints()) { wicketApplication.mount(bookmark.getCodingStrategy()); }/*www. j ava2 s. c om*/ } // Now add a tracker so we can still mount pages later mounterTracker = new PageMounterTracker(bundleContext, wicketApplication, getApplicationName()); mounterTracker.open(); for (final IInitializer initializer : initializers) { initializer.init(wicketApplication); } } private <T> void addWicketService(Class<T> service, T serviceImplementation) { Properties props = new Properties(); // Note: This is kept for legacy props.setProperty("applicationId", getApplicationName()); props.setProperty(APPLICATION_NAME, getApplicationName()); String serviceName = service.getName(); ServiceRegistration registration = bundleContext.registerService(serviceName, serviceImplementation, props); m_serviceRegistrations.add(registration); } public void onDestroy(WebApplication wicketApplication) { wicketApplication.removeComponentInstantiationListener(componentInstanciationListener); if (mounterTracker != null) { mounterTracker.close(); mounterTracker = null; } for (ServiceRegistration reg : m_serviceRegistrations) { reg.unregister(); } m_serviceRegistrations.clear(); } }); return paxWicketApplication; }