You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2006/10/15 15:40:03 UTC

svn commit: r464193 - /incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebApplication.java

Author: ehillenius
Date: Sun Oct 15 06:40:01 2006
New Revision: 464193

URL: http://svn.apache.org/viewvc?view=rev&rev=464193
Log:
sorted members and made getRequestCycleProcessor public

Modified:
    incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebApplication.java

Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebApplication.java
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebApplication.java?view=diff&rev=464193&r1=464192&r2=464193
==============================================================================
--- incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebApplication.java (original)
+++ incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/WebApplication.java Sun Oct 15 06:40:01 2006
@@ -72,11 +72,11 @@
  * init() method. For example:
  * 
  * <pre>
- *             public void init()
- *             {
- *                 String webXMLParameter = getWicketServlet().getInitParameter(&quot;myWebXMLParameter&quot;);
- *                 URL schedulersConfig = getWicketServlet().getServletContext().getResource(&quot;/WEB-INF/schedulers.xml&quot;);
- *                 ...
+ *              public void init()
+ *              {
+ *                  String webXMLParameter = getWicketServlet().getInitParameter(&quot;myWebXMLParameter&quot;);
+ *                  URL schedulersConfig = getWicketServlet().getServletContext().getResource(&quot;/WEB-INF/schedulers.xml&quot;);
+ *                  ...
  * </pre>
  * 
  * @see WicketServlet
@@ -110,6 +110,12 @@
 	}
 
 	/**
+	 * The cached application key. Will be set in
+	 * {@link #setWicketServlet(WicketServlet)} based on the servlet context.
+	 */
+	private String applicationKey;
+
+	/**
 	 * Map of buffered responses that are in progress per session. Buffered
 	 * responses are temporarily stored
 	 */
@@ -131,12 +137,6 @@
 	private WicketFilter wicketFilter;
 
 	/**
-	 * The cached application key. Will be set in
-	 * {@link #setWicketServlet(WicketServlet)} based on the servlet context.
-	 */
-	private String applicationKey;
-
-	/**
 	 * Constructor. <strong>Use {@link #init()} for any configuration of your
 	 * application instead of overriding the constructor.</strong>
 	 */
@@ -145,6 +145,64 @@
 	}
 
 	/**
+	 * @see wicket.Application#getApplicationKey()
+	 */
+	@Override
+	public final String getApplicationKey()
+	{
+		if (applicationKey == null)
+		{
+			throw new IllegalStateException("the application key does not seem to"
+					+ " be set properly or this method is called before WicketServlet is"
+					+ " set, which leads to the wrong behavior");
+		}
+		return applicationKey;
+	}
+
+	/**
+	 * Gets the default request cycle processor (with lazy initialization). This
+	 * is the {@link IRequestCycleProcessor} that will be used by
+	 * {@link RequestCycle}s when custom implementations of the request cycle
+	 * do not provide their own customized versions.
+	 * 
+	 * @return the default request cycle processor
+	 */
+	public final IRequestCycleProcessor getRequestCycleProcessor()
+	{
+		if (requestCycleProcessor == null)
+		{
+			requestCycleProcessor = newRequestCycleProcessor();
+		}
+		return requestCycleProcessor;
+	}
+
+	/**
+	 * Returns the full rootpath of this application. This is the
+	 * ApplicationSettings.contextpath and the WicketFilter.rootpath concatted.
+	 * 
+	 * @return String the full rootpath.
+	 */
+	public String getRootPath()
+	{
+		return wicketFilter.getRootPath(WebRequestCycle.get().getWebRequest()
+				.getHttpServletRequest());
+	}
+
+	/**
+	 * @return The Wicket servlet for this application
+	 */
+	public final ServletContext getServletContext()
+	{
+		if (wicketFilter == null)
+		{
+			throw new IllegalStateException("servletContext is not set yet. Any code in your"
+					+ " Application object that uses the wicketServlet instance should be put"
+					+ " in the init() method instead of your constructor");
+		}
+		return wicketFilter.getFilterConfig().getServletContext();
+	}
+
+	/**
 	 * Gets the prefix for storing variables in the actual session (typically
 	 * {@link HttpSession} for this application instance.
 	 * 
@@ -170,32 +228,23 @@
 	}
 
 	/**
-	 * @return The Wicket servlet for this application
+	 * Mounts an encoder at the given path.
+	 * 
+	 * @param path
+	 *            the path to mount the encoder on
+	 * @param encoder
+	 *            the encoder that will be used for this mount
 	 */
-	public final ServletContext getServletContext()
+	public final void mount(IRequestTargetUrlCodingStrategy encoder)
 	{
-		if (wicketFilter == null)
-		{
-			throw new IllegalStateException("servletContext is not set yet. Any code in your"
-					+ " Application object that uses the wicketServlet instance should be put"
-					+ " in the init() method instead of your constructor");
-		}
-		return wicketFilter.getFilterConfig().getServletContext();
-	}
+		checkMountPath(encoder.getMountPath());
 
-	/**
-	 * @see wicket.Application#getApplicationKey()
-	 */
-	@Override
-	public final String getApplicationKey()
-	{
-		if (applicationKey == null)
+		if (encoder == null)
 		{
-			throw new IllegalStateException("the application key does not seem to"
-					+ " be set properly or this method is called before WicketServlet is"
-					+ " set, which leads to the wrong behavior");
+			throw new IllegalArgumentException("Encoder must be not null");
 		}
-		return applicationKey;
+
+		getRequestCycleProcessor().getRequestCodingStrategy().mount(encoder);
 	}
 
 	/**
@@ -261,35 +310,35 @@
 	}
 
 	/**
-	 * Mounts an encoder at the given path.
+	 * Create new Wicket Session object. Note, this method is not called if you
+	 * registered your own ISessionFactory with the Application.
 	 * 
-	 * @param path
-	 *            the path to mount the encoder on
-	 * @param encoder
-	 *            the encoder that will be used for this mount
+	 * @return new session
+	 * 
+	 * @see wicket.ISessionFactory#newSession()
 	 */
-	public final void mount(IRequestTargetUrlCodingStrategy encoder)
+	public Session newSession()
 	{
-		checkMountPath(encoder.getMountPath());
-
-		if (encoder == null)
-		{
-			throw new IllegalArgumentException("Encoder must be not null");
-		}
+		return new WebSession(WebApplication.this);
+	}
 
-		getRequestCycleProcessor().getRequestCodingStrategy().mount(encoder);
+	/**
+	 * @see wicket.ISessionFactory#newSession(wicket.Request)
+	 */
+	public Session newSession(Request request)
+	{
+		return newSession();
 	}
 
 	/**
-	 * Unmounts whatever encoder is mounted at a given path.
-	 * 
-	 * @param path
-	 *            the path of the encoder to unmount
+	 * @param sessionId
+	 *            The session id that was destroyed
 	 */
-	public final void unmount(String path)
+	@Override
+	public void sessionDestroyed(String sessionId)
 	{
-		checkMountPath(path);
-		getRequestCycleProcessor().getRequestCodingStrategy().unmount(path);
+		super.sessionDestroyed(sessionId);
+		bufferedResponses.remove(sessionId);
 	}
 
 	/**
@@ -324,6 +373,18 @@
 	}
 
 	/**
+	 * Unmounts whatever encoder is mounted at a given path.
+	 * 
+	 * @param path
+	 *            the path of the encoder to unmount
+	 */
+	public final void unmount(String path)
+	{
+		checkMountPath(path);
+		getRequestCycleProcessor().getRequestCodingStrategy().unmount(path);
+	}
+
+	/**
 	 * @return Request cycle factory
 	 * @deprecated use {@link #getRequestCycleFactory()} instead
 	 * 
@@ -361,35 +422,6 @@
 	}
 
 	/**
-	 * Gets the default request cycle processor (with lazy initialization). This
-	 * is the {@link IRequestCycleProcessor} that will be used by
-	 * {@link RequestCycle}s when custom implementations of the request cycle
-	 * do not provide their own customized versions.
-	 * 
-	 * @return the default request cycle processor
-	 */
-	protected final IRequestCycleProcessor getRequestCycleProcessor()
-	{
-		if (requestCycleProcessor == null)
-		{
-			requestCycleProcessor = newRequestCycleProcessor();
-		}
-		return requestCycleProcessor;
-	}
-
-	/**
-	 * May be replaced by subclasses which whishes to uses there own
-	 * implementation of IRequestCycleProcessor
-	 * 
-	 * @return IRequestCycleProcessor
-	 */
-	// TODO Doesn't this method belong in Application, not WebApplication?
-	protected IRequestCycleProcessor newRequestCycleProcessor()
-	{
-		return new DefaultWebRequestCycleProcessor();
-	}
-
-	/**
 	 * @see wicket.Application#getSessionFactory()
 	 */
 	@Override
@@ -399,27 +431,6 @@
 	}
 
 	/**
-	 * Create new Wicket Session object. Note, this method is not called if you
-	 * registered your own ISessionFactory with the Application.
-	 * 
-	 * @return new session
-	 * 
-	 * @see wicket.ISessionFactory#newSession()
-	 */
-	public Session newSession()
-	{
-		return new WebSession(WebApplication.this);
-	}
-
-	/**
-	 * @see wicket.ISessionFactory#newSession(wicket.Request)
-	 */
-	public Session newSession(Request request)
-	{
-		return newSession();
-	}
-
-	/**
 	 * 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
@@ -527,6 +538,27 @@
 	}
 
 	/**
+	 * May be replaced by subclasses which whishes to uses there own
+	 * implementation of IRequestCycleProcessor
+	 * 
+	 * @return IRequestCycleProcessor
+	 */
+	// TODO Doesn't this method belong in Application, not WebApplication?
+	protected IRequestCycleProcessor newRequestCycleProcessor()
+	{
+		return new DefaultWebRequestCycleProcessor();
+	}
+
+	/**
+	 * @see wicket.Application#newSessionStore()
+	 */
+	@Override
+	protected ISessionStore newSessionStore()
+	{
+		return new SecondLevelCacheSessionStore(new FilePageStore());
+	}
+
+	/**
 	 * Create a new WebRequest. Subclasses of WebRequest could e.g. decode and
 	 * obfuscated URL which has been encoded by an appropriate WebResponse.
 	 * 
@@ -552,13 +584,12 @@
 				servletResponse) : new WebResponse(servletResponse));
 	}
 
-	/**
-	 * @see wicket.Application#newSessionStore()
+	/*
+	 * Set the application key value
 	 */
-	@Override
-	protected ISessionStore newSessionStore()
+	protected final void setApplicationKey(String applicationKey)
 	{
-		return new SecondLevelCacheSessionStore(new FilePageStore());
+		this.applicationKey = applicationKey;
 	}
 
 	/**
@@ -655,25 +686,6 @@
 		}
 		return null;
 	}
-	
-	/*
-	 * Set the application key value
-	 */
-	protected final void setApplicationKey(String applicationKey)
-	{
-		this.applicationKey=applicationKey;
-	}
-
-	/**
-	 * @param sessionId
-	 *            The session id that was destroyed
-	 */
-	@Override
-	public void sessionDestroyed(String sessionId)
-	{
-		super.sessionDestroyed(sessionId);
-		bufferedResponses.remove(sessionId);
-	}
 
 	/**
 	 * Checks mount path is valid.
@@ -695,17 +707,5 @@
 		{
 			throw new IllegalArgumentException("Mount path cannot start with '/resources'");
 		}
-	}
-
-	/**
-	 * Returns the full rootpath of this application. This is the
-	 * ApplicationSettings.contextpath and the WicketFilter.rootpath concatted.
-	 * 
-	 * @return String the full rootpath.
-	 */
-	public String getRootPath()
-	{
-		return wicketFilter.getRootPath(WebRequestCycle.get().getWebRequest()
-				.getHttpServletRequest());
 	}
 }