本文整理了Java中org.apache.cxf.jaxrs.provider.json.JSONProvider.getContext()
方法的一些代码示例,展示了JSONProvider.getContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONProvider.getContext()
方法的具体详情如下:
包路径:org.apache.cxf.jaxrs.provider.json.JSONProvider
类名称:JSONProvider
方法名:getContext
暂无
代码示例来源:origin: apache/cxf
protected boolean getBooleanJsonProperty(String name, boolean defaultValue) {
MessageContext mc = getContext();
if (mc != null) {
Object prop = mc.get(name);
if (prop != null) {
return PropertyUtils.isTrue(prop);
}
}
return defaultValue;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-extension-providers
protected boolean getBooleanJsonProperty(String name, boolean defaultValue) {
MessageContext mc = getContext();
if (mc != null) {
Object prop = mc.get(name);
if (prop != null) {
return PropertyUtils.isTrue(prop);
}
}
return defaultValue;
}
代码示例来源:origin: apache/cxf
protected List<String> getArrayKeys() {
MessageContext mc = getContext();
if (mc != null) {
Object prop = mc.get(ARRAY_KEYS_PROPERTY);
if (prop instanceof List) {
return CastUtils.cast((List<?>)prop);
}
}
return arrayKeys;
}
代码示例来源:origin: apache/cxf
protected DocumentDepthProperties getDepthProperties() {
DocumentDepthProperties depthProperties = super.getDepthProperties();
if (depthProperties != null) {
return depthProperties;
}
if (getContext() != null) {
String totalElementCountStr = (String)getContext().getContextualProperty(
DocumentDepthProperties.TOTAL_ELEMENT_COUNT);
String innerElementCountStr = (String)getContext().getContextualProperty(
DocumentDepthProperties.INNER_ELEMENT_COUNT);
String elementLevelStr = (String)getContext().getContextualProperty(
DocumentDepthProperties.INNER_ELEMENT_LEVEL);
if (totalElementCountStr != null || innerElementCountStr != null || elementLevelStr != null) {
try {
int totalElementCount = totalElementCountStr != null
? Integer.parseInt(totalElementCountStr) : -1;
int elementLevel = elementLevelStr != null ? Integer.parseInt(elementLevelStr) : -1;
int innerElementCount = innerElementCountStr != null
? Integer.parseInt(innerElementCountStr) : -1;
return new DocumentDepthProperties(totalElementCount, elementLevel, innerElementCount);
} catch (Exception ex) {
throw ExceptionUtils.toInternalServerErrorException(ex, null);
}
}
}
return null;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-extension-providers
protected List<String> getArrayKeys() {
MessageContext mc = getContext();
if (mc != null) {
Object prop = mc.get(ARRAY_KEYS_PROPERTY);
if (prop instanceof List) {
return CastUtils.cast((List<?>)prop);
}
}
return arrayKeys;
}
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
protected List<String> getArrayKeys() {
MessageContext mc = getContext();
if (mc != null) {
Object prop = mc.get(ARRAY_KEYS_PROPERTY);
if (prop instanceof List) {
return CastUtils.cast((List<?>)prop);
}
}
return arrayKeys;
}
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
protected boolean getBooleanJsonProperty(String name, boolean defaultValue) {
MessageContext mc = getContext();
if (mc != null) {
Object prop = mc.get(name);
if (prop != null) {
return MessageUtils.isTrue(prop);
}
}
return defaultValue;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-extension-providers
protected DocumentDepthProperties getDepthProperties() {
DocumentDepthProperties depthProperties = super.getDepthProperties();
if (depthProperties != null) {
return depthProperties;
}
if (getContext() != null) {
String totalElementCountStr = (String)getContext().getContextualProperty(
DocumentDepthProperties.TOTAL_ELEMENT_COUNT);
String innerElementCountStr = (String)getContext().getContextualProperty(
DocumentDepthProperties.INNER_ELEMENT_COUNT);
String elementLevelStr = (String)getContext().getContextualProperty(
DocumentDepthProperties.INNER_ELEMENT_LEVEL);
if (totalElementCountStr != null || innerElementCountStr != null || elementLevelStr != null) {
try {
int totalElementCount = totalElementCountStr != null
? Integer.parseInt(totalElementCountStr) : -1;
int elementLevel = elementLevelStr != null ? Integer.parseInt(elementLevelStr) : -1;
int innerElementCount = innerElementCountStr != null
? Integer.parseInt(innerElementCountStr) : -1;
return new DocumentDepthProperties(totalElementCount, elementLevel, innerElementCount);
} catch (Exception ex) {
throw ExceptionUtils.toInternalServerErrorException(ex, null);
}
}
}
return null;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-extension-providers
protected void marshal(Marshaller ms, Object actualObject, Class<?> actualClass,
Type genericType, String enc, OutputStream os, boolean isCollection) throws Exception {
OutputStream actualOs = os;
MessageContext mc = getContext();
if (mc != null && PropertyUtils.isTrue(mc.get(Marshaller.JAXB_FORMATTED_OUTPUT))) {
actualOs = new CachedOutputStream();
}
XMLStreamWriter writer = createWriter(actualObject, actualClass, genericType, enc,
actualOs, isCollection);
if (namespaceMap.size() > 1 || namespaceMap.size() == 1 && !namespaceMap.containsKey(JSONUtils.XSI_URI)) {
setNamespaceMapper(ms, namespaceMap);
}
org.apache.cxf.common.jaxb.JAXBUtils.setNoEscapeHandler(ms);
ms.marshal(actualObject, writer);
writer.close();
if (os != actualOs) {
StringIndenter formatter = new StringIndenter(
IOUtils.newStringFromBytes(((CachedOutputStream)actualOs).getBytes()));
Writer outWriter = new OutputStreamWriter(os, enc);
IOUtils.copy(new StringReader(formatter.result()), outWriter, 2048);
outWriter.close();
}
}
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
protected void marshal(Marshaller ms, Object actualObject, Class<?> actualClass,
Type genericType, String enc, OutputStream os, boolean isCollection) throws Exception {
OutputStream actualOs = os;
MessageContext mc = getContext();
if (mc != null && MessageUtils.isTrue(mc.get(Marshaller.JAXB_FORMATTED_OUTPUT))) {
actualOs = new CachedOutputStream();
}
XMLStreamWriter writer = createWriter(actualObject, actualClass, genericType, enc,
actualOs, isCollection);
if (namespaceMap.size() > 1 || namespaceMap.size() == 1 && !namespaceMap.containsKey(JSONUtils.XSI_URI)) {
setNamespaceMapper(ms, namespaceMap);
}
ms.marshal(actualObject, writer);
writer.close();
if (os != actualOs) {
StringIndenter formatter = new StringIndenter(
IOUtils.newStringFromBytes(((CachedOutputStream)actualOs).getBytes()));
Writer outWriter = new OutputStreamWriter(os, enc);
IOUtils.copy(new StringReader(formatter.result()), outWriter, 2048);
outWriter.close();
}
}
代码示例来源:origin: apache/cxf
protected void marshal(Marshaller ms, Object actualObject, Class<?> actualClass,
Type genericType, String enc, OutputStream os, boolean isCollection) throws Exception {
OutputStream actualOs = os;
MessageContext mc = getContext();
if (mc != null && PropertyUtils.isTrue(mc.get(Marshaller.JAXB_FORMATTED_OUTPUT))) {
actualOs = new CachedOutputStream();
}
XMLStreamWriter writer = createWriter(actualObject, actualClass, genericType, enc,
actualOs, isCollection);
if (namespaceMap.size() > 1 || namespaceMap.size() == 1 && !namespaceMap.containsKey(JSONUtils.XSI_URI)) {
setNamespaceMapper(ms, namespaceMap);
}
org.apache.cxf.common.jaxb.JAXBUtils.setNoEscapeHandler(ms);
ms.marshal(actualObject, writer);
writer.close();
if (os != actualOs) {
StringIndenter formatter = new StringIndenter(
IOUtils.newStringFromBytes(((CachedOutputStream)actualOs).getBytes()));
Writer outWriter = new OutputStreamWriter(os, enc);
IOUtils.copy(new StringReader(formatter.result()), outWriter, 2048);
outWriter.close();
}
}
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
StringBuilder sb = new StringBuilder();
sb.append("Jettison needs initialized OutputStream");
if (getContext() != null && getContext().getContent(XMLStreamWriter.class) == null) {
sb.append("; if you need to customize Jettison output with the custom XMLStreamWriter"
+ " then extend JSONProvider or when possible configure it directly.");
代码示例来源:origin: apache/cxf
StringBuilder sb = new StringBuilder();
sb.append("Jettison needs initialized OutputStream");
if (getContext() != null && getContext().getContent(XMLStreamWriter.class) == null) {
sb.append("; if you need to customize Jettison output with the custom XMLStreamWriter"
+ " then extend JSONProvider or when possible configure it directly.");
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-extension-providers
StringBuilder sb = new StringBuilder();
sb.append("Jettison needs initialized OutputStream");
if (getContext() != null && getContext().getContent(XMLStreamWriter.class) == null) {
sb.append("; if you need to customize Jettison output with the custom XMLStreamWriter"
+ " then extend JSONProvider or when possible configure it directly.");
内容来源于网络,如有侵权,请联系作者删除!