blob: b2e9a9b235ffbbf4875a77216d09933dbc95df8c [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.
***************************************************************************************************************************/
-->
RestServlet
<p>
The {@link oajr.RestServlet} class is the entry point for your REST resources.
It extends directly from <l>HttpServlet</l> and is deployed like any other servlet.
</p>
<p>
When the servlet <l>init()</l> method is called, it triggers the code to find and process the <l>@RestResource</l>
annotations on that class and all child classes.
These get constructed into a {@link oajr.RestContext} object that holds all the configuration
information about your resource in a read-only object.
</p>
<p>
Most developers are not going to be using the <l>RestServlet</l> class itself, and instead will
extend from one of the preconfigured default servlets such as {@link oajr.BasicRestServlet}.
The <l>RestServlet</l> class by itself is not configured with any serializers and parsers, and therefore
not very useful on it's own.
However, the class does provide a couple of convenience methods to be aware of:
</p>
<ul class='javatree'>
<li class='jac'><c>{@link oajr.RestServlet} <jk>extends</jk> HttpServlet</c>
<ul>
<li class='jm'>{@link oajr.RestServlet#init(ServletConfig) init(ServletConfig)} - Can override to provide custom initialization.
<li class='jm'>{@link oajr.RestServlet#service(HttpServletRequest,HttpServletResponse) service(HttpServletRequest,HttpServletResponse)} - Can override to provide custom request handling.
<li class='jm'>{@link oajr.RestServlet#destroy() destroy()} - Can override to provide custom cleanup.
<li class='jm'>{@link oajr.RestServlet#getContext() getContext()} - Returns all aspects of the configuration of your resource pulled from all annotations on the class/parent-classes and methods.
<li class='jm'>{@link oajr.RestServlet#log(Level,String,Object...) log(Level,String,Object...)} - Convenience logging method.
<li class='jm'>{@link oajr.RestServlet#log(Level,Throwable,String,Object...) log(Level,Throwable,String,Object...)} - Convenience logging method.
</ul>
</ul>