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.html.*; 017import org.apache.juneau.html.annotation.*; 018import org.apache.juneau.json.*; 019import org.apache.juneau.rest.annotation.*; 020import org.apache.juneau.serializer.annotation.*; 021 022/** 023 * Basic configuration for a REST resource that supports JSON and HTML transport. 024 * 025 * <p> 026 * Default settings defined: 027 * </p> 028 * <ul class='spaced-list'> 029 * <li class='ja'>{@link Rest}: 030 * <ul> 031 * <li class='jma'>{@link Rest#serializers() serializers}: 032 * <ul class='javatree'> 033 * <li class='jc'>{@link JsonSerializer} 034 * <li class='jc'>{@link Json5Serializer} 035 * <li class='jc'>{@link HtmlDocSerializer} 036 * </ul> 037 * </li> 038 * <li class='jma'>{@link Rest#parsers() parsers}: 039 * <ul class='javatree'> 040 * <li class='jc'>{@link JsonParser} 041 * <li class='jc'>{@link Json5Parser} 042 * <li class='jc'>{@link HtmlParser} 043 * </ul> 044 * </li> 045 * <li class='jma'>{@link Rest#defaultAccept() defaultAccept}: <js>"text/json"</js> 046 * <li class='jma'>{@link Rest#config() config}: <js>"$S{juneau.configFile,SYSTEM_DEFAULT}"</js> 047 * </ul> 048 * </li> 049 * <li class='ja'>{@link BeanConfig}: 050 * <ul> 051 * <li class='jma'>{@link BeanConfig#ignoreUnknownBeanProperties() ignoreUnknownBeanProperties}: <js>"true"</js> 052 * </ul> 053 * </li> 054 * <li class='ja'>{@link SerializerConfig}: 055 * <ul> 056 * <li class='jma'>{@link SerializerConfig#uriResolution() uriResolution}: <js>"ROOT_RELATIVE"</js> 057 * </ul> 058 * </li> 059 * <li class='ja'>{@link HtmlDocConfig}: 060 * <ul> 061 * <li class='jma'>{@link HtmlDocConfig#header() header}: <js>"<h1>$RS{title}</h><h2>$RS{operationSummary,description}</h2>$C{REST/header}"</js> 062 * <li class='jma'>{@link HtmlDocConfig#navlinks() navlinks}: <js>"up: request:/.."</js> 063 * <li class='jma'>{@link HtmlDocConfig#stylesheet() stylesheet}: <js>"$C{REST/theme,servlet:/htdocs/themes/devops.css}"</js> 064 * <li class='jma'>{@link HtmlDocConfig#head() head}: <js>"$C{REST/head}"</js> 065 * <li class='jma'>{@link HtmlDocConfig#footer() footer}: <js>"$C{REST/footer}"</js> 066 * <li class='jma'>{@link HtmlDocConfig#nowrap() nowrap}: <js>"true"</js> 067 * </ul> 068 * </li> 069 * </ul> 070 * 071 * <p> 072 * This annotation can be applied to REST resource classes to define common JSON default configurations: 073 * </p> 074 * <p class='bjava'> 075 * <jc>// Used on a top-level resource.</jc> 076 * <ja>@Rest</ja> 077 * <jk>public class</jk> MyResource <jk>extends</jk> RestServlet <jk>implements</jk> BasicJsonHtmlConfig { ... } 078 * </p> 079 * <p class='bjava'> 080 * <jc>// Used on a child resource.</jc> 081 * <ja>@Rest</ja> 082 * <jk>public class</jk> MyResource <jk>extends</jk> RestObject <jk>implements</jk> BasicJsonHtmlConfig { ... } 083 * </p> 084 * 085 * <p> 086 * Note that the framework will aggregate annotations defined on all classes in the class hierarchy with 087 * values defined on child classes overriding values defined on parent classes. That allows any values defined 088 * on this interface to be overridden by annotations defined on the implemented class. 089 * </p> 090 * 091 * <h5 class='section'>See Also:</h5><ul> 092 * <li class='link'><a class="doclink" href="../../../../../index.html#jrs.AnnotatedClasses">@Rest-Annotated Classes</a> 093 * </ul> 094 */ 095@Rest( 096 097 // Default serializers for all Java methods in the class. 098 serializers={ 099 HtmlDocSerializer.class, 100 JsonSerializer.class, 101 Json5Serializer.class 102 }, 103 104 // Default parsers for all Java methods in the class. 105 parsers={ 106 HtmlParser.class, 107 JsonParser.class, 108 Json5Parser.class 109 }, 110 111 defaultAccept="text/json" 112) 113public interface BasicJsonHtmlConfig extends DefaultConfig, DefaultHtmlConfig {}