javax.xml.bind.Marshaller#setAttachmentMarshaller ( )源码实例Demo

下面列出了javax.xml.bind.Marshaller#setAttachmentMarshaller ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: java-technology-stack   文件: Jaxb2Marshaller.java
@Override
public void marshal(Object graph, Result result, @Nullable MimeContainer mimeContainer) throws XmlMappingException {
	try {
		Marshaller marshaller = createMarshaller();
		if (this.mtomEnabled && mimeContainer != null) {
			marshaller.setAttachmentMarshaller(new Jaxb2AttachmentMarshaller(mimeContainer));
		}
		if (StaxUtils.isStaxResult(result)) {
			marshalStaxResult(marshaller, graph, result);
		}
		else {
			marshaller.marshal(graph, result);
		}
	}
	catch (JAXBException ex) {
		throw convertJaxbException(ex);
	}
}
 
源代码2 项目: openjdk-jdk9   文件: JAXBDispatchMessage.java
@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 项目: openjdk-jdk8u-backup   文件: JAXBMessage.java
@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);
    }
}
 
源代码4 项目: openjdk-jdk9   文件: JAXBMessage.java
@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);
    }
}
 
源代码5 项目: openjdk-jdk8u-backup   文件: Bridge.java
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);
}
 
源代码6 项目: openjdk-8   文件: OldBridge.java
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);
}
 
源代码7 项目: openjdk-8-source   文件: JAXBMessage.java
@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);
    }
}
 
源代码8 项目: openjdk-8-source   文件: JAXBDispatchMessage.java
@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);
    }
}
 
源代码9 项目: openjdk-jdk9   文件: Bridge.java
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);
}
 
源代码10 项目: openjdk-8   文件: OldBridge.java
/**
 * @since 2.0.2
 */
public void marshal(T object,OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException {
    Marshaller m = context.marshallerPool.take();
    m.setAttachmentMarshaller(am);
    marshal(m,object,output,nsContext);
    m.setAttachmentMarshaller(null);
    context.marshallerPool.recycle(m);
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: Bridge.java
/**
 * @since 2.0.2
 */
public void marshal(T object,OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException {
    Marshaller m = context.marshallerPool.take();
    m.setAttachmentMarshaller(am);
    marshal(m,object,output,nsContext);
    m.setAttachmentMarshaller(null);
    context.marshallerPool.recycle(m);
}
 
源代码12 项目: freehealth-connector   文件: MarshallerHelper.java
private Marshaller getMarshaller() throws JAXBException {
   this.attachmentMarshaller = new AttachmentMarshallerImpl(this.xop, this.threshold);
   Marshaller marshaller = JaxbContextFactory.getJaxbContextForClass(this.marshallClass).createMarshaller();
   marshaller.setAttachmentMarshaller(this.attachmentMarshaller);
   marshaller.setProperty("jaxb.encoding", Charset.UTF_8.getName());
   marshaller.setProperty("jaxb.formatted.output", this.format);
   return marshaller;
}
 
源代码13 项目: freehealth-connector   文件: MarshallerHelper.java
private Marshaller getMarshaller() throws JAXBException {
   this.attachmentMarshaller = new AttachmentMarshallerImpl(this.xop, this.threshold);
   Marshaller marshaller = JaxbContextFactory.getJaxbContextForClass(this.marshallClass).createMarshaller();
   marshaller.setAttachmentMarshaller(this.attachmentMarshaller);
   marshaller.setProperty("jaxb.encoding", Charset.UTF_8.getName());
   marshaller.setProperty("jaxb.formatted.output", this.format);
   return marshaller;
}
 
源代码14 项目: openjdk-8-source   文件: Bridge.java
/**
 * @since 2.0.2
 */
public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException {
    Marshaller m = context.marshallerPool.take();
    m.setAttachmentMarshaller(am);
    marshal(m,object,contentHandler);
    m.setAttachmentMarshaller(null);
    context.marshallerPool.recycle(m);
}
 
源代码15 项目: openjdk-jdk9   文件: Bridge.java
/**
 * @since 2.0.2
 */
public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException {
    Marshaller m = context.marshallerPool.take();
    m.setAttachmentMarshaller(am);
    marshal(m,object,contentHandler);
    m.setAttachmentMarshaller(null);
    context.marshallerPool.recycle(m);
}
 
源代码16 项目: hottub   文件: Bridge.java
/**
 * @since 2.0.2
 */
public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException {
    Marshaller m = context.marshallerPool.take();
    m.setAttachmentMarshaller(am);
    marshal(m,object,contentHandler);
    m.setAttachmentMarshaller(null);
    context.marshallerPool.recycle(m);
}
 
源代码17 项目: openjdk-8   文件: JAXBMessage.java
@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);
    }
}
 
源代码18 项目: hottub   文件: OldBridge.java
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);
}
 
源代码19 项目: jdk8u60   文件: OldBridge.java
/**
 * @since 2.0.2
 */
public void marshal(T object,OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException {
    Marshaller m = context.marshallerPool.take();
    m.setAttachmentMarshaller(am);
    marshal(m,object,output,nsContext);
    m.setAttachmentMarshaller(null);
    context.marshallerPool.recycle(m);
}
 
源代码20 项目: openjdk-8-source   文件: OldBridge.java
/**
 * @since 2.0.2
 */
public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException {
    Marshaller m = context.marshallerPool.take();
    m.setAttachmentMarshaller(am);
    marshal(m,object,contentHandler);
    m.setAttachmentMarshaller(null);
    context.marshallerPool.recycle(m);
}