spring-mobile-device

org.springframework.mobile.device.switcher
Class StandardSiteUrlFactory

java.lang.Object
  extended by org.springframework.mobile.device.switcher.AbstractSiteUrlFactory
      extended by org.springframework.mobile.device.switcher.StandardSiteUrlFactory
All Implemented Interfaces:
SiteUrlFactory

public class StandardSiteUrlFactory
extends AbstractSiteUrlFactory
implements SiteUrlFactory

Site URL factory implementation that differentiates each site by the value of the server name field. For example, your 'normal' site might be bound to 'myapp.com', while your mobile site might be bound to 'm.myapp.com'.

Author:
Keith Donald, Roy Clarkson

Constructor Summary
StandardSiteUrlFactory(java.lang.String serverName)
          Creates a new StandardSiteUrlFactory.
 
Method Summary
 java.lang.String createSiteUrl(javax.servlet.http.HttpServletRequest request)
          Create a fully-qualified URL that can be used to redirect the user to this site.
 boolean isRequestForSite(javax.servlet.http.HttpServletRequest request)
          Did the request originate from this site? Used to determine what site the user is currently viewing.
 
Methods inherited from class org.springframework.mobile.device.switcher.AbstractSiteUrlFactory
createSiteUrlInternal, optionalPort
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardSiteUrlFactory

public StandardSiteUrlFactory(java.lang.String serverName)
Creates a new StandardSiteUrlFactory.

Parameters:
serverName - the server name
Method Detail

isRequestForSite

public boolean isRequestForSite(javax.servlet.http.HttpServletRequest request)
Description copied from interface: SiteUrlFactory
Did the request originate from this site? Used to determine what site the user is currently viewing. For example, if the user is viewing a page on "m.app.com", this method would likely return 'true' if it constructs m.app.com URLs. The SiteSwitcherHandlerInterceptor uses this knowledge to implement its switching algorithm.

Specified by:
isRequestForSite in interface SiteUrlFactory
See Also:
SiteSwitcherHandlerInterceptor.preHandle(HttpServletRequest, javax.servlet.http.HttpServletResponse, Object)

createSiteUrl

public java.lang.String createSiteUrl(javax.servlet.http.HttpServletRequest request)
Description copied from interface: SiteUrlFactory
Create a fully-qualified URL that can be used to redirect the user to this site. A typical implementation changes the target host but preserves the request path.

Specified by:
createSiteUrl in interface SiteUrlFactory

spring-mobile-device