Author: janne
Date: Wed Jul 25 02:08:27 2007
New Revision: 559371
URL: http://svn.apache.org/viewvc?view=rev&rev=559371
Log:
[WICKET-779] Constructor of Session (and subclasses) has a redundant
Application parameter
Applied the patch.
Added:
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/WebSessionTest.java
Modified:
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebSession.java
Modified:
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java?view=diff&rev=559371&r1=559370&r2=559371
==============================================================================
---
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java
(original)
+++
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java
Wed Jul 25 02:08:27 2007
@@ -16,19 +16,6 @@
*/
package org.apache.wicket;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
import org.apache.wicket.application.IClassResolver;
import org.apache.wicket.authorization.IAuthorizationStrategy;
import org.apache.wicket.feedback.FeedbackMessage;
@@ -44,6 +31,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.Serializable;
+import java.util.*;
+import java.util.Map.Entry;
+
/**
* Holds information about a user session, including some fixed number of most
@@ -124,7 +115,7 @@
*/
public abstract class Session implements IClusterable
{
- /**
+ /**
* Visitor interface for visiting page maps
*
* @author Jonathan Locke
@@ -372,25 +363,37 @@
/** A linked list for last used pagemap queue */
private final LinkedList/* <IPageMap> */usedPageMaps = new LinkedList();
- /**
+ /**
+ * Constructor. Note that [EMAIL PROTECTED] RequestCycle} is not
available until this
+ * constructor returns.
+ *
+ * @param request
+ * The current request
+ */
+ public Session(Request request)
+ {
+ this.locale = request.getLocale();
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("Parameter 'locale' must not be
null");
+ }
+ }
+
+ /**
* Constructor. Note that [EMAIL PROTECTED] RequestCycle} is not
available until this
* constructor returns.
*
+ * @deprecated Use #Session(Request)
+ *
* @param application
* The application that this is a session of
* @param request
* The current request
- * @param response
- * The current response
*/
protected Session(Application application, Request request)
{
- this.locale = request.getLocale();
- if (locale == null)
- {
- throw new IllegalArgumentException("Parameter 'locale'
must not be null");
- }
- }
+ this(request);
+ }
/**
* Force binding this session to the application's
Modified:
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebSession.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebSession.java?view=diff&rev=559371&r1=559370&r2=559371
==============================================================================
---
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebSession.java
(original)
+++
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/WebSession.java
Wed Jul 25 02:08:27 2007
@@ -16,11 +16,7 @@
*/
package org.apache.wicket.protocol.http;
-import org.apache.wicket.Application;
-import org.apache.wicket.Component;
-import org.apache.wicket.Request;
-import org.apache.wicket.RequestCycle;
-import org.apache.wicket.Session;
+import org.apache.wicket.*;
import org.apache.wicket.util.string.Strings;
/**
@@ -35,7 +31,9 @@
/**
* Constructor. Note that [EMAIL PROTECTED] RequestCycle} is not
available until this
* constructor returns.
- *
+ *
+ * @deprecated Use #WebSession(Request) instead
+ *
* @param application
* The application
* @param request
@@ -49,6 +47,8 @@
/**
* Constructor. Note that [EMAIL PROTECTED] RequestCycle} is not
available until this
* constructor returns.
+ *
+ * @deprecated Use #WebSession(Request)
*
* @param application
* The application
@@ -59,8 +59,20 @@
{
super(application, request);
}
-
- /**
+
+ /**
+ * Constructor. Note that [EMAIL PROTECTED] RequestCycle} is not available
until this
+ * constructor returns.
+ *
+ * @param request
+ * The current request
+ */
+ public WebSession(Request request)
+ {
+ super(request);
+ }
+
+ /**
* @see
org.apache.wicket.Session#isCurrentRequestValid(org.apache.wicket.RequestCycle)
*/
protected boolean isCurrentRequestValid(RequestCycle lockedRequestCycle)
Added:
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/WebSessionTest.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/WebSessionTest.java?view=auto&rev=559371
==============================================================================
---
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/WebSessionTest.java
(added)
+++
incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/protocol/http/WebSessionTest.java
Wed Jul 25 02:08:27 2007
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.wicket.protocol.http;
+
+import junit.framework.TestCase;
+import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Locale;
+
+/**
+ * @author Timo Rantalaiho
+ */
+public class WebSessionTest extends TestCase {
+ public void testReadsLocaleFromRequestOnConstruction()
+ {
+ final Locale locale = Locale.TRADITIONAL_CHINESE;
+ HttpServletRequest request = new MockHttpServletRequest(null, null,
null)
+ {
+ public Locale getLocale()
+ {
+ return locale;
+ }
+ };
+
+ WebSession session = new WebSession(new ServletWebRequest(request));
+ assertEquals(locale, session.getLocale());
+ }
+}