diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-05-08 11:17:34 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-05-08 11:17:34 +0200 |
commit | 384e3b576fa4c4f349c5fcde7ffaea16e53c1c97 (patch) | |
tree | cfd8962503acde0d155233cd61c11ddae386abec /src/main/java/at/gv/egiz/moazs/Marshaller.java | |
parent | 1aaec2e6127b9b2261a97749daa15c23f0af7be1 (diff) | |
download | moa-zs-384e3b576fa4c4f349c5fcde7ffaea16e53c1c97.tar.gz moa-zs-384e3b576fa4c4f349c5fcde7ffaea16e53c1c97.tar.bz2 moa-zs-384e3b576fa4c4f349c5fcde7ffaea16e53c1c97.zip |
Fix Namespace Prefixes in Marshaled Messages (msg: instead of ns#:)
- Implement own NamespacePrefixMapper that maps prefixes depending on
whether a msg or a mzs object is being marshaled.
- Namespaces are not hardcoded but extracted from jaxb's generated
sources (somewhat indirect, can be considered a hack, but there's no
public API to extract namespaces)
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/Marshaller.java')
-rw-r--r-- | src/main/java/at/gv/egiz/moazs/Marshaller.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/Marshaller.java b/src/main/java/at/gv/egiz/moazs/Marshaller.java index c126f03..7e2ab17 100644 --- a/src/main/java/at/gv/egiz/moazs/Marshaller.java +++ b/src/main/java/at/gv/egiz/moazs/Marshaller.java @@ -1,8 +1,6 @@ package at.gv.egiz.moazs; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.oxm.jaxb.Jaxb2Marshaller; -import org.springframework.stereotype.Component; import javax.xml.transform.Result; import javax.xml.transform.stream.StreamResult; @@ -14,11 +12,13 @@ import java.io.StringWriter; * @author xerx593 * Source: https://stackoverflow.com/questions/44676532/how-to-use-spring-to-marshal-and-unmarshal-xml */ -@Component public class Marshaller { - @Autowired - private Jaxb2Marshaller marshaller; + private final Jaxb2Marshaller marshaller; + + public Marshaller(Jaxb2Marshaller marshaller) { + this.marshaller = marshaller; + } public <T> String marshallXml(final T obj) { StringWriter sw = new StringWriter(); |