当前位置: 首页>>代码示例>>Java>>正文


Java SessionAttributes类代码示例

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


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

示例1: SessionAttributesHandler

import org.springframework.web.bind.annotation.SessionAttributes; //导入依赖的package包/类
/**
 * Create a new instance for a controller type. Session attribute names and
 * types are extracted from the {@code @SessionAttributes} annotation, if
 * present, on the given type.
 * @param handlerType the controller type
 * @param sessionAttributeStore used for session access
 */
public SessionAttributesHandler(Class<?> handlerType, SessionAttributeStore sessionAttributeStore) {
	Assert.notNull(sessionAttributeStore, "SessionAttributeStore may not be null.");
	this.sessionAttributeStore = sessionAttributeStore;

	SessionAttributes annotation = AnnotationUtils.findAnnotation(handlerType, SessionAttributes.class);
	if (annotation != null) {
		this.attributeNames.addAll(Arrays.asList(annotation.value()));
		this.attributeTypes.addAll(Arrays.<Class<?>>asList(annotation.types()));
	}

	for (String attributeName : this.attributeNames) {
		this.knownAttributeNames.add(attributeName);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:SessionAttributesHandler.java

示例2: init

import org.springframework.web.bind.annotation.SessionAttributes; //导入依赖的package包/类
/**
 * Initialize a new HandlerMethodResolver for the specified handler type.
 * @param handlerType the handler class to introspect
 */
public void init(final Class<?> handlerType) {
	Set<Class<?>> handlerTypes = new LinkedHashSet<Class<?>>();
	Class<?> specificHandlerType = null;
	if (!Proxy.isProxyClass(handlerType)) {
		handlerTypes.add(handlerType);
		specificHandlerType = handlerType;
	}
	handlerTypes.addAll(Arrays.asList(handlerType.getInterfaces()));
	for (Class<?> currentHandlerType : handlerTypes) {
		final Class<?> targetClass = (specificHandlerType != null ? specificHandlerType : currentHandlerType);
		ReflectionUtils.doWithMethods(currentHandlerType, new ReflectionUtils.MethodCallback() {
			@Override
			public void doWith(Method method) {
				Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
				Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
				if (isHandlerMethod(specificMethod) &&
						(bridgedMethod == specificMethod || !isHandlerMethod(bridgedMethod))) {
					handlerMethods.add(specificMethod);
				}
				else if (isInitBinderMethod(specificMethod) &&
						(bridgedMethod == specificMethod || !isInitBinderMethod(bridgedMethod))) {
					initBinderMethods.add(specificMethod);
				}
				else if (isModelAttributeMethod(specificMethod) &&
						(bridgedMethod == specificMethod || !isModelAttributeMethod(bridgedMethod))) {
					modelAttributeMethods.add(specificMethod);
				}
			}
		}, ReflectionUtils.USER_DECLARED_METHODS);
	}
	this.typeLevelMapping = AnnotationUtils.findAnnotation(handlerType, RequestMapping.class);
	SessionAttributes sessionAttributes = AnnotationUtils.findAnnotation(handlerType, SessionAttributes.class);
	this.sessionAttributesFound = (sessionAttributes != null);
	if (this.sessionAttributesFound) {
		this.sessionAttributeNames.addAll(Arrays.asList(sessionAttributes.value()));
		this.sessionAttributeTypes.addAll(Arrays.asList(sessionAttributes.types()));
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:43,代码来源:HandlerMethodResolver.java

示例3: handle

import org.springframework.web.bind.annotation.SessionAttributes; //导入依赖的package包/类
@Override
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
		throws Exception {

	Class<?> clazz = ClassUtils.getUserClass(handler);
	Boolean annotatedWithSessionAttributes = this.sessionAnnotatedClassesCache.get(clazz);
	if (annotatedWithSessionAttributes == null) {
		annotatedWithSessionAttributes = (AnnotationUtils.findAnnotation(clazz, SessionAttributes.class) != null);
		this.sessionAnnotatedClassesCache.put(clazz, annotatedWithSessionAttributes);
	}

	if (annotatedWithSessionAttributes) {
		checkAndPrepare(request, response, this.cacheSecondsForSessionAttributeHandlers, true);
	}
	else {
		checkAndPrepare(request, response, true);
	}

	// Execute invokeHandlerMethod in synchronized block if required.
	if (this.synchronizeOnSession) {
		HttpSession session = request.getSession(false);
		if (session != null) {
			Object mutex = WebUtils.getSessionMutex(session);
			synchronized (mutex) {
				return invokeHandlerMethod(request, response, handler);
			}
		}
	}

	return invokeHandlerMethod(request, response, handler);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:32,代码来源:AnnotationMethodHandlerAdapter.java

示例4: SessionAttributesHandler

import org.springframework.web.bind.annotation.SessionAttributes; //导入依赖的package包/类
/**
 * Create a new instance for a controller type. Session attribute names and
 * types are extracted from the {@code @SessionAttributes} annotation, if
 * present, on the given type.
 * @param handlerType the controller type
 * @param sessionAttributeStore used for session access
 */
public SessionAttributesHandler(Class<?> handlerType, SessionAttributeStore sessionAttributeStore) {
	Assert.notNull(sessionAttributeStore, "SessionAttributeStore may not be null.");
	this.sessionAttributeStore = sessionAttributeStore;

	SessionAttributes annotation = AnnotationUtils.findAnnotation(handlerType, SessionAttributes.class);
	if (annotation != null) {
		this.attributeNames.addAll(Arrays.asList(annotation.names()));
		this.attributeTypes.addAll(Arrays.asList(annotation.types()));
	}

	for (String attributeName : this.attributeNames) {
		this.knownAttributeNames.add(attributeName);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:SessionAttributesHandler.java

示例5: init

import org.springframework.web.bind.annotation.SessionAttributes; //导入依赖的package包/类
/**
 * Initialize a new HandlerMethodResolver for the specified handler type.
 * @param handlerType the handler class to introspect
 */
public void init(final Class<?> handlerType) {
	Set<Class<?>> handlerTypes = new LinkedHashSet<Class<?>>();
	Class<?> specificHandlerType = null;
	if (!Proxy.isProxyClass(handlerType)) {
		handlerTypes.add(handlerType);
		specificHandlerType = handlerType;
	}
	handlerTypes.addAll(Arrays.asList(handlerType.getInterfaces()));
	for (Class<?> currentHandlerType : handlerTypes) {
		final Class<?> targetClass = (specificHandlerType != null ? specificHandlerType : currentHandlerType);
		ReflectionUtils.doWithMethods(currentHandlerType, new ReflectionUtils.MethodCallback() {
			@Override
			public void doWith(Method method) {
				Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
				Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
				if (isHandlerMethod(specificMethod) &&
						(bridgedMethod == specificMethod || !isHandlerMethod(bridgedMethod))) {
					handlerMethods.add(specificMethod);
				}
				else if (isInitBinderMethod(specificMethod) &&
						(bridgedMethod == specificMethod || !isInitBinderMethod(bridgedMethod))) {
					initBinderMethods.add(specificMethod);
				}
				else if (isModelAttributeMethod(specificMethod) &&
						(bridgedMethod == specificMethod || !isModelAttributeMethod(bridgedMethod))) {
					modelAttributeMethods.add(specificMethod);
				}
			}
		}, ReflectionUtils.USER_DECLARED_METHODS);
	}
	this.typeLevelMapping = AnnotationUtils.findAnnotation(handlerType, RequestMapping.class);
	SessionAttributes sessionAttributes = AnnotationUtils.findAnnotation(handlerType, SessionAttributes.class);
	this.sessionAttributesFound = (sessionAttributes != null);
	if (this.sessionAttributesFound) {
		this.sessionAttributeNames.addAll(Arrays.asList(sessionAttributes.names()));
		this.sessionAttributeTypes.addAll(Arrays.asList(sessionAttributes.types()));
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:43,代码来源:HandlerMethodResolver.java

示例6: handle

import org.springframework.web.bind.annotation.SessionAttributes; //导入依赖的package包/类
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
		throws Exception {

	Class<?> clazz = ClassUtils.getUserClass(handler);
	Boolean annotatedWithSessionAttributes = this.sessionAnnotatedClassesCache.get(clazz);
	if (annotatedWithSessionAttributes == null) {
		annotatedWithSessionAttributes = (AnnotationUtils.findAnnotation(clazz, SessionAttributes.class) != null);
		this.sessionAnnotatedClassesCache.put(clazz, annotatedWithSessionAttributes);
	}

	if (annotatedWithSessionAttributes) {
		// Always prevent caching in case of session attribute management.
		checkAndPrepare(request, response, this.cacheSecondsForSessionAttributeHandlers, true);
		// Prepare cached set of session attributes names.
	}
	else {
		// Uses configured default cacheSeconds setting.
		checkAndPrepare(request, response, true);
	}

	// Execute invokeHandlerMethod in synchronized block if required.
	if (this.synchronizeOnSession) {
		HttpSession session = request.getSession(false);
		if (session != null) {
			Object mutex = WebUtils.getSessionMutex(session);
			synchronized (mutex) {
				return invokeHandlerMethod(request, response, handler);
			}
		}
	}

	return invokeHandlerMethod(request, response, handler);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:34,代码来源:AnnotationMethodHandlerAdapter.java

示例7: SessionAttributesHandler

import org.springframework.web.bind.annotation.SessionAttributes; //导入依赖的package包/类
/**
 * Create a new instance for a controller type. Session attribute names and
 * types are extracted from the {@code @SessionAttributes} annotation, if
 * present, on the given type.
 * @param handlerType the controller type
 * @param sessionAttributeStore used for session access
 */
public SessionAttributesHandler(Class<?> handlerType, SessionAttributeStore sessionAttributeStore) {
	Assert.notNull(sessionAttributeStore, "SessionAttributeStore may not be null.");
	this.sessionAttributeStore = sessionAttributeStore;

	SessionAttributes annotation = AnnotationUtils.findAnnotation(handlerType, SessionAttributes.class);
	if (annotation != null) {
		this.attributeNames.addAll(Arrays.asList(annotation.value()));
		this.attributeTypes.addAll(Arrays.<Class<?>>asList(annotation.types()));
	}

	for (String attributeName : this.attributeNames) {
		this.knownAttributeNames.put(attributeName, Boolean.TRUE);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:22,代码来源:SessionAttributesHandler.java

示例8: init

import org.springframework.web.bind.annotation.SessionAttributes; //导入依赖的package包/类
/**
 * Initialize a new HandlerMethodResolver for the specified handler type.
 * @param handlerType the handler class to introspect
 */
public void init(final Class<?> handlerType) {
	Set<Class<?>> handlerTypes = new LinkedHashSet<Class<?>>();
	Class<?> specificHandlerType = null;
	if (!Proxy.isProxyClass(handlerType)) {
		handlerTypes.add(handlerType);
		specificHandlerType = handlerType;
	}
	handlerTypes.addAll(Arrays.asList(handlerType.getInterfaces()));
	for (Class<?> currentHandlerType : handlerTypes) {
		final Class<?> targetClass = (specificHandlerType != null ? specificHandlerType : currentHandlerType);
		ReflectionUtils.doWithMethods(currentHandlerType, new ReflectionUtils.MethodCallback() {
			public void doWith(Method method) {
				Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
				Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
				if (isHandlerMethod(specificMethod) &&
						(bridgedMethod == specificMethod || !isHandlerMethod(bridgedMethod))) {
					handlerMethods.add(specificMethod);
				}
				else if (isInitBinderMethod(specificMethod) &&
						(bridgedMethod == specificMethod || !isInitBinderMethod(bridgedMethod))) {
					initBinderMethods.add(specificMethod);
				}
				else if (isModelAttributeMethod(specificMethod) &&
						(bridgedMethod == specificMethod || !isModelAttributeMethod(bridgedMethod))) {
					modelAttributeMethods.add(specificMethod);
				}
			}
		}, ReflectionUtils.USER_DECLARED_METHODS);
	}
	this.typeLevelMapping = AnnotationUtils.findAnnotation(handlerType, RequestMapping.class);
	SessionAttributes sessionAttributes = AnnotationUtils.findAnnotation(handlerType, SessionAttributes.class);
	this.sessionAttributesFound = (sessionAttributes != null);
	if (this.sessionAttributesFound) {
		this.sessionAttributeNames.addAll(Arrays.asList(sessionAttributes.value()));
		this.sessionAttributeTypes.addAll(Arrays.asList(sessionAttributes.types()));
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:42,代码来源:HandlerMethodResolver.java

示例9: handle

import org.springframework.web.bind.annotation.SessionAttributes; //导入依赖的package包/类
public ModelAndView handle(HttpServletRequest request,
		HttpServletResponse response, Object handler) throws Exception {

	if (AnnotationUtils.findAnnotation(handler.getClass(),
			SessionAttributes.class) != null) {
		// Always prevent caching in case of session attribute management.
		checkAndPrepare(request, response,
				this.cacheSecondsForSessionAttributeHandlers, true);
		// Prepare cached set of session attributes names.
	} else {
		// Uses configured default cacheSeconds setting.
		checkAndPrepare(request, response, true);
	}

	// Execute invokeHandlerMethod in synchronized block if required.
	if (this.synchronizeOnSession) {
		HttpSession session = request.getSession(false);
		if (session != null) {
			Object mutex = WebUtils.getSessionMutex(session);
			synchronized (mutex) {
				return invokeHandlerMethod(request, response, handler);
			}
		}
	}

	return invokeHandlerMethod(request, response, handler);
}
 
开发者ID:xiyelife,项目名称:jresplus,代码行数:28,代码来源:ExtendableAnnotationMethodHandlerAdapter.java

示例10: findSessionAttributeNames

import org.springframework.web.bind.annotation.SessionAttributes; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
static String[] findSessionAttributeNames(Class<?> controllerClass) {
    SessionAttributes attrs = AnnotationUtils.findAnnotation(controllerClass, SessionAttributes.class);
    if (attrs != null) {
      return attrs.value();
    }
    return null;
}
 
开发者ID:ctc-g,项目名称:sinavi-jfw,代码行数:11,代码来源:Controllers.java

示例11: findSessionAttributeTypes

import org.springframework.web.bind.annotation.SessionAttributes; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
static Class<?>[] findSessionAttributeTypes(Class<?> controllerClass) {
    SessionAttributes attrs = AnnotationUtils.findAnnotation(controllerClass, SessionAttributes.class);
    if (attrs != null) {
      return attrs.types();
    }
    return null;
}
 
开发者ID:ctc-g,项目名称:sinavi-jfw,代码行数:11,代码来源:Controllers.java


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