Implement controller provider. Controllers are named, targetable objects that clients can invoke methods upon. *
| Modifiers | Name | Description |
|---|---|---|
static class |
ConfigurationProvider.CmdReader |
Extend JsonReader to gain access to the convertParsedMapsToJava() API. |
| Modifiers | Name | Description |
|---|---|---|
private static java.util.regex.Pattern |
cmdUrlPattern |
|
private static java.util.regex.Pattern |
cmdUrlPattern2 |
|
private static java.util.Map<java.lang.String, java.lang.reflect.Method> |
methodMap |
|
private javax.servlet.ServletConfig |
servletConfig |
|
private org.springframework.context.ApplicationContext |
springAppCtx |
| Constructor and description |
|---|
ConfigurationProvider
(javax.servlet.ServletConfig servletConfig) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
java.lang.Object |
callController(java.lang.Object controller, javax.servlet.http.HttpServletRequest request, java.lang.String json)Read the JSON request (susceptible to Exceptions that are allowed to be thrown from here), and then call the appropriate Controller method. |
|
protected static java.lang.Object[] |
convertArgs(java.lang.reflect.Method method, java.lang.Object[] args)Convert the passed in arguments to match the arguments of the passed in method. |
|
static java.lang.Object |
getArguments(java.lang.String json, java.lang.String controllerName, java.lang.String methodName)Build the argument list from the passed in json |
|
protected java.lang.Object |
getController(java.lang.String name)Fetch the controller with the given name. |
|
protected static java.lang.reflect.Method |
getMethod(java.lang.Object controller, java.lang.String controllerName, java.lang.String methodName, int argCount)Fetch the named method from the controller. |
|
protected static java.lang.reflect.Method |
getMethod(java.lang.Class c, java.lang.String name, int argc)Reflectively find the requested method on the requested class. |
|
javax.servlet.ServletConfig |
getServletConfig() |
|
static java.util.regex.Matcher |
getUrlMatcher(javax.servlet.http.HttpServletRequest request)Get a regex Matcher that matches the URL String for /context/cmd/controller/method |
|
static java.util.Map |
objectToMap(java.lang.Object o)Convert an Object to a Map. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Read the JSON request (susceptible to Exceptions that are allowed to be thrown from here), and then call the appropriate Controller method. The controller method exceptions are caught and returned carefully as JSON error String responses. Note, this should not happen - if they do, it is a case of a missing try/catch handler in a Controller method (or Advice around the Controller).
Convert the passed in arguments to match the arguments of the passed in method.
method - Method which contains argument types.args - Object[] of values, which need to be converted.Build the argument list from the passed in json
json - String argument listscontrollerName - String name of controllermethodName - String name of method to call on the controllerFetch the controller with the given name.
name - String name of a Controller instance (Spring bean name).Fetch the named method from the controller. First a local cache will be checked, and if not found, the method will be found reflectively on the controller. If the method is found, then it will be checked for a ControllerMethod annotation, which can indicate that it is NOT allowed to be called. This permits a public controller method to be blocked from remote access.
controller - Object on which the named method will be found.controllerName - String name of the controller (Spring name, n-cube name, etc.)methodName - String name of method to be located on the controller.argCount - int number of arguments. This is used as part of the cache key to allow for
duplicate method names as long as the argument list length is different.Reflectively find the requested method on the requested class.
c - Class containing the methodname - String method nameargc - int number of argumentsGet a regex Matcher that matches the URL String for /context/cmd/controller/method
request - HttpServletRequest passed to the command servlet.json - String arguments in JSON form from HTTP requestConvert an Object to a Map. This allows an object to then be passed into n-cube as a coordinate. Of course the returned map can have additional key/value pairs added to it after calling this method, but before calling getCell().
o - Object any Java object to bind to an NCube.