Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removed obsolete files.

  • Loading branch information...
commit 495f689efc6910b7874041229b22ac8c554f5668 1 parent ad2f3fa
@mdeinum authored
View
2  bookstore-shared/src/main/resources/logback.xml
@@ -15,6 +15,8 @@
</appender>
<logger name="org.springframework" level="INFO" />
+ <logger name="org.springframework.web" level="TRACE" />
+
<logger name="com.apress" level="DEBUG" />
<logger name="com.apress.prospringmvc.context" level="WARN" />
View
26 chapter2-bookstore/src/main/resources/logback.xml
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<configuration>
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <file>pizzas-r-us.log</file>
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <logger name="org.springframework" level="INFO" />
- <logger name="com.apress" level="DEBUG" />
-
- <root level="WARN">
- <appender-ref ref="STDOUT" />
- <appender-ref ref="FILE" />
- </root>
-
-
-</configuration>
View
28 chapter8-bookstore/support/SessionAttribute.java
@@ -1,28 +0,0 @@
-package com.apress.prospringmvc.bookstore.web.method.support;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target({ ElementType.PARAMETER, ElementType.METHOD })
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface SessionAttribute {
-
- /**
- * The name of the session attribute to bind to.
- */
- String value() default "";
-
- /**
- * Whether the parameter is required.
- */
- boolean required() default true;
-
- /**
- * Wheter attribute needs to be exposed as model attribtue.
- */
- boolean exposeAsModelAttribute() default false;
-}
View
54 chapter8-bookstore/support/SessionAttributeProcessor.java
@@ -1,54 +0,0 @@
-package com.apress.prospringmvc.bookstore.web.method.support;
-
-import org.springframework.core.MethodParameter;
-import org.springframework.web.bind.MissingServletRequestParameterException;
-import org.springframework.web.bind.support.WebDataBinderFactory;
-import org.springframework.web.context.request.NativeWebRequest;
-import org.springframework.web.context.request.WebRequest;
-import org.springframework.web.method.support.HandlerMethodArgumentResolver;
-import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
-import org.springframework.web.method.support.ModelAndViewContainer;
-
-public class SessionAttributeProcessor implements HandlerMethodReturnValueHandler, HandlerMethodArgumentResolver {
-
- @Override
- public boolean supportsReturnType(MethodParameter returnType) {
- return returnType.getMethodAnnotation(SessionAttribute.class) != null;
- }
-
- @Override
- public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer,
- NativeWebRequest webRequest) throws Exception {
-
- SessionAttribute annotation = returnType.getMethodAnnotation(SessionAttribute.class);
- webRequest.setAttribute(annotation.value(), returnValue, WebRequest.SCOPE_SESSION);
- exposeModelAttribute(annotation, returnValue, mavContainer);
- }
-
- @Override
- public boolean supportsParameter(MethodParameter parameter) {
- return parameter.hasParameterAnnotation(SessionAttribute.class);
- }
-
- private void exposeModelAttribute(SessionAttribute annotation, Object value, ModelAndViewContainer mavContainer) {
- if (annotation.exposeAsModelAttribute()) {
- mavContainer.addAttribute(annotation.value(), value);
- }
- }
-
- @Override
- public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
- NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
-
- SessionAttribute annotation = parameter.getParameterAnnotation(SessionAttribute.class);
-
- Object value = webRequest.getAttribute(annotation.value(), WebRequest.SCOPE_SESSION);
- if (value == null && annotation.required()) {
- throw new MissingServletRequestParameterException(annotation.value(), parameter.getParameterType()
- .getName());
- }
- exposeModelAttribute(annotation, value, mavContainer);
-
- return value;
- }
-}
Please sign in to comment.
Something went wrong with that request. Please try again.