Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MOBILE-59 Added sample demonstrating LiteDeviceDelegatingViewResolver

  • Loading branch information...
commit 5fbaf55c73ab663b5361ae232f6f52851fe31711 1 parent 14615b6
Roy Clarkson authored January 14, 2013

Showing 19 changed files with 590 additions and 3 deletions. Show diff stats Hide diff stats

  1. 27  lite-device-delegating-view-resolver/README.md
  2. 16  lite-device-delegating-view-resolver/pom.xml
  3. 41  lite-device-delegating-view-resolver/src/main/java/org/springframework/showcases/lite/AboutController.java
  4. 41  lite-device-delegating-view-resolver/src/main/java/org/springframework/showcases/lite/HomeController.java
  5. 29  ...evice-delegating-view-resolver/src/main/java/org/springframework/showcases/lite/config/ComponentConfig.java
  6. 73  lite-device-delegating-view-resolver/src/main/java/org/springframework/showcases/lite/config/WebConfig.java
  7. 41  lite-device-delegating-view-resolver/src/main/resources/log4j.xml
  8. 3  lite-device-delegating-view-resolver/src/main/webapp/META-INF/MANIFEST.MF
  9. 23  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/about.jsp
  10. 23  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/home.jsp
  11. 24  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/mobile/about.jsp
  12. 24  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/mobile/home.jsp
  13. 24  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/tablet/about.jsp
  14. 24  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/tablet/home.jsp
  15. 35  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/web.xml
  16. 48  lite-device-delegating-view-resolver/src/test/java/org/springframework/showcases/lite/AboutControllerTest.java
  17. 48  lite-device-delegating-view-resolver/src/test/java/org/springframework/showcases/lite/HomeControllerTest.java
  18. 41  lite-device-delegating-view-resolver/src/test/resources/log4j.xml
  19. 8  pom.xml
27  lite-device-delegating-view-resolver/README.md
Source Rendered
... ...
@@ -0,0 +1,27 @@
  1
+# Spring Mobile Lite Device Delegating View Resolver
  2
+
  3
+## Overview
  4
+
  5
+This sample app demonstrates many of the capabilities of the Spring Mobile Device module, including:
  6
+
  7
+* "Lite" device resolution through the use of DeviceResolverHandlerInterceptor 
  8
+* Site preference management
  9
+* View resolution with LiteDeviceDelegatingViewResolver
  10
+
  11
+## Build and Run the Sample Application
  12
+
  13
+1. Build the app:
  14
+
  15
+		$ mvn clean install
  16
+
  17
+2. Deploy the .war to a Servlet 2.5 or > ServletContainer. This can be done via Maven on the command-line by running:
  18
+
  19
+		$ mvn tomcat:run
  20
+
  21
+	_Note: Alternatively, you may import the project into your IDE and deploy to a Servlet 2.5 or > container such as Tomcat 6 or 7._
  22
+
  23
+3. Access the project at the following URL:
  24
+
  25
+		http://localhost:8080/lite-device-delegating-view-resolver
  26
+
  27
+	_Note: Accessing this URL from your browser versus an Android emulator or iOS simulator will demonstrate the functionality_
16  lite-device-delegating-view-resolver/pom.xml
... ...
@@ -0,0 +1,16 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  4
+	<modelVersion>4.0.0</modelVersion>
  5
+	
  6
+	<parent>
  7
+		<groupId>org.springframework.mobile</groupId>
  8
+		<artifactId>spring-mobile-samples</artifactId>
  9
+		<version>1.1.0-BUILD-SNAPSHOT</version>
  10
+	</parent>
  11
+
  12
+	<artifactId>lite-device-delegating-view-resolver</artifactId>
  13
+	<packaging>war</packaging>
  14
+	<name>lite-device-delegating-view-resolver</name>
  15
+
  16
+</project>
41  lite-device-delegating-view-resolver/src/main/java/org/springframework/showcases/lite/AboutController.java
... ...
@@ -0,0 +1,41 @@
  1
+/*
  2
+ * Copyright 2010-2013 the original author or authors.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package org.springframework.showcases.lite;
  18
+
  19
+import org.springframework.mobile.device.site.SitePreference;
  20
+import org.springframework.stereotype.Controller;
  21
+import org.springframework.ui.Model;
  22
+import org.springframework.web.bind.annotation.RequestMapping;
  23
+
  24
+/**
  25
+ * Handles requests for the About page.
  26
+ * @author Roy Clarkson
  27
+ */
  28
+@Controller
  29
+public class AboutController {
  30
+
  31
+	/**
  32
+	 * Show the About page to the user.
  33
+	 * Declares a {@link SitePreference} parameter to show how you can resolve the user's site preference.
  34
+	 * This controller renders a different version of the about view if the user has a mobile site preference.
  35
+	 */
  36
+	@RequestMapping("/about")
  37
+	public String home(SitePreference sitePreference, Model model) {
  38
+		return "about";
  39
+	}
  40
+
  41
+}
41  lite-device-delegating-view-resolver/src/main/java/org/springframework/showcases/lite/HomeController.java
... ...
@@ -0,0 +1,41 @@
  1
+/*
  2
+ * Copyright 2010-2013 the original author or authors.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package org.springframework.showcases.lite;
  18
+
  19
+import org.springframework.mobile.device.site.SitePreference;
  20
+import org.springframework.stereotype.Controller;
  21
+import org.springframework.ui.Model;
  22
+import org.springframework.web.bind.annotation.RequestMapping;
  23
+
  24
+/**
  25
+ * Handles requests for the Home page.
  26
+ * @author Roy Clarkson
  27
+ */
  28
+@Controller
  29
+public class HomeController {
  30
+
  31
+	/**
  32
+	 * Show the home page to the user.
  33
+	 * Declares a {@link SitePreference} parameter to show how you can resolve the user's site preference.
  34
+	 * This controller renders a different version of the home view if the user has a mobile site preference.
  35
+	 */
  36
+	@RequestMapping("/")
  37
+	public String home(SitePreference sitePreference, Model model) {
  38
+		return "home";
  39
+	}
  40
+
  41
+}
29  ...ce-delegating-view-resolver/src/main/java/org/springframework/showcases/lite/config/ComponentConfig.java
... ...
@@ -0,0 +1,29 @@
  1
+/*
  2
+ * Copyright 2010-2013 the original author or authors.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package org.springframework.showcases.lite.config;
  18
+
  19
+import org.springframework.context.annotation.ComponentScan;
  20
+import org.springframework.context.annotation.Configuration;
  21
+
  22
+/**
  23
+ * @author Roy Clarkson
  24
+ */
  25
+@Configuration
  26
+@ComponentScan(basePackages = "org.springframework.showcases.lite")
  27
+public class ComponentConfig {
  28
+
  29
+}
73  lite-device-delegating-view-resolver/src/main/java/org/springframework/showcases/lite/config/WebConfig.java
... ...
@@ -0,0 +1,73 @@
  1
+/*
  2
+ * Copyright 2010-2013 the original author or authors.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package org.springframework.showcases.lite.config;
  18
+
  19
+import java.util.List;
  20
+
  21
+import org.springframework.context.annotation.Bean;
  22
+import org.springframework.context.annotation.Configuration;
  23
+import org.springframework.mobile.device.DeviceResolverHandlerInterceptor;
  24
+import org.springframework.mobile.device.site.SitePreferenceHandlerInterceptor;
  25
+import org.springframework.mobile.device.site.SitePreferenceHandlerMethodArgumentResolver;
  26
+import org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver;
  27
+import org.springframework.web.method.support.HandlerMethodArgumentResolver;
  28
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  29
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
  30
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
  31
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  32
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  33
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
  34
+
  35
+/**
  36
+ * @author Roy Clarkson
  37
+ * @see WebMvcConfigurer
  38
+ */
  39
+@Configuration
  40
+@EnableWebMvc
  41
+public class WebConfig extends WebMvcConfigurerAdapter {
  42
+
  43
+	// implementing WebMvcConfigurer
  44
+
  45
+	public void addInterceptors(InterceptorRegistry registry) {
  46
+		registry.addInterceptor(new DeviceResolverHandlerInterceptor());
  47
+		registry.addInterceptor(new SitePreferenceHandlerInterceptor());
  48
+	}
  49
+
  50
+	public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
  51
+//		argumentResolvers.add(new DeviceHandlerMethodArgumentResolver());
  52
+		argumentResolvers.add(new SitePreferenceHandlerMethodArgumentResolver());
  53
+	}
  54
+
  55
+	public void addResourceHandlers(ResourceHandlerRegistry registry) {
  56
+		registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
  57
+	}
  58
+
  59
+	// additional webmvc-related beans
  60
+	
  61
+	@Bean
  62
+	public LiteDeviceDelegatingViewResolver liteDeviceAwareViewResolver() {
  63
+		InternalResourceViewResolver delegate = new InternalResourceViewResolver();
  64
+		delegate.setPrefix("/WEB-INF/views/");
  65
+		delegate.setSuffix(".jsp");
  66
+		LiteDeviceDelegatingViewResolver resolver = new LiteDeviceDelegatingViewResolver(delegate);
  67
+		resolver.setEnableFallback(true);
  68
+		resolver.setMobilePrefix("mobile/");
  69
+		resolver.setTabletPrefix("tablet/");
  70
+		return resolver;
  71
+	}
  72
+
  73
+}
41  lite-device-delegating-view-resolver/src/main/resources/log4j.xml
... ...
@@ -0,0 +1,41 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
  3
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
  4
+
  5
+	<!-- Appenders -->
  6
+	<appender name="console" class="org.apache.log4j.ConsoleAppender">
  7
+		<param name="Target" value="System.out" />
  8
+		<layout class="org.apache.log4j.PatternLayout">
  9
+			<param name="ConversionPattern" value="%-5p: %c - %m%n" />
  10
+		</layout>
  11
+	</appender>
  12
+	
  13
+	<!-- Application Loggers -->
  14
+	<logger name="org.springframework.showcases.lite">
  15
+		<level value="info" />
  16
+	</logger>
  17
+	
  18
+	<!-- 3rdparty Loggers -->
  19
+	<logger name="org.springframework.core">
  20
+		<level value="info" />
  21
+	</logger>	
  22
+	
  23
+	<logger name="org.springframework.beans">
  24
+		<level value="info" />
  25
+	</logger>
  26
+	
  27
+	<logger name="org.springframework.context">
  28
+		<level value="info" />
  29
+	</logger>
  30
+
  31
+	<logger name="org.springframework.web">
  32
+		<level value="info" />
  33
+	</logger>
  34
+
  35
+	<!-- Root Logger -->
  36
+	<root>
  37
+		<priority value="info" />
  38
+		<appender-ref ref="console" />
  39
+	</root>
  40
+	
  41
+</log4j:configuration>
3  lite-device-delegating-view-resolver/src/main/webapp/META-INF/MANIFEST.MF
... ...
@@ -0,0 +1,3 @@
  1
+Manifest-Version: 1.0
  2
+Class-Path: 
  3
+
23  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/about.jsp
... ...
@@ -0,0 +1,23 @@
  1
+<%@ page session="false" %>
  2
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3
+<!DOCTYPE html>
  4
+<html>
  5
+	<head>
  6
+		<title>Spring Mobile | Lite Device Aware View Resolver</title>
  7
+	</head>
  8
+	<body>
  9
+		<header>
  10
+			<h1>About (Normal Site)</h1>
  11
+		</header>
  12
+		<p>Return to the <a href="<c:url value="/" />">Home</a> page.</p>
  13
+		<footer>
  14
+			An Apache-licensed technology showcase by SpringSource.
  15
+		</footer>
  16
+		<aside id="site-preference">
  17
+			<p>Site: 
  18
+			<c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile | <a href="?site_preference=tablet">Tablet</a></c:if>
  19
+			<c:if test="${currentSitePreference.tablet}"><a href="?site_preference=normal">Normal</a> | <a href="?site_preference=mobile">Mobile</a> | Tablet</c:if>
  20
+			<c:if test="${currentSitePreference.normal}">Normal | <a href="?site_preference=mobile">Mobile</a> | <a href="?site_preference=tablet">Tablet</a></c:if>
  21
+		</aside>
  22
+	</body>
  23
+</html>
23  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/home.jsp
... ...
@@ -0,0 +1,23 @@
  1
+<%@ page session="false" %>
  2
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3
+<!DOCTYPE html>
  4
+<html>
  5
+	<head>
  6
+		<title>Spring Mobile | Lite Device Aware View Resolver</title>
  7
+	</head>
  8
+	<body>
  9
+		<header>
  10
+			<h1>Home (Normal Site)</h1>
  11
+		</header>
  12
+		<p>View the <a href="<c:url value="/about" />">About</a> page.</p>
  13
+		<footer>
  14
+			An Apache-licensed technology showcase by SpringSource.
  15
+		</footer>
  16
+		<aside id="site-preference">
  17
+			<p>Site: 
  18
+			<c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile | <a href="?site_preference=tablet">Tablet</a></c:if>
  19
+			<c:if test="${currentSitePreference.tablet}"><a href="?site_preference=normal">Normal</a> | <a href="?site_preference=mobile">Mobile</a> | Tablet</c:if>
  20
+			<c:if test="${currentSitePreference.normal}">Normal | <a href="?site_preference=mobile">Mobile</a> | <a href="?site_preference=tablet">Tablet</a></c:if>
  21
+		</aside>
  22
+	</body>
  23
+</html>
24  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/mobile/about.jsp
... ...
@@ -0,0 +1,24 @@
  1
+<%@ page session="false" %>
  2
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3
+<!DOCTYPE html>
  4
+<html>
  5
+	<head>
  6
+		<title>Spring Mobile | Lite Device Aware View Resolver</title>
  7
+		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  8
+	</head>
  9
+	<body>
  10
+		<header>
  11
+			<h1>About (Mobile Site)</h1>
  12
+		</header>
  13
+		<p>Return to the <a href="<c:url value="/" />">Home</a> page.</p>
  14
+		<footer>
  15
+			An Apache-licensed technology showcase by SpringSource.
  16
+		</footer>
  17
+		<aside id="site-preference">
  18
+			<p>Site: 
  19
+			<c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile | <a href="?site_preference=tablet">Tablet</a></c:if>
  20
+			<c:if test="${currentSitePreference.tablet}"><a href="?site_preference=normal">Normal</a> | <a href="?site_preference=mobile">Mobile</a> | Tablet</c:if>
  21
+			<c:if test="${currentSitePreference.normal}">Normal | <a href="?site_preference=mobile">Mobile</a> | <a href="?site_preference=tablet">Tablet</a></c:if>
  22
+		</aside>
  23
+	</body>
  24
+</html>
24  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/mobile/home.jsp
... ...
@@ -0,0 +1,24 @@
  1
+<%@ page session="false" %>
  2
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3
+<!DOCTYPE html>
  4
+<html>
  5
+	<head>
  6
+		<title>Spring Mobile | Lite Device Aware View Resolver</title>
  7
+		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  8
+	</head>
  9
+	<body>
  10
+		<header>
  11
+			<h1>Home (Mobile Site)</h1>
  12
+		</header>
  13
+		<p>View the <a href="<c:url value="/about" />">About</a> page.</p>
  14
+		<footer>
  15
+			An Apache-licensed technology showcase by SpringSource.
  16
+		</footer>
  17
+		<aside id="site-preference">
  18
+			<p>Site: 
  19
+			<c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile | <a href="?site_preference=tablet">Tablet</a></c:if>
  20
+			<c:if test="${currentSitePreference.tablet}"><a href="?site_preference=normal">Normal</a> | <a href="?site_preference=mobile">Mobile</a> | Tablet</c:if>
  21
+			<c:if test="${currentSitePreference.normal}">Normal | <a href="?site_preference=mobile">Mobile</a> | <a href="?site_preference=tablet">Tablet</a></c:if>
  22
+		</aside>
  23
+	</body>
  24
+</html>
24  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/tablet/about.jsp
... ...
@@ -0,0 +1,24 @@
  1
+<%@ page session="false" %>
  2
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3
+<!DOCTYPE html>
  4
+<html>
  5
+	<head>
  6
+		<title>Spring Mobile | Lite Device Aware View Resolver</title>
  7
+		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  8
+	</head>
  9
+	<body>
  10
+		<header>
  11
+			<h1>About (Tablet Site)</h1>
  12
+		</header>
  13
+		<p>Return to the <a href="<c:url value="/" />">Home</a> page.</p>
  14
+		<footer>
  15
+			An Apache-licensed technology showcase by SpringSource.
  16
+		</footer>
  17
+		<aside id="site-preference">
  18
+			<p>Site: 
  19
+			<c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile | <a href="?site_preference=tablet">Tablet</a></c:if>
  20
+			<c:if test="${currentSitePreference.tablet}"><a href="?site_preference=normal">Normal</a> | <a href="?site_preference=mobile">Mobile</a> | Tablet</c:if>
  21
+			<c:if test="${currentSitePreference.normal}">Normal | <a href="?site_preference=mobile">Mobile</a> | <a href="?site_preference=tablet">Tablet</a></c:if>
  22
+		</aside>
  23
+	</body>
  24
+</html>
24  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/tablet/home.jsp
... ...
@@ -0,0 +1,24 @@
  1
+<%@ page session="false" %>
  2
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3
+<!DOCTYPE html>
  4
+<html>
  5
+	<head>
  6
+		<title>Spring Mobile | Lite Device Aware View Resolver</title>
  7
+		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  8
+	</head>
  9
+	<body>
  10
+		<header>
  11
+			<h1>Home (Tablet Site)</h1>
  12
+		</header>
  13
+		<p>View the <a href="<c:url value="/about" />">About</a> page.</p>
  14
+		<footer>
  15
+			An Apache-licensed technology showcase by SpringSource.
  16
+		</footer>
  17
+		<aside id="site-preference">
  18
+			<p>Site: 
  19
+			<c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile | <a href="?site_preference=tablet">Tablet</a></c:if>
  20
+			<c:if test="${currentSitePreference.tablet}"><a href="?site_preference=normal">Normal</a> | <a href="?site_preference=mobile">Mobile</a> | Tablet</c:if>
  21
+			<c:if test="${currentSitePreference.normal}">Normal | <a href="?site_preference=mobile">Mobile</a> | <a href="?site_preference=tablet">Tablet</a></c:if>
  22
+		</aside>
  23
+	</body>
  24
+</html>
35  lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/web.xml
... ...
@@ -0,0 +1,35 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
  3
+  <context-param>
  4
+    <param-name>contextClass</param-name>
  5
+    <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
  6
+  </context-param>
  7
+  <context-param>
  8
+    <param-name>contextConfigLocation</param-name>
  9
+    <param-value>org.springframework.showcases.lite.config</param-value>
  10
+  </context-param>
  11
+  <context-param>
  12
+    <param-name>spring.profiles.default</param-name>
  13
+    <param-value>simple</param-value>
  14
+  </context-param>
  15
+  <listener>
  16
+    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  17
+  </listener>
  18
+  <servlet>
  19
+    <servlet-name>appServlet</servlet-name>
  20
+    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  21
+    <init-param>
  22
+      <param-name>contextConfigLocation</param-name>
  23
+      <param-value></param-value>
  24
+    </init-param>
  25
+    <init-param>
  26
+      <param-name>spring.profiles.default</param-name>
  27
+      <param-value>simple</param-value>
  28
+    </init-param>
  29
+    <load-on-startup>1</load-on-startup>
  30
+  </servlet>
  31
+  <servlet-mapping>
  32
+    <servlet-name>appServlet</servlet-name>
  33
+    <url-pattern>/</url-pattern>
  34
+  </servlet-mapping>
  35
+</web-app>
48  ...evice-delegating-view-resolver/src/test/java/org/springframework/showcases/lite/AboutControllerTest.java
... ...
@@ -0,0 +1,48 @@
  1
+/*
  2
+ * Copyright 2010-2013 the original author or authors.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package org.springframework.showcases.lite;
  18
+
  19
+import static org.junit.Assert.assertEquals;
  20
+
  21
+import org.junit.Test;
  22
+import org.springframework.mobile.device.site.SitePreference;
  23
+import org.springframework.ui.ExtendedModelMap;
  24
+import org.springframework.ui.Model;
  25
+
  26
+public class AboutControllerTest {
  27
+
  28
+	private AboutController controller = new AboutController();
  29
+
  30
+	@Test
  31
+	public void homePageMobileSitePreference() {
  32
+		Model model = new ExtendedModelMap();
  33
+		assertEquals("about", controller.home(SitePreference.MOBILE, model));
  34
+	}
  35
+	
  36
+	@Test
  37
+	public void homePageTabletSitePreference() {
  38
+		Model model = new ExtendedModelMap();
  39
+		assertEquals("about", controller.home(SitePreference.TABLET, model));
  40
+	}
  41
+
  42
+	@Test
  43
+	public void homePageNormalSitePreference() {
  44
+		Model model = new ExtendedModelMap();
  45
+		assertEquals("about", controller.home(SitePreference.NORMAL, model));
  46
+	}
  47
+
  48
+}
48  ...device-delegating-view-resolver/src/test/java/org/springframework/showcases/lite/HomeControllerTest.java
... ...
@@ -0,0 +1,48 @@
  1
+/*
  2
+ * Copyright 2010-2013 the original author or authors.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package org.springframework.showcases.lite;
  18
+
  19
+import static org.junit.Assert.assertEquals;
  20
+
  21
+import org.junit.Test;
  22
+import org.springframework.mobile.device.site.SitePreference;
  23
+import org.springframework.ui.ExtendedModelMap;
  24
+import org.springframework.ui.Model;
  25
+
  26
+public class HomeControllerTest {
  27
+
  28
+	private HomeController controller = new HomeController();
  29
+
  30
+	@Test
  31
+	public void homePageMobileSitePreference() {
  32
+		Model model = new ExtendedModelMap();
  33
+		assertEquals("home", controller.home(SitePreference.MOBILE, model));
  34
+	}
  35
+	
  36
+	@Test
  37
+	public void homePageTabletSitePreference() {
  38
+		Model model = new ExtendedModelMap();
  39
+		assertEquals("home", controller.home(SitePreference.TABLET, model));
  40
+	}
  41
+
  42
+	@Test
  43
+	public void homePageNormalSitePreference() {
  44
+		Model model = new ExtendedModelMap();
  45
+		assertEquals("home", controller.home(SitePreference.NORMAL, model));
  46
+	}
  47
+
  48
+}
41  lite-device-delegating-view-resolver/src/test/resources/log4j.xml
... ...
@@ -0,0 +1,41 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
  3
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
  4
+
  5
+	<!-- Appenders -->
  6
+	<appender name="console" class="org.apache.log4j.ConsoleAppender">
  7
+		<param name="Target" value="System.out" />
  8
+		<layout class="org.apache.log4j.PatternLayout">
  9
+			<param name="ConversionPattern" value="%-5p: %c - %m%n" />
  10
+		</layout>
  11
+	</appender>
  12
+	
  13
+	<!-- Application Loggers -->
  14
+	<logger name="org.springframework.showcases.lite">
  15
+		<level value="debug" />
  16
+	</logger>
  17
+	
  18
+	<!-- 3rdparty Loggers -->
  19
+	<logger name="org.springframework.core">
  20
+		<level value="info" />
  21
+	</logger>	
  22
+	
  23
+	<logger name="org.springframework.beans">
  24
+		<level value="info" />
  25
+	</logger>
  26
+
  27
+	<logger name="org.springframework.context">
  28
+		<level value="info" />
  29
+	</logger>
  30
+
  31
+	<logger name="org.springframework.web">
  32
+		<level value="info" />
  33
+	</logger>
  34
+	
  35
+	<!-- Root Logger -->
  36
+	<root>
  37
+		<priority value="warn" />
  38
+		<appender-ref ref="console" />
  39
+	</root>
  40
+	
  41
+</log4j:configuration>
8  pom.xml
@@ -10,6 +10,7 @@
10 10
 	<name>spring-mobile-samples</name>
11 11
 	<url>http://www.springsource.org</url>
12 12
 	<description>Demonstration of Spring Mobile's lightweight server-side device detection and site switching functionality</description>
  13
+	<inceptionYear>2010</inceptionYear>
13 14
 	<organization>
14 15
 		<name>SpringSource</name>
15 16
 		<url>http://www.springsource.org</url>
@@ -19,13 +20,14 @@
19 20
 		<module>/lite-device-resolver</module>
20 21
 		<module>/lite-site-preference-handler</module>
21 22
 		<module>/lite-site-switcher-handler</module>
  23
+		<module>/lite-device-delegating-view-resolver</module>
22 24
 		<module>/lite-showcase</module>
23 25
 	</modules>
24 26
 
25 27
 	<properties>
26 28
 		<java-version>1.6</java-version>
27  
-		<org.springframework-version>3.1.3.RELEASE</org.springframework-version>
28  
-		<org.springframework.mobile-version>1.1.0.M1</org.springframework.mobile-version>
  29
+		<org.springframework-version>3.2.0.RELEASE</org.springframework-version>
  30
+		<org.springframework.mobile-version>1.1.0.BUILD-SNAPSHOT</org.springframework.mobile-version>
29 31
 		<org.aspectj-version>1.6.9</org.aspectj-version>
30 32
 		<org.slf4j-version>1.6.1</org.slf4j-version>
31 33
 		<log4j-version>1.2.16</log4j-version>
@@ -33,7 +35,7 @@
33 35
 		<javax.servlet.jsp-version>2.1</javax.servlet.jsp-version>
34 36
 		<javax.servlet.jstl-version>1.2</javax.servlet.jstl-version>
35 37
 		<junit-version>4.9</junit-version>
36  
-		<org.apache.maven.plugins.compiler-version>2.5.1</org.apache.maven.plugins.compiler-version>
  38
+		<org.apache.maven.plugins.compiler-version>3.0</org.apache.maven.plugins.compiler-version>
37 39
 		<org.codehaus.mojo.aspectj-version>1.4</org.codehaus.mojo.aspectj-version>
38 40
 		<org.codehaus.mojo.tomcat-version>1.1</org.codehaus.mojo.tomcat-version>
39 41
 	</properties>

0 notes on commit 5fbaf55

Please sign in to comment.
Something went wrong with that request. Please try again.