Example usage for org.apache.wicket.protocol.http ContextParamWebApplicationFactory APP_CLASS_PARAM

List of usage examples for org.apache.wicket.protocol.http ContextParamWebApplicationFactory APP_CLASS_PARAM

Introduction

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

Prototype

String APP_CLASS_PARAM

To view the source code for org.apache.wicket.protocol.http ContextParamWebApplicationFactory APP_CLASS_PARAM.

Click Source Link

Document

context parameter name that must contain the class name of the application

Usage

From source file:ApplicationJettyRunner.java

License:Apache License

public static void main(final String[] args) {
    final int sessionTimeout = (int) Duration.minutes(1).seconds();// set timeout to 30min(60sec
    // */*from  w w w.  j a v  a2 s .c o m*/
    // 30min=1800sec)...
    System.setProperty("wicket.configuration", "development");
    final String projectname = "wicket-application-template";
    final File projectDirectory = PathFinder.getProjectDirectory();
    final File webapp;
    if (projectDirectory.getAbsolutePath().endsWith(projectname)) {
        webapp = PathFinder.getRelativePath(projectDirectory, "src", "main", "webapp");
    } else {
        webapp = PathFinder.getRelativePath(projectDirectory, projectname, "src", "main", "webapp");
    }
    final File logfile = new File(projectDirectory, "application.log");
    if (logfile.exists()) {
        try {
            DeleteFileExtensions.delete(logfile);
        } catch (final IOException e) {
            Logger.getRootLogger().error("logfile could not deleted.", e);
        }
    }
    final String absolutePathFromLogfile = logfile.getAbsolutePath();
    final String filterPath = "/*";
    // Add a file appender to the logger programatically
    LoggerExtensions.addFileAppender(Logger.getRootLogger(),
            LoggerExtensions.newFileAppender(absolutePathFromLogfile));

    final ContextHandlerCollection contexts = new ContextHandlerCollection();

    final ServletContextHandler servletContextHandler = ServletContextHandlerFactory
            .getNewServletContextHandler(ServletContextHandlerConfiguration.builder().parent(contexts)
                    .filterHolderConfiguration(FilterHolderConfiguration.builder()
                            .filterClass(WicketFilter.class).filterPath(filterPath)
                            .initParameter(WicketFilter.FILTER_MAPPING_PARAM, filterPath)
                            .initParameter(ContextParamWebApplicationFactory.APP_CLASS_PARAM,
                                    WicketApplication.class.getName())
                            .build())
                    .servletHolderConfiguration(ServletHolderConfiguration.builder()
                            .servletClass(DefaultServlet.class).pathSpec(filterPath).build())
                    .contextPath("/").webapp(webapp).maxInactiveInterval(sessionTimeout).filterPath(filterPath)
                    .build());

    final DeploymentManager deployer = DeploymentManagerFactory.newDeploymentManager(contexts,
            webapp.getAbsolutePath(), null);

    final Jetty9RunConfiguration config = newJetty9RunConfiguration(servletContextHandler, contexts, deployer);
    final Server server = new Server();
    Jetty9Runner.runServletContextHandler(server, config);
}

From source file:com.lyndir.lhunath.grantmywishes.webapp.listener.GrantMyWishesGuiceContext.java

License:Apache License

/**
 * {@inheritDoc}/*from  w  w  w  . ja  v  a 2 s .  c o  m*/
 */
@Override
protected Injector getInjector() {

    return Guice.createInjector(Stage.DEVELOPMENT, new DAOModule(), new ServiceModule(), new ServletModule() {

        @Override
        protected void configureServlets() {

            Builder<String, String> paramBuilder;

            // Disable jsessionid in URLs.
            filter("/*").through(DisableURLSessionFilter.class);
            bind(DisableURLSessionFilter.class).in(Scopes.SINGLETON);

            // Wicket
            paramBuilder = ImmutableMap.builder();
            paramBuilder.put(WicketFilter.APP_FACT_PARAM,
                    ContextParamWebApplicationFactory.class.getCanonicalName());
            paramBuilder.put(ContextParamWebApplicationFactory.APP_CLASS_PARAM,
                    GrantMyWishesWebApplication.class.getCanonicalName());
            paramBuilder.put(WicketFilter.FILTER_MAPPING_PARAM, PATH_WICKET);
            paramBuilder.put(Application.CONFIGURATION, Application.DEVELOPMENT);

            filter(PATH_WICKET).through(wicketFilter, paramBuilder.build());
            bind(WicketFilter.class).in(Scopes.SINGLETON);
        }
    });
}

From source file:com.lyndir.lhunath.homepage.webapp.listener.GuiceContext.java

License:Apache License

/**
 * {@inheritDoc}//  w  w w  .  java  2 s  .c  o  m
 */
@Override
protected Injector getInjector() {

    return Guice.createInjector(Stage.DEVELOPMENT, new ServletModule() {

        @Override
        protected void configureServlets() {

            Builder<String, String> paramBuilder;

            // Wicket
            paramBuilder = new ImmutableMap.Builder<String, String>();
            paramBuilder.put(ContextParamWebApplicationFactory.APP_CLASS_PARAM,
                    HomepageWebApplication.class.getCanonicalName());
            paramBuilder.put(WicketFilter.FILTER_MAPPING_PARAM, PATH_WICKET);
            filter(PATH_WICKET).through(wicketFilter, paramBuilder.build());
            bind(WicketFilter.class).in(Scopes.SINGLETON);
        }
    });
}

From source file:com.lyndir.lhunath.portal.webapp.listener.PortalGuiceContext.java

License:Apache License

/**
 * {@inheritDoc}/*from w  w  w.j a  va 2  s . c o m*/
 */
@Override
protected Injector getInjector() {

    return Guice.createInjector(Stage.DEVELOPMENT,
            ImmutableList.<Module>builder().addAll(getApplicationModules()).add(new ServletModule() {

                @Override
                protected void configureServlets() {

                    Builder<String, String> paramBuilder;

                    // Wicket
                    paramBuilder = new ImmutableMap.Builder<String, String>();
                    paramBuilder.put(WicketFilter.APP_FACT_PARAM,
                            ContextParamWebApplicationFactory.class.getCanonicalName());
                    paramBuilder.put(ContextParamWebApplicationFactory.APP_CLASS_PARAM,
                            getWebApplication().getCanonicalName());
                    paramBuilder.put(WicketFilter.FILTER_MAPPING_PARAM, PATH_WICKET);
                    paramBuilder.put(Application.CONFIGURATION, Application.DEPLOYMENT);

                    filter(PATH_WICKET).through(wicketFilter, paramBuilder.build());
                    bind(WicketFilter.class).in(Scopes.SINGLETON);
                }
            }).build());
}

From source file:com.lyndir.lhunath.snaplog.webapp.listener.GuiceContext.java

License:Apache License

/**
 * {@inheritDoc}//  w  w  w .  j a  va  2  s .co  m
 */
@Override
protected Injector getInjector() {

    return Guice.createInjector(Stage.DEVELOPMENT, new DAOModule(), new ServiceModule(), new ServletModule() {

        @Override
        protected void configureServlets() {

            Builder<String, String> paramBuilder;

            // Disable jsessionid in URLs.
            filter(PATH_ALL).through(DisableURLSessionFilter.class);
            bind(DisableURLSessionFilter.class).in(Scopes.SINGLETON);

            // Wicket
            paramBuilder = new ImmutableMap.Builder<String, String>();
            paramBuilder.put(ContextParamWebApplicationFactory.APP_CLASS_PARAM,
                    SnaplogApplication.class.getCanonicalName());
            paramBuilder.put(WicketFilter.FILTER_MAPPING_PARAM, PATH_WICKET);
            filter(PATH_WICKET).through(wicketFilter, paramBuilder.build());
            bind(WicketFilter.class).in(Scopes.SINGLETON);

            paramBuilder = new ImmutableMap.Builder<String, String>();
            paramBuilder.put("filterName", wicketFilter.toString());
            // filter( ImageServlet.PATH ).through( WicketSessionFilter.class, paramBuilder.build() );
            bind(WicketSessionFilter.class).in(Scopes.SINGLETON);

            // Snaplog Image Servlet
            // serve( ImageServlet.PATH ).with( ImageServlet.class );
            // bind( ImageServlet.class ).in( Scopes.SINGLETON );

            // Snaplog Init Servlet
            serve(InitServlet.PATH).with(InitServlet.class);
            bind(InitServlet.class).in(Scopes.SINGLETON);

            // Snaplog Logout Servlet
            paramBuilder = new ImmutableMap.Builder<String, String>();
            paramBuilder.put(AppLogoutServlet.PARAM_LOGOUT_EXIT_PATH, PATH_LINKID_LOGOUT);
            serve(AppLogoutServlet.PATH).with(AppLogoutServlet.class, paramBuilder.build());
            bind(AppLogoutServlet.class).in(Scopes.SINGLETON);

            // LinkID Login Landing Servlet
            paramBuilder = new ImmutableMap.Builder<String, String>();
            paramBuilder.put("ErrorPage", SnaplogApplication.PATH_LINKID_ERROR);
            serve(PATH_LINKID_LOGIN).with(LoginServlet.class, paramBuilder.build());
            bind(LoginServlet.class).in(Scopes.SINGLETON);

            // LinkID Logout Landing Servlet
            paramBuilder = new ImmutableMap.Builder<String, String>();
            paramBuilder.put("LogoutPath", AppLogoutServlet.PATH);
            paramBuilder.put("ErrorPage", SnaplogApplication.PATH_LINKID_ERROR);
            serve(PATH_LINKID_LOGOUT).with(LogoutServlet.class, paramBuilder.build());
            bind(LogoutServlet.class).in(Scopes.SINGLETON);
        }
    });
}

From source file:de.alpharogroup.wicket.annotated.header.contributors.examples.StartHeaderContributorsExamples.java

License:Apache License

public static void main(final String[] args) throws Exception {
    System.setProperty("wicket.configuration", "development");
    final String projectname = "jaulp.wicket.annotated.header.contributors.examples";
    final File projectDirectory = PathFinder.getProjectDirectory();
    final File webapp = PathFinder.getRelativePath(projectDirectory, projectname, "src", "main", "webapp");

    final String filterPath = "/*";

    final ServletContextHandler servletContextHandler = ServletContextHandlerFactory
            .getNewServletContextHandler(ServletContextHandlerConfiguration.builder()
                    .filterHolderConfiguration(FilterHolderConfiguration.builder()
                            .filterClass(WicketFilter.class).filterPath(filterPath)
                            .initParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*")
                            .initParameter(ContextParamWebApplicationFactory.APP_CLASS_PARAM,
                                    WicketApplication.class.getName())
                            .build())//from w  w w.ja v  a 2s .  c  o m
                    .servletHolderConfiguration(ServletHolderConfiguration.builder()
                            .servletClass(DefaultServlet.class).pathSpec(filterPath).build())
                    .contextPath("/").webapp(webapp).maxInactiveInterval(300).filterPath("/*").build());

    final Jetty9RunConfiguration config = newJetty9RunConfiguration(servletContextHandler);

    final Server server = new Server();
    Jetty9Runner.runServletContextHandler(server, config);
}

From source file:de.alpharogroup.wicket.base.examples.StartBaseExamples.java

License:Apache License

public static void main(final String[] args) throws Exception {
    System.setProperty("wicket.configuration", "development");
    final String projectname = "jaulp.wicket.base.examples";
    final File projectDirectory = PathFinder.getProjectDirectory();
    final File webapp = PathFinder.getRelativePath(projectDirectory, projectname, "src", "main", "webapp");
    final String filterPath = "/*";

    final ServletContextHandler servletContextHandler = ServletContextHandlerFactory
            .getNewServletContextHandler(ServletContextHandlerConfiguration.builder()
                    .filterHolderConfiguration(FilterHolderConfiguration.builder()
                            .filterClass(WicketFilter.class).filterPath(filterPath)
                            .initParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*")
                            .initParameter(ContextParamWebApplicationFactory.APP_CLASS_PARAM,
                                    WicketApplication.class.getName())
                            .build())//from   w  w  w. j  av  a 2s.c om
                    .servletHolderConfiguration(ServletHolderConfiguration.builder()
                            .servletClass(DefaultServlet.class).pathSpec(filterPath).build())
                    .contextPath("/").webapp(webapp).maxInactiveInterval(300).filterPath("/*").build());

    final Jetty9RunConfiguration config = newJetty9RunConfiguration(servletContextHandler);

    final Server server = new Server();
    Jetty9Runner.runServletContextHandler(server, config);
}

From source file:de.alpharogroup.wicket.behaviors.examples.StartBehaviorsExamples.java

License:Apache License

public static void main(final String[] args) throws Exception {
    System.setProperty("wicket.configuration", "development");
    final String projectname = "jaulp.wicket.behaviors.examples";
    final File projectDirectory = PathFinder.getProjectDirectory();
    final File webapp = PathFinder.getRelativePath(projectDirectory, projectname, "src", "main", "webapp");
    final String filterPath = "/*";

    final ServletContextHandler servletContextHandler = ServletContextHandlerFactory
            .getNewServletContextHandler(ServletContextHandlerConfiguration.builder()
                    .filterHolderConfiguration(FilterHolderConfiguration.builder()
                            .filterClass(WicketFilter.class).filterPath(filterPath)
                            .initParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*")
                            .initParameter(ContextParamWebApplicationFactory.APP_CLASS_PARAM,
                                    WicketApplication.class.getName())
                            .build())//from   ww w. jav a2s.  co  m
                    .servletHolderConfiguration(ServletHolderConfiguration.builder()
                            .servletClass(DefaultServlet.class).pathSpec(filterPath).build())
                    .contextPath("/").webapp(webapp).maxInactiveInterval(300).filterPath("/*").build());

    final Jetty9RunConfiguration config = newJetty9RunConfiguration(servletContextHandler);

    final Server server = new Server();
    Jetty9Runner.runServletContextHandler(server, config);
}

From source file:de.alpharogroup.wicket.data.provider.examples.StartDataProviderExamples.java

License:Apache License

public static void main(final String[] args) throws Exception {
    System.setProperty("wicket.configuration", "development");
    final String projectname = "jaulp.wicket.data.provider.examples";
    final File projectDirectory = PathFinder.getProjectDirectory();
    final File webapp = PathFinder.getRelativePath(projectDirectory, projectname, "src", "main", "webapp");
    final String filterPath = "/*";

    final ServletContextHandler servletContextHandler = ServletContextHandlerFactory
            .getNewServletContextHandler(ServletContextHandlerConfiguration.builder()
                    .filterHolderConfiguration(FilterHolderConfiguration.builder()
                            .filterClass(WicketFilter.class).filterPath(filterPath)
                            .initParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*")
                            .initParameter(ContextParamWebApplicationFactory.APP_CLASS_PARAM,
                                    WicketApplication.class.getName())
                            .build())//from  w  w  w.  j  ava 2 s .  c  om
                    .servletHolderConfiguration(ServletHolderConfiguration.builder()
                            .servletClass(DefaultServlet.class).pathSpec(filterPath).build())
                    .contextPath("/").webapp(webapp).maxInactiveInterval(300).filterPath("/*").build());

    final Jetty9RunConfiguration config = newJetty9RunConfiguration(servletContextHandler);

    final Server server = new Server();
    Jetty9Runner.runServletContextHandler(server, config);
}

From source file:de.alpharogroup.wicket.dialogs.examples.StartDialogsExamples.java

License:Apache License

/**
 * The main method./* w  w w.ja  v  a2  s .  com*/
 *
 * @param args
 *            the arguments
 * @throws Exception
 *             the exception
 */
public static void main(final String[] args) throws Exception {
    System.setProperty("wicket.configuration", "development");
    final String projectname = "jaulp.wicket.dialogs.examples";
    final File projectDirectory = PathFinder.getProjectDirectory();
    final File webapp = PathFinder.getRelativePath(projectDirectory, projectname, "src", "main", "webapp");
    final String filterPath = "/*";

    final ServletContextHandler servletContextHandler = ServletContextHandlerFactory
            .getNewServletContextHandler(ServletContextHandlerConfiguration.builder()
                    .filterHolderConfiguration(FilterHolderConfiguration.builder()
                            .filterClass(WicketFilter.class).filterPath(filterPath)
                            .initParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*")
                            .initParameter(ContextParamWebApplicationFactory.APP_CLASS_PARAM,
                                    WicketApplication.class.getName())
                            .build())
                    .servletHolderConfiguration(ServletHolderConfiguration.builder()
                            .servletClass(DefaultServlet.class).pathSpec(filterPath).build())
                    .contextPath("/").webapp(webapp).maxInactiveInterval(300).filterPath("/*").build());

    final Jetty9RunConfiguration config = newJetty9RunConfiguration(servletContextHandler);

    final Server server = new Server();
    Jetty9Runner.runServletContextHandler(server, config);
}