作者:btbxin | 来源:互联网 | 2023-10-10 18:30
本文整理了Java中org.apache.cxf.jaxrs.provider.JAXBElementProvider.getPackageContext()方法的一些
本文整理了Java中org.apache.cxf.jaxrs.provider.JAXBElementProvider.getPackageContext()
方法的一些代码示例,展示了JAXBElementProvider.getPackageContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JAXBElementProvider.getPackageContext()
方法的具体详情如下:
包路径:org.apache.cxf.jaxrs.provider.JAXBElementProvider
类名称:JAXBElementProvider
方法名:getPackageContext
JAXBElementProvider.getPackageContext介绍
暂无
代码示例
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
private T readNode(Node node, Class cls) {
if (Node.class.isAssignableFrom(cls)) {
return cls.cast(node);
}
DOMSource s = new DOMSource(node);
if (Source.class == cls || DOMSource.class == cls) {
return cls.cast(s);
}
try {
JAXBElementProvider> provider = new JAXBElementProvider();
JAXBContext c = provider.getPackageContext(cls);
if (c == null) {
c = provider.getClassContext(cls);
}
Unmarshaller u = c.createUnmarshaller();
if (cls.getAnnotation(XmlRootElement.class) != null) {
return cls.cast(u.unmarshal(s));
} else {
return u.unmarshal(s, cls).getValue();
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
代码示例来源:origin: apache/cxf
private T readNode(Node node, Class cls) {
if (Node.class.isAssignableFrom(cls)) {
return cls.cast(node);
}
DOMSource s = new DOMSource(node);
if (Source.class == cls || DOMSource.class == cls) {
return cls.cast(s);
}
try {
JAXBElementProvider> provider = new JAXBElementProvider<>();
JAXBContext c = provider.getPackageContext(cls);
if (c == null) {
c = provider.getClassContext(cls);
}
Unmarshaller u = c.createUnmarshaller();
try {
if (cls.getAnnotation(XmlRootElement.class) != null) {
return cls.cast(u.unmarshal(s));
}
return u.unmarshal(s, cls).getValue();
} finally {
JAXBUtils.closeUnmarshaller(u);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}