JBossWeb SVN: r916 - trunk.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-01-29 16:35:41 -0500 (Thu, 29 Jan 2009)
New Revision: 916
Modified:
trunk/ROADMAP.txt
trunk/build.xml
Log:
- Build fix.
Modified: trunk/ROADMAP.txt
===================================================================
--- trunk/ROADMAP.txt 2009-01-29 21:35:00 UTC (rev 915)
+++ trunk/ROADMAP.txt 2009-01-29 21:35:41 UTC (rev 916)
@@ -13,10 +13,12 @@
- Implement JSP 2.2 changes
- Implement EL 1.1 changes
- Coordinate with AS 6 to implement new web.xml parsing (out of tree)
+- JBoss Metadata parsing of .tld files (out of tree)
- Coordinate with AS 6 for annotation updates (out of tree)
Other:
-- Diagnostic and monitoring features
+- Diagnostic and monitoring features (provided by the jopr/JON agent, as JBoss Web standalone seems too
+ lightweight for embeddede jopr/JON to make sense)
- .net support like the php support (looks ok, but PHP is hard to use, how would this be different ?)
- fastcgi servlet (sounds useless)
- Java proxy (probably too many components needed to compete with mod_cluster, but a very basic HTTP proxy could be useful
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2009-01-29 21:35:00 UTC (rev 915)
+++ trunk/build.xml 2009-01-29 21:35:41 UTC (rev 916)
@@ -144,6 +144,7 @@
<jar jarfile="${servlet-api.jar}">
<fileset dir="${tomcat.classes}">
<include name="javax/servlet/*" />
+ <include name="javax/servlet/annotation/*" />
<include name="javax/servlet/http/*" />
<include name="javax/servlet/resources/*" />
<!-- Javadoc and i18n exclusions -->
15 years, 10 months
JBossWeb SVN: r915 - trunk/java/org/apache/catalina/core.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-01-29 16:35:00 -0500 (Thu, 29 Jan 2009)
New Revision: 915
Added:
trunk/java/org/apache/catalina/core/AnnotationScanner.java
Log:
- Add my current annotation scanner, after a number of experiments.
Added: trunk/java/org/apache/catalina/core/AnnotationScanner.java
===================================================================
--- trunk/java/org/apache/catalina/core/AnnotationScanner.java (rev 0)
+++ trunk/java/org/apache/catalina/core/AnnotationScanner.java 2009-01-29 21:35:00 UTC (rev 915)
@@ -0,0 +1,242 @@
+/*
+ * 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.catalina.core;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import javax.naming.Binding;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.servlet.annotation.InitParam;
+import javax.servlet.annotation.ServletFilter;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.annotation.WebServletContextListener;
+
+import org.apache.catalina.Context;
+import org.apache.naming.resources.Resource;
+
+public class AnnotationScanner {
+
+ // FIXME: probably should not be static, and tied to a Context, to allow pluggability ?
+
+ public static final Class<?>[] ANNOTATIONS_TYPES =
+ { InitParam.class, ServletFilter.class, WebServlet.class, WebServletContextListener.class };
+
+ public static final boolean USE_JAVASSIST =
+ Boolean.valueOf(System.getProperty("org.apache.catalina.core.AnnotationScanner.USE_JAVASSIST", "false")).booleanValue();
+
+ /**
+ * Scan the given context's default locations for annotations.
+ *
+ * @param context
+ */
+ public static void scan(Context context) {
+ // FIXME: obviously needs to return a result
+
+ if (context.getLoader().findLoaderRepositories() != null) {
+ String[] repositories = context.getLoader().findLoaderRepositories();
+ for (int i = 0; i < repositories.length; i++) {
+ System.out.println("Repo: " + repositories[i]);
+ if (repositories[i].endsWith(".jar")) {
+ try {
+ scanJar(context, new JarFile(repositories[i]));
+ } catch (IOException e) {
+ // Ignore
+ }
+ } else {
+ scanClasses(context, new File(repositories[i]), "");
+ }
+ }
+ }
+
+ /*
+ DirContext resources = context.getResources();
+ DirContext webInfClasses = null;
+ DirContext webInfLib = null;
+
+ try {
+ webInfClasses = (DirContext) resources.lookup("/WEB-INF/classes");
+ } catch (Exception e) {
+ // Ignore, /WEB-INF/classes not found, or not a folder
+ }
+ if (webInfClasses != null) {
+ scanClasses(context, webInfClasses, "");
+ }
+
+ try {
+ webInfLib = (DirContext) resources.lookup("/WEB-INF/lib");
+ } catch (Exception e) {
+ // Ignore, /WEB-INF/classes not found, or not a folder
+ }
+ if (webInfLib != null) {
+ scanJars(context, webInfLib);
+ }*/
+
+ }
+
+
+ /**
+ * Scan folder containing class files.
+ */
+ public static void scanClasses(Context context, File folder, String path) {
+ String[] files = folder.list();
+ for (int i = 0; i < files.length; i++) {
+ File file = new File(folder, files[i]);
+ if (file.isDirectory()) {
+ scanClasses(context, file, path + "/" + files[i]);
+ } else if (files[i].endsWith(".class")) {
+ String className = getClassName(path + "/" + files[i]);
+ scanClass(context, className, file, null);
+ }
+ }
+ }
+
+
+ /**
+ * Scan folder containing class files.
+ */
+ /*
+ public static void scanClasses(Context context, DirContext folder, String path) {
+ try {
+ NamingEnumeration<Binding> enumeration = folder.listBindings(path);
+ while (enumeration.hasMore()) {
+ Binding binding = enumeration.next();
+ Object object = binding.getObject();
+
+ if (object instanceof Resource) {
+ // This is a class, so we should load it
+ String className = getClassName(path + "/" + binding.getName());
+ scanClass(context, className, (Resource) object, null, null);
+ } else if (object instanceof DirContext) {
+ scanClasses(context, folder, path + "/" + binding.getName());
+ }
+
+ }
+ } catch (NamingException e) {
+ // Ignore for now
+ e.printStackTrace();
+ }
+ }*/
+
+
+ /**
+ * Scan folder containing JAR files.
+ */
+ public static void scanJars(Context context, DirContext folder) {
+ if (context.getLoader().findLoaderRepositories() != null) {
+ String[] repositories = context.getLoader().findLoaderRepositories();
+ for (int i = 0; i < repositories.length; i++) {
+ System.out.println("Repo: " + repositories[i]);
+ if (repositories[i].endsWith(".jar")) {
+ try {
+ scanJar(context, new JarFile(repositories[i]));
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+ }
+ /*else {
+ try {
+ NamingEnumeration<Binding> enumeration = folder.listBindings("");
+ while (enumeration.hasMore()) {
+ Binding binding = enumeration.next();
+ Object object = binding.getObject();
+
+ if (object instanceof Resource && binding.getName().endsWith(".jar")) {
+ // This is normally a JAR, put it in the work folder
+ File destDir = null;
+ File workDir =
+ (File) context.getServletContext().getAttribute(Globals.WORK_DIR_ATTR);
+ destDir = new File(workDir, "WEB-INF/lib");
+ destDir.mkdirs();
+ File destFile = new File(destDir, binding.getName());
+
+ scanJar(context, (Resource) object);
+ }
+
+ }
+ } catch (NamingException e) {
+ // Ignore for now
+ e.printStackTrace();
+ }
+ }*/
+ }
+
+
+ /**
+ * Scan all class files in the given JAR.
+ */
+ public static void scanJar(Context context, JarFile file) {
+ Enumeration<JarEntry> entries = file.entries();
+ while (entries.hasMoreElements()) {
+ JarEntry entry = entries.nextElement();
+ if (entry.getName().endsWith(".class")) {
+ scanClass(context, getClassName(entry.getName()), null, entry);
+ }
+ }
+ try {
+ file.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+
+
+ /**
+ * Get class name given a path to a classfile.
+ * /my/class/MyClass.class -> my.class.MyClass
+ */
+ public static String getClassName(String filePath) {
+ if (filePath.startsWith("/")) {
+ filePath = filePath.substring(1);
+ }
+ if (filePath.endsWith(".class")) {
+ filePath = filePath.substring(0, filePath.length() - ".class".length());
+ }
+ return filePath.replace('/', '.');
+ }
+
+
+ /**
+ * Scan class for interesting annotations.
+ */
+ public static boolean scanClass(Context context, String className, File file, JarEntry entry) {
+ if (USE_JAVASSIST) {
+ // FIXME: Javassist implementation
+ } else {
+ // Load the class using the classloader, and see if it implements one of the web annotations
+ try {
+ System.out.println("Scan class: " + className);
+ Class<?> clazz = context.getLoader().getClassLoader().loadClass(className);
+ } catch (Throwable t) {
+ // Ignore classloading errors here
+ System.out.println("CL Error: " + t);
+ }
+ }
+ return false;
+ }
+
+
+}
15 years, 10 months
JBossWeb SVN: r914 - in trunk/java/org/apache/catalina: loader and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-01-29 11:56:25 -0500 (Thu, 29 Jan 2009)
New Revision: 914
Modified:
trunk/java/org/apache/catalina/Loader.java
trunk/java/org/apache/catalina/loader/WebappLoader.java
Log:
- The loader repositories field (which seems a bit useless) seems a good place to expose the real loading location (I prefer
avoiding using URLs to handle stuff if possible).
Modified: trunk/java/org/apache/catalina/Loader.java
===================================================================
--- trunk/java/org/apache/catalina/Loader.java 2009-01-27 10:36:32 UTC (rev 913)
+++ trunk/java/org/apache/catalina/Loader.java 2009-01-29 16:56:25 UTC (rev 914)
@@ -129,6 +129,13 @@
/**
+ * Return the set of loader repositories defined for this class loader.
+ * If none are defined, a zero-length array is returned.
+ */
+ public String[] findLoaderRepositories();
+
+
+ /**
* Add a property change listener to this component.
*
* @param listener The listener to add
Modified: trunk/java/org/apache/catalina/loader/WebappLoader.java
===================================================================
--- trunk/java/org/apache/catalina/loader/WebappLoader.java 2009-01-27 10:36:32 UTC (rev 913)
+++ trunk/java/org/apache/catalina/loader/WebappLoader.java 2009-01-29 16:56:25 UTC (rev 914)
@@ -441,6 +441,10 @@
return sb.toString();
}
+ public String[] findLoaderRepositories() {
+ return getLoaderRepositories();
+ }
+
public String[] getLoaderRepositories() {
if( loaderRepositories==null ) return null;
String res[]=new String[ loaderRepositories.size()];
@@ -941,7 +945,7 @@
// Adding the repository to the class loader
classLoader.addRepository(classesPath + "/", classRepository);
- loaderRepositories.add(classesPath + "/" );
+ loaderRepositories.add(classRepository.getAbsolutePath());
}
@@ -1016,7 +1020,7 @@
// in the dir
}
- loaderRepositories.add( filename );
+ loaderRepositories.add(destFile.getAbsolutePath());
}
} catch (NamingException e) {
15 years, 10 months
JBossWeb SVN: r913 - tags.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-01-27 05:36:32 -0500 (Tue, 27 Jan 2009)
New Revision: 913
Added:
tags/JBOSSWEB_2_1_2_CR1/
Log:
- JBoss Web 2.1.2 CR 1.
Copied: tags/JBOSSWEB_2_1_2_CR1 (from rev 912, branches/2.1.x)
15 years, 11 months
JBossWeb SVN: r912 - in trunk: java/org/apache/catalina/core and 2 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-01-26 15:21:13 -0500 (Mon, 26 Jan 2009)
New Revision: 912
Modified:
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/connector/RequestFacade.java
trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
trunk/java/org/apache/catalina/core/DummyRequest.java
trunk/java/org/apache/jasper/servlet/JspCServletContext.java
trunk/webapps/docs/changelog.xml
Log:
- Add skeleton methods.
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-01-23 18:17:34 UTC (rev 911)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-01-26 20:21:13 UTC (rev 912)
@@ -35,12 +35,16 @@
import java.util.TreeMap;
import javax.security.auth.Subject;
+import javax.servlet.AsyncContext;
+import javax.servlet.AsyncListener;
import javax.servlet.FilterChain;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletInputStream;
+import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.ServletRequestAttributeListener;
+import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -2050,6 +2054,13 @@
}
+ public ServletContext getServletContext() {
+ if (context == null)
+ return (null);
+ return context.getServletContext();
+ }
+
+
/**
* Return the portion of the request URI used to select the servlet
* that will process this request.
@@ -2719,5 +2730,55 @@
}
return true;
}
+
+ @Override
+ public void addAsyncListener(AsyncListener listener,
+ ServletRequest servletRequest, ServletResponse servletResponse) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void addAsyncListener(AsyncListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public AsyncContext getAsyncContext() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isAsyncStarted() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isAsyncSupported() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void setAsyncTimeout(long timeout) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public AsyncContext startAsync() throws IllegalStateException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public AsyncContext startAsync(ServletRequest servletRequest,
+ ServletResponse servletResponse) throws IllegalStateException {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Modified: trunk/java/org/apache/catalina/connector/RequestFacade.java
===================================================================
--- trunk/java/org/apache/catalina/connector/RequestFacade.java 2009-01-23 18:17:34 UTC (rev 911)
+++ trunk/java/org/apache/catalina/connector/RequestFacade.java 2009-01-26 20:21:13 UTC (rev 912)
@@ -26,8 +26,13 @@
import java.util.Locale;
import java.util.Map;
+import javax.servlet.AsyncContext;
+import javax.servlet.AsyncListener;
import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
import javax.servlet.ServletInputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -932,4 +937,96 @@
return request.getRemotePort();
}
+
+ public void addAsyncListener(AsyncListener listener,
+ ServletRequest servletRequest, ServletResponse servletResponse) {
+ if (request == null) {
+ throw new IllegalStateException(
+ sm.getString("requestFacade.nullRequest"));
+ }
+
+ request.addAsyncListener(listener, servletRequest, servletResponse);
+ }
+
+
+ public void addAsyncListener(AsyncListener listener) {
+ if (request == null) {
+ throw new IllegalStateException(
+ sm.getString("requestFacade.nullRequest"));
+ }
+
+ request.addAsyncListener(listener);
+ }
+
+
+ public AsyncContext getAsyncContext() {
+ if (request == null) {
+ throw new IllegalStateException(
+ sm.getString("requestFacade.nullRequest"));
+ }
+
+ return request.getAsyncContext();
+ }
+
+
+ public ServletContext getServletContext() {
+ if (request == null) {
+ throw new IllegalStateException(
+ sm.getString("requestFacade.nullRequest"));
+ }
+
+ return request.getServletContext();
+ }
+
+
+ public boolean isAsyncStarted() {
+ if (request == null) {
+ throw new IllegalStateException(
+ sm.getString("requestFacade.nullRequest"));
+ }
+
+ return request.isAsyncStarted();
+ }
+
+
+ public boolean isAsyncSupported() {
+ if (request == null) {
+ throw new IllegalStateException(
+ sm.getString("requestFacade.nullRequest"));
+ }
+
+ return request.isAsyncSupported();
+ }
+
+
+ public void setAsyncTimeout(long timeout) {
+ if (request == null) {
+ throw new IllegalStateException(
+ sm.getString("requestFacade.nullRequest"));
+ }
+
+ request.setAsyncTimeout(timeout);
+ }
+
+
+ public AsyncContext startAsync() throws IllegalStateException {
+ if (request == null) {
+ throw new IllegalStateException(
+ sm.getString("requestFacade.nullRequest"));
+ }
+
+ return request.startAsync();
+ }
+
+
+ public AsyncContext startAsync(ServletRequest servletRequest,
+ ServletResponse servletResponse) throws IllegalStateException {
+ if (request == null) {
+ throw new IllegalStateException(
+ sm.getString("requestFacade.nullRequest"));
+ }
+
+ return request.startAsync(servletRequest, servletResponse);
+ }
+
}
Modified: trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationContextFacade.java 2009-01-23 18:17:34 UTC (rev 911)
+++ trunk/java/org/apache/catalina/core/ApplicationContextFacade.java 2009-01-26 20:21:13 UTC (rev 912)
@@ -27,14 +27,19 @@
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import java.util.EnumSet;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
+import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
import org.apache.catalina.Globals;
import org.apache.catalina.security.SecurityUtil;
@@ -364,6 +369,109 @@
}
+ public void addFilter(String filterName, String description,
+ String className, Map<String, String> initParameters,
+ boolean isAsyncSupported) {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ doPrivileged("addFilter", new Object[]{filterName, description,
+ className, initParameters,
+ Boolean.valueOf(isAsyncSupported)});
+ } else {
+ context.addFilter(filterName, description, className,
+ initParameters, isAsyncSupported);
+ }
+ }
+
+
+ public void addFilterMappingForServletNames(String filterName,
+ EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
+ String... servletNames) {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ doPrivileged("addFilterMappingForServletNames",
+ new Object[]{filterName, dispatcherTypes,
+ Boolean.valueOf(isMatchAfter), servletNames});
+ } else {
+ context.addFilterMappingForServletNames(filterName, dispatcherTypes,
+ isMatchAfter, servletNames);
+ }
+ }
+
+
+ public void addFilterMappingForUrlPatterns(String filterName,
+ EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
+ String... urlPatterns) {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ doPrivileged("addFilterMappingForUrlPatterns",
+ new Object[]{filterName, dispatcherTypes,
+ Boolean.valueOf(isMatchAfter), urlPatterns});
+ } else {
+ context.addFilterMappingForUrlPatterns(filterName, dispatcherTypes,
+ isMatchAfter, urlPatterns);
+ }
+ }
+
+
+ public void addServletMapping(String servletName, String[] urlPatterns) {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ doPrivileged("addServletMapping",
+ new Object[]{servletName, urlPatterns});
+ } else {
+ context.addServletMapping(servletName, urlPatterns);
+ }
+ }
+
+
+ public EnumSet<SessionTrackingMode> getDefaultSessionTrackingModes() {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ return (EnumSet<SessionTrackingMode>)
+ doPrivileged("getDefaultSessionTrackingModes", null);
+ } else {
+ return context.getDefaultSessionTrackingModes();
+ }
+ }
+
+
+ public EnumSet<SessionTrackingMode> getEffectiveSessionTrackingModes() {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ return (EnumSet<SessionTrackingMode>)
+ doPrivileged("getEffectiveSessionTrackingModes", null);
+ } else {
+ return context.getEffectiveSessionTrackingModes();
+ }
+ }
+
+
+ public SessionCookieConfig getSessionCookieConfig() {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ return (SessionCookieConfig)
+ doPrivileged("getSessionCookieConfig", null);
+ } else {
+ return context.getSessionCookieConfig();
+ }
+ }
+
+
+ public void setSessionCookieConfig(SessionCookieConfig sessionCookieConfig) {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ doPrivileged("setSessionCookieConfig",
+ new Object[]{sessionCookieConfig});
+ } else {
+ context.setSessionCookieConfig(sessionCookieConfig);
+ }
+ }
+
+
+ public void setSessionTrackingModes(
+ EnumSet<SessionTrackingMode> sessionTrackingModes) {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ doPrivileged("setSessionTrackingModes",
+ new Object[]{sessionTrackingModes});
+ } else {
+ context.setSessionTrackingModes(sessionTrackingModes);
+ }
+ }
+
+
/**
* Use reflection to invoke the requested method. Cache the method object
* to speed up the process
@@ -507,4 +615,6 @@
throw realException;
}
+
+
}
Modified: trunk/java/org/apache/catalina/core/DummyRequest.java
===================================================================
--- trunk/java/org/apache/catalina/core/DummyRequest.java 2009-01-23 18:17:34 UTC (rev 911)
+++ trunk/java/org/apache/catalina/core/DummyRequest.java 2009-01-26 20:21:13 UTC (rev 912)
@@ -30,10 +30,14 @@
import java.util.Locale;
import java.util.Map;
+import javax.servlet.AsyncContext;
+import javax.servlet.AsyncListener;
import javax.servlet.FilterChain;
import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -263,6 +267,18 @@
public String getLocalName() { return null; }
public int getLocalPort() { return -1; }
public int getRemotePort() { return -1; }
+
+ public void addAsyncListener(AsyncListener listener,
+ ServletRequest servletRequest, ServletResponse servletResponse) {}
+ public void addAsyncListener(AsyncListener listener) {}
+ public AsyncContext getAsyncContext() { return null; }
+ public ServletContext getServletContext() { return null; }
+ public boolean isAsyncStarted() { return false; }
+ public boolean isAsyncSupported() { return false; }
+ public void setAsyncTimeout(long timeout) {}
+ public AsyncContext startAsync() throws IllegalStateException { return null; }
+ public AsyncContext startAsync(ServletRequest servletRequest,
+ ServletResponse servletResponse) throws IllegalStateException { return null; }
}
Modified: trunk/java/org/apache/jasper/servlet/JspCServletContext.java
===================================================================
--- trunk/java/org/apache/jasper/servlet/JspCServletContext.java 2009-01-23 18:17:34 UTC (rev 911)
+++ trunk/java/org/apache/jasper/servlet/JspCServletContext.java 2009-01-26 20:21:13 UTC (rev 912)
@@ -23,16 +23,21 @@
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.EnumSet;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
+import java.util.Map;
import java.util.Set;
import java.util.Vector;
+import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
/**
@@ -437,5 +442,56 @@
}
+ public void addFilter(String filterName, String description,
+ String className, Map<String, String> initParameters,
+ boolean isAsyncSupported) {
+ // Do nothing
+ }
+
+ public void addFilterMappingForServletNames(String filterName,
+ EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
+ String... servletNames) {
+ // Do nothing
+ }
+
+
+ public void addFilterMappingForUrlPatterns(String filterName,
+ EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
+ String... urlPatterns) {
+ // Do nothing
+ }
+
+
+ public void addServletMapping(String servletName, String[] urlPatterns) {
+ // Do nothing
+ }
+
+
+ public EnumSet<SessionTrackingMode> getDefaultSessionTrackingModes() {
+ return EnumSet.noneOf(SessionTrackingMode.class);
+ }
+
+
+ public EnumSet<SessionTrackingMode> getEffectiveSessionTrackingModes() {
+ return EnumSet.noneOf(SessionTrackingMode.class);
+ }
+
+
+ public SessionCookieConfig getSessionCookieConfig() {
+ return null;
+ }
+
+
+ public void setSessionCookieConfig(SessionCookieConfig sessionCookieConfig) {
+ // Do nothing
+ }
+
+
+ public void setSessionTrackingModes(
+ EnumSet<SessionTrackingMode> sessionTrackingModes) {
+ // Do nothing
+ }
+
+
}
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2009-01-23 18:17:34 UTC (rev 911)
+++ trunk/webapps/docs/changelog.xml 2009-01-26 20:21:13 UTC (rev 912)
@@ -29,6 +29,9 @@
<update>
Replace TomcatCookie class with the new Cookie API. (remm)
</update>
+ <update>
+ Cookie tracking and Servlet 3.0 cookie configuration. (markt, remm)
+ </update>
</changelog>
</subsection>
<subsection name="Coyote">
15 years, 11 months
JBossWeb SVN: r911 - trunk/java/org/apache/catalina/core.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-01-23 13:17:34 -0500 (Fri, 23 Jan 2009)
New Revision: 911
Modified:
trunk/java/org/apache/catalina/core/ApplicationContext.java
trunk/java/org/apache/catalina/core/LocalStrings.properties
trunk/java/org/apache/catalina/core/StandardContext.java
Log:
- Some of the cookie and session config. I did not like putting it all in the servlet context.
Modified: trunk/java/org/apache/catalina/core/ApplicationContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-01-23 18:16:50 UTC (rev 910)
+++ trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-01-23 18:17:34 UTC (rev 911)
@@ -24,6 +24,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.EnumSet;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;
@@ -33,17 +34,23 @@
import javax.naming.Binding;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
+import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
import org.apache.catalina.Context;
import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.Wrapper;
import org.apache.catalina.deploy.ApplicationParameter;
+import org.apache.catalina.deploy.FilterDef;
+import org.apache.catalina.deploy.FilterMap;
+import org.apache.catalina.deploy.SessionCookie;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.ResourceSet;
@@ -145,6 +152,12 @@
new ThreadLocal<DispatchData>();
+ /**
+ * Effective session cookie config.
+ */
+ private SessionCookieConfig sessionCookieConfig = null;
+
+
// --------------------------------------------------------- Public Methods
@@ -801,6 +814,155 @@
}
+ public void addFilter(String filterName, String description,
+ String className, Map<String, String> initParameters,
+ boolean isAsyncSupported) {
+
+ if (context.initialized) {
+ //TODO Spec breaking enhancement to ignore this restriction
+ throw new IllegalStateException(
+ sm.getString("applicationContext.addFilter.ise",
+ getContextPath()));
+ }
+ FilterDef filterDef = new FilterDef();
+ filterDef.setFilterName(filterName);
+ filterDef.setDescription(description);
+ filterDef.setFilterClass(className);
+ filterDef.getParameterMap().putAll(initParameters);
+ context.addFilterDef(filterDef);
+ // TODO SERVLET3 - ASync support
+ }
+
+
+ public void addFilterMappingForServletNames(String filterName,
+ EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
+ String... servletNames) {
+ if (context.initialized) {
+ //TODO Spec breaking enhancement to ignore this restriction
+ throw new IllegalStateException(sm.getString(
+ "applicationContext.addFilterMapping", getContextPath()));
+ }
+ FilterMap filterMap = new FilterMap();
+ for (String servletName : servletNames) {
+ filterMap.addServletName(servletName);
+ }
+ filterMap.setFilterName(filterName);
+ for (DispatcherType dispatcherType: dispatcherTypes) {
+ filterMap.setDispatcher(dispatcherType.name());
+ }
+ if (isMatchAfter) {
+ context.addFilterMap(filterMap);
+ } else {
+ context.addFilterMapBefore(filterMap);
+ }
+ }
+
+
+ public void addFilterMappingForUrlPatterns(String filterName,
+ EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
+ String... urlPatterns) {
+
+ if (context.initialized) {
+ //TODO Spec breaking enhancement to ignore this restriction
+ throw new IllegalStateException(sm.getString(
+ "applicationContext.addFilterMapping", getContextPath()));
+ }
+ FilterMap filterMap = new FilterMap();
+ for (String urlPattern : urlPatterns) {
+ filterMap.addURLPattern(urlPattern);
+ }
+ filterMap.setFilterName(filterName);
+ for (DispatcherType dispatcherType: dispatcherTypes) {
+ filterMap.setDispatcher(dispatcherType.name());
+ }
+ if (isMatchAfter) {
+ context.addFilterMap(filterMap);
+ } else {
+ context.addFilterMapBefore(filterMap);
+ }
+ }
+
+
+ public void addServletMapping(String servletName, String[] urlPatterns) {
+ if (context.initialized) {
+ //TODO Spec breaking enhancement to ignore this restriction
+ throw new IllegalStateException(sm.getString(
+ "applicationContext.addServletMapping", getContextPath()));
+ }
+ for (String urlPattern : urlPatterns) {
+ boolean jspWildCard = ("*.jsp".equals(urlPattern));
+ context.addServletMapping(servletName, urlPattern, jspWildCard);
+ }
+ }
+
+
+ /**
+ * 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 EnumSet<SessionTrackingMode> getDefaultSessionTrackingModes() {
+ return context.getDefaultSessionTrackingModes();
+ }
+
+ /**
+ * Return the supplied value if one was previously set, else return the
+ * defaults.
+ */
+ public EnumSet<SessionTrackingMode> getEffectiveSessionTrackingModes() {
+ return context.getSessionTrackingModes();
+ }
+
+
+ public SessionCookieConfig getSessionCookieConfig() {
+ if (sessionCookieConfig != null) {
+ return sessionCookieConfig;
+ }
+ SessionCookie sessionCookie = context.getSessionCookie();
+ sessionCookieConfig = new SessionCookieConfig(sessionCookie.getDomain(), sessionCookie.getPath(),
+ sessionCookie.getComment(), sessionCookie.isHttpOnly(), sessionCookie.isSecure());
+ return sessionCookieConfig;
+ }
+
+
+ public void setSessionCookieConfig(SessionCookieConfig sessionCookieConfig) {
+ // FIXME: do something ...
+ this.sessionCookieConfig = sessionCookieConfig;
+ }
+
+
+ /**
+ * @throws IllegalStateException if the context has already been initialised
+ * @throws IllegalArgumentException TODO SERVLET3 Something to do with SSL
+ * but the spec language is not clear
+ * If an unsupported tracking mode is
+ * requested
+ */
+ public void setSessionTrackingModes(EnumSet<SessionTrackingMode> sessionTrackingModes) {
+
+ 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)) {
+ throw new IllegalArgumentException(sm.getString(
+ "applicationContext.setSessionTracking.iae",
+ sessionTrackingMode.toString(), getContextPath()));
+ }
+ }
+ // TODO SERVLET3 - The SSL test
+
+ context.setSessionTrackingModes(sessionTrackingModes);
+ }
+
+
// -------------------------------------------------------- Package Methods
protected StandardContext getContext() {
return this.context;
Modified: trunk/java/org/apache/catalina/core/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/core/LocalStrings.properties 2009-01-23 18:16:50 UTC (rev 910)
+++ trunk/java/org/apache/catalina/core/LocalStrings.properties 2009-01-23 18:17:34 UTC (rev 911)
@@ -1,3 +1,21 @@
+# 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.
+
+applicationContext.addFilter.ise=Filters can not be added to context {0} at this time. See SRV.4.4.
+applicationContext.addFilterMapping.ise=Filter mappings can not be added to context {0} at this time. See SRV.4.4.
+applicationContext.addServletMapping.ise=Servlet mappings can not be added to context {0} at this time. See SRV.4.4.
applicationContext.attributeEvent=Exception thrown by attributes event listener
applicationContext.mapping.error=Error during mapping
applicationContext.requestDispatcher.iae=Path {0} does not start with a "/" character
@@ -3,4 +21,6 @@
applicationContext.resourcePaths.iae=Path {0} does not start with a "/" character
applicationContext.setAttribute.namenull=Name cannot be null
+applicationContext.setSessionTracking.ise=The session tracking modes for context {0} cannot be set whilst the context is running
+applicationContext.setSessionTracking.iae=The session tracking mode {0} requested for context {1} is not supported by that context
applicationDispatcher.allocateException=Allocate exception for servlet {0}
applicationDispatcher.deallocateException=Deallocate exception for servlet {0}
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-01-23 18:16:50 UTC (rev 910)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-01-23 18:17:34 UTC (rev 911)
@@ -29,6 +29,7 @@
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
@@ -59,6 +60,7 @@
import javax.servlet.ServletException;
import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.ServletRequestListener;
+import javax.servlet.SessionTrackingMode;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionListener;
@@ -296,12 +298,20 @@
/**
- * Should we attempt to use cookies for session id communication?
+ * Session tracking modes.
*/
- private boolean cookies = true;
+ // FIXME: see about SSL tracking mode
+ private EnumSet<SessionTrackingMode> defaultSessionTrackingModes =
+ EnumSet.of(SessionTrackingMode.URL, SessionTrackingMode.COOKIE /*, SessionTrackingMode.SSL*/);
+
+ /**
+ * Session tracking modes.
+ */
+ private EnumSet<SessionTrackingMode> sessionTrackingModes = defaultSessionTrackingModes;
+
- /**
+ /**
* Should we allow the <code>ServletContext.getContext()</code> method
* to access the context of other web applications in this server?
*/
@@ -374,12 +384,26 @@
/**
* The set of filter mappings for this application, in the order
- * they were defined in the deployment descriptor.
+ * they were defined in the deployment descriptor with additional mappings
+ * added via the {@link ServletContext} possibly both before and after those
+ * defined in the deployment descriptor.
*/
private FilterMap filterMaps[] = new FilterMap[0];
/**
+ * Filter mappings added via {@link ServletContext} may have to be inserted
+ * before the mappings in the deploymenmt descriptor but must be inserted in
+ * the order the {@link ServletContext} methods are called. This isn't an
+ * issue for the mappings added after the deployment descriptor - they are
+ * just added to the end - but correctly the adding mappings before the
+ * deployment descriptor mappings requires knowing where the last 'before'
+ * mapping was added.
+ */
+ private int filterMapInsertPoint = 0;
+
+
+ /**
* Ignore annotations.
*/
private boolean ignoreAnnotations = false;
@@ -1130,7 +1154,7 @@
*/
public boolean getCookies() {
- return (this.cookies);
+ return (sessionTrackingModes.contains(SessionTrackingMode.COOKIE));
}
@@ -1142,11 +1166,18 @@
*/
public void setCookies(boolean cookies) {
- boolean oldCookies = this.cookies;
- this.cookies = cookies;
- support.firePropertyChange("cookies",
- new Boolean(oldCookies),
- new Boolean(this.cookies));
+ boolean oldCookies = sessionTrackingModes.contains(SessionTrackingMode.COOKIE);
+ if (oldCookies && !cookies) {
+ defaultSessionTrackingModes.remove(SessionTrackingMode.COOKIE);
+ }
+ if (!oldCookies && cookies) {
+ defaultSessionTrackingModes.add(SessionTrackingMode.COOKIE);
+ }
+ if (oldCookies != cookies) {
+ support.firePropertyChange("cookies",
+ new Boolean(oldCookies),
+ new Boolean(cookies));
+ }
}
@@ -1710,6 +1741,22 @@
}
+ public EnumSet<SessionTrackingMode> getDefaultSessionTrackingModes() {
+ return defaultSessionTrackingModes;
+ }
+
+
+ public EnumSet<SessionTrackingMode> getSessionTrackingModes() {
+ return sessionTrackingModes;
+ }
+
+
+ public void setSessionTrackingModes(
+ EnumSet<SessionTrackingMode> sessionTrackingModes) {
+ this.sessionTrackingModes = sessionTrackingModes;
+ }
+
+
/**
* Return the "replace welcome files" property.
*/
@@ -2237,7 +2284,8 @@
/**
- * Add a filter mapping to this Context.
+ * Add a filter mapping to this Context at the end of the current set
+ * of filter mappings.
*
* @param filterMap The filter mapping to be added
*
@@ -2247,6 +2295,54 @@
*/
public void addFilterMap(FilterMap filterMap) {
+ validateFilterMap(filterMap);
+ // Add this filter mapping to our registered set
+ synchronized (filterMaps) {
+ FilterMap results[] =new FilterMap[filterMaps.length + 1];
+ System.arraycopy(filterMaps, 0, results, 0, filterMaps.length);
+ results[filterMaps.length] = filterMap;
+ filterMaps = results;
+ }
+ fireContainerEvent("addFilterMap", filterMap);
+ }
+
+
+ /**
+ * Add a filter mapping to this Context before the mappings defined in the
+ * deployment descriptor but after any other mappings added via this method.
+ *
+ * @param filterMap The filter mapping to be added
+ *
+ * @exception IllegalArgumentException if the specified filter name
+ * does not match an existing filter definition, or the filter mapping
+ * is malformed
+ */
+ public void addFilterMapBefore(FilterMap filterMap) {
+
+ validateFilterMap(filterMap);
+
+ // Add this filter mapping to our registered set
+ synchronized (filterMaps) {
+ FilterMap results[] = new FilterMap[filterMaps.length + 1];
+ System.arraycopy(filterMaps, 0, results, 0, filterMapInsertPoint);
+ results[filterMapInsertPoint] = filterMap;
+ System.arraycopy(filterMaps, filterMapInsertPoint, results,
+ filterMaps.length - filterMapInsertPoint+1,
+ filterMapInsertPoint);
+
+ filterMapInsertPoint++;
+
+ results[filterMaps.length] = filterMap;
+ filterMaps = results;
+ }
+ fireContainerEvent("addFilterMap", filterMap);
+ }
+
+
+ /**
+ * Validate the supplied FilterMap.
+ */
+ private void validateFilterMap(FilterMap filterMap) {
// Validate the proposed filter mapping
String filterName = filterMap.getFilterName();
String[] servletNames = filterMap.getServletNames();
@@ -2254,9 +2350,10 @@
if (findFilterDef(filterName) == null)
throw new IllegalArgumentException
(sm.getString("standardContext.filterMap.name", filterName));
- if (!filterMap.getMatchAllServletNames()
- && !filterMap.getMatchAllUrlPatterns()
- && (servletNames.length == 0) && (urlPatterns.length == 0))
+
+ if (!filterMap.getMatchAllServletNames() &&
+ !filterMap.getMatchAllUrlPatterns() &&
+ (servletNames.length == 0) && (urlPatterns.length == 0))
throw new IllegalArgumentException
(sm.getString("standardContext.filterMap.either"));
// FIXME: Older spec revisions may still check this
@@ -2265,8 +2362,6 @@
throw new IllegalArgumentException
(sm.getString("standardContext.filterMap.either"));
*/
- // Because filter-pattern is new in 2.3, no need to adjust
- // for 2.2 backwards compatibility
for (int i = 0; i < urlPatterns.length; i++) {
if (!validateURLPattern(urlPatterns[i])) {
throw new IllegalArgumentException
@@ -2274,16 +2369,6 @@
urlPatterns[i]));
}
}
-
- // Add this filter mapping to our registered set
- synchronized (filterMaps) {
- FilterMap results[] =new FilterMap[filterMaps.length + 1];
- System.arraycopy(filterMaps, 0, results, 0, filterMaps.length);
- results[filterMaps.length] = filterMap;
- filterMaps = results;
- }
- fireContainerEvent("addFilterMap", filterMap);
-
}
@@ -3385,6 +3470,9 @@
System.arraycopy(filterMaps, 0, results, 0, n);
System.arraycopy(filterMaps, n + 1, results, n,
(filterMaps.length - 1) - n);
+ if (n < filterMapInsertPoint) {
+ filterMapInsertPoint--;
+ }
filterMaps = results;
}
@@ -5783,6 +5871,6 @@
}
}
-
-
+
+
}
15 years, 11 months
JBossWeb SVN: r910 - trunk/java/org/apache/catalina/deploy.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-01-23 13:16:50 -0500 (Fri, 23 Jan 2009)
New Revision: 910
Modified:
trunk/java/org/apache/catalina/deploy/FilterMap.java
Log:
- Port cleanup using the new API.
Modified: trunk/java/org/apache/catalina/deploy/FilterMap.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/FilterMap.java 2009-01-21 10:22:10 UTC (rev 909)
+++ trunk/java/org/apache/catalina/deploy/FilterMap.java 2009-01-23 18:16:50 UTC (rev 910)
@@ -19,10 +19,13 @@
package org.apache.catalina.deploy;
-import org.apache.catalina.util.RequestUtil;
import java.io.Serializable;
+import javax.servlet.DispatcherType;
+import org.apache.catalina.util.RequestUtil;
+
+
/**
* Representation of a filter mapping for a web application, as represented
* in a <code><filter-mapping></code> element in the deployment
@@ -161,7 +164,7 @@
public void setDispatcher(String dispatcherString) {
String dispatcher = dispatcherString.toUpperCase();
- if (dispatcher.equals("FORWARD")) {
+ if (dispatcher.equals(DispatcherType.FORWARD.name())) {
// apply FORWARD to the global dispatcherMapping.
switch (dispatcherMapping) {
@@ -174,7 +177,7 @@
case REQUEST_ERROR_INCLUDE : dispatcherMapping = REQUEST_ERROR_FORWARD_INCLUDE; break;
case REQUEST_INCLUDE : dispatcherMapping = REQUEST_FORWARD_INCLUDE; break;
}
- } else if (dispatcher.equals("INCLUDE")) {
+ } else if (dispatcher.equals(DispatcherType.INCLUDE.name())) {
// apply INCLUDE to the global dispatcherMapping.
switch (dispatcherMapping) {
case NOT_SET : dispatcherMapping = INCLUDE; break;
@@ -186,7 +189,7 @@
case REQUEST_ERROR_FORWARD : dispatcherMapping = REQUEST_ERROR_FORWARD_INCLUDE; break;
case REQUEST_FORWARD : dispatcherMapping = REQUEST_FORWARD_INCLUDE; break;
}
- } else if (dispatcher.equals("REQUEST")) {
+ } else if (dispatcher.equals(DispatcherType.REQUEST.name())) {
// apply REQUEST to the global dispatcherMapping.
switch (dispatcherMapping) {
case NOT_SET : dispatcherMapping = REQUEST; break;
@@ -198,7 +201,7 @@
case INCLUDE_FORWARD : dispatcherMapping = REQUEST_FORWARD_INCLUDE; break;
case INCLUDE_ERROR_FORWARD : dispatcherMapping = REQUEST_ERROR_FORWARD_INCLUDE; break;
}
- } else if (dispatcher.equals("ERROR")) {
+ } else if (dispatcher.equals(DispatcherType.ERROR.name())) {
// apply ERROR to the global dispatcherMapping.
switch (dispatcherMapping) {
case NOT_SET : dispatcherMapping = ERROR; break;
15 years, 11 months
JBossWeb SVN: r909 - branches/JBOSSWEB_2_0_0_GA_CP05_JBPAPP-1617/src/share/classes/org/apache/tomcat/util/net.
by jbossweb-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2009-01-21 05:22:10 -0500 (Wed, 21 Jan 2009)
New Revision: 909
Modified:
branches/JBOSSWEB_2_0_0_GA_CP05_JBPAPP-1617/src/share/classes/org/apache/tomcat/util/net/AprEndpoint.java
Log:
[JBPAPP-1617] Backported revision 214 for AprEndpoint to avoid race condition in APREndpoint on non-linux machines.
Modified: branches/JBOSSWEB_2_0_0_GA_CP05_JBPAPP-1617/src/share/classes/org/apache/tomcat/util/net/AprEndpoint.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP05_JBPAPP-1617/src/share/classes/org/apache/tomcat/util/net/AprEndpoint.java 2009-01-20 11:16:42 UTC (rev 908)
+++ branches/JBOSSWEB_2_0_0_GA_CP05_JBPAPP-1617/src/share/classes/org/apache/tomcat/util/net/AprEndpoint.java 2009-01-21 10:22:10 UTC (rev 909)
@@ -52,6 +52,7 @@
*
* @author Mladen Turk
* @author Remy Maucherat
+ * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
*/
public class AprEndpoint {
@@ -767,6 +768,14 @@
sendfileThread.start();
}
}
+
+ // Start acceptor threads
+ for (int i = 0; i < acceptorThreadCount; i++) {
+ Thread acceptorThread = new Thread(new Acceptor(), getName() + "-Acceptor-" + i);
+ acceptorThread.setPriority(threadPriority);
+ acceptorThread.setDaemon(daemon);
+ acceptorThread.start();
+ }
}
}
15 years, 11 months
JBossWeb SVN: r908 - branches.
by jbossweb-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2009-01-20 06:16:42 -0500 (Tue, 20 Jan 2009)
New Revision: 908
Added:
branches/JBOSSWEB_2_0_0_GA_CP05_JBPAPP-1617/
Log:
Create branch.
Copied: branches/JBOSSWEB_2_0_0_GA_CP05_JBPAPP-1617 (from rev 907, tags/JBOSSWEB_2_0_0_GA_CP05)
15 years, 11 months
JBossWeb SVN: r906 - in trunk: java/org/apache/tomcat/util/http and 2 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-01-16 11:11:42 -0500 (Fri, 16 Jan 2009)
New Revision: 906
Removed:
trunk/java/org/apache/tomcat/util/http/TomcatCookie.java
Modified:
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/connector/Response.java
trunk/java/org/jboss/web/rewrite/RewriteValve.java
trunk/webapps/docs/changelog.xml
Log:
- Remove TomcatCookie, the standard Cookie API adds httpOnly.
- Use standard Cookie in the rewrite valve.
- Still won't build due to unimplemented methods; use an IDE for now.
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-01-16 16:10:23 UTC (rev 905)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-01-16 16:11:42 UTC (rev 906)
@@ -67,7 +67,6 @@
import org.apache.tomcat.util.http.FastHttpDateFormat;
import org.apache.tomcat.util.http.Parameters;
import org.apache.tomcat.util.http.ServerCookie;
-import org.apache.tomcat.util.http.TomcatCookie;
import org.apache.tomcat.util.http.mapper.MappingData;
@@ -2371,7 +2370,7 @@
if ( (session != null) && (getContext() != null)
&& getContext().getCookies()
&& !(isRequestedSessionIdFromCookie() && (session.getIdInternal().equals(getRequestedSessionId()))) ) {
- TomcatCookie cookie = new TomcatCookie(Globals.SESSION_COOKIE_NAME,
+ Cookie cookie = new Cookie(Globals.SESSION_COOKIE_NAME,
session.getIdInternal());
configureSessionCookie(cookie);
response.addCookieInternal(cookie);
@@ -2391,7 +2390,7 @@
*
* @param cookie The JSESSIONID cookie to be configured
*/
- protected void configureSessionCookie(TomcatCookie cookie) {
+ protected void configureSessionCookie(Cookie cookie) {
cookie.setMaxAge(-1);
if (context.getSessionCookie().getPath() != null) {
cookie.setPath(context.getSessionCookie().getPath());
Modified: trunk/java/org/apache/catalina/connector/Response.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Response.java 2009-01-16 16:10:23 UTC (rev 905)
+++ trunk/java/org/apache/catalina/connector/Response.java 2009-01-16 16:11:42 UTC (rev 906)
@@ -51,7 +51,6 @@
import org.apache.tomcat.util.http.FastHttpDateFormat;
import org.apache.tomcat.util.http.MimeHeaders;
import org.apache.tomcat.util.http.ServerCookie;
-import org.apache.tomcat.util.http.TomcatCookie;
import org.apache.tomcat.util.net.URL;
/**
@@ -986,23 +985,6 @@
*
* @param cookie Cookie to be added
*/
- public void addTomcatCookie(final TomcatCookie cookie) {
-
- // Ignore any call from an included servlet
- if (included)
- return;
-
- addCookieInternal(cookie);
-
- }
-
-
- /**
- * Add the specified Cookie to those that will be included with
- * this Response.
- *
- * @param cookie Cookie to be added
- */
public void addCookieInternal(final Cookie cookie) {
if (isCommitted())
@@ -1018,7 +1000,7 @@
(sb, cookie.getVersion(), cookie.getName(),
cookie.getValue(), cookie.getPath(),
cookie.getDomain(), cookie.getComment(),
- cookie.getMaxAge(), cookie.getSecure(), false);
+ cookie.getMaxAge(), cookie.getSecure(), cookie.isHttpOnly());
return null;
}
});
@@ -1026,7 +1008,7 @@
ServerCookie.appendCookieValue
(sb, cookie.getVersion(), cookie.getName(), cookie.getValue(),
cookie.getPath(), cookie.getDomain(), cookie.getComment(),
- cookie.getMaxAge(), cookie.getSecure(), false);
+ cookie.getMaxAge(), cookie.getSecure(), cookie.isHttpOnly());
}
// if we reached here, no exception, cookie is valid
// the header name is Set-Cookie for both "old" and v.1 ( RFC2109 )
@@ -1039,47 +1021,6 @@
/**
- * Add the specified Cookie to those that will be included with
- * this Response.
- *
- * @param cookie Cookie to be added
- */
- public void addCookieInternal(final TomcatCookie cookie) {
-
- if (isCommitted())
- return;
-
- final StringBuffer sb = new StringBuffer();
- // web application code can receive a IllegalArgumentException
- // from the appendCookieValue invocation
- if (SecurityUtil.isPackageProtectionEnabled()) {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run(){
- ServerCookie.appendCookieValue
- (sb, cookie.getVersion(), cookie.getName(),
- cookie.getValue(), cookie.getPath(),
- cookie.getDomain(), cookie.getComment(),
- cookie.getMaxAge(), cookie.getSecure(), cookie.getHttpOnly());
- return null;
- }
- });
- } else {
- ServerCookie.appendCookieValue
- (sb, cookie.getVersion(), cookie.getName(), cookie.getValue(),
- cookie.getPath(), cookie.getDomain(), cookie.getComment(),
- cookie.getMaxAge(), cookie.getSecure(), cookie.getHttpOnly());
- }
- // if we reached here, no exception, cookie is valid
- // the header name is Set-Cookie for both "old" and v.1 ( RFC2109 )
- // RFC2965 is not supported by browsers and the Servlet spec
- // asks for 2109.
- addHeader("Set-Cookie", sb.toString());
-
- cookies.add(cookie);
- }
-
-
- /**
* Add the specified date header to the specified value.
*
* @param name Name of the header to set
Deleted: trunk/java/org/apache/tomcat/util/http/TomcatCookie.java
===================================================================
--- trunk/java/org/apache/tomcat/util/http/TomcatCookie.java 2009-01-16 16:10:23 UTC (rev 905)
+++ trunk/java/org/apache/tomcat/util/http/TomcatCookie.java 2009-01-16 16:11:42 UTC (rev 906)
@@ -1,38 +0,0 @@
-/*
- * 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.tomcat.util.http;
-
-import javax.servlet.http.Cookie;
-
-public class TomcatCookie extends Cookie {
-
- boolean httpOnly = false;
-
- public TomcatCookie(String name, String value) {
- super(name, value);
- }
-
- public boolean getHttpOnly() {
- return httpOnly;
- }
-
- public void setHttpOnly(boolean httpOnly) {
- this.httpOnly = httpOnly;
- }
-
-}
Modified: trunk/java/org/jboss/web/rewrite/RewriteValve.java
===================================================================
--- trunk/java/org/jboss/web/rewrite/RewriteValve.java 2009-01-16 16:10:23 UTC (rev 905)
+++ trunk/java/org/jboss/web/rewrite/RewriteValve.java 2009-01-16 16:11:42 UTC (rev 906)
@@ -53,7 +53,6 @@
import org.apache.catalina.valves.ValveBase;
import org.apache.tomcat.util.buf.CharChunk;
import org.apache.tomcat.util.buf.MessageBytes;
-import org.apache.tomcat.util.http.TomcatCookie;
import org.apache.tomcat.util.net.URL;
public class RewriteValve extends ValveBase
@@ -357,7 +356,7 @@
// - cookie
if (rules[i].isCookie() && newtest != null) {
- TomcatCookie cookie = new TomcatCookie(rules[i].getCookieName(),
+ Cookie cookie = new Cookie(rules[i].getCookieName(),
rules[i].getCookieResult());
cookie.setDomain(rules[i].getCookieDomain());
cookie.setMaxAge(rules[i].getCookieLifetime());
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2009-01-16 16:10:23 UTC (rev 905)
+++ trunk/webapps/docs/changelog.xml 2009-01-16 16:11:42 UTC (rev 906)
@@ -16,6 +16,27 @@
<body>
+<section name="JBoss Web 3.0.0.CR1 (remm)">
+ <subsection name="General">
+ <changelog>
+ <update>
+ Servlet 3.0 API. (markt, remm)
+ </update>
+ </changelog>
+ </subsection>
+ <subsection name="Catalina">
+ <changelog>
+ <update>
+ Replace TomcatCookie class with the new Cookie API. (remm)
+ </update>
+ </changelog>
+ </subsection>
+ <subsection name="Coyote">
+ <changelog>
+ </changelog>
+ </subsection>
+</section>
+
<section name="JBoss Web 2.1.2.CR1 (remm)">
<subsection name="General">
<changelog>
15 years, 11 months