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 org.apache.logging.log4j.Logger |
LOG |
|
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 |
Constructor and description |
---|
ConfigurationProvider
(javax.servlet.ServletConfig servletConfig) |
Type | Name and description |
---|---|
static T[] |
arrayBuilder(java.lang.Class<T> classToCastTo, java.util.Collection c) Convert Collection to a Java (typed) array []. |
Envelope |
callController(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. |
private static java.lang.Object |
callMethod(java.lang.reflect.Method method, java.lang.Object target, java.lang.Object[] args) Invoke the passed in method, on the passed in target, with the passed in arguments. |
private 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 java.lang.String |
getLogPrefix() @return String prefix to append to log so that we can tell what controller type was used (spring:, ncube:, etc.) |
private static java.lang.Object |
getMethod(java.lang.Object controller, java.lang.String controllerName, java.lang.String methodName, int argCount) Fetch the named method from the controller. |
private 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/controller/method |
protected boolean |
isMethodAllowed(java.lang.String methodName) Verify that the passed in method is allowed to be called remotely. |
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() |
Convert Collection to a Java (typed) array [].
classToCastTo
- array type (Object[], Person[], etc.)c
- Collection containing items to be placed into the array.
- Type of the arrayRead 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. Troll the logs to find these and fix them as they come up.
Invoke the passed in method, on the passed in target, with the passed in arguments.
method
- Method to be invokedtarget
- instance which contains the methodargs
- Object[] of values which line up to the method arguments.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.
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/controller/method
request
- HttpServletRequest passed to the command servlet.json
- String arguments in JSON form from HTTP requestVerify that the passed in method is allowed to be called remotely.
methodName
- String method name to check