Example usage for org.apache.wicket.protocol.http WebApplication getExceptionSettings

List of usage examples for org.apache.wicket.protocol.http WebApplication getExceptionSettings

Introduction

In this page you can find the example usage for org.apache.wicket.protocol.http WebApplication getExceptionSettings.

Prototype

public final ExceptionSettings getExceptionSettings() 

Source Link

Usage

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());
                }//w  w w  .  ja  v  a2 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;
}