• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java InvocableHandlerMethod类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.web.method.support.InvocableHandlerMethod的典型用法代码示例。如果您正苦于以下问题:Java InvocableHandlerMethod类的具体用法?Java InvocableHandlerMethod怎么用?Java InvocableHandlerMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InvocableHandlerMethod类属于org.springframework.web.method.support包,在下文中一共展示了InvocableHandlerMethod类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: invokeModelAttributeMethods

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
/**
 * Invoke model attribute methods to populate the model. Attributes are
 * added only if not already present in the model.
 */
private void invokeModelAttributeMethods(NativeWebRequest request, ModelAndViewContainer mavContainer)
		throws Exception {

	for (InvocableHandlerMethod attrMethod : this.attributeMethods) {
		String modelName = attrMethod.getMethodAnnotation(ModelAttribute.class).value();
		if (mavContainer.containsAttribute(modelName)) {
			continue;
		}

		Object returnValue = attrMethod.invokeForRequest(request, mavContainer);

		if (!attrMethod.isVoid()){
			String returnValueName = getNameForReturnValue(returnValue, attrMethod.getReturnType());
			if (!mavContainer.containsAttribute(returnValueName)) {
				mavContainer.addAttribute(returnValueName, returnValue);
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:ModelFactory.java


示例2: invokeModelAttributeMethods

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
/**
 * Invoke model attribute methods to populate the model.
 * Attributes are added only if not already present in the model.
 */
private void invokeModelAttributeMethods(NativeWebRequest request, ModelAndViewContainer mavContainer)
		throws Exception {

	while (!this.modelMethods.isEmpty()) {
		InvocableHandlerMethod attrMethod = getNextModelMethod(mavContainer).getHandlerMethod();
		String modelName = attrMethod.getMethodAnnotation(ModelAttribute.class).value();
		if (mavContainer.containsAttribute(modelName)) {
			continue;
		}

		Object returnValue = attrMethod.invokeForRequest(request, mavContainer);

		if (!attrMethod.isVoid()){
			String returnValueName = getNameForReturnValue(returnValue, attrMethod.getReturnType());
			if (!mavContainer.containsAttribute(returnValueName)) {
				mavContainer.addAttribute(returnValueName, returnValue);
			}
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:ModelFactory.java


示例3: ModelFactory

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
/**
 * Create a new instance with the given {@code @ModelAttribute} methods.
 * @param attributeMethods for model initialization
 * @param binderFactory for adding {@link BindingResult} attributes
 * @param sessionAttributesHandler for access to session attributes
 */
public ModelFactory(List<InvocableHandlerMethod> attributeMethods,
					WebDataBinderFactory binderFactory,
					SessionAttributesHandler sessionAttributesHandler) {
	this.attributeMethods = (attributeMethods != null) ? attributeMethods : new ArrayList<InvocableHandlerMethod>();
	this.binderFactory = binderFactory;
	this.sessionAttributesHandler = sessionAttributesHandler;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:ModelFactory.java


示例4: initBinder

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
/**
 * Initialize a WebDataBinder with {@code @InitBinder} methods.
 * If the {@code @InitBinder} annotation specifies attributes names, it is
 * invoked only if the names include the target object name.
 * @throws Exception if one of the invoked @{@link InitBinder} methods fail.
 */
@Override
public void initBinder(WebDataBinder binder, NativeWebRequest request) throws Exception {
	for (InvocableHandlerMethod binderMethod : this.binderMethods) {
		if (isBinderMethodApplicable(binderMethod, binder)) {
			Object returnValue = binderMethod.invokeForRequest(request, null, binder);
			if (returnValue != null) {
				throw new IllegalStateException("@InitBinder methods should return void: " + binderMethod);
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:InitBinderDataBinderFactory.java


示例5: createModelAttributeMethod

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
private InvocableHandlerMethod createModelAttributeMethod(WebDataBinderFactory factory, Object bean, Method method) {
	InvocableHandlerMethod attrMethod = new InvocableHandlerMethod(bean, method);
	attrMethod.setHandlerMethodArgumentResolvers(this.argumentResolvers);
	attrMethod.setParameterNameDiscoverer(this.parameterNameDiscoverer);
	attrMethod.setDataBinderFactory(factory);
	return attrMethod;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:RequestMappingHandlerAdapter.java


示例6: createInitBinderMethod

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
private InvocableHandlerMethod createInitBinderMethod(Object bean, Method method) {
	InvocableHandlerMethod binderMethod = new InvocableHandlerMethod(bean, method);
	binderMethod.setHandlerMethodArgumentResolvers(this.initBinderArgumentResolvers);
	binderMethod.setDataBinderFactory(new DefaultDataBinderFactory(this.webBindingInitializer));
	binderMethod.setParameterNameDiscoverer(this.parameterNameDiscoverer);
	return binderMethod;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:RequestMappingHandlerAdapter.java


示例7: setUp

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	TestMockServletContext servletContext = new TestMockServletContext();
	appContext = new GenericWebApplicationContext();
	appContext.setServletContext(servletContext);
	LocaleContextHolder.setLocale(Locale.US);

	String attributeName = WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE;
	appContext.getServletContext().setAttribute(attributeName, appContext);

	handler = new TestController();
	Method method = TestController.class.getMethod("testBind", Date.class, Double.class, TestBean.class, BindingResult.class);
	handlerMethod = new InvocableHandlerMethod(handler, method);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:MvcNamespaceTests.java


示例8: ModelFactory

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
/**
 * Create a new instance with the given {@code @ModelAttribute} methods.
 * @param invocableMethods the {@code @ModelAttribute} methods to invoke
 * @param dataBinderFactory for preparation of {@link BindingResult} attributes
 * @param sessionAttributesHandler for access to session attributes
 */
public ModelFactory(List<InvocableHandlerMethod> invocableMethods, WebDataBinderFactory dataBinderFactory,
		SessionAttributesHandler sessionAttributesHandler) {

	if (invocableMethods != null) {
		for (InvocableHandlerMethod method : invocableMethods) {
			this.modelMethods.add(new ModelMethod(method));
		}
	}
	this.dataBinderFactory = dataBinderFactory;
	this.sessionAttributesHandler = sessionAttributesHandler;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:ModelFactory.java


示例9: ModelMethod

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
private ModelMethod(InvocableHandlerMethod handlerMethod) {
	this.handlerMethod = handlerMethod;
	for (MethodParameter parameter : handlerMethod.getMethodParameters()) {
		if (parameter.hasParameterAnnotation(ModelAttribute.class)) {
			this.dependencies.add(getNameForParameter(parameter));
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:ModelFactory.java


示例10: setUp

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	this.controller = new TestController();

	Method method = TestController.class.getDeclaredMethod("handle");
	this.handleMethod = new InvocableHandlerMethod(this.controller, method);

	method = TestController.class.getDeclaredMethod("handleSessionAttr", String.class);
	this.handleSessionAttrMethod = new InvocableHandlerMethod(this.controller, method);

	this.sessionAttributeStore = new DefaultSessionAttributeStore();
	this.sessionAttrsHandler = new SessionAttributesHandler(TestController.class, this.sessionAttributeStore);
	this.webRequest = new ServletWebRequest(new MockHttpServletRequest());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:ModelFactoryTests.java


示例11: createModelFactory

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
private ModelFactory createModelFactory(String methodName, Class<?>... parameterTypes) throws Exception{
	Method method = TestController.class.getMethod(methodName, parameterTypes);

	HandlerMethodArgumentResolverComposite argResolvers = new HandlerMethodArgumentResolverComposite();
	argResolvers.addResolver(new ModelMethodProcessor());

	InvocableHandlerMethod handlerMethod = new InvocableHandlerMethod(this.controller, method);
	handlerMethod.setHandlerMethodArgumentResolvers(argResolvers);
	handlerMethod.setDataBinderFactory(null);
	handlerMethod.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());

	return new ModelFactory(Arrays.asList(handlerMethod), null, this.sessionAttrsHandler);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:ModelFactoryTests.java


示例12: runTest

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
private void runTest(Object controller) throws Exception {
	HandlerMethodArgumentResolverComposite resolvers = new HandlerMethodArgumentResolverComposite();
	resolvers.addResolver(new ModelAttributeMethodProcessor(false));
	resolvers.addResolver(new ModelMethodProcessor());
	WebDataBinderFactory dataBinderFactory = new DefaultDataBinderFactory(null);

	Class<?> type = controller.getClass();
	Set<Method> methods = MethodIntrospector.selectMethods(type, METHOD_FILTER);
	List<InvocableHandlerMethod> modelMethods = new ArrayList<InvocableHandlerMethod>();
	for (Method method : methods) {
		InvocableHandlerMethod modelMethod = new InvocableHandlerMethod(controller, method);
		modelMethod.setHandlerMethodArgumentResolvers(resolvers);
		modelMethod.setDataBinderFactory(dataBinderFactory);
		modelMethods.add(modelMethod);
	}
	Collections.shuffle(modelMethods);

	SessionAttributesHandler sessionHandler = new SessionAttributesHandler(type, this.sessionAttributeStore);
	ModelFactory factory = new ModelFactory(modelMethods, dataBinderFactory, sessionHandler);
	factory.initModel(this.webRequest, this.mavContainer, new HandlerMethod(controller, "handle"));
	if (logger.isDebugEnabled()) {
		StringBuilder sb = new StringBuilder();
		for (String name : getInvokedMethods()) {
			sb.append(" >> ").append(name);
		}
		logger.debug(sb);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:ModelFactoryOrderingTests.java


示例13: createBinderFactory

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
private WebDataBinderFactory createBinderFactory(String methodName, Class<?>... parameterTypes)
		throws Exception {

	Object handler = new InitBinderHandler();
	Method method = handler.getClass().getMethod(methodName, parameterTypes);

	InvocableHandlerMethod handlerMethod = new InvocableHandlerMethod(handler, method);
	handlerMethod.setHandlerMethodArgumentResolvers(argumentResolvers);
	handlerMethod.setDataBinderFactory(new DefaultDataBinderFactory(null));
	handlerMethod.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());

	return new InitBinderDataBinderFactory(Arrays.asList(handlerMethod), bindingInitializer);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:InitBinderDataBinderFactoryTests.java


示例14: setUp

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	appContext = new GenericWebApplicationContext();
	appContext.setServletContext(new TestMockServletContext());
	LocaleContextHolder.setLocale(Locale.US);

	handler = new TestController();
	Method method = TestController.class.getMethod("testBind", Date.class, TestBean.class, BindingResult.class);
	handlerMethod = new InvocableHandlerMethod(handler, method);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:11,代码来源:MvcNamespaceTests.java


示例15: setUp

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	Class<?> handlerType = handler.getClass();
	handleMethod = new InvocableHandlerMethod(handler, handlerType.getDeclaredMethod("handle"));
	Method method = handlerType.getDeclaredMethod("handleSessionAttr", String.class);
	handleSessionAttrMethod = new InvocableHandlerMethod(handler, method);
	sessionAttributeStore = new DefaultSessionAttributeStore();
	sessionAttrsHandler = new SessionAttributesHandler(handlerType, sessionAttributeStore);
	webRequest = new ServletWebRequest(new MockHttpServletRequest());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:11,代码来源:ModelFactoryTests.java


示例16: createModelFactory

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
private ModelFactory createModelFactory(String methodName, Class<?>... parameterTypes) throws Exception{
	Method method = ModelHandler.class.getMethod(methodName, parameterTypes);

	HandlerMethodArgumentResolverComposite argResolvers = new HandlerMethodArgumentResolverComposite();
	argResolvers.addResolver(new ModelMethodProcessor());

	InvocableHandlerMethod handlerMethod = new InvocableHandlerMethod(handler, method);
	handlerMethod.setHandlerMethodArgumentResolvers(argResolvers);
	handlerMethod.setDataBinderFactory(null);
	handlerMethod.setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());

	return new ModelFactory(Arrays.asList(handlerMethod), null, sessionAttrsHandler);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:ModelFactoryTests.java


示例17: handlerMethod

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
private HandlerMethod handlerMethod(String methodName, Class<?>... paramTypes) throws Exception {
	Method method = handler.getClass().getDeclaredMethod(methodName, paramTypes);
	return new InvocableHandlerMethod(handler, method);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:RequestMappingHandlerAdapterIntegrationTests.java


示例18: handlerMethod

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
private HandlerMethod handlerMethod(Object handler, String methodName, Class<?>... paramTypes) throws Exception {
	Method method = handler.getClass().getDeclaredMethod(methodName, paramTypes);
	return new InvocableHandlerMethod(handler, method);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:RequestMappingHandlerAdapterTests.java


示例19: getHandlerMethod

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
public InvocableHandlerMethod getHandlerMethod() {
	return this.handlerMethod;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:ModelFactory.java


示例20: createDataBinderFactory

import org.springframework.web.method.support.InvocableHandlerMethod; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected ServletRequestDataBinderFactory createDataBinderFactory(
        List<InvocableHandlerMethod> binderMethods) throws Exception {
    return new UifServletRequestDataBinderFactory(binderMethods, getWebBindingInitializer());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:9,代码来源:UifRequestMappingHandlerAdapter.java



注:本文中的org.springframework.web.method.support.InvocableHandlerMethod类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HeadersToolbar类代码示例发布时间:2022-05-23
下一篇:
Java GuildMessageUpdateEvent类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap