本文整理汇总了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;
}
示例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());
}
示例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);
}
示例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));
}
示例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();
}
示例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);
}
示例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;
}
示例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));
}
示例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");
}
示例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);
}
示例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();
}
示例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");
}
示例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;
}
示例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);
}
示例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));
}
}