New annotations that can be applied to REST classes and methods to configure serializers and parsers.
// Old way using generic properties.
@RestResource(
path="/atom",
title="Sample ATOM feed resource",
properties={
@Property(name=WSERIALIZER_quoteChar, value="'"),
@Property(name=RDF_rdfxml_tab, value="5"),
@Property(nameRDF_addRootProperty, value="true"),
@Property(name=BEAN_examples, value="{'org.apache.juneau.dto.atom.Feed': $F{AtomFeedResource_example.json}}")
}
...
)
public class AtomFeedResource extends BasicRestServletJena {
...
}
// New way using specific annotations.
@RestResource(
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:
- {@link oaj.annotation.BeanConfig BeanConfig}
- {@link oaj.csv.annotation.CsvConfig CsvConfig}
- {@link oaj.html.annotation.HtmlConfig HtmlConfig}
- {@link oaj.html.annotation.HtmlDocConfig HtmlDocConfig}
JsoConfig JsoConfig
- {@link oaj.json.annotation.JsonConfig JsonConfig}
- {@link oaj.jsonschema.annotation.JsonSchemaConfig JsonSchemaConfig}
- {@link oaj.msgpack.annotation.MsgPackConfig MsgPackConfig}
- {@link oaj.oapi.annotation.OpenApiConfig OpenApiConfig}
- {@link oaj.parser.annotation.ParserConfig ParserConfig}
- {@link oaj.plaintext.annotation.PlainTextConfig PlainTextConfig}
RdfConfig
- {@link oaj.serializer.annotation.SerializerConfig SerializerConfig}
- {@link oaj.soap.annotation.SoapXmlConfig SoapXmlConfig}
- {@link oaj.uon.annotation.UonConfig UonConfig}
- {@link oaj.urlencoding.annotation.UrlEncodingConfig UrlEncodingConfig}
- {@link oaj.xml.annotation.XmlConfig XmlConfig}
Support for fine-tuned logging of HTTP requests and responses.
@RestResource(
debug="per-request",
logging=@Logging(
level="info",
rules={
@LoggingRule(codes"400-499", level="warning", req="short", res="short")
@LoggingRule(codes"500-", level="severe", req="long", res="long")
}
)
)
public class MyRest {
@RestMethod(
method="POST",
path="foo"
logging=@Logging(
level="info",
rules={
@LoggingRule(exceptions"NotFound*", level="info")
@LoggingRule(codes"200", disabled="true")
}
)
)
public String myMethod() throws Exception {...}
See RestLoggingAndDebuggingfor details.