001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.rest.config;
014
015import org.apache.juneau.annotation.*;
016import org.apache.juneau.csv.*;
017import org.apache.juneau.html.*;
018import org.apache.juneau.html.annotation.*;
019import org.apache.juneau.json.*;
020import org.apache.juneau.msgpack.*;
021import org.apache.juneau.oapi.*;
022import org.apache.juneau.plaintext.*;
023import org.apache.juneau.rest.annotation.*;
024import org.apache.juneau.rest.servlet.*;
025import org.apache.juneau.serializer.annotation.*;
026import org.apache.juneau.soap.*;
027import org.apache.juneau.uon.*;
028import org.apache.juneau.urlencoding.*;
029import org.apache.juneau.xml.*;
030
031/**
032 * Predefined configuration for a REST resource that supports all languages
033 * and provides common default configuration values.
034 *
035 * <p>
036 *    Default settings defined:
037 * </p>
038 * <ul class='spaced-list'>
039 *    <li class='ja'>{@link Rest}:
040 *       <ul>
041 *          <li class='jma'>{@link Rest#serializers() serializers}:
042 *             <ul class='javatree'>
043 *                <li class='jc'>{@link HtmlDocSerializer}
044 *                <li class='jc'>{@link HtmlStrippedDocSerializer}
045 *                <li class='jc'>{@link HtmlSchemaDocSerializer}
046 *                <li class='jc'>{@link JsonSerializer}
047 *                <li class='jc'>{@link Json5Serializer}
048 *                <li class='jc'>{@link JsonSchemaSerializer}
049 *                <li class='jc'>{@link XmlDocSerializer}
050 *                <li class='jc'>{@link UonSerializer}
051 *                <li class='jc'>{@link UrlEncodingSerializer}
052 *                <li class='jc'>{@link OpenApiSerializer}
053 *                <li class='jc'>{@link MsgPackSerializer}
054 *                <li class='jc'>{@link SoapXmlSerializer}
055 *                <li class='jc'>{@link PlainTextSerializer}
056 *             </ul>
057 *          </li>
058 *          <li class='jma'>{@link Rest#parsers() parsers}:
059 *             <ul class='javatree'>
060 *                <li class='jc'>{@link JsonParser}
061 *                <li class='jc'>{@link Json5Parser}
062 *                <li class='jc'>{@link XmlParser}
063 *                <li class='jc'>{@link HtmlParser}
064 *                <li class='jc'>{@link UonParser}
065 *                <li class='jc'>{@link UrlEncodingParser}
066 *                <li class='jc'>{@link OpenApiParser}
067 *                <li class='jc'>{@link MsgPackParser}
068 *                <li class='jc'>{@link PlainTextParser}
069 *             </ul>
070 *          </li>
071 *          <li class='jma'>{@link Rest#config() config}:  <js>"$S{juneau.configFile,SYSTEM_DEFAULT}"</js>
072 *    </ul>
073 * </li>
074 *    <li class='ja'>{@link BeanConfig}:
075 *       <ul>
076 *          <li class='jma'>{@link BeanConfig#ignoreUnknownBeanProperties() ignoreUnknownBeanProperties}:  <js>"true"</js>
077 *       </ul>
078 *    </li>
079 *    <li class='ja'>{@link SerializerConfig}:
080 *       <ul>
081 *          <li class='jma'>{@link SerializerConfig#uriResolution() uriResolution}:  <js>"ROOT_RELATIVE"</js>
082 *       </ul>
083 *    </li>
084 *    <li class='ja'>{@link HtmlDocConfig}:
085 *       <ul>
086 *          <li class='jma'>{@link HtmlDocConfig#header() header}:  <js>"&lt;h1&gt;$RS{title}&lt;/h1&gt;&lt;h2&gt;$RS{operationSummary,description}&lt;/h2&gt;$C{REST/header}"</js>
087 *          <li class='jma'>{@link HtmlDocConfig#navlinks() navlinks}:  <js>"up: request:/.."</js>
088 *          <li class='jma'>{@link HtmlDocConfig#stylesheet() stylesheet}:  <js>"$C{REST/theme,servlet:/htdocs/themes/devops.css}"</js>
089 *          <li class='jma'>{@link HtmlDocConfig#head() head}:  <js>"$C{REST/head}"</js>
090 *          <li class='jma'>{@link HtmlDocConfig#footer() footer}:  <js>"$C{REST/footer}"</js>
091 *          <li class='jma'>{@link HtmlDocConfig#nowrap() nowrap}:  <js>"true"</js>
092 *       </ul>
093 *    </li>
094 * </ul>
095 *
096 * <p>
097 *    This annotation can be applied to REST resource classes to define common default configurations:
098 * </p>
099 * <p class='bjava'>
100 *    <jc>// Used on a top-level resource.</jc>
101 *    <ja>@Rest</ja>
102 *    <jk>public class</jk> MyResource <jk>extends</jk> RestServlet <jk>implements</jk> BasicUniversalConfig { ... }
103 * </p>
104 * <p class='bjava'>
105 *    <jc>// Used on a child resource.</jc>
106 *    <ja>@Rest</ja>
107 *    <jk>public class</jk> MyResource <jk>extends</jk> RestObject <jk>implements</jk> BasicUniversalConfig { ... }
108 * </p>
109 *
110 * <p>
111 *    Note that the framework will aggregate annotations defined on all classes in the class hierarchy with
112 *    values defined on child classes overriding values defined on parent classes.  That allows any values defined
113 *    on this interface to be overridden by annotations defined on the implemented class.
114 * </p>
115 *
116 * <h5 class='section'>See Also:</h5><ul>
117 *    <ul class='javatreec'>
118 *       <li class='jc'>{@link BasicRestServlet}
119 *       <li class='jc'>{@link BasicRestServletGroup}
120 *       <li class='jc'>{@link BasicRestObject}
121 *       <li class='jc'>{@link BasicRestObjectGroup}
122 * </ul>
123 *    <li class='link'><a class="doclink" href="../../../../../index.html#jrs.AnnotatedClasses">@Rest-Annotated Classes</a>
124 * </ul>
125 */
126@Rest(
127
128   // Default serializers for all Java methods in the class.
129   serializers={
130      HtmlDocSerializer.class, // HTML must be listed first because Internet Explore does not include text/html in their Accept header.
131      HtmlStrippedDocSerializer.class,
132      HtmlSchemaDocSerializer.class,
133      JsonSerializer.class,
134      Json5Serializer.class,
135      JsonSchemaSerializer.class,
136      XmlDocSerializer.class,
137      UonSerializer.class,
138      UrlEncodingSerializer.class,
139      OpenApiSerializer.class,
140      MsgPackSerializer.class,
141      SoapXmlSerializer.class,
142      PlainTextSerializer.class,
143      CsvSerializer.class
144   },
145
146   // Default parsers for all Java methods in the class.
147   parsers={
148      JsonParser.class,
149      Json5Parser.class,
150      XmlParser.class,
151      HtmlParser.class,
152      UonParser.class,
153      UrlEncodingParser.class,
154      OpenApiParser.class,
155      MsgPackParser.class,
156      PlainTextParser.class,
157      CsvParser.class
158   }
159)
160public interface BasicUniversalConfig extends DefaultConfig, DefaultHtmlConfig {}