ValidatingMessageBodyReader.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:OpenNMS 作者:
public T readFrom(final Class<T> clazz, final Type type, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, String> parameters, final InputStream stream) throws IOException, WebApplicationException {
    LogUtils.debugf(this, "readFrom: %s/%s/%s", clazz.getSimpleName(), type, mediaType);

    JAXBContext jaxbContext = null;
    final ContextResolver<JAXBContext> resolver = providers.getContextResolver(JAXBContext.class, mediaType);
    try {

        if (resolver != null) {
            jaxbContext = resolver.getContext(clazz);
        }

        if (jaxbContext == null) {
            jaxbContext = JAXBContext.newInstance(clazz);

        }

        return JaxbUtils.unmarshal(clazz, new InputSource(stream), jaxbContext);

    } catch (final JAXBException e) {
        LogUtils.warnf(this, e, "An error occurred while unmarshaling a %s object", clazz.getSimpleName());
        throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号