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