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