Class XmlCodec
- All Implemented Interfaces:
Codec
Here because most estates have something that speaks XML and will not be rewritten, and a messaging library that cannot talk to it forces a translation layer nobody wants to own. New services should publish JSON; this exists so that the ones that cannot are not a special case.
Also the second implementation of CodecProvider, which is the
point. One implementation never proves a seam: it proves that a class compiles against an
interface written around it. Two, in separate modules, discovered the same way, is what shows
that a third can be added by somebody who does not work on this library.
External entities are disabled. An XML parser that resolves them will read files off the machine and open connections on behalf of whoever sent the message, and a queue is exactly the sort of place a message from somewhere unexpected arrives. This is not configurable, because the configuration would only ever be wrong.
-
Constructor Details
-
XmlCodec
public XmlCodec()Uses a mapper that ignores unknown elements and refuses external entities. -
XmlCodec
public XmlCodec(com.fasterxml.jackson.dataformat.xml.XmlMapper mapper) - Parameters:
mapper- the mapper to use; disable external entity resolution on its factory, or a message from anywhere can read files off the machine it is handled on
-
-
Method Details
-
defaultMapper
public static com.fasterxml.jackson.dataformat.xml.XmlMapper defaultMapper()- Returns:
- a mapper that tolerates unknown elements and cannot be talked into resolving external entities
-
contentType
- Specified by:
contentTypein interfaceCodec- Returns:
- the content type this codec produces, for example
application/json
-
encode
-
decode
-
canDecode
-
toString
-