use of com.blade.mvc.http.HttpMethod in project blade by biezhi.
the class Routers method addRoute.
public void addRoute(HttpMethod httpMethod, String path, com.blade.mvc.handler.RouteHandler handler, String methodName) throws NoSuchMethodException {
Class<?> handleType = handler.getClass();
Method method = handleType.getMethod(methodName, Request.class, Response.class);
addRoute(httpMethod, path, handler, com.blade.mvc.handler.RouteHandler.class, method);
}
use of com.blade.mvc.http.HttpMethod in project blade by biezhi.
the class Routers method route.
public void route(String path, Class<?> clazz, String methodName, HttpMethod httpMethod) {
try {
Assert.notNull(path, "Route path not is null!");
Assert.notNull(clazz, "Class Type not is null!");
Assert.notNull(methodName, "Method name not is null");
Assert.notNull(httpMethod, "Request Method not is null");
Method[] methods = classMethosPool.get(clazz.getName());
if (null == methods) {
methods = clazz.getMethods();
classMethosPool.put(clazz.getName(), methods);
}
if (null != methods) {
for (Method method : methods) {
if (method.getName().equals(methodName)) {
Object controller = controllerPool.get(clazz);
if (null == controller) {
controller = ReflectKit.newInstance(clazz);
controllerPool.put(clazz, controller);
}
addRoute(httpMethod, path, controller, clazz, method);
}
}
}
} catch (Exception e) {
LOGGER.error("", e);
}
}
use of com.blade.mvc.http.HttpMethod in project blade by biezhi.
the class AbstractFileRouteLoader method buildRoute.
/**
* Construct a routing object
*
* @param httpMethod request httpMethod
* @param path route path
* @param controllerName controller name
* @param methodName method name
* @return return route object
* @throws RouteException
*/
private Route buildRoute(String httpMethod, String path, String controllerName, String methodName) throws RouteException {
Object controller = controllerLoader.load(controllerName);
Class<?> controllerType = controller.getClass();
Method method = getMethod(controllerType, methodName);
return new Route(HttpMethod.valueOf(httpMethod.toUpperCase()), path, controller, controllerType, method);
}
Aggregations