當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。