本文整理汇总了Java中javax.xml.bind.Marshaller.setAttachmentMarshaller方法的典型用法代码示例。如果您正苦于以下问题:Java Marshaller.setAttachmentMarshaller方法的具体用法?Java Marshaller.setAttachmentMarshaller怎么用?Java Marshaller.setAttachmentMarshaller使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.bind.Marshaller
的用法示例。
在下文中一共展示了Marshaller.setAttachmentMarshaller方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writePayloadTo
import javax.xml.bind.Marshaller; //导入方法依赖的package包/类
@Override
public void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException {
try {
// MtomCodec sets its own AttachmentMarshaller
AttachmentMarshaller am = (sw instanceof MtomStreamWriter)
? ((MtomStreamWriter)sw).getAttachmentMarshaller()
: new AttachmentMarshallerImpl(attachmentSet);
// Get the encoding of the writer
String encoding = XMLStreamWriterUtil.getEncoding(sw);
// Get output stream and use JAXB UTF-8 writer
OutputStream os = bridge.supportOutputStream() ? XMLStreamWriterUtil.getOutputStream(sw) : null;
if (rawContext != null) {
Marshaller m = rawContext.createMarshaller();
m.setProperty("jaxb.fragment", Boolean.TRUE);
m.setAttachmentMarshaller(am);
if (os != null) {
m.marshal(jaxbObject, os);
} else {
m.marshal(jaxbObject, sw);
}
} else {
if (os != null && encoding != null && encoding.equalsIgnoreCase(SOAPBindingCodec.UTF8_ENCODING)) {
bridge.marshal(jaxbObject, os, sw.getNamespaceContext(), am);
} else {
bridge.marshal(jaxbObject, sw, am);
}
}
//cleanup() is not needed since JAXB doesn't keep ref to AttachmentMarshaller
//am.cleanup();
} catch (JAXBException e) {
// bug 6449684, spec 4.3.4
throw new WebServiceException(e);
}
}
示例2: writeTo
import javax.xml.bind.Marshaller; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void writeTo(XMLStreamWriter sw) throws XMLStreamException {
try {
// MtomCodec sets its own AttachmentMarshaller
AttachmentMarshaller am = (sw instanceof MtomStreamWriter)
? ((MtomStreamWriter) sw).getAttachmentMarshaller()
: new AttachmentMarshallerImpl(attachmentSet);
// Get the encoding of the writer
String encoding = XMLStreamWriterUtil.getEncoding(sw);
// Get output stream and use JAXB UTF-8 writer
OutputStream os = bridge.supportOutputStream() ? XMLStreamWriterUtil.getOutputStream(sw) : null;
if (rawContext != null) {
Marshaller m = rawContext.createMarshaller();
m.setProperty("jaxb.fragment", Boolean.FALSE);
m.setAttachmentMarshaller(am);
if (os != null) {
m.marshal(jaxbObject, os);
} else {
m.marshal(jaxbObject, sw);
}
} else {
if (os != null && encoding != null && encoding.equalsIgnoreCase(SOAPBindingCodec.UTF8_ENCODING)) {
bridge.marshal(jaxbObject, os, sw.getNamespaceContext(), am);
} else {
bridge.marshal(jaxbObject, sw, am);
}
}
//cleanup() is not needed since JAXB doesn't keep ref to AttachmentMarshaller
} catch (JAXBException e) {
// bug 6449684, spec 4.3.4
throw new WebServiceException(e);
}
}
示例3: marshal
import javax.xml.bind.Marshaller; //导入方法依赖的package包/类
public final void marshal(T object,XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException {
Marshaller m = context.marshallerPool.take();
m.setAttachmentMarshaller(am);
marshal(m,object,output);
m.setAttachmentMarshaller(null);
context.marshallerPool.recycle(m);
}