Permalink
Browse files

m3 release prepartions; collapsed mvc package into device, extracted …

…DeviceUtils, added missing copyrights and updated copyright date to 2011
  • Loading branch information...
1 parent f970b68 commit ddc7a49d5148acf6ca471922aae6bc2735c19549 Keith Donald committed Feb 2, 2011
Showing with 182 additions and 89 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 spring-mobile-device/src/main/java/org/springframework/mobile/device/Device.java
  3. +1 −1 spring-mobile-device/src/main/java/org/springframework/mobile/device/DeviceResolver.java
  4. +56 −0 ...bile-device/src/main/java/org/springframework/mobile/device/DeviceResolverHandlerInterceptor.java
  5. +8 −38 .../org/springframework/mobile/device/{mvc/DeviceResolverHandlerInterceptor.java → DeviceUtils.java}
  6. +3 −4 ...le-device/src/main/java/org/springframework/mobile/device/{mvc → }/DeviceWebArgumentResolver.java
  7. +1 −1 ...-mobile-device/src/main/java/org/springframework/mobile/device/config/DeviceNamespaceHandler.java
  8. +15 −0 ...c/main/java/org/springframework/mobile/device/config/WurflDeviceResolverBeanDefinitionParser.java
  9. +1 −1 spring-mobile-device/src/main/java/org/springframework/mobile/device/lite/LiteDevice.java
  10. +1 −1 spring-mobile-device/src/main/java/org/springframework/mobile/device/lite/LiteDeviceResolver.java
  11. +0 −5 spring-mobile-device/src/main/java/org/springframework/mobile/device/mvc/package-info.java
  12. +1 −1 ...e-device/src/main/java/org/springframework/mobile/device/site/CookieSitePreferenceRepository.java
  13. +1 −1 spring-mobile-device/src/main/java/org/springframework/mobile/device/site/SitePreference.java
  14. +15 −0 spring-mobile-device/src/main/java/org/springframework/mobile/device/site/SitePreferenceHandler.java
  15. +1 −1 ...device/src/main/java/org/springframework/mobile/device/site/SitePreferenceHandlerInterceptor.java
  16. +1 −1 ...-mobile-device/src/main/java/org/springframework/mobile/device/site/SitePreferenceRepository.java
  17. +15 −0 spring-mobile-device/src/main/java/org/springframework/mobile/device/site/SitePreferenceUtils.java
  18. +1 −1 ...evice/src/main/java/org/springframework/mobile/device/site/SitePreferenceWebArgumentResolver.java
  19. +3 −3 ...le-device/src/main/java/org/springframework/mobile/device/site/StandardSitePreferenceHandler.java
  20. +3 −3 ...vice/src/main/java/org/springframework/mobile/device/switcher/SiteSwitcherHandlerInterceptor.java
  21. +1 −1 spring-mobile-device/src/main/java/org/springframework/mobile/device/switcher/SiteUrlFactory.java
  22. +1 −1 ...obile-device/src/main/java/org/springframework/mobile/device/switcher/StandardSiteUrlFactory.java
  23. +1 −1 spring-mobile-device/src/main/java/org/springframework/mobile/device/wurfl/WurflDevice.java
  24. +1 −1 spring-mobile-device/src/main/java/org/springframework/mobile/device/wurfl/WurflDeviceResolver.java
  25. +1 −1 ...-mobile-device/src/main/java/org/springframework/mobile/device/wurfl/WurflManagerFactoryBean.java
  26. +15 −0 ...device/src/main/java/org/springframework/mobile/device/wurfl/wng/BufferedHttpServletResponse.java
  27. +3 −3 spring-mobile-device/src/main/java/org/springframework/mobile/device/wurfl/wng/WngView.java
  28. +15 −0 spring-mobile-device/src/main/java/org/springframework/mobile/device/wurfl/wng/WngViewResolver.java
  29. +3 −5 ...rc/test/java/org/springframework/mobile/device/{mvc → }/DeviceResolverHandlerInterceptorTest.java
  30. +3 −4 ...evice/src/test/java/org/springframework/mobile/device/{mvc → }/DeviceWebArgumentResolverTest.java
  31. +1 −1 spring-mobile-device/src/test/java/org/springframework/mobile/device/{mvc → }/StubDevice.java
  32. +4 −4 ...evice/src/test/java/org/springframework/mobile/device/site/StandardSitePreferenceHandlerTest.java
  33. +3 −3 .../src/test/java/org/springframework/mobile/device/switcher/SiteSwitcherHandlerInterceptorTest.java
  34. +1 −1 spring-mobile-device/src/test/resources/org/springframework/mobile/device/config/device.xml
View
@@ -9,3 +9,4 @@
.gradle
build
target
+bin
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2010-2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.mobile.device;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.mobile.device.lite.LiteDeviceResolver;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
+
+/**
+ * A Spring MVC interceptor that resolves the Device that originated the web request <i>before</i> any request handler is invoked.
+ * The resolved Device is exported as a request attribute under the well-known name of {@link #CURRENT_DEVICE_ATTRIBUTE}.
+ * Request handlers such as @Controllers and views may then access the currentDevice to vary their control and rendering logic, respectively.
+ * @author Keith Donald
+ */
+public class DeviceResolverHandlerInterceptor extends HandlerInterceptorAdapter {
+
+ private final DeviceResolver deviceResolver;
+
+ /**
+ * Create a device resolving {@link HandlerInterceptor} that defaults to a {@link LiteDeviceResolver} implementation.
+ */
+ public DeviceResolverHandlerInterceptor() {
+ this(new LiteDeviceResolver());
+ }
+
+ /**
+ * Create a device resolving {@link HandlerInterceptor}.
+ * @param deviceResolver the device resolver to delegate to in {@link #preHandle(HttpServletRequest, HttpServletResponse, Object)}.
+ */
+ public DeviceResolverHandlerInterceptor(DeviceResolver deviceResolver) {
+ this.deviceResolver = deviceResolver;
+ }
+
+ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+ Device device = deviceResolver.resolveDevice(request);
+ request.setAttribute(DeviceUtils.CURRENT_DEVICE_ATTRIBUTE, device);
+ return true;
+ }
+
+}
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,63 +13,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.mobile.device.mvc;
+package org.springframework.mobile.device;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.springframework.mobile.device.Device;
-import org.springframework.mobile.device.DeviceResolver;
-import org.springframework.mobile.device.lite.LiteDeviceResolver;
import org.springframework.web.context.request.RequestAttributes;
-import org.springframework.web.servlet.HandlerInterceptor;
-import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
/**
- * A Spring MVC interceptor that resolves the Device that originated the web request <i>before</i> any request handler is invoked.
- * The resolved Device is exported as a request attribute under the well-known name of {@link #CURRENT_DEVICE_ATTRIBUTE}.
- * Request handlers such as @Controllers and views may then access the currentDevice to vary their control and rendering logic, respectively.
+ * Static helper for accessing request-scoped Device values.
* @author Keith Donald
*/
-public class DeviceResolverHandlerInterceptor extends HandlerInterceptorAdapter {
+public class DeviceUtils {
/**
* The name of the request attribute the current Device is indexed by.
* The attribute name is 'currentDevice'.
*/
public static final String CURRENT_DEVICE_ATTRIBUTE = "currentDevice";
- private final DeviceResolver deviceResolver;
-
- /**
- * Create a device resolving {@link HandlerInterceptor} that defaults to a {@link LiteDeviceResolver} implementation.
- */
- public DeviceResolverHandlerInterceptor() {
- this(new LiteDeviceResolver());
- }
-
- /**
- * Create a device resolving {@link HandlerInterceptor}.
- * @param deviceResolver the device resolver to delegate to in {@link #preHandle(HttpServletRequest, HttpServletResponse, Object)}.
- */
- public DeviceResolverHandlerInterceptor(DeviceResolver deviceResolver) {
- this.deviceResolver = deviceResolver;
- }
-
- public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
- Device device = deviceResolver.resolveDevice(request);
- request.setAttribute(CURRENT_DEVICE_ATTRIBUTE, device);
- return true;
- }
-
/**
* Static utility method that extracts the current device from the web request.
* Encapsulates the {@link HttpServletRequest#getAttribute(String)} lookup.
* @param request the servlet request
* @return the current device, or null if no device has been resolved for the request
*/
public static Device getCurrentDevice(HttpServletRequest request) {
- return (Device) request.getAttribute(DeviceResolverHandlerInterceptor.CURRENT_DEVICE_ATTRIBUTE);
+ return (Device) request.getAttribute(CURRENT_DEVICE_ATTRIBUTE);
}
/**
@@ -94,7 +63,8 @@ public static Device getRequiredCurrentDevice(HttpServletRequest request) {
* @return the current device, or null if no device has been resolved for the request
*/
public static Device getCurrentDevice(RequestAttributes attributes) {
- return (Device) attributes.getAttribute(DeviceResolverHandlerInterceptor.CURRENT_DEVICE_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+ return (Device) attributes.getAttribute(CURRENT_DEVICE_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
}
-}
+
+}
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.springframework.mobile.device.mvc;
+package org.springframework.mobile.device;
import org.springframework.core.MethodParameter;
-import org.springframework.mobile.device.Device;
import org.springframework.web.bind.support.WebArgumentResolver;
import org.springframework.web.context.request.NativeWebRequest;
@@ -29,7 +28,7 @@
public Object resolveArgument(MethodParameter param, NativeWebRequest request) throws Exception {
if (Device.class.isAssignableFrom(param.getParameterType())) {
- return DeviceResolverHandlerInterceptor.getCurrentDevice(request);
+ return DeviceUtils.getCurrentDevice(request);
} else {
return WebArgumentResolver.UNRESOLVED;
}
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2010-2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.mobile.device.config;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +0,0 @@
-/**
- * Device resolver integration with Spring MVC.
- */
-package org.springframework.mobile.device.mvc;
-
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2010-2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.mobile.device.site;
import javax.servlet.http.HttpServletRequest;
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2010-2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.mobile.device.site;
import static org.springframework.mobile.device.site.SitePreferenceHandler.CURRENT_SITE_PREFERENCE_ATTRIBUTE;
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
import javax.servlet.http.HttpServletResponse;
import org.springframework.mobile.device.Device;
-import org.springframework.mobile.device.mvc.DeviceResolverHandlerInterceptor;
+import org.springframework.mobile.device.DeviceUtils;
/**
* A helper that resolves the user's site preference and makes it available as a request attribute.
@@ -51,7 +51,7 @@ public SitePreference handleSitePreference(HttpServletRequest request, HttpServl
preference = sitePreferenceRepository.loadSitePreference(request);
}
if (preference == null) {
- preference = getDefaultSitePreferenceForDevice(DeviceResolverHandlerInterceptor.getCurrentDevice(request));
+ preference = getDefaultSitePreferenceForDevice(DeviceUtils.getCurrentDevice(request));
}
if (preference != null) {
request.setAttribute(CURRENT_SITE_PREFERENCE_ATTRIBUTE, preference);
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
import javax.servlet.http.HttpServletResponse;
import org.springframework.mobile.device.Device;
-import org.springframework.mobile.device.mvc.DeviceResolverHandlerInterceptor;
+import org.springframework.mobile.device.DeviceUtils;
import org.springframework.mobile.device.site.CookieSitePreferenceRepository;
import org.springframework.mobile.device.site.SitePreference;
import org.springframework.mobile.device.site.SitePreferenceHandler;
@@ -71,7 +71,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
return false;
}
} else {
- Device device = DeviceResolverHandlerInterceptor.getRequiredCurrentDevice(request);
+ Device device = DeviceUtils.getRequiredCurrentDevice(request);
if (sitePreference == SitePreference.MOBILE || device.isMobile() && sitePreference == null) {
response.sendRedirect(response.encodeRedirectURL(mobileSiteUrlFactory.createSiteUrl(request)));
return false;
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 the original author or authors.
+ * Copyright 2010-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Oops, something went wrong.

0 comments on commit ddc7a49

Please sign in to comment.