{8.1.0-new, 8.1.3-updated} Configurable Annotations

All configurable properties described in the previous section have annotation equivalents that can be applied on classes or methods.

In the section on the REST server API, we describe how to configure serializers and parsers using @Property annotations such as shown below:

// Configuring serializers/parsers using @Property annotations. @Rest( path="/atom", title="Sample ATOM feed resource", properties={ @Property(name=WSERIALIZER_quoteChar, value="'"), @Property(name=RDF_rdfxml_tab, value="5"), @Property(name=RDF_addRootProperty, value="true"), @Property(name=BEAN_examples, value="{'org.apache.juneau.dto.atom.Feed': $F{AtomFeedResource_example.json}}") } ... ) public class AtomFeedResource extends BasicRestServletJena { ... }

However, an even easier way to configure serializers and parsers are to used provided specialized @XConfig annotations like those shown below:

// Same as above but using specialized annotations. @Rest( path="/atom", title="Sample ATOM feed resource" ... ) @SerializerConfig(quoteChar="'") @RdfConfig(rdfxml_tab="5", addRootProperty="true") @BeanConfig(examples="Feed: $F{AtomFeedResource_example.json}") public class AtomFeedResource extends BasicRestServletJena { ... }

Config annotations are provided for all serializers and parsers:

Config annotations defined on classes and methods can be applied to serializers and parsers using the following methods:

The following example shows how annotations defined on a dummy class can be applied to a serializer:

@SerializerConfig(quoteChar="'") @BeanConfig(bpi="AddressBean: street,city,state") public static class DummyClass {} WriterSerializer ws = JsonSerializer.create().applyAnnotations(DummyClass.class).build(); String json = ws.toString(addressBean);