當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。