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;
014
015import static org.apache.juneau.serializer.Serializer.*;
016
017import org.apache.juneau.html.*;
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.annotation.*;
023import org.apache.juneau.soap.*;
024import org.apache.juneau.uon.*;
025import org.apache.juneau.urlencoding.*;
026import org.apache.juneau.xml.*;
027import org.apache.juneau.xmlschema.XmlSchemaDocSerializer;
028
029/**
030 * Basic configuration for a REST resource.
031 *
032 * <p>
033 * Classes that don't extend from {@link BasicRestServlet} can implement this interface to
034 * be configured with the same serializers/parsers/etc... as {@link BasicRestServlet}.
035 */
036@RestResource(
037
038   // Default serializers for all Java methods in the class.
039   serializers={
040      HtmlDocSerializer.class, // HTML must be listed first because Internet Explore does not include text/html in their Accept header.
041      HtmlStrippedDocSerializer.class,
042      HtmlSchemaDocSerializer.class,
043      JsonSerializer.class,
044      SimpleJsonSerializer.class,
045      JsonSchemaSerializer.class,
046      XmlDocSerializer.class,
047      XmlSchemaDocSerializer.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      JsonParser.Simple.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   // Properties to apply to all serializers/parsers and REST-specific API objects.
070   properties={
071      // Enable automatic resolution of URI objects to root-relative values.
072      @Property(name=SERIALIZER_uriResolution, value="ROOT_RELATIVE")
073   },
074
075   // HTML-page specific settings
076   htmldoc=@HtmlDoc(
077
078      // Default page header contents.
079      header={
080         "<h1>$R{resourceTitle}</h1>",  // Use @RestResource(title)
081         "<h2>$R{methodSummary,resourceDescription}</h2>", // Use either @RestMethod(summary) or @RestResource(description)
082         "$C{REST/header}"  // Extra header HTML defined in external config file.
083      },
084
085      // Basic page navigation links.
086      navlinks={
087         "up: request:/.."
088      },
089
090      // Default stylesheet to use for the page.
091      // Can be overridden from external config file.
092      // Default is DevOps look-and-feel (aka Depression look-and-feel).
093      stylesheet="$C{REST/theme,servlet:/htdocs/themes/devops.css}",
094
095      // Default contents to add to the <head> section of the HTML page.
096      // Use it to add a favicon link to the page.
097      head={
098         "<link rel='icon' href='$U{$C{REST/favicon}}'/>"
099      },
100
101      // No default page footer contents.
102      // Can be overridden from external config file.
103      footer="$C{REST/footer}",
104
105      // By default, table cell contents should not wrap.
106      nowrap="true"
107   ),
108
109   // Optional external configuration file.
110   config="$S{juneau.configFile}",
111
112   // These are static files that are served up by the servlet under the specified sub-paths.
113   // For example, "/servletPath/htdocs/javadoc.css" resolves to the file "[servlet-package]/htdocs/javadoc.css"
114   // By default, we define static files through the external configuration file.
115   staticFiles="$C{REST/staticFiles}"
116)
117public interface BasicRestConfig {}