當前位置: 首頁>>代碼示例>>Java>>正文


Java FilterHolder.setInitParameter方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.servlet.FilterHolder.setInitParameter方法的典型用法代碼示例。如果您正苦於以下問題:Java FilterHolder.setInitParameter方法的具體用法?Java FilterHolder.setInitParameter怎麽用?Java FilterHolder.setInitParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.servlet.FilterHolder的用法示例。


在下文中一共展示了FilterHolder.setInitParameter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
public int run() throws Exception {
    org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(port);
    HandlerList handlerList = new HandlerList();

    ServletContextHandler servletContextHandler = new ServletContextHandler();
    FilterHolder cof = new FilterHolder(new CrossOriginFilter());
    cof.setInitParameter(
            CrossOriginFilter.EXPOSED_HEADERS_PARAM,
            "Date");
    servletContextHandler.addFilter(cof, "/*", EnumSet.of(DispatcherType.INCLUDE, DispatcherType.REQUEST));
    servletContextHandler.addServlet(new ServletHolder(new SmoothStreamingServlet(dataDir)), "/*");
    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setBaseResource(Resource.newClassPathResource("supportfiles"));
    handlerList.addHandler(resourceHandler);
    handlerList.addHandler(servletContextHandler);
    server.setHandler(handlerList);

    server.start();
    server.dumpStdErr();
    server.join();
    return 0;
}
 
開發者ID:sannies,項目名稱:ismv-server,代碼行數:23,代碼來源:Server.java

示例2: initJerseyServlet

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
/**
 * Initializes the Jersey Servlet.
 */
private void initJerseyServlet() {
  servletContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
  servletContext.setContextPath("/");
  // This is used for allowing access to different domains/ports.
  FilterHolder filterHolder = new FilterHolder(CrossOriginFilter.class);
  filterHolder.setInitParameter("allowedOrigins", "*");
  filterHolder.setInitParameter("allowedMethods", "GET, POST");
  servletContext.addFilter(filterHolder, "/*", null);

  jerseyServlet = servletContext.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
  jerseyServlet.setInitOrder(0);

  // Tell the Jersey Servlet which REST class to load.
  jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
      ProvisioningAction.class.getCanonicalName());
}
 
開發者ID:google,項目名稱:account-provisioning-for-google-apps,代碼行數:20,代碼來源:RESTApp.java

示例3: EmbeddableJetty

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
public EmbeddableJetty() {
    System.setProperty("wicket.configuration", "development");

    ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(new HttpConfiguration()));
    http.setPort(PORT);
    http.setIdleTimeout(1000 * 60 * 60);

    server.addConnector(http);

    ServletContextHandler sch = new ServletContextHandler(ServletContextHandler.SESSIONS);
    FilterHolder fh2 = new FilterHolder(WicketFilter.class);
    fh2.setInitParameter(ContextParamWebApplicationFactory.APP_CLASS_PARAM, WicketTestApplication.class.getName());
    fh2.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, "/*");
    sch.addFilter(fh2, "/*", EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR));

    server.setHandler(sch);

    MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
    server.addEventListener(mBeanContainer);
    server.addBean(mBeanContainer);

}
 
開發者ID:TDC-Netdesign,項目名稱:ManagedProperties,代碼行數:24,代碼來源:EmbeddableJetty.java

示例4: initCasSecurity

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
private void initCasSecurity() {
    FilterHolder authFilter = webapp.addFilter(
            "org.jasig.cas.client.authentication.AuthenticationFilter", "/*",
            EnumSet.of(DispatcherType.REQUEST));

    authFilter.setInitParameter("casServerLoginUrl", props.getProperty("auth.cas.url") + "/login");
    authFilter.setInitParameter("service", props.getProperty("auth.zico.url"));

    FilterHolder validationFilter = webapp.addFilter(
            "org.jasig.cas.client.validation.Cas10TicketValidationFilter", "/*",
            EnumSet.of(DispatcherType.REQUEST)
    );

    validationFilter.setInitParameter("casServerUrlPrefix", props.getProperty("auth.cas.url"));
    validationFilter.setInitParameter("service", props.getProperty("auth.zico.url"));

    webapp.addFilter(
            "org.jasig.cas.client.util.HttpServletRequestWrapperFilter", "/*",
            EnumSet.of(DispatcherType.REQUEST));

}
 
開發者ID:jitlogic,項目名稱:zico,代碼行數:22,代碼來源:ZicoMain.java

示例5: execute1

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
protected void execute1(String component) throws Exception {
	System.out.println("Starting codeine "+component+" at version " + CodeineVersion.get());
	injector = Guice.createInjector(getModules(component));
	FilterHolder guiceFilter = new FilterHolder(injector.getInstance(GuiceFilter.class));
	ServletContextHandler handler = createServletContextHandler();
	handler.setContextPath("/");
	FilterHolder crossHolder = new FilterHolder(new CrossOriginFilter());
	crossHolder.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET, POST, PUT, DELETE");
	crossHolder.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "X-Requested-With,Origin,Content-Type,Accept,api_token");
	handler.addFilter(crossHolder, "/api/*", EnumSet.allOf(DispatcherType.class));
	handler.addFilter(crossHolder, "/api-with-token/*", EnumSet.allOf(DispatcherType.class));
	handler.addFilter(guiceFilter, "/*", EnumSet.allOf(DispatcherType.class));
	createAdditionalServlets(handler);
	ContextHandlerCollection contexts = createFileServerContexts();
	contexts.addHandler(handler);
	int port = startServer(contexts);
	log.info("jetty started on port " + port);
	injector.getInstance(CodeineRuntimeInfo.class).setPort(port);
	execute();
}
 
開發者ID:codeine-cd,項目名稱:codeine,代碼行數:21,代碼來源:AbstractCodeineBootstrap.java

示例6: build

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
public FilterWrapper build() {
    if (built) {
        throw new IllegalStateException("This builder can be used to produce one filter wrapper instance.  Please create a new builder.");
    }
    if (filterClass == null) {
        throw new IllegalStateException("Cannot build filter wrapper without a filter class");
    }
    if (pathSpecs.isEmpty()) {
        logger.warn("Filter {} has no pathSpecs, therefore this filter will not handle any requests.", filterClass);
    }
    FilterHolder filterHolder = new FilterHolder(filterClass);
    for (String key : initParams.keySet()) {
        filterHolder.setInitParameter(key, initParams.get(key));
    }
    built = true;
    logger.info("Built {}", this);
    return new FilterWrapper(filterHolder, pathSpecs, dispatcherTypeSet);
}
 
開發者ID:xoom,項目名稱:feathercon,代碼行數:19,代碼來源:FilterWrapper.java

示例7: configureCors

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
private FilterHolder configureCors() {
	final FilterHolder filter = new FilterHolder(new CrossOriginFilter());
	filter.setInitParameter(ALLOWED_ORIGINS_PARAM, "*");
	filter.setInitParameter(ACCESS_CONTROL_ALLOW_CREDENTIALS_HEADER, valueOf(TRUE));
	filter.setInitParameter(ALLOWED_METHODS_PARAM, on(",").join(HttpMethod.values()));
	filter.setInitParameter(ALLOWED_HEADERS_PARAM,
			on(",").join(X_PING_OTHER, ORIGIN, X_REQUESTED_WITH, CONTENT_TYPE, ACCEPT));
	filter.setInitParameter(PREFLIGHT_MAX_AGE_PARAM, PREFLIGHT_MAX_AGE_VALUE);
	filter.setInitParameter(ALLOW_CREDENTIALS_PARAM, valueOf(TRUE));
	return filter;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:12,代碼來源:JettyManager.java

示例8: configureCORS

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
protected void configureCORS() {
 
 FilterHolder holder = new FilterHolder(new CrossOriginFilter());
 holder.setInitParameter("allowedOrigins", "*"); // TODO - restrict this
 holder.setInitParameter("allowedMethods", "GET,POST,PUT,DELETE,HEAD,OPTIONS");
 holder.setInitParameter("allowedCredentials", "true");
 
 this.handler.addFilterWithMapping(holder, "/*", EnumSet.of(DispatcherType.REQUEST));
}
 
開發者ID:thingweb,項目名稱:thingweb-directory,代碼行數:10,代碼來源:HTTPServer.java

示例9: initCorsFilter

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
private void initCorsFilter(ServletContextHandler context) {
    FilterHolder corsFilter = context.addFilter(CrossOriginFilter.class, REST_PATH, EnumSet.of(DispatcherType.REQUEST));
    corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
    corsFilter.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*");
    corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "DELETE,GET,POST,PUT");
    corsFilter.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "X-Requested-With,Content-Type,Accept,Origin");
}
 
開發者ID:sparkled,項目名稱:sparkled,代碼行數:8,代碼來源:RestApiServerImpl.java

示例10: enableMultipartFilter

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
private void enableMultipartFilter(HttpEndpoint endpoint, Server server, String connectorKey) throws Exception {
    ServletContextHandler context = server.getChildHandlerByClass(ServletContextHandler.class);
    CamelContext camelContext = this.getCamelContext();
    FilterHolder filterHolder = new FilterHolder();
    filterHolder.setInitParameter("deleteFiles", "true");
    if (ObjectHelper.isNotEmpty(camelContext.getProperty(TMP_DIR))) {
        File file = new File(camelContext.getProperty(TMP_DIR));
        if (!file.isDirectory()) {
            throw new RuntimeCamelException(
                    "The temp file directory of camel-jetty is not exists, please recheck it with directory name :"
                            + camelContext.getProperties().get(TMP_DIR));
        }
        context.setAttribute("javax.servlet.context.tempdir", file);
    }
    // if a filter ref was provided, use it.
    Filter filter = ((JettyHttpEndpoint) endpoint).getMultipartFilter();
    if (filter == null) {
        // if no filter ref was provided, use the default filter
        filter = new MultiPartFilter();
    }
    filterHolder.setFilter(new CamelFilterWrapper(filter));
    String pathSpec = endpoint.getPath();
    if (pathSpec == null || "".equals(pathSpec)) {
        pathSpec = "/";
    }
    if (endpoint.isMatchOnUriPrefix()) {
        pathSpec = pathSpec.endsWith("/") ? pathSpec + "*" : pathSpec + "/*";
    }
    addFilter(context, filterHolder, pathSpec);
    if (LOG.isDebugEnabled()) LOG.debug("using multipart filter implementation " + filter.getClass().getName() + " for path " + pathSpec);
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:32,代碼來源:JettyHttpComponent.java

示例11: main

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    ResourceConfig config = new DefaultResourceConfig(ResourceNominatim.class, ObjectMapperContextResolver.class);
    org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(8080);
    ServletContextHandler context = new ServletContextHandler(server, "/");
    FilterHolder cof = new FilterHolder(new CrossOriginFilter()); cof.setInitParameter(ALLOWED_HEADERS_PARAM, "*");
    context.addFilter(cof, "/*", EnumSet.allOf(DispatcherType.class));
    context.addServlet(new ServletHolder(new ServletContainer(config)), "/*");
    server.start();
    server.join();
}
 
開發者ID:ibaca,項目名稱:autorest-nominatim-example,代碼行數:11,代碼來源:Server.java

示例12: run

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
@Override
public void run(Environment environment) {
    MutableServletContextHandler applicationContext = environment.getApplicationContext();
    FilterHolder filterHolder = applicationContext
            .addFilter(CrossOriginFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
    filterHolder.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*");
    filterHolder.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "X-Requested-With,Content-Type,Accept,Origin");
    filterHolder.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,HEAD");

    filterHolder.setInitParameter(CrossOriginFilter.ALLOW_CREDENTIALS_PARAM, "false");
}
 
開發者ID:openregister,項目名稱:openregister-java,代碼行數:12,代碼來源:CorsBundle.java

示例13: generateServletContextHandler

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
private static ServletContextHandler generateServletContextHandler(
    WebApplicationContext webappContext
) throws IOException {
    ServletContextHandler contextHandler = new ServletContextHandler();
    contextHandler.setContextPath("/");
    contextHandler.addServlet(new ServletHolder(new DispatcherServlet(webappContext)), "/*");
    contextHandler.addEventListener(new ContextLoaderListener(webappContext));
    FilterHolder requestTracingFilterHolder = contextHandler.addFilter(
        RequestTracingFilter.class, "/*", EnumSet.allOf(DispatcherType.class)
    );
    requestTracingFilterHolder.setInitParameter(USER_ID_HEADER_KEYS_LIST_INIT_PARAM_NAME, USER_ID_HEADER_KEYS);
    return contextHandler;
}
 
開發者ID:Nike-Inc,項目名稱:wingtips,代碼行數:14,代碼來源:Main.java

示例14: enableMultipartFilter

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
private void enableMultipartFilter(HttpCommonEndpoint endpoint, Server server, String connectorKey) throws Exception {
    ServletContextHandler context = server.getChildHandlerByClass(ServletContextHandler.class);
    CamelContext camelContext = this.getCamelContext();
    FilterHolder filterHolder = new FilterHolder();
    filterHolder.setInitParameter("deleteFiles", "true");
    if (ObjectHelper.isNotEmpty(camelContext.getProperty(TMP_DIR))) {
        File file = new File(camelContext.getProperty(TMP_DIR));
        if (!file.isDirectory()) {
            throw new RuntimeCamelException(
                    "The temp file directory of camel-jetty is not exists, please recheck it with directory name :"
                            + camelContext.getProperties().get(TMP_DIR));
        }
        context.setAttribute("javax.servlet.context.tempdir", file);
    }
    // if a filter ref was provided, use it.
    Filter filter = ((JettyHttpEndpoint) endpoint).getMultipartFilter();
    if (filter == null) {
        // if no filter ref was provided, use the default filter
        filter = new MultiPartFilter();
    }
    filterHolder.setFilter(new CamelFilterWrapper(filter));
    String pathSpec = endpoint.getPath();
    if (pathSpec == null || "".equals(pathSpec)) {
        pathSpec = "/";
    }
    if (endpoint.isMatchOnUriPrefix()) {
        pathSpec = pathSpec.endsWith("/") ? pathSpec + "*" : pathSpec + "/*";
    }
    addFilter(context, filterHolder, pathSpec);
    LOG.debug("using multipart filter implementation " + filter.getClass().getName() + " for path " + pathSpec);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:32,代碼來源:JettyHttpComponent.java

示例15: applyCrossOriginFiltering

import org.eclipse.jetty.servlet.FilterHolder; //導入方法依賴的package包/類
private void applyCrossOriginFiltering(WebsocketEndpoint endpoint, ServletContextHandler context) {
    if (endpoint.isCrossOriginFilterOn()) {
        FilterHolder filterHolder = new FilterHolder();
        CrossOriginFilter filter = new CrossOriginFilter();
        filterHolder.setFilter(filter);
        filterHolder.setInitParameter("allowedOrigins", endpoint.getAllowedOrigins());
        context.addFilter(filterHolder, endpoint.getFilterPath(), EnumSet.allOf(DispatcherType.class));
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:10,代碼來源:WebsocketComponent.java


注:本文中的org.eclipse.jetty.servlet.FilterHolder.setInitParameter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。