Package com.storedobject.core
Interface ParameterService
- All Known Implementing Classes:
GMailRegistrationService
public interface ParameterService
Parameter-driven web service interface. However, such a service can use just JSON too.
- Author:
- Syam
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault String
Mime type of the content.Gets the mandatory set of parameters to be present when calling this service.getName()
Name of the service.default boolean
requiresPOST
(ApplicationServer applicationServer) This checks whether this service requires POST method or not (means no GET method is allowed).default String
Implement the service here.default String
Same like the other "serve" method except that additional JSON parameter received is also passed here.void
Set the "Transaction Manager".default void
writeResponse
(jakarta.servlet.http.HttpServletRequest request, Map<String, String[]> parameters, PrintWriter response) This will be invoked if the getContentType method returns a non-null value and the request does not contain JSON.default void
writeResponse
(Map<String, String[]> parameters, JSON jsonReceived, PrintWriter response) This will be invoked if the getContentType method returns a non-null value and the request contains JSON.
-
Field Details
-
UNAUTHORIZED
- See Also:
-
OK
- See Also:
-
-
Method Details
-
getName
-
setTransactionManager
Set the "Transaction Manager". This method will be invoked by the platform with the currently active Transaction Manager.- Parameters:
tm
- Transaction Manager.
-
getMandatoryParameters
StringList getMandatoryParameters()Gets the mandatory set of parameters to be present when calling this service. If any one of these parameters is not present, this service will not be invoked.- Returns:
- List of mandatory parameters.
-
requiresPOST
This checks whether this service requires POST method or not (means no GET method is allowed). Default is "true" if the current Application Server is not in "developer" mode.- Parameters:
applicationServer
- Current application server.- Returns:
- True if the service requires POST method.
-
serve
Implement the service here. If the service requires JSON body received for processing, implement the other "serve" method that passes JSON as an additional parameter. (The default implementation does nothing).- Parameters:
parameters
- Map of the parameters received.- Returns:
- Status of the service such as "Ok", "Created" etc. This will be sent as JSON response. Example: { "Status": "Ok" }. If plain text needs to be sent as response, the status should be prefixed with "Plain:". Example: "Plain:Error while creating login".
- Throws:
Exception
- Any
-
serve
Same like the other "serve" method except that additional JSON parameter received is also passed here. (The default implementation simply invokes the other "serve" method, ignoring the JSON parameter).- Parameters:
parameters
- Map of the parameters received.jsonReceived
- JSON parameter received. This could be null.- Returns:
- Status like the other "serve" method.
- Throws:
Exception
- Any
-
getContentType
Mime type of the content. If this method returns non-null value, writeResponse method should be implemented and none of the "serve" methods will be invoked.- Returns:
- Mime type of the content. Default implementation returns "null".
-
writeResponse
default void writeResponse(Map<String, String[]> parameters, JSON jsonReceived, PrintWriter response) This will be invoked if the getContentType method returns a non-null value and the request contains JSON. In this case, none of the "serve" methods will be invoked.- Parameters:
parameters
- Map of the parameters received.jsonReceived
- JSON parameter received.response
- Response needs to be written into this and format of that should match the mime type.
-
writeResponse
default void writeResponse(jakarta.servlet.http.HttpServletRequest request, Map<String, String[]> parameters, PrintWriter response) This will be invoked if the getContentType method returns a non-null value and the request does not contain JSON. In this case, none of the "serve" methods will be invoked.- Parameters:
request
- Request received.parameters
- Map of the parameters received.response
- Response needs to be written into this and format of that should match the mime type.
-