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


Java Providers.getMessageBodyReader方法代码示例

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


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

示例1: testLocateMostRelevantConstructor

import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateMostRelevantConstructor() {
    ReflectionProvider rp = instance(ReflectionProvider.class);

    Providers providers = instance(Providers.class);
    ProviderFilter providerFilter = instance(ProviderFilter.class);

    Field f = rp.getField(JaxRsResolverTest.class, "genericField3");

    RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());

    MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_XML_TYPE);

    assertNotNull(messageBodyReader);
    assertEquals(PersonMessageBodyReader.class, messageBodyReader.getClass());

    Constructor<?> c = providerFilter.mostRelevantConstructor(messageBodyReader.getClass());
    assertEquals(4, c.getParameterCount());
    assertEquals("public com.geemvc.jaxrs.PersonMessageBodyReader(javax.ws.rs.core.Application,javax.ws.rs.core.UriInfo,javax.ws.rs.core.HttpHeaders,javax.ws.rs.ext.Providers)", c.toString());
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:21,代码来源:JaxRsResolverTest.java

示例2: testLocateClosestPersonMapMessageBodyReaderJSON

import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestPersonMapMessageBodyReaderJSON() {
    ReflectionProvider rp = instance(ReflectionProvider.class);

    Providers providers = instance(Providers.class);

    Field f = rp.getField(JaxRsResolverTest.class, "genericField1");

    RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());

    MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_JSON_TYPE);

    assertNotNull(messageBodyReader);
    assertEquals(ModelMapMessageBodyReader.class, messageBodyReader.getClass());
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:16,代码来源:JaxRsResolverTest.java

示例3: testLocateClosestPersonMapMessageBodyReaderXML

import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestPersonMapMessageBodyReaderXML() {
    ReflectionProvider rp = instance(ReflectionProvider.class);

    Providers providers = instance(Providers.class);

    Field f = rp.getField(JaxRsResolverTest.class, "genericField1");

    RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());

    MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_XML_TYPE);

    assertNotNull(messageBodyReader);
    assertEquals(PersonMapMessageBodyReader.class, messageBodyReader.getClass());
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:16,代码来源:JaxRsResolverTest.java

示例4: testLocateModelMapMessageBodyReader

import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateModelMapMessageBodyReader() {
    ReflectionProvider rp = instance(ReflectionProvider.class);

    Providers providers = instance(Providers.class);

    Field f = rp.getField(JaxRsResolverTest.class, "genericField1");

    RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());

    MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_JSON_TYPE);

    assertNotNull(messageBodyReader);
    assertEquals(ModelMapMessageBodyReader.class, messageBodyReader.getClass());
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:16,代码来源:JaxRsResolverTest.java

示例5: testLocateStringMapMessageBodyReader

import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateStringMapMessageBodyReader() {
    ReflectionProvider rp = instance(ReflectionProvider.class);

    Providers providers = instance(Providers.class);

    Field f = rp.getField(JaxRsResolverTest.class, "genericField2");

    RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());

    MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_JSON_TYPE);

    assertNotNull(messageBodyReader);
    assertEquals(MapMessageBodyReader.class, messageBodyReader.getClass());
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:16,代码来源:JaxRsResolverTest.java

示例6: testLocateClosestPersonMessageBodyReaderJSON

import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestPersonMessageBodyReaderJSON() {
    ReflectionProvider rp = instance(ReflectionProvider.class);

    Providers providers = instance(Providers.class);

    Field f = rp.getField(JaxRsResolverTest.class, "genericField3");

    RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());

    MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_JSON_TYPE);

    assertNotNull(messageBodyReader);
    assertEquals(AbstractModelMessageBodyReader.class, messageBodyReader.getClass());
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:16,代码来源:JaxRsResolverTest.java

示例7: testLocateClosestPersonMessageBodyReaderXML

import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestPersonMessageBodyReaderXML() {
    ReflectionProvider rp = instance(ReflectionProvider.class);

    Providers providers = instance(Providers.class);

    Field f = rp.getField(JaxRsResolverTest.class, "genericField3");

    RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());

    MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_XML_TYPE);

    assertNotNull(messageBodyReader);
    assertEquals(PersonMessageBodyReader.class, messageBodyReader.getClass());
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:16,代码来源:JaxRsResolverTest.java

示例8: testLocateClosestPersonMessageBodyReaderTextPlain

import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestPersonMessageBodyReaderTextPlain() {
    ReflectionProvider rp = instance(ReflectionProvider.class);

    Providers providers = instance(Providers.class);

    Field f = rp.getField(JaxRsResolverTest.class, "genericField3");

    RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());

    MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.TEXT_PLAIN_TYPE);

    assertNotNull(messageBodyReader);
    assertEquals(AbstractModelMessageBodyReader.class, messageBodyReader.getClass());
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:16,代码来源:JaxRsResolverTest.java

示例9: testLocateClosestAddressMessageBodyReaderJSON

import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestAddressMessageBodyReaderJSON() {
    ReflectionProvider rp = instance(ReflectionProvider.class);

    Providers providers = instance(Providers.class);

    Field f = rp.getField(JaxRsResolverTest.class, "genericField4");

    RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());

    MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_JSON_TYPE);

    assertNotNull(messageBodyReader);
    assertEquals(ObjectMessageBodyReaderJSON.class, messageBodyReader.getClass());
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:16,代码来源:JaxRsResolverTest.java

示例10: testLocateClosestAddressMessageBodyReaderXML

import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestAddressMessageBodyReaderXML() {
    ReflectionProvider rp = instance(ReflectionProvider.class);

    Providers providers = instance(Providers.class);

    Field f = rp.getField(JaxRsResolverTest.class, "genericField4");

    RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());

    MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.APPLICATION_XML_TYPE);

    assertNotNull(messageBodyReader);
    assertEquals(ObjectMessageBodyReaderXML.class, messageBodyReader.getClass());
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:16,代码来源:JaxRsResolverTest.java

示例11: testLocateClosestAddressMessageBodyReaderTextPlain

import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
@Test
public void testLocateClosestAddressMessageBodyReaderTextPlain() {
    ReflectionProvider rp = instance(ReflectionProvider.class);

    Providers providers = instance(Providers.class);

    Field f = rp.getField(JaxRsResolverTest.class, "genericField4");

    RuntimeDelegate.setInstance(new DefaultRuntimeDelegate());

    MessageBodyReader messageBodyReader = providers.getMessageBodyReader(f.getType(), f.getGenericType(), f.getAnnotations(), MediaType.TEXT_PLAIN_TYPE);

    assertNotNull(messageBodyReader);
    assertEquals(ObjectMessageBodyReaderWildCard.class, messageBodyReader.getClass());
}
 
开发者ID:geetools,项目名称:geeMVC-Java-MVC-Framework,代码行数:16,代码来源:JaxRsResolverTest.java

示例12: getContent

import javax.ws.rs.ext.Providers; //导入方法依赖的package包/类
/**
 * @param inputStream
 * @param providers
 * @param httpHeaders
 * @param type
 * @param genericType
 * @param annotations
 * @return
 */
public static <T> T getContent(InputStream inputStream, Providers providers, HttpHeaders httpHeaders, Class<T> type, Type genericType, Annotation[] annotations) {
	MessageBodyReader<T> reader = providers.getMessageBodyReader(type, genericType, annotations, httpHeaders.getMediaType());
	try {
		return reader.readFrom(type, genericType, annotations, httpHeaders.getMediaType(), httpHeaders.getRequestHeaders(), inputStream);
	} catch (Exception e) {e.printStackTrace();
		throw new MinnalInstrumentationException("Failed while getting the content from the request stream", e);
	}
}
 
开发者ID:minnal,项目名称:minnal,代码行数:18,代码来源:ResourceUtil.java


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