Example usage for org.apache.wicket RuntimeConfigurationType DEPLOYMENT

List of usage examples for org.apache.wicket RuntimeConfigurationType DEPLOYMENT

Introduction

In this page you can find the example usage for org.apache.wicket RuntimeConfigurationType DEPLOYMENT.

Prototype

RuntimeConfigurationType DEPLOYMENT

To view the source code for org.apache.wicket RuntimeConfigurationType DEPLOYMENT.

Click Source Link

Usage

From source file:org.apache.isis.viewer.wicket.viewer.integration.isis.DeploymentTypeWicketAbstract.java

License:Apache License

public RuntimeConfigurationType getConfigurationType() {
    return getDeploymentCategory().isProduction() ? RuntimeConfigurationType.DEPLOYMENT
            : RuntimeConfigurationType.DEVELOPMENT;
}

From source file:org.apache.openmeetings.db.util.ApplicationHelper.java

License:Apache License

public static IApplication ensureApplication(Long langId) {
    IApplication a = null;/* w  w  w . j a  va  2 s. co m*/
    if (Application.exists()) {
        a = (IApplication) Application.get();
    } else {
        WebApplication app = (WebApplication) Application.get(wicketApplicationName);
        LabelDao.initLanguageMap();
        if (app == null) {
            try {
                app = (WebApplication) LabelDao.getAppClass().newInstance();
            } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
                log.error("Failed to create Application");
                return null;
            }
            app.setServletContext(new MockServletContext(app, null));
            app.setName(wicketApplicationName);
            ServletContext sc = app.getServletContext();
            OMContextListener omcl = new OMContextListener();
            omcl.contextInitialized(new ServletContextEvent(sc));
            XmlWebApplicationContext xmlContext = new XmlWebApplicationContext();
            xmlContext.setConfigLocation("classpath:openmeetings-applicationContext.xml");
            xmlContext.setServletContext(sc);
            xmlContext.refresh();
            sc.setAttribute(ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, xmlContext);
            app.setConfigurationType(RuntimeConfigurationType.DEPLOYMENT);
            ThreadContext.setApplication(app);
            app.initApplication();
        } else {
            ThreadContext.setApplication(app);
        }
        a = (IApplication) Application.get(wicketApplicationName);
    }
    if (ThreadContext.getRequestCycle() == null) {
        ServletWebRequest req = new ServletWebRequest(new MockHttpServletRequest((Application) a,
                new MockHttpSession(a.getServletContext()), a.getServletContext()), "");
        RequestCycleContext rctx = new RequestCycleContext(req, new MockWebResponse(), a.getRootRequestMapper(),
                a.getExceptionMapperProvider().get());
        ThreadContext.setRequestCycle(new RequestCycle(rctx));
    }
    if (ThreadContext.getSession() == null) {
        WebSession s = WebSession.get();
        if (langId > 0) {
            ((IWebSession) s).setLanguage(langId);
        }
    }
    return a;
}

From source file:org.devgateway.eudevfin.ui.common.spring.WicketSpringApplication.java

License:Open Source License

@Override
protected void init() {
    super.init();

    configureBootstrap();//from  www  .j a va  2s  .com
    configureResourceBundles();

    //http://stackoverflow.com/questions/15996913/wicket-avoid-302-redirect-to-homepage
    //getRequestCycleSettings().setRenderStrategy(RenderStrategy.ONE_PASS_RENDER);

    setHeaderResponseDecorator(new RenderJavaScriptToFooterHeaderResponseDecorator());

    //mount annotated pages
    new AnnotatedMountScanner().scanPackage("org.devgateway.eudevfin").mount(this);

    //implemented ApplicationContextAware and added context as a parameter to help JUnit tests work
    getComponentInstantiationListeners().add(new SpringComponentInjector(this, springContext, true));

    if (getSecuritySettings().getAuthorizationStrategy() instanceof CompoundAuthorizationStrategy) {
        CompoundAuthorizationStrategy cas = (CompoundAuthorizationStrategy) getSecuritySettings()
                .getAuthorizationStrategy();
        cas.add(new PermissionAuthorizationStrategy());
    }

    getResourceSettings().setUseMinifiedResources(false); //prevents bug in wicket-bootstrap that's trying to minify a png       

    getApplicationSettings().setDefaultMaximumUploadSize(Bytes.megabytes(5));//set maximum file size for upload form

    //DEPLOYMENT MODE?
    if (RuntimeConfigurationType.DEPLOYMENT.equals(this.getConfigurationType())) {
        //compress resources
        getResourceSettings().setJavaScriptCompressor(
                new GoogleClosureJavaScriptCompressor(CompilationLevel.SIMPLE_OPTIMIZATIONS));
        getResourceSettings().setCssCompressor(new YuiCssCompressor());
    } else {
        //see https://issues.apache.org/jira/browse/WICKET-5388
        //we do not use SessionSizeDebugPanel
        List<IDebugBarContributor> debugContributors = new ArrayList<>();
        debugContributors.add(VersionDebugContributor.DEBUG_BAR_CONTRIB);
        debugContributors.add(InspectorDebugPanel.DEBUG_BAR_CONTRIB);
        debugContributors.add(SessionSizeDebugPanel.DEBUG_BAR_CONTRIB);
        DebugBar.setContributors(debugContributors, this);
    }

    //set response for session timeout:
    getApplicationSettings().setPageExpiredErrorPage(LoginPage.class);

    //add the navbar 
    //        Navbar navbar = new Navbar("navbar");
    //        navbar.setPosition(Navbar.Position.TOP);
    //        // show brand name
    //        navbar.brandName(Model.of("EU-DEVFIN"));
    //        //register the navbar as a spring bean
    //        springContext.getAutowireCapableBeanFactory().initializeBean(navbar, "wicketNavbar");

}

From source file:org.hippoecm.frontend.model.DetachMonitor.java

License:Apache License

private void writeObject(ObjectOutputStream output) throws IOException {
    if ((flags & ATTACHED) != 0) {
        // TODO: walk the stack to identify owner
        log.warn("Undetached DetachMonitor");
        if (RuntimeConfigurationType.DEPLOYMENT.equals(Application.get().getConfigurationType())) {
            detach();/*from   w ww.  j  av a 2s.  c o  m*/
        }
    }
    output.defaultWriteObject();
}

From source file:org.hippoecm.frontend.model.JcrItemModel.java

License:Apache License

private void writeObject(ObjectOutputStream output) throws IOException {
    if (isAttached()) {
        log.warn("Undetached JcrItemModel " + getPath());
        T object = this.getObject();
        if (object != null) {
            TraceMonitor.trace(object);/*from   w ww .j a v a  2 s. c o m*/
        }
        if (RuntimeConfigurationType.DEPLOYMENT.equals(Application.get().getConfigurationType())) {
            detach();
        }
    }
    output.defaultWriteObject();
}

From source file:org.hippoecm.frontend.plugins.console.menu.CheckPlugin.java

License:Apache License

public CheckPlugin(IPluginContext context, IPluginConfig config) {
    super(context, config);
    final Label message;
    add(message = new Label("message", new Model("")));
    message.setOutputMarkupId(true);/*from  w  ww  .j  a  v a 2s. c  o m*/
    add(new AjaxLink("check-link") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            String result = CheckPlugin.this.check();
            message.setDefaultModel(new Model(result));
            setModel(new Model(result));
            target.add(message);
        }
    });

    UserSession session = getSession();
    /* Uncommented at this time, the console can always show this plugin */
    if (session.getApplication().getConfigurationType().equals(RuntimeConfigurationType.DEPLOYMENT)) {
        setVisible(false);
    }
}

From source file:org.hippoecm.frontend.plugins.yui.header.YuiHeaderCache.java

License:Apache License

private static boolean isCacheEnabled() {
    return Application.get().getConfigurationType().equals(RuntimeConfigurationType.DEPLOYMENT);
}

From source file:org.hippoecm.frontend.plugins.yui.YuiWicketApplication.java

License:Apache License

@Override
public RuntimeConfigurationType getConfigurationType() {
    // suppress development mode warning from test output
    return RuntimeConfigurationType.DEPLOYMENT;
}

From source file:org.lbogdanov.poker.web.AppInitializer.java

License:Apache License

/**
 * {@inheritDoc}//  w ww . j a va 2s  . c  om
 */
@Override
protected Injector getInjector() {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();
    try {
        InputStream settings = Resources.newInputStreamSupplier(Resources.getResource("settings.properties"))
                .getInput();
        Properties props = new Properties();
        try {
            props.load(settings);
        } finally {
            settings.close();
        }
        Settings.init(Maps.fromProperties(props));
    } catch (IOException ioe) {
        throw Throwables.propagate(ioe);
    }
    final boolean isDevel = DEVELOPMENT_MODE.asBool().or(false);
    Module shiroModule = new ShiroWebModule(servletContext) {

        @Override
        @SuppressWarnings("unchecked")
        protected void configureShiroWeb() {
            bind(String.class).annotatedWith(Names.named(InjectableOAuthFilter.FAILURE_URL_PARAM))
                    .toInstance("/");
            // TODO simple ini-based realm for development
            bindRealm().toInstance(new IniRealm(IniFactorySupport.loadDefaultClassPathIni()));
            bindRealm().to(InjectableOAuthRealm.class).in(Singleton.class);

            addFilterChain("/" + Constants.OAUTH_CLBK_FILTER_URL, Key.get(InjectableOAuthFilter.class));
            addFilterChain("/" + Constants.OAUTH_FILTER_URL,
                    config(CallbackUrlSetterFilter.class, Constants.OAUTH_CLBK_FILTER_URL),
                    Key.get(InjectableOAuthUserFilter.class));
        }

        @Provides
        @Singleton
        private OAuthProvider getOAuthProvider() {
            Google2Provider provider = new Google2Provider();
            provider.setKey(GOOGLE_OAUTH_KEY.asString().get());
            provider.setSecret(GOOGLE_OAUTH_SECRET.asString().get());
            provider.setCallbackUrl("example.com"); // fake URL, will be replaced by CallbackUrlSetterFilter
            provider.setScope(Google2Scope.EMAIL_AND_PROFILE);
            return provider;
        }

    };
    Module appModule = new ServletModule() {

        @Override
        protected void configureServlets() {
            ServerConfig dbConfig = new ServerConfig();
            String jndiDataSource = DB_DATA_SOURCE.asString().orNull();
            if (Strings.isNullOrEmpty(jndiDataSource)) { // use direct JDBC connection
                DataSourceConfig dsConfig = new DataSourceConfig();
                dsConfig.setDriver(DB_DRIVER.asString().get());
                dsConfig.setUrl(DB_URL.asString().get());
                dsConfig.setUsername(DB_USER.asString().orNull());
                dsConfig.setPassword(DB_PASSWORD.asString().orNull());
                dbConfig.setDataSourceConfig(dsConfig);
            } else {
                dbConfig.setDataSourceJndiName(jndiDataSource);
            }
            dbConfig.setName("PlanningPoker");
            dbConfig.setDefaultServer(true);
            dbConfig.addClass(Session.class);
            dbConfig.addClass(User.class);

            bind(EbeanServer.class).toInstance(EbeanServerFactory.create(dbConfig));
            bind(SessionService.class).to(SessionServiceImpl.class);
            bind(UserService.class).to(UserServiceImpl.class);
            bind(WebApplication.class).to(PokerWebApplication.class);
            bind(MeteorServlet.class).in(Singleton.class);
            bind(ObjectMapper.class).toProvider(new Provider<ObjectMapper>() {

                @Override
                public ObjectMapper get() {
                    SimpleModule module = new SimpleModule().addSerializer(UserSerializer.get());
                    return new ObjectMapper().registerModule(module);
                }

            }).in(Singleton.class);
            String wicketConfig = (isDevel ? RuntimeConfigurationType.DEVELOPMENT
                    : RuntimeConfigurationType.DEPLOYMENT).toString();
            ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
            params.put(ApplicationConfig.FILTER_CLASS, WicketFilter.class.getName())
                    .put(ApplicationConfig.PROPERTY_SESSION_SUPPORT, Boolean.TRUE.toString())
                    .put(ApplicationConfig.BROADCAST_FILTER_CLASSES, TrackMessageSizeFilter.class.getName())
                    .put(ApplicationConfig.BROADCASTER_CACHE, UUIDBroadcasterCache.class.getName())
                    .put(ApplicationConfig.SHOW_SUPPORT_MESSAGE, Boolean.FALSE.toString())
                    .put(WicketFilter.FILTER_MAPPING_PARAM, "/*")
                    .put(WebApplication.CONFIGURATION, wicketConfig)
                    .put(WicketFilter.APP_FACT_PARAM, GuiceWebApplicationFactory.class.getName())
                    .put("injectorContextAttribute", Injector.class.getName()).build();
            serve("/*").with(MeteorServlet.class, params.build());
        }

    };
    Stage stage = isDevel ? Stage.DEVELOPMENT : Stage.PRODUCTION;
    return Guice.createInjector(stage, ShiroWebModule.guiceFilterModule(), shiroModule, appModule);
}

From source file:org.projectforge.web.wicket.WicketApplication.java

License:Open Source License

/**
 * Own solution: uses development parameter of servlet context init parameter (see context.xml or server.xml).
 * @return DEVELOPMENT, if development variable of servlet context is set to "true" otherwise DEPLOYMENT.
 * @see org.apache.wicket.protocol.http.WebApplication#getConfigurationType()
 *//*from w w  w.  j av a  2 s.  c om*/
@Override
public RuntimeConfigurationType getConfigurationType() {
    if (isDevelopmentSystem() == true) {
        return RuntimeConfigurationType.DEVELOPMENT;
    }
    return RuntimeConfigurationType.DEPLOYMENT;
}