use of cn.taketoday.web.annotation.ActionMapping in project today-framework by TAKETODAY.
the class HandlerMethodRegistry method buildHandlerMethod.
/**
* Set Action Mapping
*
* @param beanName bean name
* @param method Action or Handler
* @param beanClass Controller
* @param controllerMapping find mapping on class
*/
protected void buildHandlerMethod(String beanName, Method method, Class<?> beanClass, @Nullable MergedAnnotation<ActionMapping> controllerMapping) {
MergedAnnotation<ActionMapping> annotation = MergedAnnotations.from(method).get(ActionMapping.class);
if (annotation.isPresent()) {
// build HandlerMethod
ActionMappingAnnotationHandler handler = createHandler(beanName, beanClass, method);
// do mapping url
mappingHandlerMethod(handler, controllerMapping, annotation);
}
}
use of cn.taketoday.web.annotation.ActionMapping in project today-framework by TAKETODAY.
the class RequestPathMappingHandlerMethodRegistryTests method mappingHandlerMethod.
@Test
public void mappingHandlerMethod() throws Exception {
AnnotationAttributes mapping = new AnnotationAttributes();
Method method = TEST.class.getDeclaredMethod("mapping");
MergedAnnotation<ActionMapping> actionMapping = MergedAnnotations.from(method).get(ActionMapping.class);
MergedAnnotation<ActionMapping> controllerMapping = MergedAnnotations.from(method).get(ActionMapping.class);
RequestPathMappingHandlerMapping registry = new RequestPathMappingHandlerMapping();
registry.mergeMappingAttributes(mapping, actionMapping, controllerMapping);
System.out.println(mapping);
}
use of cn.taketoday.web.annotation.ActionMapping in project today-infrastructure by TAKETODAY.
the class RequestMappingHandlerMapping method createRequestMappingInfo.
/**
* Delegates to {@link #createRequestMappingInfo(ActionMapping, RequestCondition)},
* supplying the appropriate custom {@link RequestCondition} depending on whether
* the supplied {@code annotatedElement} is a class or method.
*
* @see #getCustomTypeCondition(Class)
* @see #getCustomMethodCondition(Method)
*/
@Nullable
private RequestMappingInfo createRequestMappingInfo(AnnotatedElement element) {
ActionMapping requestMapping = AnnotatedElementUtils.findMergedAnnotation(element, ActionMapping.class);
RequestCondition<?> condition = element instanceof Class ? getCustomTypeCondition((Class<?>) element) : getCustomMethodCondition((Method) element);
return requestMapping != null ? createRequestMappingInfo(requestMapping, condition) : null;
}
use of cn.taketoday.web.annotation.ActionMapping in project today-infrastructure by TAKETODAY.
the class RequestPathMappingHandlerMethodRegistryTests method mappingHandlerMethod.
@Test
public void mappingHandlerMethod() throws Exception {
AnnotationAttributes mapping = new AnnotationAttributes();
Method method = TEST.class.getDeclaredMethod("mapping");
MergedAnnotation<ActionMapping> actionMapping = MergedAnnotations.from(method).get(ActionMapping.class);
MergedAnnotation<ActionMapping> controllerMapping = MergedAnnotations.from(method).get(ActionMapping.class);
RequestPathMappingHandlerRegistry registry = new RequestPathMappingHandlerRegistry();
registry.mergeMappingAttributes(mapping, actionMapping, controllerMapping);
System.out.println(mapping);
}
Aggregations