Hello,
I am using Rest easy 2.0 Version. and trying to use the JAXB Decorator during Marshalling
I followed the documentation as per 19.1 of REST easy Reference Guide but this does not work.
I have done the below steps
Please let me know if i am doing some thing wrong.
1. Declared a annotation Named Format
/*
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Decorator(processor = FormatProcessor.class, target = Marshaller.class) public @interface Format {
}
*/
2. A Concrete class implemented the above Declared interface
/* @DecorateTypes({"text/*+xml", "application/*+xml"}) public class FormatProcessor implements DecoratorProcessor<Marshaller, Format> { public Marshaller decorate(Marshaller target, Format annotation, Class type, Annotation annotations, MediaType mediaType) { try { target.setProperty(Marshaller.JAXB_ENCODING,"UTF-16"); return target; } catch (Exception ex) { throw new RuntimeException(ex); } } }
3. Modified my Resource class to use the above declared annoation
/* @POST @Format @Consumes("application/xml") @Produces("application/xml") public Customer createCustomer(Customer customer) {
I am deploying this to Oc4j Server. Server Starts up normally ..but the framework does not recognize the annoation when it invokes the Resource.
Please let me know a way. to solve this.
Sure this is not a Bug ,As the @Formatted annoation works really good.
Thanks Premkumar
Log in to post a comment.
Hello,
I am using Rest easy 2.0 Version. and trying to use the JAXB Decorator during Marshalling
I followed the documentation as per 19.1 of REST easy Reference Guide but this does not work.
I have done the below steps
Please let me know if i am doing some thing wrong.
1. Declared a annotation Named Format
/*
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Decorator(processor = FormatProcessor.class, target = Marshaller.class)
public @interface Format
{
}
*/
2. A Concrete class implemented the above Declared interface
/* @DecorateTypes({"text/*+xml", "application/*+xml"})
public class FormatProcessor implements DecoratorProcessor<Marshaller, Format>
{
public Marshaller decorate(Marshaller target, Format annotation,
Class type, Annotation annotations, MediaType mediaType)
{
try
{
target.setProperty(Marshaller.JAXB_ENCODING,"UTF-16");
return target;
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
}
}
*/
3. Modified my Resource class to use the above declared annoation
/* @POST
@Format
@Consumes("application/xml")
@Produces("application/xml")
public Customer createCustomer(Customer customer) {
}
*/
I am deploying this to Oc4j Server. Server Starts up normally ..but the framework does not recognize the annoation when it invokes the Resource.
Please let me know a way. to solve this.
Sure this is not a Bug ,As the @Formatted annoation works really good.
Thanks
Premkumar