Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated samples for Spring Mobile 1.0.0.RC2

  • Loading branch information...
commit 0a2e46bf13160f7f25606c53b3e1a0f5472d4f3e 1 parent 297e4d0
@royclarkson royclarkson authored
Showing with 1,143 additions and 21 deletions.
  1. +6 −2 README.md
  2. +3 −3 {lite-showcase → lite-filter-mdot}/README.md
  3. +9 −10 {lite-showcase → lite-filter-mdot}/pom.xml
  4. 0  {lite-showcase → lite-filter-mdot}/src/main/java/org/springframework/showcases/lite/HomeController.java
  5. 0  {lite-showcase → lite-filter-mdot}/src/main/resources/log4j.xml
  6. +3 −0  lite-filter-mdot/src/main/webapp/META-INF/MANIFEST.MF
  7. 0  {lite-showcase → lite-filter-mdot}/src/main/webapp/WEB-INF/spring/appServlet/controllers.xml
  8. +40 −0 lite-filter-mdot/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
  9. 0  {lite-showcase → lite-filter-mdot}/src/main/webapp/WEB-INF/views/home-mobile.jsp
  10. 0  {lite-showcase → lite-filter-mdot}/src/main/webapp/WEB-INF/views/home.jsp
  11. +3 −6 {lite-showcase → lite-filter-mdot}/src/main/webapp/WEB-INF/web.xml
  12. 0  ...-showcase → lite-filter-mdot}/src/test/java/org/springframework/showcases/lite/HomeControllerTest.java
  13. 0  {lite-showcase → lite-filter-mdot}/src/test/resources/log4j.xml
  14. +34 −0 lite-interceptor-mdot/README.md
  15. +213 −0 lite-interceptor-mdot/pom.xml
  16. +44 −0 lite-interceptor-mdot/src/main/java/org/springframework/showcases/lite/HomeController.java
  17. +41 −0 lite-interceptor-mdot/src/main/resources/log4j.xml
  18. +3 −0  lite-interceptor-mdot/src/main/webapp/META-INF/MANIFEST.MF
  19. +13 −0 lite-interceptor-mdot/src/main/webapp/WEB-INF/spring/appServlet/controllers.xml
  20. 0  {lite-showcase → lite-interceptor-mdot}/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
  21. +20 −0 lite-interceptor-mdot/src/main/webapp/WEB-INF/views/home-mobile.jsp
  22. +19 −0 lite-interceptor-mdot/src/main/webapp/WEB-INF/views/home.jsp
  23. +19 −0 lite-interceptor-mdot/src/main/webapp/WEB-INF/web.xml
  24. +26 −0 lite-interceptor-mdot/src/test/java/org/springframework/showcases/lite/HomeControllerTest.java
  25. +41 −0 lite-interceptor-mdot/src/test/resources/log4j.xml
  26. +27 −0 lite-interceptor-urlpath/README.md
  27. +213 −0 lite-interceptor-urlpath/pom.xml
  28. +44 −0 lite-interceptor-urlpath/src/main/java/org/springframework/showcases/lite/AboutController.java
  29. +44 −0 lite-interceptor-urlpath/src/main/java/org/springframework/showcases/lite/HomeController.java
  30. +41 −0 lite-interceptor-urlpath/src/main/resources/log4j.xml
  31. +3 −0  lite-interceptor-urlpath/src/main/webapp/META-INF/MANIFEST.MF
  32. +13 −0 lite-interceptor-urlpath/src/main/webapp/WEB-INF/spring/appServlet/controllers.xml
  33. +44 −0 lite-interceptor-urlpath/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
  34. +23 −0 lite-interceptor-urlpath/src/main/webapp/WEB-INF/views/about-mobile.jsp
  35. +22 −0 lite-interceptor-urlpath/src/main/webapp/WEB-INF/views/about.jsp
  36. +23 −0 lite-interceptor-urlpath/src/main/webapp/WEB-INF/views/home-mobile.jsp
  37. +22 −0 lite-interceptor-urlpath/src/main/webapp/WEB-INF/views/home.jsp
  38. +20 −0 lite-interceptor-urlpath/src/main/webapp/WEB-INF/web.xml
  39. +26 −0 lite-interceptor-urlpath/src/test/java/org/springframework/showcases/lite/HomeControllerTest.java
  40. +41 −0 lite-interceptor-urlpath/src/test/resources/log4j.xml
View
8 README.md
@@ -6,9 +6,13 @@ This repository contains sample projects illustrating usage of the [Spring Mobil
## Sample Apps
-See the README in each directory for more information on the sample project and additional instructions.
+The following "lite" sample apps demonstrate the capabilities of the Spring Mobile LiteDeviceResolver for server-side device detection. See the README in each directory for more information on the sample project and additional instructions.
-* lite-showcase - demonstrating the capabilities of the Spring Mobile "Lite" DeviceResolver for server-side device detection.
+* lite-filter-mdot - configured with the DeviceResolverHandlerFilter, a Servlet Filter, for device resolution, and the mDot site switching strategy.
+
+* lite-interceptor-mdot - configured with the DeviceResolverHandlerInterceptor for device resolution, and the mDot site switching strategy.
+
+* lite-interceptor-urlpath - configured with the DeviceResolverHandlerInterceptor for device resolution, and the urlPath site switching strategy.
## Additional Resources
View
6 lite-showcase/README.md → lite-filter-mdot/README.md
@@ -4,9 +4,9 @@
This sample app demonstrates many of the capabilities of the Spring Mobile Device module, including:
-* "Lite" device resolution
+* "Lite" device resolution through the use of the DeviceResolverHandlerFilter
* Site preference management
-* Site switching
+* Site switching configured for the mDot strategy
## Build and Run the Sample Application
@@ -22,7 +22,7 @@ This sample app demonstrates many of the capabilities of the Spring Mobile Devic
3. Access the project at the following URL:
- http://localhost:8080/lite-showcase
+ http://localhost:8080/lite-filter-mdot
_Note: Accessing this URL from your browser versus an Android emulator or iOS simulator will demonstrate the functionality_
View
19 lite-showcase/pom.xml → lite-filter-mdot/pom.xml
@@ -4,10 +4,10 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.mobile</groupId>
- <artifactId>lite-showcase</artifactId>
+ <artifactId>lite-filter-mdot</artifactId>
<version>1.0.0-BUILD-SNAPSHOT</version>
<packaging>war</packaging>
- <name>lite-showcase</name>
+ <name>lite-filter-mdot</name>
<url>http://www.springsource.org</url>
<description>Demonstration of Spring Mobile's lightweight server-side device detection and site switching functionality</description>
<organization>
@@ -18,7 +18,7 @@
<properties>
<java-version>1.6</java-version>
<org.springframework-version>3.1.1.RELEASE</org.springframework-version>
- <org.springframework.mobile-version>1.0.0.BUILD-SNAPSHOT</org.springframework.mobile-version>
+ <org.springframework.mobile-version>1.0.0.RC2</org.springframework.mobile-version>
<org.aspectj-version>1.6.9</org.aspectj-version>
<org.slf4j-version>1.6.1</org.slf4j-version>
<log4j-version>1.2.16</log4j-version>
@@ -189,9 +189,9 @@
<repositories>
<!-- For testing against latest Spring snapshots -->
<repository>
- <id>org.springframework.maven.snapshot</id>
- <name>Spring Maven Snapshot Repository</name>
- <url>http://repo.springframework.org/snapshot</url>
+ <id>spring-snapshot</id>
+ <name>SpringSource Snapshot Repository</name>
+ <url>http://repo.springsource.org/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
@@ -201,14 +201,13 @@
</repository>
<!-- For developing against latest Spring milestones -->
<repository>
- <id>org.springframework.maven.milestone</id>
- <name>Spring Maven Milestone Repository</name>
- <url>http://repo.springframework.org/milestone</url>
+ <id>spring-milestone</id>
+ <name>SpringSource Milestone Repository</name>
+ <url>http://repo.springsource.org/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
-
</repositories>
</project>
View
0  ...mework/showcases/lite/HomeController.java → ...mework/showcases/lite/HomeController.java
File renamed without changes
View
0  lite-showcase/src/main/resources/log4j.xml → ...-filter-mdot/src/main/resources/log4j.xml
File renamed without changes
View
3  lite-filter-mdot/src/main/webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
View
0  ...WEB-INF/spring/appServlet/controllers.xml → ...WEB-INF/spring/appServlet/controllers.xml
File renamed without changes
View
40 lite-filter-mdot/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:beans xmlns="http://www.springframework.org/schema/mvc"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xmlns:device="http://www.springframework.org/schema/mobile/device"
+ xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/mobile/device http://www.springframework.org/schema/mobile/device/spring-mobile-device-1.0.xsd">
+
+ <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
+
+ <!-- Configures the Spring MVC @Controller programming model -->
+ <annotation-driven>
+ <argument-resolvers>
+ <beans:bean class="org.springframework.mobile.device.site.SitePreferenceWebArgumentResolver" />
+ </argument-resolvers>
+ </annotation-driven>
+
+ <!-- Interceptors that execute common control logic across multiple requests -->
+ <interceptors>
+
+ <!-- Redirects the client to their preferred site if necessary.
+ This particular configuration redirects clients preferring the mobile site to 'm.testdomain'.
+ NOTE: for this redirect to work testdomain.com and m.testdomain.com must be added to your hosts file when running the app -->
+ <beans:bean class="org.springframework.mobile.device.switcher.SiteSwitcherHandlerInterceptor" factory-method="mDot">
+ <beans:constructor-arg value="testdomain.com" />
+ </beans:bean>
+
+ </interceptors>
+
+ <!-- Maps view names to JSP templates in /WEB-INF/views -->
+ <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
+ <beans:property name="prefix" value="/WEB-INF/views/" />
+ <beans:property name="suffix" value=".jsp" />
+ </beans:bean>
+
+ <!-- Imports the application controllers that process client requests -->
+ <beans:import resource="controllers.xml" />
+
+</beans:beans>
View
0  ...main/webapp/WEB-INF/views/home-mobile.jsp → ...main/webapp/WEB-INF/views/home-mobile.jsp
File renamed without changes
View
0  ...se/src/main/webapp/WEB-INF/views/home.jsp → ...ot/src/main/webapp/WEB-INF/views/home.jsp
File renamed without changes
View
9 ...-showcase/src/main/webapp/WEB-INF/web.xml → ...lter-mdot/src/main/webapp/WEB-INF/web.xml
@@ -16,10 +16,8 @@
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
-
- <!-- Disable the DeviceResolverHandlerInterceptor in servlet-context.xml to use this filter -->
+
<!-- Detects the client's Device -->
- <!--
<filter>
<filter-name>deviceResolverHandlerFilter</filter-name>
<filter-class>org.springframework.mobile.device.DeviceResolverHandlerFilter</filter-class>
@@ -28,7 +26,6 @@
<filter-mapping>
<filter-name>deviceResolverHandlerFilter</filter-name>
<servlet-name>appServlet</servlet-name>
- </filter-mapping>
- -->
-
+ </filter-mapping>
+
</web-app>
View
0  ...rk/showcases/lite/HomeControllerTest.java → ...rk/showcases/lite/HomeControllerTest.java
File renamed without changes
View
0  lite-showcase/src/test/resources/log4j.xml → ...-filter-mdot/src/test/resources/log4j.xml
File renamed without changes
View
34 lite-interceptor-mdot/README.md
@@ -0,0 +1,34 @@
+# Spring Mobile Lite Showcase
+
+## Overview
+
+This sample app demonstrates many of the capabilities of the Spring Mobile Device module, including:
+
+* "Lite" device resolution through the use of DeviceResolverHandlerInterceptor
+* Site preference management
+* Site switching configured for the mDot strategy
+
+## Build and Run the Sample Application
+
+1. Build the app:
+
+ $ mvn clean install
+
+2. Deploy the .war to a Servlet 2.5 or > ServletContainer. This can be done via Maven on the command-line by running:
+
+ $ mvn tomcat:run
+
+ _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._
+
+3. Access the project at the following URL:
+
+ http://localhost:8080/lite-interceptor-mdot
+
+ _Note: Accessing this URL from your browser versus an Android emulator or iOS simulator will demonstrate the functionality_
+
+## Configure your Hosts file
+
+In order for the site switcher demonstration to work in a local test environment, you will need to add the following to your hosts file; for example, /etc/hosts on Unix and OS X systems:
+
+ 127.0.0.1 testdomain.com
+ 127.0.0.1 m.testdomain.com
View
213 lite-interceptor-mdot/pom.xml
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.springframework.mobile</groupId>
+ <artifactId>lite-interceptor-mdot</artifactId>
+ <version>1.0.0-BUILD-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <name>lite-interceptor-mdot</name>
+ <url>http://www.springsource.org</url>
+ <description>Demonstration of Spring Mobile's lightweight server-side device detection and site switching functionality</description>
+ <organization>
+ <name>SpringSource</name>
+ <url>http://www.springsource.org</url>
+ </organization>
+
+ <properties>
+ <java-version>1.6</java-version>
+ <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
+ <org.springframework.mobile-version>1.0.0.RC2</org.springframework.mobile-version>
+ <org.aspectj-version>1.6.9</org.aspectj-version>
+ <org.slf4j-version>1.6.1</org.slf4j-version>
+ <log4j-version>1.2.16</log4j-version>
+ <javax.servlet.api-version>2.5</javax.servlet.api-version>
+ <javax.servlet.jsp-version>2.1</javax.servlet.jsp-version>
+ <javax.servlet.jstl-version>1.2</javax.servlet.jstl-version>
+ <junit-version>4.9</junit-version>
+ <org.apache.maven.plugins.compiler-version>2.3.2</org.apache.maven.plugins.compiler-version>
+ <org.codehaus.mojo.aspectj-version>1.4</org.codehaus.mojo.aspectj-version>
+ <org.codehaus.mojo.tomcat-version>1.1</org.codehaus.mojo.tomcat-version>
+ </properties>
+
+ <dependencies>
+ <!-- Spring -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${org.springframework-version}</version>
+ <exclusions>
+ <!-- Exclude Commons Logging in favor of SLF4j -->
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>${org.springframework-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.mobile</groupId>
+ <artifactId>spring-mobile-device</artifactId>
+ <version>${org.springframework.mobile-version}</version>
+ </dependency>
+
+ <!-- Aspect J -->
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>${org.aspectj-version}</version>
+ </dependency>
+
+ <!-- @Inject -->
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+
+ <!-- Logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${org.slf4j-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>${org.slf4j-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${org.slf4j-version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j-version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- Servlet -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>${javax.servlet.api-version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>${javax.servlet.jsp-version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>${javax.servlet.jstl-version}</version>
+ </dependency>
+
+ <!-- Test -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit-version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${org.apache.maven.plugins.compiler-version}</version>
+ <configuration>
+ <source>${java-version}</source>
+ <target>${java-version}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>aspectj-maven-plugin</artifactId>
+ <version>${org.codehaus.mojo.aspectj-version}</version>
+ <dependencies>
+ <!-- NB: You must use Maven 2.0.9 or above or these are ignored (see
+ MNG-2972) -->
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>${org.aspectj-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjtools</artifactId>
+ <version>${org.aspectj-version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>test-compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <outxml>true</outxml>
+ <source>${java-version}</source>
+ <target>${java-version}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>install</id>
+ <phase>install</phase>
+ <goals>
+ <goal>sources</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>tomcat-maven-plugin</artifactId>
+ <version>${org.codehaus.mojo.tomcat-version}</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <!-- For testing against latest Spring snapshots -->
+ <repository>
+ <id>spring-snapshot</id>
+ <name>SpringSource Snapshot Repository</name>
+ <url>http://repo.springsource.org/snapshot</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <!-- For developing against latest Spring milestones -->
+ <repository>
+ <id>spring-milestone</id>
+ <name>SpringSource Milestone Repository</name>
+ <url>http://repo.springsource.org/milestone</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+</project>
View
44 lite-interceptor-mdot/src/main/java/org/springframework/showcases/lite/HomeController.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2010 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.showcases.lite;
+
+import org.springframework.mobile.device.site.SitePreference;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Handles requests for the showcase application.
+ * @author Keith Donald
+ */
+@Controller
+public class HomeController {
+
+ /**
+ * Show the home page to the user.
+ * Declares a {@link SitePreference} parameter to show how you can resolve the user's site preference.
+ * This controller renders a different version of the home view if the user has a mobile site preference.
+ */
+ @RequestMapping("/")
+ public String home(SitePreference sitePreference, Model model) {
+ if (sitePreference == SitePreference.MOBILE) {
+ return "home-mobile";
+ } else {
+ return "home";
+ }
+ }
+
+}
View
41 lite-interceptor-mdot/src/main/resources/log4j.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Appenders -->
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p: %c - %m%n" />
+ </layout>
+ </appender>
+
+ <!-- Application Loggers -->
+ <logger name="org.springframework.showcases.lite">
+ <level value="info" />
+ </logger>
+
+ <!-- 3rdparty Loggers -->
+ <logger name="org.springframework.core">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.beans">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.context">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.web">
+ <level value="info" />
+ </logger>
+
+ <!-- Root Logger -->
+ <root>
+ <priority value="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
View
3  lite-interceptor-mdot/src/main/webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
View
13 lite-interceptor-mdot/src/main/webapp/WEB-INF/spring/appServlet/controllers.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:mvc="http://www.springframework.org/schema/mvc"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
+ http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
+
+ <context:component-scan base-package="org.springframework.showcases.lite" />
+
+</beans>
View
0  ...INF/spring/appServlet/servlet-context.xml → ...INF/spring/appServlet/servlet-context.xml
File renamed without changes
View
20 lite-interceptor-mdot/src/main/webapp/WEB-INF/views/home-mobile.jsp
@@ -0,0 +1,20 @@
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Spring Mobile | Lite Showcase</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
+ </head>
+ <body>
+ <header>
+ <h1>Mobile Site</h1>
+ </header>
+ <footer>
+ An Apache-licensed technology showcase by SpringSource.
+ </footer>
+ <aside id="site-switcher">
+ <p>Site: <c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile</c:if><c:if test="${!currentSitePreference.mobile}">Normal | <a href="?site_preference=mobile">Mobile</a></c:if></p>
+ </aside>
+ </body>
+</html>
View
19 lite-interceptor-mdot/src/main/webapp/WEB-INF/views/home.jsp
@@ -0,0 +1,19 @@
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Spring Mobile | Lite Showcase</title>
+ </head>
+ <body>
+ <header>
+ <h1>Normal Site</h1>
+ </header>
+ <footer>
+ An Apache-licensed technology showcase by SpringSource.
+ </footer>
+ <aside id="site-switcher">
+ <p>Site: <c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile</c:if><c:if test="${!currentSitePreference.mobile}">Normal | <a href="?site_preference=mobile">Mobile</a></c:if></p>
+ </aside>
+ </body>
+</html>
View
19 lite-interceptor-mdot/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+ <servlet>
+ <servlet-name>appServlet</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ <init-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>appServlet</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+</web-app>
View
26 ...interceptor-mdot/src/test/java/org/springframework/showcases/lite/HomeControllerTest.java
@@ -0,0 +1,26 @@
+package org.springframework.showcases.lite;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.springframework.mobile.device.site.SitePreference;
+import org.springframework.ui.ExtendedModelMap;
+import org.springframework.ui.Model;
+
+public class HomeControllerTest {
+
+ private HomeController controller = new HomeController();
+
+ @Test
+ public void homePageMobileSitePreference() {
+ Model model = new ExtendedModelMap();
+ assertEquals("home-mobile", controller.home(SitePreference.MOBILE, model));
+ }
+
+ @Test
+ public void homePageNormalSitePreference() {
+ Model model = new ExtendedModelMap();
+ assertEquals("home", controller.home(SitePreference.NORMAL, model));
+ }
+
+}
View
41 lite-interceptor-mdot/src/test/resources/log4j.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Appenders -->
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p: %c - %m%n" />
+ </layout>
+ </appender>
+
+ <!-- Application Loggers -->
+ <logger name="org.springframework.showcases.lite">
+ <level value="debug" />
+ </logger>
+
+ <!-- 3rdparty Loggers -->
+ <logger name="org.springframework.core">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.beans">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.context">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.web">
+ <level value="info" />
+ </logger>
+
+ <!-- Root Logger -->
+ <root>
+ <priority value="warn" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
View
27 lite-interceptor-urlpath/README.md
@@ -0,0 +1,27 @@
+# Spring Mobile Lite Showcase
+
+## Overview
+
+This sample app demonstrates many of the capabilities of the Spring Mobile Device module, including:
+
+* "Lite" device resolution through the use of DeviceResolverHandlerInterceptor
+* Site preference management
+* Site switching configured for the URL Path strategy
+
+## Build and Run the Sample Application
+
+1. Build the app:
+
+ $ mvn clean install
+
+2. Deploy the .war to a Servlet 2.5 or > ServletContainer. This can be done via Maven on the command-line by running:
+
+ $ mvn tomcat:run
+
+ _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._
+
+3. Access the project at the following URL:
+
+ http://localhost:8080/lite-interceptor-urlpath
+
+ _Note: Accessing this URL from your browser versus an Android emulator or iOS simulator will demonstrate the functionality_
View
213 lite-interceptor-urlpath/pom.xml
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.springframework.mobile</groupId>
+ <artifactId>lite-interceptor-urlpath</artifactId>
+ <version>1.0.0-BUILD-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <name>lite-interceptor-urlpath</name>
+ <url>http://www.springsource.org</url>
+ <description>Demonstration of Spring Mobile's lightweight server-side device detection and site switching functionality</description>
+ <organization>
+ <name>SpringSource</name>
+ <url>http://www.springsource.org</url>
+ </organization>
+
+ <properties>
+ <java-version>1.6</java-version>
+ <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
+ <org.springframework.mobile-version>1.0.0.RC2</org.springframework.mobile-version>
+ <org.aspectj-version>1.6.9</org.aspectj-version>
+ <org.slf4j-version>1.6.1</org.slf4j-version>
+ <log4j-version>1.2.16</log4j-version>
+ <javax.servlet.api-version>2.5</javax.servlet.api-version>
+ <javax.servlet.jsp-version>2.1</javax.servlet.jsp-version>
+ <javax.servlet.jstl-version>1.2</javax.servlet.jstl-version>
+ <junit-version>4.9</junit-version>
+ <org.apache.maven.plugins.compiler-version>2.3.2</org.apache.maven.plugins.compiler-version>
+ <org.codehaus.mojo.aspectj-version>1.4</org.codehaus.mojo.aspectj-version>
+ <org.codehaus.mojo.tomcat-version>1.1</org.codehaus.mojo.tomcat-version>
+ </properties>
+
+ <dependencies>
+ <!-- Spring -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${org.springframework-version}</version>
+ <exclusions>
+ <!-- Exclude Commons Logging in favor of SLF4j -->
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>${org.springframework-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.mobile</groupId>
+ <artifactId>spring-mobile-device</artifactId>
+ <version>${org.springframework.mobile-version}</version>
+ </dependency>
+
+ <!-- Aspect J -->
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>${org.aspectj-version}</version>
+ </dependency>
+
+ <!-- @Inject -->
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+
+ <!-- Logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${org.slf4j-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>${org.slf4j-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${org.slf4j-version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j-version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <!-- Servlet -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>${javax.servlet.api-version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>${javax.servlet.jsp-version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>${javax.servlet.jstl-version}</version>
+ </dependency>
+
+ <!-- Test -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit-version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${org.apache.maven.plugins.compiler-version}</version>
+ <configuration>
+ <source>${java-version}</source>
+ <target>${java-version}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>aspectj-maven-plugin</artifactId>
+ <version>${org.codehaus.mojo.aspectj-version}</version>
+ <dependencies>
+ <!-- NB: You must use Maven 2.0.9 or above or these are ignored (see
+ MNG-2972) -->
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>${org.aspectj-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjtools</artifactId>
+ <version>${org.aspectj-version}</version>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>test-compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <outxml>true</outxml>
+ <source>${java-version}</source>
+ <target>${java-version}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>install</id>
+ <phase>install</phase>
+ <goals>
+ <goal>sources</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>tomcat-maven-plugin</artifactId>
+ <version>${org.codehaus.mojo.tomcat-version}</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <!-- For testing against latest Spring snapshots -->
+ <repository>
+ <id>spring-snapshot</id>
+ <name>SpringSource Snapshot Repository</name>
+ <url>http://repo.springsource.org/snapshot</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <!-- For developing against latest Spring milestones -->
+ <repository>
+ <id>spring-milestone</id>
+ <name>SpringSource Milestone Repository</name>
+ <url>http://repo.springsource.org/milestone</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+</project>
View
44 ...interceptor-urlpath/src/main/java/org/springframework/showcases/lite/AboutController.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2012 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.showcases.lite;
+
+import org.springframework.mobile.device.site.SitePreference;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Handles requests for the About page.
+ * @author Roy Clarkson
+ */
+@Controller
+public class AboutController {
+
+ /**
+ * Show the About page to the user.
+ * Declares a {@link SitePreference} parameter to show how you can resolve the user's site preference.
+ * This controller renders a different version of the home view if the user has a mobile site preference.
+ */
+ @RequestMapping("/about")
+ public String home(SitePreference sitePreference, Model model) {
+ if (sitePreference == SitePreference.MOBILE) {
+ return "about-mobile";
+ } else {
+ return "about";
+ }
+ }
+
+}
View
44 ...-interceptor-urlpath/src/main/java/org/springframework/showcases/lite/HomeController.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2010 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.showcases.lite;
+
+import org.springframework.mobile.device.site.SitePreference;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Handles requests for the showcase application.
+ * @author Keith Donald
+ */
+@Controller
+public class HomeController {
+
+ /**
+ * Show the home page to the user.
+ * Declares a {@link SitePreference} parameter to show how you can resolve the user's site preference.
+ * This controller renders a different version of the home view if the user has a mobile site preference.
+ */
+ @RequestMapping("/")
+ public String home(SitePreference sitePreference, Model model) {
+ if (sitePreference == SitePreference.MOBILE) {
+ return "home-mobile";
+ } else {
+ return "home";
+ }
+ }
+
+}
View
41 lite-interceptor-urlpath/src/main/resources/log4j.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Appenders -->
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p: %c - %m%n" />
+ </layout>
+ </appender>
+
+ <!-- Application Loggers -->
+ <logger name="org.springframework.showcases.lite">
+ <level value="info" />
+ </logger>
+
+ <!-- 3rdparty Loggers -->
+ <logger name="org.springframework.core">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.beans">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.context">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.web">
+ <level value="info" />
+ </logger>
+
+ <!-- Root Logger -->
+ <root>
+ <priority value="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
View
3  lite-interceptor-urlpath/src/main/webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
View
13 lite-interceptor-urlpath/src/main/webapp/WEB-INF/spring/appServlet/controllers.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:mvc="http://www.springframework.org/schema/mvc"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
+ http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
+
+ <context:component-scan base-package="org.springframework.showcases.lite" />
+
+</beans>
View
44 lite-interceptor-urlpath/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:beans xmlns="http://www.springframework.org/schema/mvc"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xmlns:device="http://www.springframework.org/schema/mobile/device"
+ xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/mobile/device http://www.springframework.org/schema/mobile/device/spring-mobile-device-1.0.xsd">
+
+ <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
+
+ <!-- Configures the Spring MVC @Controller programming model -->
+ <annotation-driven>
+ <argument-resolvers>
+ <beans:bean class="org.springframework.mobile.device.site.SitePreferenceWebArgumentResolver" />
+ </argument-resolvers>
+ </annotation-driven>
+
+ <!-- Interceptors that execute common control logic across multiple requests -->
+ <interceptors>
+
+ <!-- Detects the client's Device -->
+ <beans:bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor" />
+
+ <!-- Redirects the client to their preferred site if necessary.
+ This particular configuration redirects clients preferring the mobile site to 'm.testdomain'.
+ NOTE: for this redirect to work testdomain.com and m.testdomain.com must be added to your hosts file when running the app -->
+ <beans:bean class="org.springframework.mobile.device.switcher.SiteSwitcherHandlerInterceptor" factory-method="urlPath">
+ <beans:constructor-arg value="/mobile" />
+ <beans:constructor-arg value="/lite-interceptor-urlpath" />
+ </beans:bean>
+
+ </interceptors>
+
+ <!-- Maps view names to JSP templates in /WEB-INF/views -->
+ <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
+ <beans:property name="prefix" value="/WEB-INF/views/" />
+ <beans:property name="suffix" value=".jsp" />
+ </beans:bean>
+
+ <!-- Imports the application controllers that process client requests -->
+ <beans:import resource="controllers.xml" />
+
+</beans:beans>
View
23 lite-interceptor-urlpath/src/main/webapp/WEB-INF/views/about-mobile.jsp
@@ -0,0 +1,23 @@
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Spring Mobile | Lite Showcase</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
+ </head>
+ <body>
+ <header>
+ <h1>About (Mobile Site)</h1>
+ </header>
+ <content>
+ <p>Return to the <a href="<c:url value="/" />">Home</a> page.</p>
+ </content>
+ <footer>
+ An Apache-licensed technology showcase by SpringSource.
+ </footer>
+ <aside id="site-switcher">
+ <p>Site: <c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile</c:if><c:if test="${!currentSitePreference.mobile}">Normal | <a href="?site_preference=mobile">Mobile</a></c:if></p>
+ </aside>
+ </body>
+</html>
View
22 lite-interceptor-urlpath/src/main/webapp/WEB-INF/views/about.jsp
@@ -0,0 +1,22 @@
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Spring Mobile | Lite Showcase</title>
+ </head>
+ <body>
+ <header>
+ <h1>About (Normal Site)</h1>
+ </header>
+ <content>
+ <p>Return to the <a href="<c:url value="/" />">Home</a> page.</p>
+ </content>
+ <footer>
+ An Apache-licensed technology showcase by SpringSource.
+ </footer>
+ <aside id="site-switcher">
+ <p>Site: <c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile</c:if><c:if test="${!currentSitePreference.mobile}">Normal | <a href="?site_preference=mobile">Mobile</a></c:if></p>
+ </aside>
+ </body>
+</html>
View
23 lite-interceptor-urlpath/src/main/webapp/WEB-INF/views/home-mobile.jsp
@@ -0,0 +1,23 @@
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Spring Mobile | Lite Showcase</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
+ </head>
+ <body>
+ <header>
+ <h1>Home (Mobile Site)</h1>
+ </header>
+ <content>
+ <p>View the <a href="<c:url value="/about" />">About</a> page.</p>
+ </content>
+ <footer>
+ An Apache-licensed technology showcase by SpringSource.
+ </footer>
+ <aside id="site-switcher">
+ <p>Site: <c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile</c:if><c:if test="${!currentSitePreference.mobile}">Normal | <a href="?site_preference=mobile">Mobile</a></c:if></p>
+ </aside>
+ </body>
+</html>
View
22 lite-interceptor-urlpath/src/main/webapp/WEB-INF/views/home.jsp
@@ -0,0 +1,22 @@
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Spring Mobile | Lite Showcase</title>
+ </head>
+ <body>
+ <header>
+ <h1>Home (Normal Site)</h1>
+ </header>
+ <content>
+ <p>View the <a href="<c:url value="/about" />">About</a> page.</p>
+ </content>
+ <footer>
+ An Apache-licensed technology showcase by SpringSource.
+ </footer>
+ <aside id="site-switcher">
+ <p>Site: <c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile</c:if><c:if test="${!currentSitePreference.mobile}">Normal | <a href="?site_preference=mobile">Mobile</a></c:if></p>
+ </aside>
+ </body>
+</html>
View
20 lite-interceptor-urlpath/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+ <servlet>
+ <servlet-name>appServlet</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ <init-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>appServlet</servlet-name>
+ <url-pattern>/</url-pattern>
+ <url-pattern>/mobile/*</url-pattern>
+ </servlet-mapping>
+</web-app>
View
26 ...erceptor-urlpath/src/test/java/org/springframework/showcases/lite/HomeControllerTest.java
@@ -0,0 +1,26 @@
+package org.springframework.showcases.lite;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.springframework.mobile.device.site.SitePreference;
+import org.springframework.ui.ExtendedModelMap;
+import org.springframework.ui.Model;
+
+public class HomeControllerTest {
+
+ private HomeController controller = new HomeController();
+
+ @Test
+ public void homePageMobileSitePreference() {
+ Model model = new ExtendedModelMap();
+ assertEquals("home-mobile", controller.home(SitePreference.MOBILE, model));
+ }
+
+ @Test
+ public void homePageNormalSitePreference() {
+ Model model = new ExtendedModelMap();
+ assertEquals("home", controller.home(SitePreference.NORMAL, model));
+ }
+
+}
View
41 lite-interceptor-urlpath/src/test/resources/log4j.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Appenders -->
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p: %c - %m%n" />
+ </layout>
+ </appender>
+
+ <!-- Application Loggers -->
+ <logger name="org.springframework.showcases.lite">
+ <level value="debug" />
+ </logger>
+
+ <!-- 3rdparty Loggers -->
+ <logger name="org.springframework.core">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.beans">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.context">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.web">
+ <level value="info" />
+ </logger>
+
+ <!-- Root Logger -->
+ <root>
+ <priority value="warn" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
Please sign in to comment.
Something went wrong with that request. Please try again.