Package org.gcube.smartgears.extensions
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 anHttpController.- 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
Constructors Constructor Description ApiResource(ApiSignature signature)Creates an instance with a given signature.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccepts(HttpExtension.Method method, String type)Returnstrueif this resource accepts a given media type for a given method.voiddoDelete(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)voiddoGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)voiddoHead(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)voiddoOptions(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)voiddoPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)voiddoPut(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)voiddoTrace(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)Set<GCubeExclude>excludes()Returns the set of request paths that should be excluded from request management.static ApiSignaturehandles(String mapping)Returns aApiSignaturethat declares the method and media types handled by anApiResourcefor a given mapping.static ApiMethodSignaturemethod(HttpExtension.Method method)Returns anApiMethodSignaturethat declares the media types handled by anApiResourcefor a given method.booleanproduces(HttpExtension.Method method, String type)Returnstrueif this resource produces a given media type for a given method.ApiSignaturesignature()Return the signature of this resource.booleansupports(HttpExtension.Method method)Returnstrueif 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
-
-
-
-
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 aApiSignaturethat declares the method and media types handled by anApiResourcefor a given mapping.- Parameters:
mapping- the mapping- Returns:
- the signature
-
method
public static ApiMethodSignature method(HttpExtension.Method method)
Returns anApiMethodSignaturethat declares the media types handled by anApiResourcefor a given method.- Parameters:
method- the method- Returns:
- the signature
-
excludes
public Set<GCubeExclude> excludes()
Description copied from interface:ApplicationExtensionReturns the set of request paths that should be excluded from request management.- Specified by:
excludesin interfaceApplicationExtension- Overrides:
excludesin classHttpExtension- Returns:
- the set of request paths that should be excluded from request management
-
supports
public boolean supports(HttpExtension.Method method)
Returnstrueif this resource supports a given method.- Parameters:
method- the method- Returns:
trueif this resource supports the given method
-
accepts
public boolean accepts(HttpExtension.Method method, String type)
Returnstrueif this resource accepts a given media type for a given method.- Parameters:
method- the methodtype- the media type- Returns:
trueif this resource accepts the given media type for the given method
-
produces
public boolean produces(HttpExtension.Method method, String type)
Returnstrueif this resource produces a given media type for a given method.- Parameters:
method- the methodtype- the media type- Returns:
trueif 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:
doHeadin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
doGet
public void doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException- Overrides:
doGetin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
doPost
public void doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException- Overrides:
doPostin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
doPut
public void doPut(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException- Overrides:
doPutin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
doDelete
public void doDelete(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException- Overrides:
doDeletein classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
doOptions
public void doOptions(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException- Overrides:
doOptionsin classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
doTrace
public void doTrace(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException- Overrides:
doTracein classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
-