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


Java WriterInterceptor类代码示例

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


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

示例1: shouldRegisterAMultiTypedProviderInstanceWithPriorities

import javax.ws.rs.ext.WriterInterceptor; //导入依赖的package包/类
@Test
public void shouldRegisterAMultiTypedProviderInstanceWithPriorities() {
    MultiTypedProvider provider = new MultiTypedProvider();
    Map<Class<?>, Integer> priorities = new HashMap<>();
    priorities.put(ClientRequestFilter.class, 500);
    priorities.put(ClientResponseFilter.class, 501);
    priorities.put(MessageBodyReader.class, 502);
    priorities.put(MessageBodyWriter.class, 503);
    priorities.put(ReaderInterceptor.class, 504);
    priorities.put(WriterInterceptor.class, 505);
    priorities.put(ResponseExceptionMapper.class, 506);
    priorities.put(ParamConverterProvider.class, 507);
    RestClientBuilder builder = RestClientBuilder.newBuilder().register(provider, priorities);
    Configuration configuration = builder.getConfiguration();
    assertTrue(configuration.isRegistered(MultiTypedProvider.class), MultiTypedProvider.class + " should be registered");
    assertTrue(configuration.isRegistered(provider), MultiTypedProvider.class + " should be registered");
    Map<Class<?>, Integer> contracts = configuration.getContracts(MultiTypedProvider.class);
    assertEquals(contracts.size(), priorities.size(),
        "There should be "+priorities.size()+" provider types registered");
    for(Map.Entry<Class<?>, Integer> priority : priorities.entrySet()) {
        Integer contractPriority = contracts.get(priority.getKey());
        assertEquals(contractPriority, priority.getValue(), "The priority for "+priority.getKey()+" should be "+priority.getValue());
    }
}
 
开发者ID:eclipse,项目名称:microprofile-rest-client,代码行数:25,代码来源:AdditionalRegistrationTest.java

示例2: shouldRegisterAMultiTypedProviderClassWithPriorities

import javax.ws.rs.ext.WriterInterceptor; //导入依赖的package包/类
@Test
public void shouldRegisterAMultiTypedProviderClassWithPriorities() {
    Map<Class<?>, Integer> priorities = new HashMap<>();
    priorities.put(ClientRequestFilter.class, 500);
    priorities.put(ClientResponseFilter.class, 501);
    priorities.put(MessageBodyReader.class, 502);
    priorities.put(MessageBodyWriter.class, 503);
    priorities.put(ReaderInterceptor.class, 504);
    priorities.put(WriterInterceptor.class, 505);
    priorities.put(ResponseExceptionMapper.class, 506);
    priorities.put(ParamConverterProvider.class, 507);
    RestClientBuilder builder = RestClientBuilder.newBuilder().register(MultiTypedProvider.class, priorities);
    Configuration configuration = builder.getConfiguration();
    assertTrue(configuration.isRegistered(MultiTypedProvider.class), MultiTypedProvider.class + " should be registered");
    Map<Class<?>, Integer> contracts = configuration.getContracts(MultiTypedProvider.class);
    assertEquals(contracts.size(), priorities.size(),
        "There should be "+priorities.size()+" provider types registered");
    for(Map.Entry<Class<?>, Integer> priority : priorities.entrySet()) {
        Integer contractPriority = contracts.get(priority.getKey());
        assertEquals(contractPriority, priority.getValue(), "The priority for "+priority.getKey()+" should be "+priority.getValue());
    }
}
 
开发者ID:eclipse,项目名称:microprofile-rest-client,代码行数:23,代码来源:AdditionalRegistrationTest.java

示例3: simpleWriterInterceptors

import javax.ws.rs.ext.WriterInterceptor; //导入依赖的package包/类
@Test
public void simpleWriterInterceptors() {
  Response response =
      client
          .target(mockServer.url("/writerInterceptor").uri())
          .register(
              new WriterInterceptor() {
                @Override
                public void aroundWriteTo(WriterInterceptorContext context)
                    throws IOException, WebApplicationException {
                  context.getHeaders().putSingle(HEADER_NAME, HEADER_VALUE);
                  context.proceed();
                }
              })
          .request()
          .post(Entity.json(PAYLOAD));

  assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
  assertThat(response.readEntity(String.class)).isEqualTo(HEADER_VALUE);
}
 
开发者ID:tbroyer,项目名称:jaxrs-utils,代码行数:21,代码来源:OkHttpClientEngineTest.java

示例4: shouldRegisterAMultiTypedProviderInstance

import javax.ws.rs.ext.WriterInterceptor; //导入依赖的package包/类
@Test
public void shouldRegisterAMultiTypedProviderInstance() {
    MultiTypedProvider provider = new MultiTypedProvider();
    Class[] providerTypes = {ClientRequestFilter.class, ClientResponseFilter.class,
        MessageBodyReader.class, MessageBodyWriter.class, ReaderInterceptor.class, WriterInterceptor.class,
        ResponseExceptionMapper.class, ParamConverterProvider.class};
    RestClientBuilder builder = RestClientBuilder.newBuilder().register(provider, providerTypes);
    Configuration configuration = builder.getConfiguration();
    assertTrue(configuration.isRegistered(MultiTypedProvider.class), MultiTypedProvider.class + " should be registered");
    assertTrue(configuration.isRegistered(provider), MultiTypedProvider.class + " should be registered");
    assertEquals(configuration.getContracts(MultiTypedProvider.class).size(), providerTypes.length,
        "There should be "+providerTypes.length+" provider types registered");
}
 
开发者ID:eclipse,项目名称:microprofile-rest-client,代码行数:14,代码来源:AdditionalRegistrationTest.java

示例5: shouldRegisterAMultiTypedProviderClass

import javax.ws.rs.ext.WriterInterceptor; //导入依赖的package包/类
@Test
public void shouldRegisterAMultiTypedProviderClass() {
    Class[] providerTypes = {ClientRequestFilter.class, ClientResponseFilter.class,
        MessageBodyReader.class, MessageBodyWriter.class, ReaderInterceptor.class, WriterInterceptor.class,
        ResponseExceptionMapper.class, ParamConverterProvider.class};
    RestClientBuilder builder = RestClientBuilder.newBuilder().register(MultiTypedProvider.class, providerTypes);
    Configuration configuration = builder.getConfiguration();
    assertTrue(configuration.isRegistered(MultiTypedProvider.class), MultiTypedProvider.class + " should be registered");
    assertEquals(configuration.getContracts(MultiTypedProvider.class).size(), providerTypes.length,
        "There should be "+providerTypes.length+" provider types registered");
}
 
开发者ID:eclipse,项目名称:microprofile-rest-client,代码行数:12,代码来源:AdditionalRegistrationTest.java

示例6: configure

import javax.ws.rs.ext.WriterInterceptor; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void configure() {
    bind(TemplateMethodInterceptor.class).to(WriterInterceptor.class).in(Singleton.class);
    //noinspection unchecked
    bind(ViewableMessageBodyWriter.class).to(MessageBodyWriter.class).in(Singleton.class);

    bind(TemplateModelProcessor.class).to(ModelProcessor.class).in(Singleton.class);
    bindAsContract(ResolvingViewableContext.class).in(Singleton.class);
    bind(ResolvingViewableContext.class).to(ViewableContext.class).in(Singleton.class).ranked(1);
}
 
开发者ID:icode,项目名称:ameba,代码行数:14,代码来源:MvcBinder.java

示例7: isProvider

import javax.ws.rs.ext.WriterInterceptor; //导入依赖的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

示例8: getWriterInterceptors

import javax.ws.rs.ext.WriterInterceptor; //导入依赖的package包/类
@Override
public WriterInterceptor[] getWriterInterceptors() {

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

示例9: registerBinders

import javax.ws.rs.ext.WriterInterceptor; //导入依赖的package包/类
private void registerBinders(final Splinter application) {
    final Logger logger = new LoggerProvider().provide();
    logger.debug("Dependency injection start");
    
    SimpleContainer.setApplication(application);
    SimpleContainer.setLogger(logger);
    SimpleContainer.setSharedVariablesManager(new SharedVariablesManager());

    register(new AbstractBinder() {
        @Override
        protected void configure() {
            // Template method interceptor
            bind(UserDataInterceptor.class).to(WriterInterceptor.class).in(Singleton.class);
        }
    });
    register(new AbstractBinder() {
        @Override
        protected void configure() {
            bind(application.getConfiguration().getDatabaseConfiguration()).to(DatabaseConfiguration.class);
        }
    });
    register(new AbstractBinder() {
        @Override
        protected void configure() {
            bind(application).to(Splinter.class);
        }
    });
    register(new AbstractBinder() {
        @Override
        protected void configure() {
            bind(logger).to(Logger.class);
        }
    });
    register(new AbstractBinder() {
        @Override
        protected void configure() {
            bind(SimpleContainer.getSharedVariablesManager()).to(SharedVariablesManager.class);
        }
    });
    logger.debug("Finished dependency injection registration");
}
 
开发者ID:autoschool,项目名称:splinter,代码行数:42,代码来源:Server.java

示例10: setWriterInterceptors

import javax.ws.rs.ext.WriterInterceptor; //导入依赖的package包/类
@Override
public void setWriterInterceptors(final WriterInterceptor[] writerInterceptors) {

    this.writerInterceptors = writerInterceptors;

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


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