| Modifier and Type | Class and Description |
|---|---|
static interface |
Engine.EngineListener
Receives
Engine and Api lifecycle,
per request and per error callback notifications. |
Rule.RuleMatcher| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<Api> |
apis
The
Apis being service by this Engine |
protected java.lang.String |
configPath
Optional override for the configPath sys/env prop used by Config to locate configuration property files
|
protected java.lang.String |
configProfile
Optional override for the sys/env prop used by Config to determine which profile specific configuration property files to load
|
protected java.lang.String |
corsAllowHeaders
Base value for the CORS "Access-Control-Allow-Headers" response header.
|
protected Response |
lastResponse
The last
Response served by this Engine, primarily used for writing test cases. |
protected java.util.List<Engine.EngineListener> |
listeners
Listeners that will receive Engine and Api lifecycle, request, and error callbacks.
|
configMap, configStr, excludeMatchers, excludeOn, includeMatchers, includeOn, log, name, order| Modifier and Type | Method and Description |
|---|---|
Response |
delete(java.lang.String url)
Convenience overloading of
#service(Request, Response) to run a REST DELETE Request on this Engine. |
Response |
delete(java.lang.String url,
JSArray hrefs)
Convenience overloading of
#service(Request, Response) to run a REST DELETE Request on this Engine. |
Response |
get(java.lang.String url)
Convenience overloading of
#service(Request, Response) to run a REST GET Request on this Engine. |
Response |
get(java.lang.String url,
java.util.List queryTerms)
Convenience overloading of
#service(Request, Response) to run a REST GET Request on this Engine. |
Response |
get(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> params)
Convenience overloading of
#service(Request, Response) to run a REST GET Request on this Engine. |
Api |
getApi(java.lang.String apiName) |
java.util.List<Api> |
getApis() |
java.lang.String |
getConfigPath() |
java.lang.String |
getConfigProfile() |
Response |
getLastResponse() |
java.net.URL |
getResource(java.lang.String name) |
boolean |
isStarted() |
Response |
patch(java.lang.String url,
JSNode body)
Convenience overloading of
#service(Request, Response) to run a REST PATCH Request on this Engine. |
Response |
post(java.lang.String url,
JSNode body)
Convenience overloading of
#service(Request, Response) to run a REST POST Request on this Engine. |
Response |
put(java.lang.String url,
JSNode body)
Convenience overloading of
#service(Request, Response) to run a REST PUT Request on this Engine. |
void |
removeApi(Api api)
Removes the api, notifies EngineListeners and calls api.shutdown().
|
Chain |
service(Request req,
Response res)
The main entry point for processing a Request and generating Response content.
|
Response |
service(java.lang.String method,
java.lang.String url)
Convenience overloading of
#service(Request, Response) |
Response |
service(java.lang.String method,
java.lang.String url,
java.lang.String body)
Convenience overloading of
#service(Request, Response) |
Response |
service(java.lang.String method,
java.lang.String url,
java.lang.String body,
java.util.Map<java.lang.String,java.lang.String> params)
Convenience overloading of
#service(Request, Response) |
void |
shutdown()
Removes all Apis and notifies listeners.onShutdown
|
protected void |
shutdownApi(Api api) |
Engine |
startup()
Runs the
Configurator and calls startupApi for each Api. |
protected void |
startup0()
Convenient pre-startup hook for subclasses guaranteed to only be called once.
|
protected void |
startupApi(Api api) |
Engine |
withAllowHeaders(java.lang.String allowHeaders) |
Engine |
withApi(Api api) |
Engine |
withConfigPath(java.lang.String configPath) |
Engine |
withConfigProfile(java.lang.String configProfile) |
Engine |
withEngineListener(Engine.EngineListener listener)
Registers
listener to receive Engine, Api, request and error callbacks. |
checkLazyConfig, compareTo, doLazyConfig, getAllExcludePaths, getAllIncludePaths, getConfig, getConfig, getConfigKeys, getDefaultIncludeMatch, getExcludeMatchers, getIncludeMatchers, getName, getOrder, match, matches, matches, toString, withConfig, withExcludeOn, withExcludeOn, withExcludeOn, withIncludeOn, withIncludeOn, withIncludeOn, withName, withOrderprotected final transient java.util.List<Engine.EngineListener> listeners
protected transient volatile Response lastResponse
Response served by this Engine, primarily used for writing test cases.protected java.util.List<Api> apis
Apis being service by this Engineprotected java.lang.String corsAllowHeaders
Values from the request "Access-Control-Request-Header" header are concatenated to this resulting in the final value of "Access-Control-Allow-Headers" sent in the response.
Unless you are really doing something specific with browser security you probably won't need to customize this list.
protected java.lang.String configPath
Config.loadConfiguration(String, String)protected java.lang.String configProfile
Config.loadConfiguration(String, String)public Engine()
public Engine(Api... apis)
protected void startup0()
Called after starting has been set to true but before the Configurator is run or any Apis have been started.
public Engine startup()
Configurator and calls startupApi for each Api.
An Engine can only be started once.
Any calls to startup after the initial call will not have any affect.
public void shutdown()
public Response get(java.lang.String url)
#service(Request, Response) to run a REST GET Request on this Engine.
IMPORTANT: This method does not make an external HTTP request, it runs the request on this Engine.
If you want to make an external HTTP request see RestClient.
GET requests for a specific resource should return 200 of 404. GET requests with query string search conditions should return 200 even if the search did not yield any results.
url - the url that will be serviced by this Engineservice(Request, Response),
DbGetActionpublic Response get(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> params)
#service(Request, Response) to run a REST GET Request on this Engine.
IMPORTANT: This method does not make an external HTTP request, it runs the request on this Engine.
If you want to make an external HTTP request see RestClient.
GET requests for a specific resource should return 200 of 404. GET requests with query string search conditions should return 200 even if the search did not yield any results.
url - the url that will be serviced by this Engineparams - additional key/value pairs to add to the url query stringservice(Request, Response),
DbGetActionpublic Response get(java.lang.String url, java.util.List queryTerms)
#service(Request, Response) to run a REST GET Request on this Engine.
IMPORTANT: This method does not make an external HTTP request, it runs the request on this Engine.
If you want to make an external HTTP request see RestClient.
GET requests for a specific resource should return 200 of 404. GET requests with query string search conditions should return 200 even if the search did not yield any results.
url - the url that will be serviced by this EnginequeryTerms - additional keys (no values) to add to the url query stringservice(Request, Response),
DbGetActionpublic Response post(java.lang.String url, JSNode body)
#service(Request, Response) to run a REST POST Request on this Engine.
IMPORTANT: This method does not make an external HTTP request, it runs the request on this Engine.
If you want to make an external HTTP request see RestClient.
Successful POSTs that create a new resource should return a 201.
url - the url that will be serviced by this Enginebody - the JSON body to POST which will be stringified firstservice(Request, Response),
DbPostActionpublic Response put(java.lang.String url, JSNode body)
#service(Request, Response) to run a REST PUT Request on this Engine.
IMPORTANT: This method does not make an external HTTP request, it runs the request on this Engine.
If you want to make an external HTTP request see RestClient.
Successful PUTs that update an existing resource should return a 204. If the PUT references a resource that does not exist, a 404 will be returned.
url - the url that will be serviced by this Enginebody - the JSON body to POST which will be stringified firstservice(Request, Response),
DbPutActionpublic Response patch(java.lang.String url, JSNode body)
#service(Request, Response) to run a REST PATCH Request on this Engine.
IMPORTANT: This method does not make an external HTTP request, it runs the request on this Engine.
If you want to make an external HTTP request see RestClient.
Successful PATCHes that update an existing resource should return a 204. If the PATCH references a resource that does not exist, a 404 will be returned.
url - the url for a specific resource that should be PATCHed that will be serviced by this Enginebody - the JSON body to POST which will be stringified firstservice(Request, Response),
DbPatchActionpublic Response delete(java.lang.String url)
#service(Request, Response) to run a REST DELETE Request on this Engine.
IMPORTANT: This method does not make an external HTTP request, it runs the request on this Engine.
If you want to make an external HTTP request see RestClient.
url - the url of the resource to be DELETEDservice(Request, Response),
DbDeleteActionpublic Response delete(java.lang.String url, JSArray hrefs)
#service(Request, Response) to run a REST DELETE Request on this Engine.
IMPORTANT: This method does not make an external HTTP request, it runs the request on this Engine.
If you want to make an external HTTP request see RestClient.
url - the url of the resource to be DELETEDhrefs - the hrefs of the resource to deleteservice(Request, Response),
DbDeleteActionpublic Response service(java.lang.String method, java.lang.String url)
#service(Request, Response)
IMPORTANT: This method does not make an external HTTP request, it runs the request on this Engine.
If you want to make an external HTTP request see RestClient.
method - the http method of the requested operationurl - the url that will be serviced by this Engineservice(Request, Response)public Response service(java.lang.String method, java.lang.String url, java.lang.String body)
#service(Request, Response)
IMPORTANT: This method does not make an external HTTP request, it runs the request on this Engine.
If you want to make an external HTTP request see RestClient.
method - the http method of the requested operationurl - the url that will be serviced by this Engine.body - a stringified JSON body presumably to PUT/POST/PATCHservice(Request, Response)public Response service(java.lang.String method, java.lang.String url, java.lang.String body, java.util.Map<java.lang.String,java.lang.String> params)
#service(Request, Response)
IMPORTANT: This method does not make an external HTTP request, it runs the request on this Engine.
If you want to make an external HTTP request see RestClient.
method - the http method of the requested operationurl - the url that will be serviced by this Engine.body - a stringified JSON body presumably to PUT/POST/PATCHparams - additional key/value pairs to add to the url query stringservice(Request, Response)public Chain service(Request req, Response res)
This method is designed to be called by integrating runtimes such as EngineServlet or by Actions that
need to make recursive calls to the Engine when performing composite operations.
The host and port component of the Request url are ignored assuming that this Engine instance is supposed to be servicing the request. The url does not have to start with "http[s]://". If it does not, urls that start with "/" or not are handled the same.
All of the following would be processed the same way:
req - the api Requestres - the api Responsepublic boolean isStarted()
public Engine withEngineListener(Engine.EngineListener listener)
listener to receive Engine, Api, request and error callbacks.listener - the listener to addpublic java.util.List<Api> getApis()
public Api getApi(java.lang.String apiName)
protected void startupApi(Api api)
public void removeApi(Api api)
api - the api to be removedprotected void shutdownApi(Api api)
public Engine withAllowHeaders(java.lang.String allowHeaders)
public Response getLastResponse()
public java.net.URL getResource(java.lang.String name)
public java.lang.String getConfigPath()
public Engine withConfigPath(java.lang.String configPath)
public java.lang.String getConfigProfile()
public Engine withConfigProfile(java.lang.String configProfile)
Copyright © 2021 Rocket Partners, LLC. All rights reserved.