public class SiteSwitcherHandlerInterceptor
extends org.springframework.web.servlet.handler.HandlerInterceptorAdapter
Constructor and Description |
---|
SiteSwitcherHandlerInterceptor(SiteUrlFactory normalSiteUrlFactory,
SiteUrlFactory mobileSiteUrlFactory,
SitePreferenceHandler sitePreferenceHandler)
Creates a new site switcher.
|
Modifier and Type | Method and Description |
---|---|
static SiteSwitcherHandlerInterceptor |
dotMobi(java.lang.String serverName)
Creates a site switcher that redirects to a
.mobi domain for normal site requests that either
originate from a mobile device or indicate a mobile site preference. |
static SiteSwitcherHandlerInterceptor |
mDot(java.lang.String serverName)
Creates a site switcher that redirects to a
m. domain for normal site requests that either
originate from a mobile device or indicate a mobile site preference. |
boolean |
preHandle(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.Object handler) |
static SiteSwitcherHandlerInterceptor |
urlPath(java.lang.String mobilePath)
Creates a site switcher that redirects to a path on the current domain for normal site requests that either
originate from a mobile device or indicate a mobile site preference.
|
static SiteSwitcherHandlerInterceptor |
urlPath(java.lang.String mobilePath,
java.lang.String rootPath)
Creates a site switcher that redirects to a path on the current domain for normal site requests that either
originate from a mobile device or indicate a mobile site preference.
|
public SiteSwitcherHandlerInterceptor(SiteUrlFactory normalSiteUrlFactory, SiteUrlFactory mobileSiteUrlFactory, SitePreferenceHandler sitePreferenceHandler)
normalSiteUrlFactory
- the factory for a "normal" site URL e.g. http://app.commobileSiteUrlFactory
- the factory for a "mobile" site URL e.g. http://m.app.comsitePreferenceHandler
- the handler for the user site preferencepublic boolean preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler) throws java.lang.Exception
preHandle
in interface org.springframework.web.servlet.HandlerInterceptor
preHandle
in class org.springframework.web.servlet.handler.HandlerInterceptorAdapter
java.lang.Exception
public static SiteSwitcherHandlerInterceptor mDot(java.lang.String serverName)
m.
domain for normal site requests that either
originate from a mobile device or indicate a mobile site preference.
Uses a CookieSitePreferenceRepository
that saves a cookie that is shared between the two domains.public static SiteSwitcherHandlerInterceptor dotMobi(java.lang.String serverName)
.mobi
domain for normal site requests that either
originate from a mobile device or indicate a mobile site preference.
Will strip off the trailing domain name when building the mobile domain
e.g. "app.com" will become "app.mobi" (the .com will be stripped).
Uses a CookieSitePreferenceRepository
that saves a cookie that is shared between the two domains.public static SiteSwitcherHandlerInterceptor urlPath(java.lang.String mobilePath)
CookieSitePreferenceRepository
that saves a cookie that is stored on the root path.public static SiteSwitcherHandlerInterceptor urlPath(java.lang.String mobilePath, java.lang.String rootPath)
CookieSitePreferenceRepository
that saves a cookie that is stored on the root path.