Skip to content

Commit 367a0c2

Browse files
committed
Upgrade javax.servlet dependency to 3.0 for .web
In support of SPR-7672 which will support code-based configuration alternatives to web.xml using new features in the Servlet 3.0 API. This upgrade does *not* force Spring users to upgrade to Servlet 3.0 capable containers. Compatibility with and support for javax.servlet >= 2.4 remains. Issue: SPR-7672
1 parent 2ceeff3 commit 367a0c2

File tree

9 files changed

+204
-15
lines changed

9 files changed

+204
-15
lines changed

org.springframework.web/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<classpathentry kind="var" path="IVY_CACHE/javax.faces/com.springsource.javax.faces/1.2.0.08/com.springsource.javax.faces-1.2.0.08.jar" sourcepath="/IVY_CACHE/javax.faces/com.springsource.javax.faces/1.2.0.08/com.springsource.javax.faces-sources-1.2.0.08.jar"/>
1616
<classpathentry kind="var" path="IVY_CACHE/javax.portlet/com.springsource.javax.portlet/2.0.0/com.springsource.javax.portlet-2.0.0.jar"/>
1717
<classpathentry kind="var" path="IVY_CACHE/javax.servlet/com.springsource.javax.servlet.jsp/2.1.0/com.springsource.javax.servlet.jsp-2.1.0.jar" sourcepath="/IVY_CACHE/javax.servlet/com.springsource.javax.servlet.jsp/2.1.0/com.springsource.javax.servlet.jsp-sources-2.1.0.jar"/>
18-
<classpathentry kind="var" path="IVY_CACHE/javax.servlet/com.springsource.javax.servlet/2.5.0/com.springsource.javax.servlet-2.5.0.jar" sourcepath="/IVY_CACHE/javax.servlet/com.springsource.javax.servlet/2.5.0/com.springsource.javax.servlet-sources-2.5.0.jar"/>
18+
<classpathentry kind="var" path="IVY_CACHE/javax.servlet/javax.servlet/3.0.0.v201103241009/javax.servlet-3.0.0.v201103241009.jar" sourcepath="IVY_CACHE/javax.servlet/javax.servlet/3.0.0.v201103241009/javax.servlet-sources-3.0.0.v201103241009.jar"/>
1919
<classpathentry kind="var" path="IVY_CACHE/javax.xml.rpc/com.springsource.javax.xml.rpc/1.1.0/com.springsource.javax.xml.rpc-1.1.0.jar"/>
2020
<classpathentry kind="var" path="IVY_CACHE/javax.xml.soap/com.springsource.javax.xml.soap/1.3.0/com.springsource.javax.xml.soap-1.3.0.jar" sourcepath="/IVY_CACHE/javax.xml.soap/com.springsource.javax.xml.soap/1.3.0/com.springsource.javax.xml.soap-sources-1.3.0.jar"/>
2121
<classpathentry kind="var" path="IVY_CACHE/org.aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-1.0.0.jar" sourcepath="/IVY_CACHE/org.aopalliance/com.springsource.org.aopalliance/1.0.0/com.springsource.org.aopalliance-sources-1.0.0.jar"/>

org.springframework.web/ivy.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<dependency org="javax.faces" name="com.springsource.javax.faces" rev="1.2.0.08"
4444
conf="provided, faces->compile"/>
4545
<dependency org="javax.portlet" name="com.springsource.javax.portlet" rev="2.0.0" conf="provided->compile"/>
46-
<dependency org="javax.servlet" name="com.springsource.javax.servlet" rev="2.5.0" conf="provided->compile"/>
46+
<dependency org="javax.servlet" name="javax.servlet" rev="3.0.0.v201103241009" conf="provided->compile"/>
4747
<dependency org="javax.servlet" name="com.springsource.javax.servlet.jsp" rev="2.1.0"
4848
conf="provided, jsp->compile"/>
4949
<dependency org="javax.xml.rpc" name="com.springsource.javax.xml.rpc" rev="1.1.0"

org.springframework.web/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<dependency>
4848
<groupId>javax.servlet</groupId>
4949
<artifactId>servlet-api</artifactId>
50-
<version>2.5</version>
50+
<version>3.0</version>
5151
<scope>provided</scope>
5252
</dependency>
5353
<dependency>

org.springframework.web/src/test/java/org/springframework/mock/web/MockHttpServletRequest.java

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2011 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import java.io.BufferedReader;
2020
import java.io.ByteArrayInputStream;
21+
import java.io.IOException;
2122
import java.io.InputStream;
2223
import java.io.InputStreamReader;
2324
import java.io.Reader;
@@ -34,19 +35,28 @@
3435
import java.util.Locale;
3536
import java.util.Map;
3637
import java.util.Set;
38+
39+
import javax.servlet.AsyncContext;
40+
import javax.servlet.DispatcherType;
3741
import javax.servlet.RequestDispatcher;
3842
import javax.servlet.ServletContext;
43+
import javax.servlet.ServletException;
3944
import javax.servlet.ServletInputStream;
45+
import javax.servlet.ServletRequest;
46+
import javax.servlet.ServletResponse;
4047
import javax.servlet.http.Cookie;
4148
import javax.servlet.http.HttpServletRequest;
49+
import javax.servlet.http.HttpServletResponse;
4250
import javax.servlet.http.HttpSession;
51+
import javax.servlet.http.Part;
4352

4453
import org.springframework.util.Assert;
4554
import org.springframework.util.LinkedCaseInsensitiveMap;
4655

4756
/**
4857
* Mock implementation of the {@link javax.servlet.http.HttpServletRequest}
49-
* interface. Supports the Servlet 2.5 API level.
58+
* interface. Supports the Servlet 2.5 API level; throws
59+
* {@link UnsupportedOperationException} for all methods introduced in Servlet 3.0.
5060
*
5161
* <p>Used for testing the web framework; also useful for testing
5262
* application controllers.
@@ -55,6 +65,7 @@
5565
* @author Rod Johnson
5666
* @author Rick Evans
5767
* @author Mark Fisher
68+
* @author Chris Beams
5869
* @since 1.0.2
5970
*/
6071
public class MockHttpServletRequest implements HttpServletRequest {
@@ -847,4 +858,53 @@ public boolean isRequestedSessionIdFromUrl() {
847858
return isRequestedSessionIdFromURL();
848859
}
849860

861+
862+
//---------------------------------------------------------------------
863+
// Methods introduced in Servlet 3.0
864+
//---------------------------------------------------------------------
865+
866+
public AsyncContext getAsyncContext() {
867+
throw new UnsupportedOperationException();
868+
}
869+
870+
public DispatcherType getDispatcherType() {
871+
throw new UnsupportedOperationException();
872+
}
873+
874+
public boolean isAsyncSupported() {
875+
throw new UnsupportedOperationException();
876+
}
877+
878+
public AsyncContext startAsync() {
879+
throw new UnsupportedOperationException();
880+
}
881+
882+
public AsyncContext startAsync(ServletRequest arg0, ServletResponse arg1) {
883+
throw new UnsupportedOperationException();
884+
}
885+
886+
public boolean isAsyncStarted() {
887+
throw new UnsupportedOperationException();
888+
}
889+
890+
public boolean authenticate(HttpServletResponse arg0) throws IOException, ServletException {
891+
throw new UnsupportedOperationException();
892+
}
893+
894+
public Part getPart(String arg0) throws IOException, IllegalStateException, ServletException {
895+
throw new UnsupportedOperationException();
896+
}
897+
898+
public Collection<Part> getParts() throws IOException, IllegalStateException, ServletException {
899+
throw new UnsupportedOperationException();
900+
}
901+
902+
public void login(String arg0, String arg1) throws ServletException {
903+
throw new UnsupportedOperationException();
904+
}
905+
906+
public void logout() throws ServletException {
907+
throw new UnsupportedOperationException();
908+
}
909+
850910
}

org.springframework.web/src/test/java/org/springframework/mock/web/MockHttpServletResponse.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2011 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@
3939

4040
/**
4141
* Mock implementation of the {@link javax.servlet.http.HttpServletResponse}
42-
* interface. Supports the Servlet 2.5 API level.
42+
* interface. Supports the Servlet 3.0 API level
4343
*
4444
* <p>Used for testing the web framework; also useful for testing
4545
* application controllers.
@@ -292,19 +292,19 @@ public Set<String> getHeaderNames() {
292292
* @param name the name of the header
293293
* @return the associated header value, or <code>null<code> if none
294294
*/
295-
public Object getHeader(String name) {
295+
public String getHeader(String name) {
296296
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
297-
return (header != null ? header.getValue() : null);
297+
return (header != null ? header.getValue().toString() : null);
298298
}
299299

300300
/**
301301
* Return all values for the given header as a List of value objects.
302302
* @param name the name of the header
303303
* @return the associated header values, or an empty List if none
304304
*/
305-
public List<Object> getHeaders(String name) {
305+
public List<String> getHeaders(String name) {
306306
HeaderValueHolder header = HeaderValueHolder.getByName(this.headers, name);
307-
return (header != null ? header.getValues() : Collections.emptyList());
307+
return (header != null ? header.getStringValues() : Collections.<String>emptyList());
308308
}
309309

310310
/**

org.springframework.web/src/test/java/org/springframework/mock/web/MockServletContext.java

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2011 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,16 +23,25 @@
2323
import java.net.URL;
2424
import java.util.Collections;
2525
import java.util.Enumeration;
26+
import java.util.EventListener;
2627
import java.util.HashMap;
2728
import java.util.HashSet;
2829
import java.util.LinkedHashMap;
2930
import java.util.LinkedHashSet;
3031
import java.util.Map;
3132
import java.util.Set;
3233
import javax.activation.FileTypeMap;
34+
import javax.servlet.Filter;
35+
import javax.servlet.FilterRegistration;
36+
import javax.servlet.FilterRegistration.Dynamic;
3337
import javax.servlet.RequestDispatcher;
3438
import javax.servlet.Servlet;
3539
import javax.servlet.ServletContext;
40+
import javax.servlet.ServletException;
41+
import javax.servlet.ServletRegistration;
42+
import javax.servlet.SessionCookieConfig;
43+
import javax.servlet.SessionTrackingMode;
44+
import javax.servlet.descriptor.JspConfigDescriptor;
3645

3746
import org.apache.commons.logging.Log;
3847
import org.apache.commons.logging.LogFactory;
@@ -67,8 +76,12 @@
6776
* and XmlWebApplicationContext with an underlying MockServletContext (as long as
6877
* the MockServletContext has been configured with a FileSystemResourceLoader).
6978
*
79+
* Supports the Servlet 3.0 API level, but throws {@link UnsupportedOperationException}
80+
* for all methods introduced in Servlet 3.0.
81+
*
7082
* @author Rod Johnson
7183
* @author Juergen Hoeller
84+
* @author Chris Beams
7285
* @since 1.0.2
7386
* @see #MockServletContext(org.springframework.core.io.ResourceLoader)
7487
* @see org.springframework.web.context.support.XmlWebApplicationContext
@@ -361,4 +374,119 @@ public static String getMimeType(String filePath) {
361374
}
362375
}
363376

377+
378+
//---------------------------------------------------------------------
379+
// Methods introduced in Servlet 3.0
380+
//---------------------------------------------------------------------
381+
382+
public Dynamic addFilter(String arg0, String arg1) {
383+
throw new UnsupportedOperationException();
384+
}
385+
386+
public Dynamic addFilter(String arg0, Filter arg1) {
387+
throw new UnsupportedOperationException();
388+
}
389+
390+
public Dynamic addFilter(String arg0, Class<? extends Filter> arg1) {
391+
throw new UnsupportedOperationException();
392+
}
393+
394+
public void addListener(Class<? extends EventListener> arg0) {
395+
throw new UnsupportedOperationException();
396+
}
397+
398+
public void addListener(String arg0) {
399+
throw new UnsupportedOperationException();
400+
}
401+
402+
public <T extends EventListener> void addListener(T arg0) {
403+
throw new UnsupportedOperationException();
404+
}
405+
406+
public javax.servlet.ServletRegistration.Dynamic addServlet(String arg0, String arg1) {
407+
throw new UnsupportedOperationException();
408+
}
409+
410+
public javax.servlet.ServletRegistration.Dynamic addServlet(String arg0,
411+
Servlet arg1) {
412+
throw new UnsupportedOperationException();
413+
}
414+
415+
public javax.servlet.ServletRegistration.Dynamic addServlet(String arg0,
416+
Class<? extends Servlet> arg1) {
417+
throw new UnsupportedOperationException();
418+
}
419+
420+
public <T extends Filter> T createFilter(Class<T> arg0)
421+
throws ServletException {
422+
throw new UnsupportedOperationException();
423+
}
424+
425+
public <T extends EventListener> T createListener(Class<T> arg0)
426+
throws ServletException {
427+
throw new UnsupportedOperationException();
428+
}
429+
430+
public <T extends Servlet> T createServlet(Class<T> arg0)
431+
throws ServletException {
432+
throw new UnsupportedOperationException();
433+
}
434+
435+
public void declareRoles(String... arg0) {
436+
throw new UnsupportedOperationException();
437+
}
438+
439+
public ClassLoader getClassLoader() {
440+
throw new UnsupportedOperationException();
441+
}
442+
443+
public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
444+
throw new UnsupportedOperationException();
445+
}
446+
447+
public int getEffectiveMajorVersion() {
448+
throw new UnsupportedOperationException();
449+
}
450+
451+
public int getEffectiveMinorVersion() {
452+
throw new UnsupportedOperationException();
453+
}
454+
455+
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
456+
throw new UnsupportedOperationException();
457+
}
458+
459+
public FilterRegistration getFilterRegistration(String arg0) {
460+
throw new UnsupportedOperationException();
461+
}
462+
463+
public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
464+
throw new UnsupportedOperationException();
465+
}
466+
467+
public JspConfigDescriptor getJspConfigDescriptor() {
468+
throw new UnsupportedOperationException();
469+
}
470+
471+
public ServletRegistration getServletRegistration(String arg0) {
472+
throw new UnsupportedOperationException();
473+
}
474+
475+
public Map<String, ? extends ServletRegistration> getServletRegistrations() {
476+
throw new UnsupportedOperationException();
477+
}
478+
479+
public SessionCookieConfig getSessionCookieConfig() {
480+
throw new UnsupportedOperationException();
481+
}
482+
483+
public boolean setInitParameter(String arg0, String arg1) {
484+
throw new UnsupportedOperationException();
485+
}
486+
487+
public void setSessionTrackingModes(Set<SessionTrackingMode> arg0)
488+
throws IllegalStateException, IllegalArgumentException {
489+
throw new UnsupportedOperationException();
490+
}
491+
364492
}

org.springframework.web/src/test/java/org/springframework/web/context/request/ServletWebRequestTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void checkModifiedTimeStamp() {
136136
request.checkNotModified(currentTime);
137137

138138
assertEquals(200, servletResponse.getStatus());
139-
assertEquals(currentTime, servletResponse.getHeader("Last-Modified"));
139+
assertEquals(""+currentTime, servletResponse.getHeader("Last-Modified"));
140140
}
141141

142142
@Test

org.springframework.web/template.mf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Import-Template:
1515
javax.portlet.*;version="[2.0.0, 3.0.0)";resolution:=optional,
1616
javax.servlet;version="[2.4.0, 4.0.0)",
1717
javax.servlet.http;version="[2.4.0, 4.0.0)",
18+
javax.servlet.annotation;version="[3.0.0, 4.0.0)";resolution:=optional,
1819
javax.servlet.jsp.*;version="[2.0.0, 3.0.0)";resolution:=optional,
1920
javax.xml.*;version="0";resolution:=optional,
2021
org.aopalliance.*;version="[1.0.0, 2.0.0)",

org.springframework.web/web.iml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@
4747
<orderEntry type="module-library">
4848
<library>
4949
<CLASSES>
50-
<root url="jar://$IVY_CACHE$/javax.servlet/com.springsource.javax.servlet/2.5.0/com.springsource.javax.servlet-2.5.0.jar!/" />
50+
<root url="jar://$IVY_CACHE$/javax.servlet/javax.servlet/3.0.0.v201103241009/javax.servlet-3.0.0.v201103241009.jar!/" />
5151
</CLASSES>
5252
<JAVADOC />
5353
<SOURCES>
54-
<root url="jar://$IVY_CACHE$/javax.servlet/com.springsource.javax.servlet/2.5.0/com.springsource.javax.servlet-sources-2.5.0.jar!/" />
54+
<root url="jar://$IVY_CACHE$/javax.servlet/javax.servlet/3.0.0.v201103241009/javax.servlet-sources-3.0.0.v201103241009.jar!/" />
5555
</SOURCES>
5656
</library>
5757
</orderEntry>

0 commit comments

Comments
 (0)