Class ApiResource

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

public abstract class ApiResource extends HttpExtension
A resource-specifc API handled by an HttpController.
Author:
Fabio Simeoni
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.gcube.smartgears.extensions.HttpExtension

    HttpExtension.Method
  • Field Summary

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance with a given signature.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if this resource accepts a given media type for a given method.
    void
    doDelete(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
     
    void
    doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
     
    void
    doHead(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
     
    void
    doOptions(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
     
    void
    doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
     
    void
    doPut(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
     
    void
    doTrace(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
     
    Returns the set of request paths that should be excluded from request management.
    handles(String mapping)
    Returns a ApiSignature that declares the method and media types handled by an ApiResource for a given mapping.
    Returns an ApiMethodSignature that declares the media types handled by an ApiResource for a given method.
    boolean
    Returns true if this resource produces a given media type for a given method.
    Return the signature of this resource.
    boolean
    Returns true if this resource supports a given method.

    Methods inherited from class org.gcube.smartgears.extensions.HttpExtension

    context, init, init, mapping, mapping, name, name, stop

    Methods inherited from class jakarta.servlet.http.HttpServlet

    getLastModified, init, service, service

    Methods inherited from class jakarta.servlet.GenericServlet

    destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface jakarta.servlet.Servlet

    destroy, getServletConfig, getServletInfo, init, service
  • Constructor Details

    • ApiResource

      public ApiResource(ApiSignature signature)
      Creates an instance with a given signature.
      Parameters:
      signature - the signature
  • Method Details

    • 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
    • excludes

      public Set<GCubeExclude> excludes()
      Description copied from interface: ApplicationExtension
      Returns the set of request paths that should be excluded from request management.
      Specified by:
      excludes in interface ApplicationExtension
      Overrides:
      excludes in class HttpExtension
      Returns:
      the set of request paths that should be excluded from request management
    • 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(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException
      Overrides:
      doHead in class jakarta.servlet.http.HttpServlet
      Throws:
      jakarta.servlet.ServletException
      IOException
    • doGet

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

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

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

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

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

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