Author: remy.maucherat(a)jboss.com
Date: 2009-08-18 10:06:05 -0400 (Tue, 18 Aug 2009)
New Revision: 1145
Modified:
trunk/java/org/apache/catalina/Context.java
trunk/java/org/apache/catalina/connector/Response.java
trunk/java/org/apache/catalina/core/ApplicationContext.java
trunk/java/org/apache/catalina/core/Constants.java
trunk/java/org/apache/catalina/core/StandardContext.java
Log:
- Implement 4 methods (two new and two that I forgot).
- Cleanup FIXMEs (restricted methods need to be done, basically).
Modified: trunk/java/org/apache/catalina/Context.java
===================================================================
--- trunk/java/org/apache/catalina/Context.java 2009-08-17 16:21:14 UTC (rev 1144)
+++ trunk/java/org/apache/catalina/Context.java 2009-08-18 14:06:05 UTC (rev 1145)
@@ -415,6 +415,18 @@
/**
+ * Return the Servlet API version defined for the webapp.
+ */
+ public int getVersionMajor();
+
+
+ /**
+ * Return the Servlet API version defined for the webapp.
+ */
+ public int getVersionMinor();
+
+
+ /**
* Set the Servlet API version defined for the webapp.
*
* @param version The version
Modified: trunk/java/org/apache/catalina/connector/Response.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Response.java 2009-08-17 16:21:14 UTC (rev
1144)
+++ trunk/java/org/apache/catalina/connector/Response.java 2009-08-18 14:06:05 UTC (rev
1145)
@@ -876,16 +876,13 @@
* a zero-length array if no headers have been set.
*/
public Collection<String> getHeaderNames() {
-
MimeHeaders headers = coyoteResponse.getMimeHeaders();
+ Collection<String> headersCollection = new ArrayList<String>();
int n = headers.size();
- String[] result = new String[n];
for (int i = 0; i < n; i++) {
- result[i] = headers.getName(i).toString();
+ headersCollection.add(headers.getName(i).toString());
}
- // FIXME
- return null;
-
+ return headersCollection;
}
@@ -914,8 +911,12 @@
* @param name Header name to look up
*/
public Collection<String> getHeaders(String name) {
- // FIXME
- return null;
+ Enumeration enumeration = coyoteResponse.getMimeHeaders().values(name);
+ Collection<String> headerValuesCollection = new ArrayList<String>();
+ while (enumeration.hasMoreElements()) {
+ headerValuesCollection.add((String) enumeration.nextElement());
+ }
+ return headerValuesCollection;
}
Modified: trunk/java/org/apache/catalina/core/ApplicationContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-08-17 16:21:14 UTC
(rev 1144)
+++ trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-08-18 14:06:05 UTC
(rev 1145)
@@ -847,6 +847,7 @@
public FilterRegistration.Dynamic addFilter(String filterName, String className)
throws IllegalArgumentException, IllegalStateException {
+ // FIXME: restricted method
if (context.isInitialized()) {
throw new
IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
@@ -862,6 +863,7 @@
public FilterRegistration.Dynamic addFilter(String filterName, Filter filter) {
+ // FIXME: restricted method
if (context.isInitialized()) {
throw new
IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
@@ -879,12 +881,14 @@
public FilterRegistration.Dynamic addFilter(String filterName,
Class<? extends Filter> filterClass) {
+ // FIXME: restricted method
return addFilter(filterName, filterClass.getName());
}
public ServletRegistration.Dynamic addServlet(String servletName, String className)
throws IllegalArgumentException, IllegalStateException {
+ // FIXME: restricted method
if (context.isInitialized()) {
throw new
IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
@@ -901,11 +905,13 @@
public ServletRegistration.Dynamic addServlet(String servletName,
Class<? extends Servlet> clazz) throws IllegalArgumentException,
IllegalStateException {
+ // FIXME: restricted method
return addServlet(servletName, clazz.getName());
}
public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) {
+ // FIXME: restricted method
if (context.isInitialized()) {
throw new
IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
@@ -921,6 +927,7 @@
public FilterRegistration getFilterRegistration(String filterName) {
+ // FIXME: restricted method
ApplicationFilterConfig filterConfig =
context.findApplicationFilterConfig(filterName);
if (filterConfig == null) {
FilterDef filterDef = context.findFilterDef(filterName);
@@ -936,6 +943,7 @@
public ServletRegistration getServletRegistration(String servletName) {
+ // FIXME: restricted method
Wrapper wrapper = (Wrapper) context.findChild(servletName);
if (wrapper != null) {
return wrapper.getFacade();
@@ -946,6 +954,7 @@
public Map<String, FilterRegistration> getFilterRegistrations() {
+ // FIXME: restricted method
HashMap<String, FilterRegistration> result =
new HashMap<String, FilterRegistration>();
ApplicationFilterConfig[] filterConfigs =
context.findApplicationFilterConfigs();
@@ -957,6 +966,7 @@
public Map<String, ServletRegistration> getServletRegistrations() {
+ // FIXME: restricted method
HashMap<String, ServletRegistration> result =
new HashMap<String, ServletRegistration>();
Container[] wrappers = context.findChildren();
@@ -968,34 +978,26 @@
}
- /**
- * By default {@link SessionTrackingMode#URL} is always supported, {@link
- * SessionTrackingMode#COOKIE} is supported unless the
<code>cookies</code>
- * attribute has been set to <code>false</code> for the context and
{@link
- * SessionTrackingMode#SSL} is supported if at least one of the connectors
- * used by this context has the attribute <code>secure</code> set to
- * <code>true</code>.
- */
public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
+ // FIXME: restricted method
return context.getDefaultSessionTrackingModes();
}
- /**
- * Return the supplied value if one was previously set, else return the
- * defaults.
- */
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
+ // FIXME: restricted method
return context.getSessionTrackingModes();
}
public SessionCookieConfig getSessionCookieConfig() {
+ // FIXME: restricted method
return context.getSessionCookie();
}
public <T extends Filter> T createFilter(Class<T> c)
throws ServletException {
+ // FIXME: restricted method
try {
return (T) context.getInstanceManager().newInstance(c);
} catch (Throwable e) {
@@ -1007,6 +1009,7 @@
public <T extends Servlet> T createServlet(Class<T> c)
throws ServletException {
+ // FIXME: restricted method
try {
return (T) context.getInstanceManager().newInstance(c);
} catch (Throwable e) {
@@ -1017,6 +1020,7 @@
public boolean setInitParameter(String name, String value) {
+ // FIXME: restricted method
mergeParameters();
if (parameters.get(name) != null) {
return false;
@@ -1035,13 +1039,12 @@
* requested
*/
public void setSessionTrackingModes(Set<SessionTrackingMode>
sessionTrackingModes) {
-
+ // FIXME: restricted method
if (context.getAvailable()) {
throw new IllegalStateException(
sm.getString("applicationContext.setSessionTracking.ise",
getContextPath()));
}
-
// Check that only supported tracking modes have been requested
for (SessionTrackingMode sessionTrackingMode : sessionTrackingModes) {
if (!getDefaultSessionTrackingModes().contains(sessionTrackingMode)) {
@@ -1050,38 +1053,37 @@
sessionTrackingMode.toString(), getContextPath()));
}
}
- // TODO SERVLET3 - The SSL test
-
+ // TODO: Possible SSL tracking mode
context.setSessionTrackingModes(sessionTrackingModes);
}
public void addListener(String className) {
+ // FIXME: restricted method
if (context.isInitialized()) {
throw new
IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
}
- // FIXME: forbidden if the listener is from a TLD
context.addApplicationListener(className);
}
public <T extends EventListener> void addListener(T listener) {
+ // FIXME: restricted method
if (context.isInitialized()) {
throw new
IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
}
- // FIXME: forbidden if the listener is from a TLD
context.addApplicationListenerInstance(listener);
}
public void addListener(Class<? extends EventListener> listenerClass) {
+ // FIXME: restricted method
if (context.isInitialized()) {
throw new
IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
}
- // FIXME: forbidden if the listener is from a TLD
try {
EventListener listenerInstance =
(EventListener) context.getInstanceManager().newInstance(listenerClass);
@@ -1095,6 +1097,7 @@
public <T extends EventListener> T createListener(Class<T> clazz)
throws ServletException {
+ // FIXME: restricted method
if (context.isInitialized()) {
throw new
IllegalStateException(sm.getString("applicationContext.alreadyInitialized",
getContextPath()));
@@ -1111,11 +1114,13 @@
public ClassLoader getClassLoader() {
+ // FIXME: restricted method
return context.getLoader().getClassLoader();
}
public JspConfigDescriptor getJspConfigDescriptor() {
+ // FIXME: restricted method
ArrayList<TaglibDescriptor> taglibDescriptors = new
ArrayList<TaglibDescriptor>();
String[] taglibURIs = context.findTaglibs();
for (int i = 0; i < taglibURIs.length; i++) {
@@ -1135,14 +1140,14 @@
public int getEffectiveMajorVersion() {
- // TODO Auto-generated method stub
- return 0;
+ // FIXME: restricted method
+ return context.getVersionMajor();
}
public int getEffectiveMinorVersion() {
- // TODO Auto-generated method stub
- return 0;
+ // FIXME: restricted method
+ return context.getVersionMinor();
}
// -------------------------------------------------------- Package Methods
Modified: trunk/java/org/apache/catalina/core/Constants.java
===================================================================
--- trunk/java/org/apache/catalina/core/Constants.java 2009-08-17 16:21:14 UTC (rev 1144)
+++ trunk/java/org/apache/catalina/core/Constants.java 2009-08-18 14:06:05 UTC (rev 1145)
@@ -22,8 +22,8 @@
public class Constants {
public static final String Package = "org.apache.catalina.core";
- public static final int MAJOR_VERSION = 2;
- public static final int MINOR_VERSION = 5;
+ public static final int MAJOR_VERSION = 3;
+ public static final int MINOR_VERSION = 0;
public static final String JSP_SERVLET_CLASS =
"org.apache.jasper.servlet.JspServlet";
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-08-17 16:21:14 UTC (rev
1144)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-08-18 14:06:05 UTC (rev
1145)
@@ -519,6 +519,18 @@
/**
+ * Version number.
+ */
+ protected int versionMinor = 0;
+
+
+ /**
+ * Version number.
+ */
+ protected int versionMajor = 0;
+
+
+ /**
* The reloadable flag for this web application.
*/
protected boolean reloadable = false;
@@ -1604,6 +1616,34 @@
/**
+ * Return the Servlet API version defined for the webapp.
+ */
+ public int getVersionMajor() {
+ if (version != null) {
+ int pos = version.indexOf('.');
+ if (pos != -1) {
+ versionMajor = Integer.parseInt(version.substring(0, pos));
+ }
+ }
+ return versionMajor;
+ }
+
+
+ /**
+ * Return the Servlet API version defined for the webapp.
+ */
+ public int getVersionMinor() {
+ if (version != null) {
+ int pos = version.indexOf('.');
+ if (pos < version.length()) {
+ versionMinor = Integer.parseInt(version.substring(pos + 1));
+ }
+ }
+ return versionMinor;
+ }
+
+
+ /**
* Set the Servlet API version defined for the webapp.
*
* @param version The version
@@ -1611,6 +1651,8 @@
public void setVersion(String version) {
String oldVersion = this.version;
this.version = version;
+ getVersionMajor();
+ getVersionMinor();
support.firePropertyChange("version", oldVersion, version);
}