wicket.protocol.http
Class WebApplication

java.lang.Object
  extended by wicket.Application
      extended by wicket.protocol.http.WebApplication
All Implemented Interfaces:
ISessionFactory
Direct Known Subclasses:
MockWebApplication

public abstract class WebApplication
extends Application
implements ISessionFactory

A web application is a subclass of Application which associates with an instance of WicketServlet to serve pages over the HTTP protocol. This class is intended to be subclassed by framework clients to define a web application.

Application settings are given defaults by the WebApplication() constructor and internalInit method, such as error page classes appropriate for HTML. WebApplication subclasses can override these values and/or modify other application settings by overriding the init() method and then by calling getXXXSettings() to retrieve an interface to a mutable Settings object. Do not do this in the constructor itself because the defaults will then override your settings.

If you want to use servlet specific configuration, e.g. using init parameters from the ServletConfigobject, you should override the init() method. For example:

              public void init()
              {
                  String webXMLParameter = getWicketServlet().getInitParameter("myWebXMLParameter");
                  URL schedulersConfig = getWicketServlet().getServletContext().getResource("/WEB-INF/schedulers.xml");
                  ...
 

Author:
Jonathan Locke, Chris Turner, Johan Compagner, Eelco Hillenius, Juergen Donnerstag
See Also:
WicketServlet, IApplicationSettings, IDebugSettings, IExceptionSettings, IMarkupSettings, IPageSettings, IRequestCycleSettings, IResourceSettings, ISecuritySettings, ISessionSettings

Field Summary
 
Fields inherited from class wicket.Application
CONFIGURATION, CONTEXTPATH, DEPLOYMENT, DEVELOPMENT
 
Constructor Summary
WebApplication()
          Constructor.
 
Method Summary
 java.lang.String getApplicationKey()
          Gets the unique key of this application within a given context (like a web application).
protected  IRequestCycleFactory getDefaultRequestCycleFactory()
          Create a request cycle factory which is used by default by WebSession.
 IRequestCycleProcessor getRequestCycleProcessor()
          Gets the default request cycle processor (with lazy initialization).
 RequestLogger getRequestLogger()
          Gets the RequestLogger.
 java.lang.String getSessionAttributePrefix(WebRequest request)
          Gets the prefix for storing variables in the actual session (typically HttpSession for this application instance.
protected  ISessionFactory getSessionFactory()
          Gets the factory for creating session instances.
 WicketServlet getWicketServlet()
           
protected  void init()
          Initialize; if you need the wicket servlet for initialization, e.g.
protected  void internalDestroy()
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
protected  void internalInit()
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 void logEventTarget(IRequestTarget target)
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 void logResponseTarget(IRequestTarget target)
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 void mount(java.lang.String path, IRequestTargetUrlCodingStrategy encoder)
          Mounts an encoder at the given path.
 void mount(java.lang.String path, PackageName packageName)
          Mounts all bookmarkable pages at the given path.
 void mountBookmarkablePage(java.lang.String path, java.lang.Class bookmarkablePageClass)
          Mounts a bookmarkable page class to the given path.
 void mountBookmarkablePage(java.lang.String path, PageMap pageMap, java.lang.Class bookmarkablePageClass)
          Deprecated. You won't be able to use this mount. Use mountBookmarkablePage(String, String, Class) instead
 void mountBookmarkablePage(java.lang.String path, java.lang.String pageMapName, java.lang.Class bookmarkablePageClass)
          Mounts a bookmarkable page class to the given pagemap and path.
 void mountSharedResource(java.lang.String path, java.lang.String resourceKey)
          Mounts a shared resource class to the given path.
protected  IRequestCycleProcessor newRequestCycleProcessor()
          May be replaced by subclasses which whishes to uses there own implementation of IRequestCycleProcessor
 Session newSession()
          Create new Wicket Session object.
protected  ISessionStore newSessionStore()
          Creates a new session facade.
protected  WebRequest newWebRequest(javax.servlet.http.HttpServletRequest servletRequest)
          Create a new WebRequest.
protected  WebResponse newWebResponse(javax.servlet.http.HttpServletResponse servletResponse)
          Create a WebResponse.
 void sessionDestroyed(java.lang.String sessionId)
           
protected  void setApplicationKey(java.lang.String applicationKey)
           
 void setRequestLogger(RequestLogger logger)
          Sets the RequestLogger.
 void setSessionFactory(ISessionFactory sessionFactory)
           
 void setWicketServlet(WicketServlet wicketServlet)
          THIS METHOD IS NOT PART OF THE WICKET PUBLIC API.
 void unmount(java.lang.String path)
          Unmounts whatever encoder is mounted at a given path.
 
Methods inherited from class wicket.Application
addComponentInstantiationListener, configure, configure, configure, destroy, exists, get, get, getAjaxSettings, getApplicationSettings, getConfigurationType, getDebugSettings, getExceptionSettings, getFrameworkSettings, getHomePage, getMarkupCache, getMarkupSettings, getMetaData, getName, getPageSettings, getRequestCycleSettings, getResourceSettings, getSecuritySettings, getSessionSettings, getSessionStore, getSettings, getSharedResources, initializeComponents, isAttached, removeComponentInstantiationListener, set, setMetaData, unset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebApplication

public WebApplication()
Constructor. Use init() for any configuration of your application instead of overriding the constructor.

Method Detail

getApplicationKey

public final java.lang.String getApplicationKey()
Description copied from class: Application
Gets the unique key of this application within a given context (like a web application). NOT INTENDED FOR FRAMEWORK CLIENTS.

Specified by:
getApplicationKey in class Application
Returns:
The unique key of this application
See Also:
Application.getApplicationKey()

getRequestCycleProcessor

public final IRequestCycleProcessor getRequestCycleProcessor()
Gets the default request cycle processor (with lazy initialization). This is the IRequestCycleProcessor that will be used by RequestCycles when custom implementations of the request cycle do not provide their own customized versions.

Returns:
the default request cycle processor

getRequestLogger

public final RequestLogger getRequestLogger()
Gets the RequestLogger.

Returns:
The RequestLogger

getSessionAttributePrefix

public final java.lang.String getSessionAttributePrefix(WebRequest request)
Gets the prefix for storing variables in the actual session (typically HttpSession for this application instance.

Parameters:
request - the request
Returns:
the prefix for storing variables in the actual session

getWicketServlet

public final WicketServlet getWicketServlet()
Returns:
The Wicket servlet for this application

logEventTarget

public void logEventTarget(IRequestTarget target)
Description copied from class: Application
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.

Overrides:
logEventTarget in class Application
See Also:
Application.logEventTarget(wicket.IRequestTarget)

logResponseTarget

public void logResponseTarget(IRequestTarget target)
Description copied from class: Application
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.

Overrides:
logResponseTarget in class Application
See Also:
Application.logResponseTarget(wicket.IRequestTarget)

mount

public final void mount(java.lang.String path,
                        IRequestTargetUrlCodingStrategy encoder)
Mounts an encoder at the given path.

Parameters:
path - the path to mount the encoder on
encoder - the encoder that will be used for this mount

mount

public final void mount(java.lang.String path,
                        PackageName packageName)
Mounts all bookmarkable pages at the given path.

Parameters:
path - the path to mount the bookmarkable page class on
packageName - the name of the package for which all bookmarkable pages or sharedresources should be mounted

mountBookmarkablePage

public final void mountBookmarkablePage(java.lang.String path,
                                        java.lang.Class bookmarkablePageClass)
Mounts a bookmarkable page class to the given path.

Parameters:
path - the path to mount the bookmarkable page class on
bookmarkablePageClass - the bookmarkable page class to mount

mountBookmarkablePage

public final void mountBookmarkablePage(java.lang.String path,
                                        PageMap pageMap,
                                        java.lang.Class bookmarkablePageClass)
Deprecated. You won't be able to use this mount. Use mountBookmarkablePage(String, String, Class) instead

Mounts a bookmarkable page class to the given pagemap and path.

Parameters:
path - the path to mount the bookmarkable page class on
pageMap - pagemap this mount is for
bookmarkablePageClass - the bookmarkable page class to mount

mountBookmarkablePage

public final void mountBookmarkablePage(java.lang.String path,
                                        java.lang.String pageMapName,
                                        java.lang.Class bookmarkablePageClass)
Mounts a bookmarkable page class to the given pagemap and path.

Parameters:
path - the path to mount the bookmarkable page class on
pageMapName - name of the pagemap this mount is for
bookmarkablePageClass - the bookmarkable page class to mount

mountSharedResource

public final void mountSharedResource(java.lang.String path,
                                      java.lang.String resourceKey)
Mounts a shared resource class to the given path.

Parameters:
path - the path to mount the bookmarkable page class on
resourceKey - the shared key of the resource being mounted

newSession

public Session newSession()
Create new Wicket Session object. Note, this method is not called if you registered your own ISessionFactory with the Application.

Specified by:
newSession in interface ISessionFactory
Returns:
The session
See Also:
ISessionFactory.newSession()

sessionDestroyed

public void sessionDestroyed(java.lang.String sessionId)
Parameters:
sessionId - The session id that was destroyed

setRequestLogger

public final void setRequestLogger(RequestLogger logger)
Sets the RequestLogger.

Parameters:
logger - The request logger

setSessionFactory

public final void setSessionFactory(ISessionFactory sessionFactory)
Parameters:
sessionFactory - The session factory to use

setWicketServlet

public final void setWicketServlet(WicketServlet wicketServlet)
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.

Parameters:
wicketServlet - The wicket servlet instance for this application
Throws:
java.lang.IllegalStateException - If an attempt is made to call this method once the wicket servlet has been set for the application.

unmount

public final void unmount(java.lang.String path)
Unmounts whatever encoder is mounted at a given path.

Parameters:
path - the path of the encoder to unmount

getDefaultRequestCycleFactory

protected IRequestCycleFactory getDefaultRequestCycleFactory()
Create a request cycle factory which is used by default by WebSession. You may provide your own default factory by subclassing WebApplication and overriding this method or your may subclass WebSession to create a session specific request cycle factory.

Returns:
Request cycle factory
See Also:
WebSession.getRequestCycleFactory(), IRequestCycleFactory

getSessionFactory

protected ISessionFactory getSessionFactory()
Description copied from class: Application
Gets the factory for creating session instances.

Specified by:
getSessionFactory in class Application
Returns:
Factory for creating session instances
See Also:
Application.getSessionFactory()

init

protected void init()
Initialize; if you need the wicket servlet for initialization, e.g. because you want to read an initParameter from web.xml or you want to read a resource from the servlet's context path, you can override this method and provide custom initialization. This method is called right after this application class is constructed, and the wicket servlet is set. Use this method for any application setup instead of the constructor.

Overrides:
init in class Application

internalDestroy

protected void internalDestroy()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.

Overrides:
internalDestroy in class Application

internalInit

protected void internalInit()
THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT. Internal intialization. First determine the deployment mode. First check the system property -Dwicket.configuration. If it does not exist check the servlet init parameter ( <init-param><param-name>configuration</param-name>). If not found check the servlet context init paramert <context-param><param-name6gt;configuration</param-name>). If the parameter is "development" (which is default), settings appropriate for development are set. If it's "deployment" , deployment settings are used. If development is specified and a "sourceFolder" init parameter is also set, then resources in that folder will be polled for changes.

Overrides:
internalInit in class Application

newRequestCycleProcessor

protected IRequestCycleProcessor newRequestCycleProcessor()
May be replaced by subclasses which whishes to uses there own implementation of IRequestCycleProcessor

Returns:
IRequestCycleProcessor

newSessionStore

protected ISessionStore newSessionStore()
Description copied from class: Application
Creates a new session facade. Is called once per application, and is typically not something clients reimplement.

Specified by:
newSessionStore in class Application
Returns:
The session facade
See Also:
Application.newSessionStore()

newWebRequest

protected WebRequest newWebRequest(javax.servlet.http.HttpServletRequest servletRequest)
Create a new WebRequest. Subclasses of WebRequest could e.g. decode and obfuscated URL which has been encoded by an appropriate WebResponse.

Parameters:
servletRequest -
Returns:
a WebRequest object

newWebResponse

protected WebResponse newWebResponse(javax.servlet.http.HttpServletResponse servletResponse)
Create a WebResponse. Subclasses of WebRequest could e.g. encode wicket's default URL and hide the details from the user. A appropriate WebRequest must be implemented and configured to decode the encoded URL.

Parameters:
servletResponse -
Returns:
a WebResponse object

setApplicationKey

protected final void setApplicationKey(java.lang.String applicationKey)


Copyright © 2004-2007 Wicket developers. All Rights Reserved.