Example usage for org.apache.wicket.protocol.http WicketFilter WicketFilter

List of usage examples for org.apache.wicket.protocol.http WicketFilter WicketFilter

Introduction

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

Prototype

public WicketFilter(WebApplication application) 

Source Link

Document

constructor supporting programmatic setup of the filter

this can be useful for programmatically creating and appending the wicket filter to the servlet context using servlet 3 features.

Usage

From source file:com.norconex.jefmon.server.JEFMonServer.java

License:Apache License

private WebAppContext buildWebappContext() {

    WebAppContext webappContext = new WebAppContext();
    webappContext.setResourceBase("/");

    // Add Wicket filter
    WicketFilter filter = new WicketFilter(app);
    FilterHolder filterHolder = new FilterHolder(filter);
    filterHolder.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, JEFMON_MAPPING);
    webappContext.addFilter(filterHolder, JEFMON_MAPPING, EnumSet.of(DispatcherType.REQUEST));

    // Add custom error message
    webappContext.setErrorHandler(new ErrorHandler() {
        protected void writeErrorPageBody(HttpServletRequest request, Writer writer, int code, String message,
                boolean showStacks) throws IOException {
            String uri = request.getRequestURI();
            writeErrorPageMessage(request, writer, code, message, uri);
            if (showStacks)
                writeErrorPageStacks(request, writer);
            writer.write("<hr><i><small>" + "Norconex JEF Monitor</small></i><hr/>\n");
        }//from  w w w . j a v a2  s. co  m
    });

    return webappContext;
}

From source file:com.olegchir.flussonic_userlinks.init.AppInitializer.java

License:Apache License

@Override
public void onStartup(ServletContext servletContext) throws ServletException {

    //Create webapp context
    AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); //part of spring-web
    root.register(SpringSecurityConfiguration.class); //register class by annotation. Here be all security rules.

    //Register DelegatingFilterProxy
    FilterRegistration.Dynamic springSecurityFilterChainReg = servletContext
            .addFilter("springSecurityFilterChain", DelegatingFilterProxy.class);
    springSecurityFilterChainReg//from  w w w  . j  av a  2  s . co  m
            .addMappingForUrlPatterns(EnumSet.of(DispatcherType.ERROR, DispatcherType.REQUEST), false, "/*");

    servletContext.addListener(new ContextLoaderListener(root));

    //Register WicketFilter
    WicketFilter wicketFilter = new WicketFilter(new WicketApplication()) {
        @Override
        public void init(boolean isServlet, FilterConfig filterConfig) throws ServletException {
            setFilterPath(""); //don't use web.xml. WicketApplication.init is a custom override for it.
            super.init(isServlet, filterConfig);
        }
    };
    FilterRegistration.Dynamic wicketFilterReg = servletContext.addFilter("wicketFilter", wicketFilter);
    wicketFilterReg.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "*");
}

From source file:org.geoserver.web.GeoServerWicketServlet.java

License:Open Source License

@Override
protected WicketFilter newWicketFilter() {
    WicketFilter filter = new WicketFilter(GeoServerExtensions.bean(GeoServerApplication.class));
    filter.setFilterPath("/web");
    return filter;
}

From source file:org.kantega.reststop.wicket.WicketPlugin.java

License:Apache License

public WicketPlugin(ServletBuilder servletBuilder) throws ServletException {

    wicketApplication = new WicketApplication();

    WicketFilter filter = new WicketFilter(wicketApplication);

    Properties properties = new Properties();
    String filterPath = "/wicket/*";
    properties.setProperty(WicketFilter.FILTER_MAPPING_PARAM, filterPath);

    filter.init(servletBuilder.filterConfig("wicket", properties));

    wicketFilter = servletBuilder.filter(filter, filterPath, FilterPhase.USER);

}