Package org.gcube.smartgears.extensions
Class ApiResource
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.gcube.smartgears.extensions.HttpExtension
-
- org.gcube.smartgears.extensions.ApiResource
-
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig,ApplicationExtension
- Direct Known Subclasses:
ConfigurationResource,FrontPageResource,LifecycleResource,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(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)voiddoHead(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)voiddoOptions(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)voiddoPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)voiddoPut(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)voiddoTrace(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)Set<Exclude>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
-
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, 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<Exclude> 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(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException- Overrides:
doHeadin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
doGet
public void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException- Overrides:
doGetin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
doPost
public void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException- Overrides:
doPostin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
doPut
public void doPut(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException- Overrides:
doPutin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
doDelete
public void doDelete(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException- Overrides:
doDeletein classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
doOptions
public void doOptions(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException- Overrides:
doOptionsin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
doTrace
public void doTrace(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException- Overrides:
doTracein classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
-