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

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

Introduction

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

Prototype

public final DebugSettings getDebugSettings() 

Source Link

Usage

From source file:org.efaps.esjp.ui.dev.DevUtils.java

License:Apache License

public Return toggleDevUtils(final Parameter _parameter) throws EFapsException {
    //Administration
    if (Role.get(UUID.fromString("1d89358d-165a-4689-8c78-fc625d37aacd")).isAssigned()) {
        final WebApplication application = WebApplication.get();
        DevUtils.LOG/*from   w  w  w. j av a2  s . c  o m*/
                .info("Toggle devutils: " + !application.getDebugSettings().isDevelopmentUtilitiesEnabled());
        application.getDebugSettings().setDevelopmentUtilitiesEnabled(
                !application.getDebugSettings().isDevelopmentUtilitiesEnabled());

        // check to add them only once
        if (application.getMetaData(DevUtils.DEBUG_BAR_CONTRIBUTED) == null) {
            DebugBar.registerContributor(VersionDebugContributor.DEBUG_BAR_CONTRIB, application);
            DebugBar.registerContributor(InspectorDebugPanel.DEBUG_BAR_CONTRIB, application);
            DebugBar.registerContributor(SessionSizeDebugPanel.DEBUG_BAR_CONTRIB, application);
            DebugBar.registerContributor(PageSizeDebugPanel.DEBUG_BAR_CONTRIB, application);
            application.setMetaData(DevUtils.DEBUG_BAR_CONTRIBUTED, true);
        }
    }
    return new Return();
}

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());
                }/*from  w w  w.j  av 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;
}