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


Java ContainerResponseFilter类代码示例

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


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

示例1: testExtensionWithoutAName

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@Test
public void testExtensionWithoutAName() {
    Dictionary<String, Object> properties = new Hashtable<>();

    properties.put(JAX_RS_EXTENSION, true);

    ServiceRegistration<ContainerResponseFilter> registration =
        bundleContext.registerService(
            ContainerResponseFilter.class, new TestFilter(), properties);

    try {
        RuntimeDTO runtimeDTO = _runtime.getRuntimeDTO();

        assertEquals(
            (long)registration.getReference().getProperty("service.id"),
            runtimeDTO.defaultApplication.extensionDTOs[0].serviceId);
    }
    finally {
        registration.unregister();
    }

}
 
开发者ID:apache,项目名称:aries-jax-rs-whiteboard,代码行数:23,代码来源:JaxrsTest.java

示例2: ControllerAdminApiApplication

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
public ControllerAdminApiApplication(String consoleWebPath) {
    super();
    CONSOLE_WEB_PATH = consoleWebPath;
    if (!CONSOLE_WEB_PATH.endsWith("/")) {
      CONSOLE_WEB_PATH += "/";
    }
    packages(RESOURCE_PACKAGE);
    // TODO See ControllerResponseFilter
//    register(new LoggingFeature());
    register(JacksonFeature.class);
    register(MultiPartFeature.class);
    registerClasses(io.swagger.jaxrs.listing.ApiListingResource.class);
    registerClasses(io.swagger.jaxrs.listing.SwaggerSerializers.class);
    register(new ContainerResponseFilter() {
      @Override
      public void filter(ContainerRequestContext containerRequestContext,
          ContainerResponseContext containerResponseContext)
          throws IOException {
        containerResponseContext.getHeaders().add("Access-Control-Allow-Origin", "*");
      }
    });
    // property("jersey.config.server.tracing.type", "ALL");
    // property("jersey.config.server.tracing.threshold", "VERBOSE");
  }
 
开发者ID:linkedin,项目名称:pinot,代码行数:25,代码来源:ControllerAdminApiApplication.java

示例3: AdminApiApplication

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
public AdminApiApplication(ServerInstance instance) {
  this.serverInstance = instance;
  packages(RESOURCE_PACKAGE);
  register(new AbstractBinder() {
    @Override
    protected void configure() {
      bind(serverInstance).to(ServerInstance.class);
    }
  });

  register(JacksonFeature.class);

  registerClasses(io.swagger.jaxrs.listing.ApiListingResource.class);
  registerClasses(io.swagger.jaxrs.listing.SwaggerSerializers.class);
  register(new ContainerResponseFilter() {
    @Override
    public void filter(ContainerRequestContext containerRequestContext,
        ContainerResponseContext containerResponseContext)
        throws IOException {
      containerResponseContext.getHeaders().add("Access-Control-Allow-Origin", "*");
    }
  });

}
 
开发者ID:linkedin,项目名称:pinot,代码行数:25,代码来源:AdminApiApplication.java

示例4: buildResponseFilter

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
public static <F,T> ContainerResponseFilter buildResponseFilter(
        final ContainerResponsePredicate predicate,
        final Function<ContainerRequestAndResponse, F> extractData,
        final Function<F,T> transform,
        final Function<ContainerRequestAndResponse, DateTime> determineTimestamp,
        final WritingWorkerManager<T> writingWorkerManager,
        final boolean skipNulls)
{
    final Recorder<ContainerRequestAndResponse> recorder = new BasicRecorder<>(
            predicate,
            extractData,
            transform,
            determineTimestamp,
            writingWorkerManager,
            skipNulls);
    return buildResponseFilter(recorder);
}
 
开发者ID:Multifarious,项目名称:skid-road,代码行数:18,代码来源:RecorderFilterFactory.java

示例5: registerFilter

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void registerFilter(final Class<?> c) {
    if (ContainerRequestFilter.class.isAssignableFrom(c)) {
        requestFilters.add((Class<? extends ContainerRequestFilter>) c);
    }

    if (ContainerResponseFilter.class.isAssignableFrom(c)) {
        responseFilters.add((Class<? extends ContainerResponseFilter>) c);
    }
}
 
开发者ID:minijax,项目名称:minijax,代码行数:11,代码来源:MinijaxApplication.java

示例6: runResponseFilters

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
private void runResponseFilters(final MinijaxRequestContext context, final Response response) throws IOException {
    final ContainerResponseContext responseContext = (ContainerResponseContext) response;
    for (final Class<? extends ContainerResponseFilter> filterClass : responseFilters) {
        final ContainerResponseFilter filter = get(filterClass);
        filter.filter(context, responseContext);
    }
}
 
开发者ID:minijax,项目名称:minijax,代码行数:8,代码来源:MinijaxApplication.java

示例7: setContainerResponseFilter

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@Reference(
	cardinality = MULTIPLE, policyOption = GREEDY,
	target = "(liferay.apio.architect.container.response.filter=true)"
)
public void setContainerResponseFilter(
	ServiceReference<ContainerResponseFilter> serviceReference,
	ContainerResponseFilter containerResponseFilter) {

	_containerResponseFilters.add(containerResponseFilter);
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:11,代码来源:ApioApplication.java

示例8: unsetContainerResponseFilter

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@SuppressWarnings("unused")
public <T> void unsetContainerResponseFilter(
	ServiceReference<ContainerResponseFilter> serviceReference,
	ContainerResponseFilter containerResponseFilter) {

	_containerResponseFilters.remove(containerResponseFilter);
}
 
开发者ID:liferay,项目名称:com-liferay-apio-architect,代码行数:8,代码来源:ApioApplication.java

示例9: configure

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {

    Method resourceMethod = resourceInfo.getResourceMethod();
    if (resourceMethod.getReturnType() != Optional.class) {
        return;
    }

    Type returnType = resourceMethod.getGenericReturnType();
    if ((returnType instanceof ParameterizedType) == false) {
        return;
    }

    ParameterizedType pt = (ParameterizedType) returnType;
    if (pt.getActualTypeArguments()[0] != UIResponse.class) {
        return;
    }

    context.register(new ContainerResponseFilter() {

        @Override
        public void filter(ContainerRequestContext requestContext,
                ContainerResponseContext responseContext) throws IOException {
            if (responseContext.hasEntity() == false) {
                return;
            }
            Optional<?> opt = (Optional<?>) responseContext.getEntity();
            responseContext.setEntity(opt.orElse(null));
            responseContext.setStatusInfo(
                    opt.map(a -> responseContext.getStatusInfo()).orElse(Status.NOT_FOUND));
        }
    });
}
 
开发者ID:backpaper0,项目名称:sealion,代码行数:34,代码来源:UIResponseProvider.java

示例10: isProvider

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
private static <T> boolean isProvider(final Class<T> clazz) {
    return MessageBodyReader.class.isAssignableFrom(clazz) ||
            MessageBodyWriter.class.isAssignableFrom(clazz) ||
            ParamConverter.class.isAssignableFrom(clazz) ||
            ContainerRequestFilter.class.isAssignableFrom(clazz) ||
            ContainerResponseFilter.class.isAssignableFrom(clazz) ||
            ReaderInterceptor.class.isAssignableFrom(clazz) ||
            WriterInterceptor.class.isAssignableFrom(clazz) ||
            ParamConverterProvider.class.isAssignableFrom(clazz) ||
            ContextResolver.class.isAssignableFrom(clazz) ||
            new MetaAnnotatedClass<>(clazz).isAnnotationPresent(Provider.class);
}
 
开发者ID:apache,项目名称:tomee,代码行数:13,代码来源:RESTService.java

示例11: getResponseFilters

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@Override
public ContainerResponseFilter[] getResponseFilters() {

    return responseFilters;
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:6,代码来源:VertxAsynchronousResponse.java

示例12: setResponseFilters

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
@Override
public void setResponseFilters(final ContainerResponseFilter[] responseFilters) {

    this.responseFilters = responseFilters;
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:6,代码来源:VertxAsynchronousResponse.java

示例13: xPoweredByFilter

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
ContainerResponseFilter xPoweredByFilter() {
  return (req, res) -> res.getHeaders().add("X-Powered-By", "UnitTest-Webserver (1.0-SNAPSHOT)");
}
 
开发者ID:sorskod,项目名称:webserver,代码行数:4,代码来源:WebServerIntegrationTest.java

示例14: registerExtension

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
private ServiceRegistration<?> registerExtension(
    String name, Object... keyValues) {

    TestFilter testFilter = new TestFilter();

    Dictionary<String, Object> properties = new Hashtable<>();

    properties.put(JAX_RS_EXTENSION, true);
    properties.put(JAX_RS_NAME, name);

    for (int i = 0; i < keyValues.length; i = i + 2) {
        properties.put(keyValues[i].toString(), keyValues[i + 1]);
    }

    ServiceRegistration<ContainerResponseFilter> serviceRegistration =
        bundleContext.registerService(
            ContainerResponseFilter.class, testFilter, properties);

    _registrations.add(serviceRegistration);

    return serviceRegistration;
}
 
开发者ID:apache,项目名称:aries-jax-rs-whiteboard,代码行数:23,代码来源:JaxrsTest.java

示例15: addContainerResponseFilter

import javax.ws.rs.container.ContainerResponseFilter; //导入依赖的package包/类
public JerseyEndpoints addContainerResponseFilter(ContainerResponseFilter containerResponseFilter) {
    containerResponseFilters.add(containerResponseFilter);
    return this;
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:5,代码来源:JerseyEndpoints.java


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