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.msgpack.*;
020import org.apache.juneau.oapi.*;
021import org.apache.juneau.plaintext.*;
022import org.apache.juneau.rest.*;
023import org.apache.juneau.rest.annotation.*;
024import org.apache.juneau.serializer.annotation.*;
025import org.apache.juneau.soap.*;
026import org.apache.juneau.uon.*;
027import org.apache.juneau.urlencoding.*;
028import org.apache.juneau.xml.*;
029
030/**
031 * Basic configuration for a REST resource that supports all languages.
032 *
033 * <p>
034 * Classes that don't extend from {@link BasicRestServlet} can implement this interface to
035 * be configured with the same serializers/parsers/etc... as {@link BasicRestServlet}.
036 */
037@Rest(
038
039   // Default serializers for all Java methods in the class.
040   serializers={
041      HtmlDocSerializer.class, // HTML must be listed first because Internet Explore does not include text/html in their Accept header.
042      HtmlStrippedDocSerializer.class,
043      HtmlSchemaDocSerializer.class,
044      JsonSerializer.class,
045      SimpleJsonSerializer.class,
046      JsonSchemaSerializer.class,
047      XmlDocSerializer.class,
048      UonSerializer.class,
049      UrlEncodingSerializer.class,
050      OpenApiSerializer.class,
051      MsgPackSerializer.class,
052      SoapXmlSerializer.class,
053      PlainTextSerializer.class
054   },
055
056   // Default parsers for all Java methods in the class.
057   parsers={
058      JsonParser.class,
059      SimpleJsonParser.class,
060      XmlParser.class,
061      HtmlParser.class,
062      UonParser.class,
063      UrlEncodingParser.class,
064      OpenApiParser.class,
065      MsgPackParser.class,
066      PlainTextParser.class
067   },
068
069   // Optional external configuration file.
070   config="$S{juneau.configFile,SYSTEM_DEFAULT}",
071
072   // These are static files that are served up by the servlet under the specified sub-paths.
073   // For example, "/servletPath/htdocs/javadoc.css" resolves to the file "[servlet-package]/htdocs/javadoc.css"
074   // By default, we define static files through the external configuration file.
075   staticFiles="$C{REST/staticFiles,htdocs:/htdocs,htdocs:htdocs}",
076
077   logging=@Logging(
078      level="INFO",
079      useStackTraceHashing="true",
080      rules={
081         @LoggingRule(codes="500-", level="WARNING")
082      }
083   )
084)
085@SerializerConfig(
086   // Enable automatic resolution of URI objects to root-relative values.
087   uriResolution="ROOT_RELATIVE"
088)
089@HtmlDocConfig(
090
091   // Default page header contents.
092   header={
093      "<h1>$R{resourceTitle}</h1>",  // Use @Rest(title)
094      "<h2>$R{methodSummary,resourceDescription}</h2>", // Use either @RestMethod(summary) or @Rest(description)
095      "$C{REST/header}"  // Extra header HTML defined in external config file.
096   },
097
098   // Basic page navigation links.
099   navlinks={
100      "up: request:/.."
101   },
102
103   // Default stylesheet to use for the page.
104   // Can be overridden from external config file.
105   // Default is DevOps look-and-feel (aka Depression look-and-feel).
106   stylesheet="$C{REST/theme,servlet:/htdocs/themes/devops.css}",
107
108   // Default contents to add to the <head> section of the HTML page.
109   // Use it to add a favicon link to the page.
110   head="$C{REST/head}",
111
112   // No default page footer contents.
113   // Can be overridden from external config file.
114   footer="$C{REST/footer}",
115
116   // By default, table cell contents should not wrap.
117   nowrap="true"
118)
119@BeanConfig(
120   // When parsing generated beans, ignore unknown properties that may only exist as getters and not setters.
121   ignoreUnknownBeanProperties="true"
122)
123public interface BasicUniversalRest {}