users@jersey.java.net

[Jersey] Re: Jersey 2.0 How to provide custom serialization/de-serialization via moxy

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Wed, 16 Oct 2013 11:22:43 +0200

Have you tried MOXy's external binding?
http://blog.bdoughan.com/2012/07/jaxb-no-annotations-required.html

Marek

On Oct 14, 2013, at 6:19 PM, Piers Powlesland <piers_at_aptusinteractive.com> wrote:

> Hi I'm trying to send from server to client a simple object holding a list of java.nio.file.Path objects.
>
> Using the following moxy configuration results in an empty list being serialized out.
>
>
> ...
>
> register(createMoxyJsonResolver());
> ...
> public static ContextResolver<MoxyJsonConfig> createMoxyJsonResolver() {
> final MoxyJsonConfig moxyJsonConfig = new MoxyJsonConfig();
> Map<String, String> namespacePrefixMapper = new HashMap<String, String>(1);
> namespacePrefixMapper.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");
> moxyJsonConfig.setNamespacePrefixMapper(namespacePrefixMapper).setNamespaceSeparator(':');
> return moxyJsonConfig.resolver();
> }
>
> ...
>
> I guess that i need to tell moxy how to serialize and deserialize Path objects but looking at the examples I can't see any way to do this since I cannot add annotations to Path. So does anyone know how to provide a custom serializer/de-serializer for an object that cannot be annotated?
>
> Thanks
>
> Piers