当前位置: 首页>>代码示例>>Java>>正文


Java GzipFilter类代码示例

本文整理汇总了Java中org.eclipse.jetty.servlets.GzipFilter的典型用法代码示例。如果您正苦于以下问题:Java GzipFilter类的具体用法?Java GzipFilter怎么用?Java GzipFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GzipFilter类属于org.eclipse.jetty.servlets包,在下文中一共展示了GzipFilter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initGzipFilter

import org.eclipse.jetty.servlets.GzipFilter; //导入依赖的package包/类
/**
 * Initializes the GZip filter.
 */
private void initGzipFilter(ServletContext servletContext, EnumSet<DispatcherType> disps) {
  log.debug("Registering GZip Filter");

  FilterRegistration.Dynamic compressingFilter = servletContext.addFilter("gzipFilter", new GzipFilter());

  if (compressingFilter == null) {
    compressingFilter = (FilterRegistration.Dynamic)servletContext.getFilterRegistration("gzipFilter");
  }

  compressingFilter.addMappingForUrlPatterns(disps, true, "*.css");
  compressingFilter.addMappingForUrlPatterns(disps, true, "*.json");
  compressingFilter.addMappingForUrlPatterns(disps, true, "*.html");
  compressingFilter.addMappingForUrlPatterns(disps, true, "*.js");
  compressingFilter.addMappingForUrlPatterns(disps, true, "/metrics/*");
  compressingFilter.addMappingForUrlPatterns(disps, true, WS_ROOT + "/*");
  compressingFilter.setAsyncSupported(true);
}
 
开发者ID:obiba,项目名称:agate,代码行数:21,代码来源:WebConfiguration.java

示例2: initGzipFilter

import org.eclipse.jetty.servlets.GzipFilter; //导入依赖的package包/类
/**
 * Initializes the GZip filter.
 */
private void initGzipFilter(ServletContext servletContext, EnumSet<DispatcherType> disps) {
  log.debug("Registering GZip Filter");

  FilterRegistration.Dynamic filterRegistration = servletContext.addFilter("gzipFilter", new GzipFilter());

  if(filterRegistration == null) {
    filterRegistration = (FilterRegistration.Dynamic) servletContext.getFilterRegistration("gzipFilter");
  }

  filterRegistration.addMappingForUrlPatterns(disps, true, "*.css");
  filterRegistration.addMappingForUrlPatterns(disps, true, "*.json");
  filterRegistration.addMappingForUrlPatterns(disps, true, "*.html");
  filterRegistration.addMappingForUrlPatterns(disps, true, "*.js");
  filterRegistration.addMappingForUrlPatterns(disps, true, "/jvm/*");
  filterRegistration.addMappingForUrlPatterns(disps, true, WS_ROOT + "/*");
  filterRegistration.setAsyncSupported(true);
}
 
开发者ID:obiba,项目名称:mica2,代码行数:21,代码来源:WebConfiguration.java

示例3: configureServlets

import org.eclipse.jetty.servlets.GzipFilter; //导入依赖的package包/类
@Override
protected void configureServlets()
{
	binder().requireExplicitBindings();
	bind(GuiceFilter.class);

	//Bind web server
	bind(WebServer.class);

	//Bind resource classes here
	bind(MetricsResource.class).in(Scopes.SINGLETON);

	bind(GuiceContainer.class);

	ImmutableMap<String, String> params = new ImmutableMap.Builder<String, String>()
			.put("mimeTypes", MediaType.APPLICATION_JSON)
			.put("methods", "GET,POST")
			.build();
	bind(GzipFilter.class).in(Scopes.SINGLETON);
	filter("/*").through(GzipFilter.class, params);

	bind(LoggingFilter.class).in(Scopes.SINGLETON);
	filter("/*").through(LoggingFilter.class);

	// hook Jackson into Jersey as the POJO <-> JSON mapper
	bind(JacksonJsonProvider.class).in(Scopes.SINGLETON);
	serve("/*").with(GuiceContainer.class);


}
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:31,代码来源:WebServletModule.java

示例4: beforeStart

import org.eclipse.jetty.servlets.GzipFilter; //导入依赖的package包/类
@Override
public void beforeStart(WebAppContext context) {
    FilterHolder filterHolder  = new FilterHolder(GzipFilter.class);
    filterHolder.setInitParameter("mimeTypes", DEFAULT_MIME_TYPES);

    context.addFilter(filterHolder, "/*",  EnumSet.of(DispatcherType.FORWARD, DispatcherType.REQUEST));
}
 
开发者ID:eirbjo,项目名称:jetty-console,代码行数:8,代码来源:GzipPlugin.java

示例5: GzipHandler

import org.eclipse.jetty.servlets.GzipFilter; //导入依赖的package包/类
public GzipHandler(final int bufferSize,
				   final int minGzipSize,
				   final String excludedAgents,
				   Handler wrappedHandler) throws ServletException {
	this.wrappedHandler = wrappedHandler;
	this.gzipFilter = new GzipFilter();
	this.gzipFilter.init(new FilterConfig() {

		@Override
		public String getFilterName() {
			return "gzipFilter";
		}

		@Override
		public String getInitParameter(String name) {
			if ("bufferSize".equals(name)) return Integer.toString(bufferSize);
			if ("minGzipSize".equals(name)) return Integer.toString(minGzipSize);
			if ("excludedAgents".equals(name)) return excludedAgents;
			return null;
		}

		@Override
		public Enumeration getInitParameterNames() {
			return null;
		}

		@Override
		public ServletContext getServletContext() {
			return new ContextHandler.NoContext();
		}});
}
 
开发者ID:betfair,项目名称:cougar,代码行数:32,代码来源:GzipHandler.java

示例6: startWebSocketServer

import org.eclipse.jetty.servlets.GzipFilter; //导入依赖的package包/类
public void startWebSocketServer(final Injector injector) {
  httpServer = new Server();

  List<Connector> connectors = getSelectChannelConnectors(httpAddresses);
  if (connectors.isEmpty()) {
    LOG.severe("No valid http end point address provided!");
  }
  for (Connector connector : connectors) {
    httpServer.addConnector(connector);
  }
  final WebAppContext context = new WebAppContext();

  context.setParentLoaderPriority(true);

  if (jettySessionManager != null) {
    // This disables JSessionIDs in URLs redirects
    // see: http://stackoverflow.com/questions/7727534/how-do-you-disable-jsessionid-for-jetty-running-with-the-eclipse-jetty-maven-plu
    // and: http://jira.codehaus.org/browse/JETTY-467?focusedCommentId=114884&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-114884
    jettySessionManager.setSessionIdPathParameterName(null);

    context.getSessionHandler().setSessionManager(jettySessionManager);
  }
  final ResourceCollection resources = new ResourceCollection(resourceBases);
  context.setBaseResource(resources);

  addWebSocketServlets();

  try {
    final Injector parentInjector = injector;

    final ServletModule servletModule = getServletModule(parentInjector);

    ServletContextListener contextListener = new GuiceServletContextListener() {

      private final Injector childInjector = parentInjector.createChildInjector(servletModule);

      @Override
      protected Injector getInjector() {
        return childInjector;
      }
    };

    context.addEventListener(contextListener);
    context.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
    context.addFilter(GzipFilter.class, "/webclient/*", EnumSet.allOf(DispatcherType.class));
    httpServer.setHandler(context);

    httpServer.start();
    restoreSessions();

  } catch (Exception e) { // yes, .start() throws "Exception"
    LOG.severe("Fatal error starting http server.", e);
    return;
  }
  LOG.fine("WebSocket server running.");
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:57,代码来源:ServerRpcProvider.java

示例7: adminServer

import org.eclipse.jetty.servlets.GzipFilter; //导入依赖的package包/类
@Bean(initMethod="start", destroyMethod="stop")
@Order(0)
public Server adminServer(
           @Value("${admin.hostname}") String hostname,
           @Value("${admin.port}") int port) {

       // set up servlets
       ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS | ServletContextHandler.NO_SECURITY);
	context.setErrorHandler(null);
	context.setWelcomeFiles(new String[] { "/" });
	
	// enable gzip
	context.addFilter(GzipFilter.class, "/*", null);
	
	// add common admin servlets
	context.addServlet(new ServletHolder(new HealthServlet(healthCheckRegistry)), "/healthcheck");
	context.addServlet(new ServletHolder(new ClasspathResourceServlet("com/kixeye/chassis/transport/admin", "/admin/", "index.html")), "/admin/*");
	context.addServlet(new ServletHolder(new PropertiesServlet()), "/admin/properties");
	context.addServlet(new ServletHolder(new ClasspathDumpServlet()), "/admin/classpath");

       // add websocket servlets if WebSockets have been initialized
       if (mappingRegistry != null && messageRegistry != null) {
           context.addServlet(new ServletHolder(new ProtobufMessagesDocumentationServlet(appName, mappingRegistry, messageRegistry)), "/schema/messages/protobuf");
           context.addServlet(new ServletHolder(new ProtobufEnvelopeDocumentationServlet()), "/schema/envelope/protobuf");
       }
	
       // add metric servlets if Metric has been initialized
       if (metricRegistry != null && healthCheckRegistry != null) {
           context.getServletContext().setAttribute(MetricsServlet.METRICS_REGISTRY, metricRegistry);
           context.getServletContext().setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, healthCheckRegistry);
           
           ServletHolder holder = new ServletHolder(new AdminServlet());
           holder.setInitParameter("service-name", System.getProperty("app.name"));
           context.addServlet(holder, "/metrics/*");
       }

       // create the server
   	InetSocketAddress address = StringUtils.isBlank(hostname) ? new InetSocketAddress(port) : new InetSocketAddress(hostname, port);
   	
   	Server server = new Server();

   	JettyConnectorRegistry.registerHttpConnector(server, address);
       server.setHandler(context);
   
	return server;
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:47,代码来源:AdminTransportConfiguration.java

示例8: startWebSocketServer

import org.eclipse.jetty.servlets.GzipFilter; //导入依赖的package包/类
public void startWebSocketServer(final Injector injector) {
  httpServer = new Server();

  List<Connector> connectors = getSelectChannelConnectors(httpAddresses);
  if (connectors.isEmpty()) {
    LOG.severe("No valid http end point address provided!");
  }
  for (Connector connector : connectors) {
    httpServer.addConnector(connector);
  }
  final WebAppContext context = new WebAppContext();

  context.setParentLoaderPriority(true);

  if (jettySessionManager != null) {
    // This disables JSessionIDs in URLs redirects
    // see: http://stackoverflow.com/questions/7727534/how-do-you-disable-jsessionid-for-jetty-running-with-the-eclipse-jetty-maven-plu
    // and: http://jira.codehaus.org/browse/JETTY-467?focusedCommentId=114884&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-114884
    jettySessionManager.setSessionIdPathParameterName(null);

    context.getSessionHandler().setSessionManager(jettySessionManager);
  }
  final ResourceCollection resources = new ResourceCollection(resourceBases);
  context.setBaseResource(resources);

  addWebSocketServlets();

  try {

    final ServletModule servletModule = getServletModule();

    ServletContextListener contextListener = new GuiceServletContextListener() {

      private final Injector childInjector = injector.createChildInjector(servletModule);

      @Override
      protected Injector getInjector() {
        return childInjector;
      }
    };

    context.addEventListener(contextListener);
    context.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
    context.addFilter(GzipFilter.class, "/webclient/*", EnumSet.allOf(DispatcherType.class));
    httpServer.setHandler(context);

    httpServer.start();
    restoreSessions();

  } catch (Exception e) { // yes, .start() throws "Exception"
    LOG.severe("Fatal error starting http server.", e);
    return;
  }
  LOG.fine("WebSocket server running.");
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:56,代码来源:ServerRpcProvider.java


注:本文中的org.eclipse.jetty.servlets.GzipFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。