blob: 885796fda76ce2d7433c9e533c8f7bf8a3bd95aa [file] [log] [blame]
<!--
/***************************************************************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
***************************************************************************************************************************/
-->
{new} Configurable Annotations
<p>
Config annotations allow you to define serializer and parser properties using specialized annotations.
All configuration properties have annotation-equivalents.
</p>
<p>
The following shows the difference between the two approaches:
</p>
<h5 class='figure'>Example:</h5>
<p class='bpcode w800'>
<jc>// Servlet with properties applied</jc>
<ja>@RestResource</ja>(
properties={
<ja>@Property</ja>(name=<jsf>BEAN_sortProperties</jsf>, value=<js>"true"</js>),
<ja>@Property</ja>(name=<jsf>SERIALIZER_trimNulls</jsf>, value=<js>"true"</js>),
<ja>@Property</ja>(name=<jsf>JSON_escapeSolidus</jsf>, value=<js>"true"</js>)
}
)
<jk>public</jk> MyRestServlet <jk>extends</jk> BasicRestServlet {...}
</p>
<p class='bpcode w800'>
<jc>// Servlet with config annotations applied</jc>
<ja>@RestResource</ja>(
...
)
<ja>@BeanConfig</ja>(sortProperties=<js>"true"</js>)
<ja>@SerializerConfig</ja>(trimNulls=<js>"true"</js>)
<ja>@JsonConfig</ja>(escapeSolidus=<js>"true"</js>)
<jk>public</jk> MyRestServlet <jk>extends</jk> BasicRestServlet {...}
</p>
<p>
Using config annotations is often cleaner and supports the same SVL variable support as those in the REST annotations.
</p>
<p>
Config annotations are defined for all serializers and parsers:
</p>
<ul>
<li class='ja'>{@link oaj.annotation.BeanConfig BeanConfig}
<li class='ja'>{@link oaj.csv.annotation.CsvConfig CsvConfig}
<li class='ja'>{@link oaj.html.annotation.HtmlConfig HtmlConfig}
<li class='ja'>{@link oaj.html.annotation.HtmlDocConfig HtmlDocConfig}
<li class='ja'>{@link oaj.jso.annotation.JsoConfig JsoConfig}
<li class='ja'>{@link oaj.json.annotation.JsonConfig JsonConfig}
<li class='ja'>{@link oaj.jsonschema.annotation.JsonSchemaConfig JsonSchemaConfig}
<li class='ja'>{@link oaj.msgpack.annotation.MsgPackConfig MsgPackConfig}
<li class='ja'>{@link oaj.oapi.annotation.OpenApiConfig OpenApiConfig}
<li class='ja'>{@link oaj.parser.annotation.ParserConfig ParserConfig}
<li class='ja'>{@link oaj.plaintext.annotation.PlainTextConfig PlainTextConfig}
<li class='ja'>{@link oaj.jena.annotation.RdfConfig RdfConfig}
<li class='ja'>{@link oaj.serializer.annotation.SerializerConfig SerializerConfig}
<li class='ja'>{@link oaj.soap.annotation.SoapXmlConfig SoapXmlConfig}
<li class='ja'>{@link oaj.uon.annotation.UonConfig UonConfig}
<li class='ja'>{@link oaj.urlencoding.annotation.UrlEncodingConfig UrlEncodingConfig}
<li class='ja'>{@link oaj.xml.annotation.XmlConfig XmlConfig}
</ul>
<p>
Config annotations can be defined at both the class and method level just like properties.
</p>