org.gcube.smartgears.extensions
Class ApiResource

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.gcube.smartgears.extensions.HttpExtension
              extended by org.gcube.smartgears.extensions.ApiResource
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, ApplicationExtension
Direct Known Subclasses:
ConfigurationResource, FrontPageResource, LifecycleResource, ProfileResource, ScopesResource

public abstract class ApiResource
extends HttpExtension

A resource-specifc API handled by an HttpController.

Author:
Fabio Simeoni
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.gcube.smartgears.extensions.HttpExtension
HttpExtension.Method
 
Constructor Summary
ApiResource(ApiSignature signature)
          Creates an instance with a given signature.
 
Method Summary
 boolean accepts(HttpExtension.Method method, String type)
          Returns true if this resource accepts a given media type for a given method.
 void doDelete(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
           
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
           
 void doHead(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
           
 void doOptions(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
           
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
           
 void doPut(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
           
 void doTrace(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
           
static ApiSignature handles(String mapping)
          Returns a ApiSignature that declares the method and media types handled by an ApiResource for a given mapping.
static ApiMethodSignature method(HttpExtension.Method method)
          Returns an ApiMethodSignature that declares the media types handled by an ApiResource for a given method.
 boolean produces(HttpExtension.Method method, String type)
          Returns true if this resource produces a given media type for a given method.
 ApiSignature signature()
          Return the signature of this resource.
 boolean supports(HttpExtension.Method method)
          Returns true if this resource supports a given method.
 
Methods inherited from class org.gcube.smartgears.extensions.HttpExtension
context, excludes, init, init, mapping, mapping, name, name
 
Methods inherited from class javax.servlet.http.HttpServlet
getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.Servlet
destroy, getServletConfig, getServletInfo, init, service
 

Constructor Detail

ApiResource

public ApiResource(ApiSignature signature)
Creates an instance with a given signature.

Parameters:
signature - the signature
Method Detail

handles

public static ApiSignature handles(String mapping)
Returns a ApiSignature that declares the method and media types handled by an ApiResource for a given mapping.

Parameters:
mapping - the mapping
Returns:
the signature

method

public static ApiMethodSignature method(HttpExtension.Method method)
Returns an ApiMethodSignature that declares the media types handled by an ApiResource for a given method.

Parameters:
method - the method
Returns:
the signature

supports

public boolean supports(HttpExtension.Method method)
Returns true if this resource supports a given method.

Parameters:
method - the method
Returns:
true if this resource supports the given method

accepts

public boolean accepts(HttpExtension.Method method,
                       String type)
Returns true if this resource accepts a given media type for a given method.

Parameters:
method - the method
type - the media type
Returns:
true if this resource accepts the given media type for the given method

produces

public boolean produces(HttpExtension.Method method,
                        String type)
Returns true if this resource produces a given media type for a given method.

Parameters:
method - the method
type - the media type
Returns:
true if this resource produces the given media type for the given method

signature

public ApiSignature signature()
Return the signature of this resource.

Returns:
the signature

doHead

public void doHead(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse resp)
            throws javax.servlet.ServletException,
                   IOException
Overrides:
doHead in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
IOException

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse resp)
           throws javax.servlet.ServletException,
                  IOException
Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse resp)
            throws javax.servlet.ServletException,
                   IOException
Overrides:
doPost in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
IOException

doPut

public void doPut(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse resp)
           throws javax.servlet.ServletException,
                  IOException
Overrides:
doPut in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
IOException

doDelete

public void doDelete(javax.servlet.http.HttpServletRequest req,
                     javax.servlet.http.HttpServletResponse resp)
              throws javax.servlet.ServletException,
                     IOException
Overrides:
doDelete in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
IOException

doOptions

public void doOptions(javax.servlet.http.HttpServletRequest req,
                      javax.servlet.http.HttpServletResponse resp)
               throws javax.servlet.ServletException,
                      IOException
Overrides:
doOptions in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
IOException

doTrace

public void doTrace(javax.servlet.http.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse resp)
             throws javax.servlet.ServletException,
                    IOException
Overrides:
doTrace in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
IOException


Copyright © 2013. All Rights Reserved.