JBossWeb SVN: r1051 - trunk/java/org/apache/catalina/startup.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-13 19:10:37 -0400 (Wed, 13 May 2009)
New Revision: 1051
Modified:
trunk/java/org/apache/catalina/startup/ContextConfig.java
trunk/java/org/apache/catalina/startup/LocalStrings.properties
trunk/java/org/apache/catalina/startup/OrderingResolver.java
Log:
- Add WIP relative ordering impl. Now need to test and fix it (arrrr ...).
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-12 07:00:11 UTC (rev 1050)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-13 23:10:37 UTC (rev 1051)
@@ -1083,7 +1083,12 @@
}
} else if (orderings.size() > 0) {
// Resolve relative ordering
- OrderingResolver.resolveOrder(orderings, order);
+ try {
+ OrderingResolver.resolveOrder(orderings, order);
+ } catch (IllegalStateException e) {
+ log.error(e.getMessage(), e);
+ ok = false;
+ }
} else {
// No order specified
order.addAll(jarsSet);
Modified: trunk/java/org/apache/catalina/startup/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/startup/LocalStrings.properties 2009-05-12 07:00:11 UTC (rev 1050)
+++ trunk/java/org/apache/catalina/startup/LocalStrings.properties 2009-05-13 23:10:37 UTC (rev 1051)
@@ -82,3 +82,8 @@
userConfig.error=Error deploying web application for user {0}
userConfig.start=UserConfig: Processing START
userConfig.stop=UserConfig: Processing STOP
+
+ordering.afterAndBeforeOthers=Jar fragment {0} contains an invalid ordering specifying both after and before other fragments
+ordering.duplicateName=Jar fragment {0} declares a duplicate name
+ordering.unkonwnName=Jar fragment {0} ordering refers to an unknown fragment name
+ordering.orderConflict=Jar fragment {0} causes an order conflict
Modified: trunk/java/org/apache/catalina/startup/OrderingResolver.java
===================================================================
--- trunk/java/org/apache/catalina/startup/OrderingResolver.java 2009-05-12 07:00:11 UTC (rev 1050)
+++ trunk/java/org/apache/catalina/startup/OrderingResolver.java 2009-05-13 23:10:37 UTC (rev 1051)
@@ -24,10 +24,13 @@
package org.apache.catalina.startup;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import org.apache.catalina.deploy.WebOrdering;
+import org.apache.catalina.util.StringManager;
/**
* Resolves the relative ordering of web fragments. This is in a separate class
@@ -37,12 +40,126 @@
*/
public class OrderingResolver {
- protected class Ordering {
+ protected static org.jboss.logging.Logger log =
+ org.jboss.logging.Logger.getLogger(OrderingResolver.class);
+
+ /**
+ * The string resources for this package.
+ */
+ protected static final StringManager sm =
+ StringManager.getManager(Constants.Package);
+
+ protected static class Ordering {
protected WebOrdering ordering;
- protected List<WebOrdering> after = new ArrayList<WebOrdering>();
- protected List<WebOrdering> before = new ArrayList<WebOrdering>();
+ protected Set<Ordering> after = new HashSet<Ordering>();
+ protected Set<Ordering> before = new HashSet<Ordering>();
protected boolean afterOthers = false;
protected boolean beforeOthers = false;
+
+ public boolean validate() {
+ try {
+ isBefore(new Ordering());
+ isAfter(new Ordering());
+ } catch (IllegalStateException e) {
+ return false;
+ }
+ return true;
+ }
+
+ public boolean isBefore(Ordering ordering) {
+ Set<Ordering> checked = new HashSet<Ordering>();
+ return isBeforeInternal(ordering, checked);
+ }
+
+ protected boolean isBeforeInternal(Ordering ordering, Set<Ordering> checked) {
+ checked.add(this);
+ if (before.contains(ordering)) {
+ return true;
+ }
+ Iterator<Ordering> beforeIterator = before.iterator();
+ while (beforeIterator.hasNext()) {
+ Ordering check = beforeIterator.next();
+ if (checked.contains(check)) {
+ throw new IllegalStateException();
+ }
+ if (check.isBeforeInternal(ordering, checked)) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check (recursively) if a fragment is after the specified fragment.
+ *
+ * @param ordering
+ * @return
+ */
+ public boolean isAfter(Ordering ordering) {
+ Set<Ordering> checked = new HashSet<Ordering>();
+ return isAfterInternal(ordering, checked);
+ }
+
+ protected boolean isAfterInternal(Ordering ordering, Set<Ordering> checked) {
+ checked.add(this);
+ if (after.contains(ordering)) {
+ return true;
+ }
+ Iterator<Ordering> afterIterator = after.iterator();
+ while (afterIterator.hasNext()) {
+ Ordering check = afterIterator.next();
+ if (checked.contains(check)) {
+ throw new IllegalStateException();
+ }
+ if (check.isAfterInternal(ordering, checked)) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check is a fragment marked as before others is after a fragment that is not.
+ *
+ * @return true if a fragment marked as before others is after a fragment that is not
+ */
+ public boolean isLastBeforeOthers() {
+ if (!beforeOthers) {
+ throw new IllegalStateException();
+ }
+ Iterator<Ordering> beforeIterator = before.iterator();
+ while (beforeIterator.hasNext()) {
+ Ordering check = beforeIterator.next();
+ if (!check.beforeOthers) {
+ return true;
+ } else if (check.isLastBeforeOthers()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check is a fragment marked as after others is before a fragment that is not.
+ *
+ * @return true if a fragment marked as after others is before a fragment that is not
+ */
+ public boolean isFirstAfterOthers() {
+ if (!afterOthers) {
+ throw new IllegalStateException();
+ }
+ Iterator<Ordering> afterIterator = after.iterator();
+ while (afterIterator.hasNext()) {
+ Ordering check = afterIterator.next();
+ if (!check.afterOthers) {
+ return true;
+ } else if (check.isFirstAfterOthers()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
}
/**
@@ -52,7 +169,153 @@
* @param order The generated order list
*/
public static void resolveOrder(List<WebOrdering> webOrderings, List<String> order) {
+ List<Ordering> work = new ArrayList<Ordering>();
+ // Populate the work Ordering list
+ Iterator<WebOrdering> webOrderingsIterator = webOrderings.iterator();
+ while (webOrderingsIterator.hasNext()) {
+ WebOrdering webOrdering = webOrderingsIterator.next();
+ Ordering ordering = new Ordering();
+ ordering.ordering = webOrdering;
+ ordering.afterOthers = webOrdering.isAfterOthers();
+ ordering.beforeOthers = webOrdering.isBeforeOthers();
+ if (ordering.afterOthers && ordering.beforeOthers) {
+ // Cannot be both after and before others
+ throw new IllegalStateException(sm.getString("ordering.afterAndBeforeOthers", webOrdering.getJar()));
+ }
+ work.add(ordering);
+ }
+
+ // Create double linked relationships between the orderings,
+ // and resolve names
+ Iterator<Ordering> workIterator = work.iterator();
+ while (workIterator.hasNext()) {
+ Ordering ordering = workIterator.next();
+ WebOrdering webOrdering = ordering.ordering;
+ Iterator<String> after = webOrdering.getAfter().iterator();
+ while (after.hasNext()) {
+ String name = after.next();
+ Iterator<Ordering> workIterator2 = work.iterator();
+ boolean found = false;
+ while (workIterator2.hasNext()) {
+ Ordering ordering2 = workIterator.next();
+ if (name.equals(ordering2.ordering.getName())) {
+ if (found) {
+ // Duplicate name
+ throw new IllegalStateException(sm.getString("ordering.duplicateName", webOrdering.getJar()));
+ }
+ ordering.after.add(ordering2);
+ ordering2.before.add(ordering);
+ found = true;
+ }
+ }
+ if (!found) {
+ // Unknown name
+ throw new IllegalStateException(sm.getString("ordering.unkonwnName", webOrdering.getJar()));
+ }
+ }
+ Iterator<String> before = webOrdering.getAfter().iterator();
+ while (before.hasNext()) {
+ String name = before.next();
+ Iterator<Ordering> workIterator2 = work.iterator();
+ boolean found = false;
+ while (workIterator2.hasNext()) {
+ Ordering ordering2 = workIterator.next();
+ if (name.equals(ordering2.ordering.getName())) {
+ if (found) {
+ // Duplicate name
+ throw new IllegalStateException(sm.getString("ordering.duplicateName", webOrdering.getJar()));
+ }
+ ordering.before.add(ordering2);
+ ordering2.after.add(ordering);
+ found = true;
+ }
+ }
+ if (!found) {
+ // Unknown name
+ throw new IllegalStateException(sm.getString("ordering.unkonwnName", webOrdering.getJar()));
+ }
+ }
+ }
+
+ // Validate ordering
+ workIterator = work.iterator();
+ while (workIterator.hasNext()) {
+ workIterator.next().validate();
+ }
+
+ // Create three ordered lists that will then be merged
+ List<Ordering> tempOrder = new ArrayList<Ordering>();
+
+ // Create the ordered list of fragments which are before others
+ workIterator = work.iterator();
+ while (workIterator.hasNext()) {
+ Ordering ordering = workIterator.next();
+ if (ordering.beforeOthers) {
+ // Insert at the first possible position
+ int insertAfter = -1;
+ boolean last = ordering.isLastBeforeOthers();
+ int lastBeforeOthers = -1;
+ for (int i = 0; i < tempOrder.size(); i++) {
+ if (ordering.isAfter(tempOrder.get(i))) {
+ insertAfter = i;
+ }
+ if (tempOrder.get(i).beforeOthers) {
+ lastBeforeOthers = i;
+ }
+ }
+ int pos = insertAfter;
+ if (last && lastBeforeOthers > insertAfter) {
+ pos = lastBeforeOthers;
+ }
+ tempOrder.add(pos + 1, ordering);
+ } else if (ordering.afterOthers) {
+ // Insert at the last possible element
+ int insertBefore = tempOrder.size() - 1;
+ boolean first = ordering.isFirstAfterOthers();
+ int firstAfterOthers = tempOrder.size() - 1;
+ for (int i = tempOrder.size() - 1; i >= 0; i--) {
+ if (ordering.isBefore(tempOrder.get(i))) {
+ insertBefore = i;
+ }
+ if (tempOrder.get(i).afterOthers) {
+ firstAfterOthers = i;
+ }
+ }
+ int pos = insertBefore;
+ if (first && firstAfterOthers < insertBefore) {
+ pos = firstAfterOthers;
+ }
+ tempOrder.add(pos, ordering);
+ } else {
+ // Insert according to other already inserted elements
+ int insertAfter = -1;
+ int insertBefore = tempOrder.size() - 1;
+ for (int i = 0; i < tempOrder.size(); i++) {
+ if (ordering.isAfter(tempOrder.get(i)) || tempOrder.get(i).beforeOthers) {
+ insertAfter = i;
+ }
+ if (ordering.isBefore(tempOrder.get(i)) || tempOrder.get(i).afterOthers) {
+ insertBefore = i;
+ }
+ }
+ if (insertAfter > insertBefore) {
+ // Conflicting order (probably caught earlier)
+ throw new IllegalStateException(sm.getString("ordering.orderConflict", ordering.ordering.getJar()));
+ }
+ // Insert somewhere in the range
+ tempOrder.add(insertAfter + 1, ordering);
+ }
+ }
+
+ // Create the final ordered list
+ Iterator<Ordering> tempOrderIterator = tempOrder.iterator();
+ while (tempOrderIterator.hasNext()) {
+ Ordering ordering = tempOrderIterator.next();
+ order.add(ordering.ordering.getJar());
+ }
+
}
+
}
15 years, 7 months
JBossWeb SVN: r1050 - tags/JBOSSWEB_2_0_0_GA_CP10.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-05-12 03:00:11 -0400 (Tue, 12 May 2009)
New Revision: 1050
Added:
tags/JBOSSWEB_2_0_0_GA_CP10/build.properties
Log:
Add a build.properties file for CP10.
Added: tags/JBOSSWEB_2_0_0_GA_CP10/build.properties
===================================================================
--- tags/JBOSSWEB_2_0_0_GA_CP10/build.properties (rev 0)
+++ tags/JBOSSWEB_2_0_0_GA_CP10/build.properties 2009-05-12 07:00:11 UTC (rev 1050)
@@ -0,0 +1,5 @@
+# ----- Vesion Control Flags -----
+version.major=2
+version.minor=0
+version.build=0
+version.patch=GA_CP10
15 years, 7 months
JBossWeb SVN: r1049 - tags.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-05-12 02:40:24 -0400 (Tue, 12 May 2009)
New Revision: 1049
Added:
tags/JBOSSWEB_2_0_0_GA_CP10/
Log:
JBoss Web 2.0.0 GA CP 10.
Copied: tags/JBOSSWEB_2_0_0_GA_CP10 (from rev 1048, branches/JBOSSWEB_2_0_0_GA_CP)
15 years, 7 months
JBossWeb SVN: r1048 - trunk/java/org/apache/catalina/startup.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-11 17:44:19 -0400 (Mon, 11 May 2009)
New Revision: 1048
Modified:
trunk/java/org/apache/catalina/startup/ContextConfig.java
Log:
- Jasper will likely need the actual fragment order (sigh).
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-11 17:10:57 UTC (rev 1047)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-11 21:44:19 UTC (rev 1048)
@@ -341,7 +341,7 @@
public Iterator<String> getWebFragments() {
- return webFragments.iterator();
+ return order.iterator();
}
@@ -1010,7 +1010,7 @@
// Read order from web.xml and fragments (note: if no fragments, skip)
WebAbsoluteOrdering absoluteOrdering = context.getWebAbsoluteOrdering();
List<WebOrdering> orderings = new ArrayList<WebOrdering>();
- Iterator<String> jarsWithWebFragments = getWebFragments();
+ Iterator<String> jarsWithWebFragments = webFragments.iterator();
HashSet<String> jarsSet = new HashSet<String>();
// Parse the ordering defined in web fragments
15 years, 7 months
JBossWeb SVN: r1047 - in trunk/java/org/apache: catalina/core and 4 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-11 13:10:57 -0400 (Mon, 11 May 2009)
New Revision: 1047
Added:
trunk/java/org/apache/catalina/core/ServerJarRepository.java
trunk/java/org/apache/catalina/startup/OrderingResolver.java
trunk/java/org/apache/naming/resources/ProxyDirContextFacade.java
Removed:
trunk/java/org/apache/catalina/ContextScanner.java
trunk/java/org/apache/catalina/startup/BaseContextScanner.java
trunk/java/org/apache/catalina/startup/ClassLoadingContextScanner.java
trunk/java/org/apache/catalina/startup/JavassistContextScanner.java
Modified:
trunk/java/org/apache/catalina/deploy/WebOrdering.java
trunk/java/org/apache/catalina/loader/WebappClassLoader.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
trunk/java/org/apache/catalina/startup/LocalStrings.properties
trunk/java/org/apache/catalina/startup/WebOrderingRuleSet.java
trunk/java/org/apache/naming/resources/ProxyDirContext.java
Log:
- Ongoing work with the ordering.
- Also add a DirContext facade for possible use.
- Remove ContextScanner, and add a stub ServerJarRepository.
Deleted: trunk/java/org/apache/catalina/ContextScanner.java
===================================================================
--- trunk/java/org/apache/catalina/ContextScanner.java 2009-05-11 09:35:06 UTC (rev 1046)
+++ trunk/java/org/apache/catalina/ContextScanner.java 2009-05-11 17:10:57 UTC (rev 1047)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-
-package org.apache.catalina;
-
-import org.apache.tomcat.WarComponents;
-
-public interface ContextScanner extends WarComponents {
-
- /**
- * Scan the given context's default locations for annotations, overlays
- * and web.xml fragments.
- *
- * @param context
- */
- public void scan(Context context);
-
-
-}
Added: trunk/java/org/apache/catalina/core/ServerJarRepository.java
===================================================================
--- trunk/java/org/apache/catalina/core/ServerJarRepository.java (rev 0)
+++ trunk/java/org/apache/catalina/core/ServerJarRepository.java 2009-05-11 17:10:57 UTC (rev 1047)
@@ -0,0 +1,403 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 1999-2009 The Apache Software Foundation
+ *
+ * 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.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.jar.JarFile;
+
+import javax.naming.Binding;
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.servlet.ServletContext;
+
+import org.apache.catalina.Contained;
+import org.apache.catalina.Container;
+import org.apache.catalina.Context;
+import org.apache.catalina.Globals;
+import org.apache.catalina.JarRepository;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.util.IOTools;
+import org.apache.catalina.util.LifecycleSupport;
+import org.apache.catalina.util.StringManager;
+import org.apache.naming.resources.Resource;
+import org.jboss.logging.Logger;
+
+
+/**
+ * Server specific implementation for a JAR repository, which will manage
+ * shared JARs which may contain descriptors.
+ *
+ * FIXME: Stub impl
+ * @author Remy Maucherat
+ */
+public class ServerJarRepository
+ implements JarRepository, Contained, Lifecycle {
+
+ private static Logger log = Logger.getLogger(ServerJarRepository.class);
+
+ /**
+ * Names of JARs that are known not to contain any descriptors or annotations.
+ */
+ protected static HashSet<String> skipJars;
+
+ /**
+ * Initializes the set of JARs that are known not to contain any descriptors.
+ */
+ static {
+ skipJars = new HashSet<String>();
+ // Bootstrap JARs
+ skipJars.add("bootstrap.jar");
+ skipJars.add("commons-daemon.jar");
+ skipJars.add("tomcat-juli.jar");
+ // Main JARs
+ skipJars.add("annotations-api.jar");
+ skipJars.add("catalina.jar");
+ skipJars.add("catalina-ant.jar");
+ skipJars.add("el-api.jar");
+ skipJars.add("jasper.jar");
+ skipJars.add("jasper-el.jar");
+ skipJars.add("jasper-jdt.jar");
+ skipJars.add("jsp-api.jar");
+ skipJars.add("servlet-api.jar");
+ skipJars.add("tomcat-coyote.jar");
+ skipJars.add("tomcat-dbcp.jar");
+ // i18n JARs
+ skipJars.add("tomcat-i18n-en.jar");
+ skipJars.add("tomcat-i18n-es.jar");
+ skipJars.add("tomcat-i18n-fr.jar");
+ skipJars.add("tomcat-i18n-ja.jar");
+ // Misc JARs not included with Tomcat
+ skipJars.add("ant.jar");
+ skipJars.add("commons-dbcp.jar");
+ skipJars.add("commons-beanutils.jar");
+ skipJars.add("commons-fileupload-1.0.jar");
+ skipJars.add("commons-pool.jar");
+ skipJars.add("commons-digester.jar");
+ skipJars.add("commons-logging.jar");
+ skipJars.add("commons-collections.jar");
+ skipJars.add("jmx.jar");
+ skipJars.add("jmx-tools.jar");
+ skipJars.add("xercesImpl.jar");
+ skipJars.add("xmlParserAPIs.jar");
+ skipJars.add("xml-apis.jar");
+ // JARs from J2SE runtime
+ skipJars.add("sunjce_provider.jar");
+ skipJars.add("ldapsec.jar");
+ skipJars.add("localedata.jar");
+ skipJars.add("dnsns.jar");
+ skipJars.add("tools.jar");
+ skipJars.add("sunpkcs11.jar");
+ }
+
+ // ----------------------------------------------------------- Constructors
+
+
+ /**
+ * Construct a new ContextJarRepository instance with no associated Container.
+ */
+ public ServerJarRepository() {
+
+ this(null);
+
+ }
+
+
+ /**
+ * Construct a new ContextJarRepository instance that is associated with the
+ * specified Container.
+ *
+ * @param container The container we should be associated with
+ */
+ public ServerJarRepository(Container container) {
+
+ super();
+ setContainer(container);
+
+ }
+
+
+ // ----------------------------------------------------- Instance Variables
+
+
+ /**
+ * The Container with which this Pipeline is associated.
+ */
+ protected Container container = null;
+
+
+ /**
+ * Descriptive information about this implementation.
+ */
+ protected String info = "org.apache.catalina.core.ServerJarRepository/1.0";
+
+
+ /**
+ * The lifecycle event support for this component.
+ */
+ protected LifecycleSupport lifecycle = new LifecycleSupport(this);
+
+
+ /**
+ * The string manager for this package.
+ */
+ protected static StringManager sm =
+ StringManager.getManager(Constants.Package);
+
+
+ /**
+ * Has this component been started yet?
+ */
+ protected boolean started = false;
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Return descriptive information about this implementation class.
+ */
+ public String getInfo() {
+
+ return (this.info);
+
+ }
+
+
+ // ------------------------------------------------------ Contained Methods
+
+
+ /**
+ * Return the Container with which this Pipeline is associated.
+ */
+ public Container getContainer() {
+
+ return (this.container);
+
+ }
+
+
+ /**
+ * Set the Container with which this Pipeline is associated.
+ *
+ * @param container The new associated container
+ */
+ public void setContainer(Container container) {
+
+ this.container = container;
+
+ }
+
+
+ // ------------------------------------------------------ Lifecycle Methods
+
+
+ /**
+ * Add a lifecycle event listener to this component.
+ *
+ * @param listener The listener to add
+ */
+ public void addLifecycleListener(LifecycleListener listener) {
+
+ lifecycle.addLifecycleListener(listener);
+
+ }
+
+
+ /**
+ * Get the lifecycle listeners associated with this lifecycle. If this
+ * Lifecycle has no listeners registered, a zero-length array is returned.
+ */
+ public LifecycleListener[] findLifecycleListeners() {
+
+ return lifecycle.findLifecycleListeners();
+
+ }
+
+
+ /**
+ * Remove a lifecycle event listener from this component.
+ *
+ * @param listener The listener to remove
+ */
+ public void removeLifecycleListener(LifecycleListener listener) {
+
+ lifecycle.removeLifecycleListener(listener);
+
+ }
+
+ /**
+ * Prepare for active use of the public methods of this Component.
+ *
+ * @exception LifecycleException if this component detects a fatal error
+ * that prevents it from being started
+ */
+ public synchronized void start() throws LifecycleException {
+
+ // Validate and update our current component state
+ if (started) {
+ if(log.isDebugEnabled())
+ log.debug(sm.getString("contextJarRepository.alreadyStarted"));
+ return;
+ }
+
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, null);
+
+ started = true;
+
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(START_EVENT, null);
+
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(AFTER_START_EVENT, null);
+
+ }
+
+
+ /**
+ * Gracefully shut down active use of the public methods of this Component.
+ *
+ * @exception LifecycleException if this component detects a fatal error
+ * that needs to be reported
+ */
+ public synchronized void stop() throws LifecycleException {
+
+ // Validate and update our current component state
+ if (!started) {
+ if(log.isDebugEnabled())
+ log.debug(sm.getString("contextJarRepository.notStarted"));
+ return;
+ }
+
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);
+
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(STOP_EVENT, null);
+ started = false;
+
+ // Notify our interested LifecycleListeners
+ lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
+ }
+
+
+ // -------------------------------------------------- JarRepository Methods
+
+
+ /**
+ * Execute a periodic task, such as reloading, etc. This method will be
+ * invoked inside the classloading context of this container. Unexpected
+ * throwables will be caught and logged.
+ */
+ public void backgroundProcess() {
+
+ }
+
+
+ /**
+ * Get the JarFile map.
+ *
+ * @return the JarFile map, associating logical name with JarFile
+ */
+ public Map<String, JarFile> getJars() {
+ return null;
+ }
+
+
+ /**
+ * Find the JarFile corresponding to the path.
+ *
+ * @return the JarFile, or null if not found
+ */
+ public JarFile findJar(String path) {
+ return null;
+ }
+
+
+ /**
+ * Find all JarFile managed by the JARRepository.
+ *
+ * @return All JarFile
+ */
+ public JarFile[] findJars() {
+ return null;
+ }
+
+
+ /**
+ * Get the exploded Jar map.
+ *
+ * @return the Jar map, associating logical name with File
+ */
+ public Map<String, File> getExplodedJars() {
+ return null;
+ }
+
+
+ /**
+ * Find all exploded Jars managed by the JARRepository.
+ *
+ * @return All exploded File
+ */
+ public File[] findExplodedJars() {
+ return null;
+ }
+
+
+}
Modified: trunk/java/org/apache/catalina/deploy/WebOrdering.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/WebOrdering.java 2009-05-11 09:35:06 UTC (rev 1046)
+++ trunk/java/org/apache/catalina/deploy/WebOrdering.java 2009-05-11 17:10:57 UTC (rev 1047)
@@ -28,14 +28,19 @@
public class WebOrdering implements Serializable {
+ private static final long serialVersionUID = 5603203103871892211L;
+
protected String jar = null;
protected String name = null;
protected List<String> after = new ArrayList<String>();
protected List<String> before = new ArrayList<String>();
-
+ protected boolean afterOthers = false;
+ protected boolean beforeOthers = false;
+
public String getName() {
return name;
}
+
public void setName(String name) {
this.name = name;
}
@@ -55,11 +60,29 @@
public void addBefore(String name) {
before.add(name);
}
+
public String getJar() {
return jar;
}
+
public void setJar(String jar) {
this.jar = jar;
}
+
+ public boolean isAfterOthers() {
+ return afterOthers;
+ }
+
+ public void setAfterOthers(boolean afterOthers) {
+ this.afterOthers = afterOthers;
+ }
+
+ public boolean isBeforeOthers() {
+ return beforeOthers;
+ }
+
+ public void setBeforeOthers(boolean beforeOthers) {
+ this.beforeOthers = beforeOthers;
+ }
}
Modified: trunk/java/org/apache/catalina/loader/WebappClassLoader.java
===================================================================
--- trunk/java/org/apache/catalina/loader/WebappClassLoader.java 2009-05-11 09:35:06 UTC (rev 1046)
+++ trunk/java/org/apache/catalina/loader/WebappClassLoader.java 2009-05-11 17:10:57 UTC (rev 1047)
@@ -741,7 +741,7 @@
if (getJarPath() != null) {
try {
- NamingEnumeration enumeration = resources.listBindings(getJarPath());
+ NamingEnumeration enumeration = resources.list(getJarPath());
int i = 0;
while (enumeration.hasMoreElements() && (i < length)) {
NameClassPair ncPair = (NameClassPair) enumeration.nextElement();
Deleted: trunk/java/org/apache/catalina/startup/BaseContextScanner.java
===================================================================
--- trunk/java/org/apache/catalina/startup/BaseContextScanner.java 2009-05-11 09:35:06 UTC (rev 1046)
+++ trunk/java/org/apache/catalina/startup/BaseContextScanner.java 2009-05-11 17:10:57 UTC (rev 1047)
@@ -1,400 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-
-package org.apache.catalina.startup;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import javax.naming.NameClassPair;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.DirContext;
-import javax.servlet.annotation.HandlesTypes;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.ContextScanner;
-import org.apache.catalina.Globals;
-import org.apache.catalina.JarRepository;
-
-public abstract class BaseContextScanner
- implements ContextScanner {
-
-
- /**
- * Names of JARs that are known not to contain any descriptors or annotations.
- */
- protected static HashSet<String> skipJars;
-
- /**
- * Initializes the set of JARs that are known not to contain any descriptors.
- */
- static {
- skipJars = new HashSet<String>();
- // Bootstrap JARs
- skipJars.add("bootstrap.jar");
- skipJars.add("commons-daemon.jar");
- skipJars.add("tomcat-juli.jar");
- // Main JARs
- skipJars.add("annotations-api.jar");
- skipJars.add("catalina.jar");
- skipJars.add("catalina-ant.jar");
- skipJars.add("el-api.jar");
- skipJars.add("jasper.jar");
- skipJars.add("jasper-el.jar");
- skipJars.add("jasper-jdt.jar");
- skipJars.add("jsp-api.jar");
- skipJars.add("servlet-api.jar");
- skipJars.add("tomcat-coyote.jar");
- skipJars.add("tomcat-dbcp.jar");
- // i18n JARs
- skipJars.add("tomcat-i18n-en.jar");
- skipJars.add("tomcat-i18n-es.jar");
- skipJars.add("tomcat-i18n-fr.jar");
- skipJars.add("tomcat-i18n-ja.jar");
- // Misc JARs not included with Tomcat
- skipJars.add("ant.jar");
- skipJars.add("commons-dbcp.jar");
- skipJars.add("commons-beanutils.jar");
- skipJars.add("commons-fileupload-1.0.jar");
- skipJars.add("commons-pool.jar");
- skipJars.add("commons-digester.jar");
- skipJars.add("commons-logging.jar");
- skipJars.add("commons-collections.jar");
- skipJars.add("jmx.jar");
- skipJars.add("jmx-tools.jar");
- skipJars.add("xercesImpl.jar");
- skipJars.add("xmlParserAPIs.jar");
- skipJars.add("xml-apis.jar");
- // JARs from J2SE runtime
- skipJars.add("sunjce_provider.jar");
- skipJars.add("ldapsec.jar");
- skipJars.add("localedata.jar");
- skipJars.add("dnsns.jar");
- skipJars.add("tools.jar");
- skipJars.add("sunpkcs11.jar");
- }
-
-
- protected ArrayList<Class<?>> annotatedClasses = new ArrayList<Class<?>>();
- protected ArrayList<String> overlays = new ArrayList<String>();
- protected ArrayList<String> webFragments = new ArrayList<String>();
- protected Map<String, Set<String>> TLDs = new HashMap<String, Set<String>>();
- protected Map<String, ServletContainerInitializerInfo> servletContainerInitializerInfos =
- new HashMap<String, ServletContainerInitializerInfo>();
-
- /**
- * Used to speed up scanning for the services interest classes.
- */
- protected Class<?>[] handlesTypesArray = null;
- protected Map<Class<?>, ServletContainerInitializerInfoImpl> handlesTypes =
- new HashMap<Class<?>, ServletContainerInitializerInfoImpl>();
-
-
- public Iterator<Class<?>> getAnnotatedClasses() {
- return annotatedClasses.iterator();
- }
-
-
- public Iterator<String> getOverlays() {
- return overlays.iterator();
- }
-
-
- public Iterator<String> getWebFragments() {
- return webFragments.iterator();
- }
-
-
- public Map<String, Set<String>> getTLDs() {
- return TLDs;
- }
-
-
- public Map<String, ServletContainerInitializerInfo> getServletContainerInitializerInfo() {
- return servletContainerInitializerInfos;
- }
-
-
- /**
- * Scan the given context's default locations for annotations.
- *
- * @param context
- */
- public void scan(Context context) {
- JarRepository jarRepository = context.getJarRepository();
- if (jarRepository != null) {
- JarFile[] jars = jarRepository.findJars();
- for (int i = 0; i < jars.length; i++) {
- scanJar(context, jars[i]);
- }
- File[] explodedJars = jarRepository.findExplodedJars();
- for (int i = 0; i < explodedJars.length; i++) {
- scanClasses(context, explodedJars[i], "");
- }
- }
- // Do the same for the context parent
- jarRepository = context.getParent().getJarRepository();
- if (jarRepository != null) {
- JarFile[] jars = jarRepository.findJars();
- for (int i = 0; i < jars.length; i++) {
- // FIXME: maybe add an option to do the full scan
- scanSharedJar(context, jars[i]);
- }
- File[] explodedJars = jarRepository.findExplodedJars();
- for (int i = 0; i < explodedJars.length; i++) {
- // FIXME: maybe add an option to do the full scan
- // scanClasses(context, explodedJars[i], "");
- }
- }
-
- HashSet<String> warTLDs = new HashSet<String>();
-
- // Find any TLD file in /WEB-INF
- DirContext resources = context.getResources();
- if (resources != null) {
- tldScanResourcePathsWebInf(resources, "/WEB-INF", warTLDs);
- }
- TLDs.put("", warTLDs);
-
- }
-
-
- /**
- * Scans the web application's subdirectory identified by rootPath,
- * along with its subdirectories, for TLDs.
- *
- * Initially, rootPath equals /WEB-INF. The /WEB-INF/classes and
- * /WEB-INF/lib subdirectories are excluded from the search, as per the
- * JSP 2.0 spec.
- *
- * @param resources The web application's resources
- * @param rootPath The path whose subdirectories are to be searched for
- * TLDs
- * @param tldPaths The set of TLD resource paths to add to
- */
- protected void tldScanResourcePathsWebInf(DirContext resources,
- String rootPath,
- HashSet<String> tldPaths) {
- try {
- NamingEnumeration<NameClassPair> items = resources.list(rootPath);
- while (items.hasMoreElements()) {
- NameClassPair item = items.nextElement();
- String resourcePath = rootPath + "/" + item.getName();
- if (!resourcePath.endsWith(".tld")
- && (resourcePath.startsWith("/WEB-INF/classes")
- || resourcePath.startsWith("/WEB-INF/lib"))) {
- continue;
- }
- if (resourcePath.endsWith(".tld")) {
- tldPaths.add(resourcePath);
- } else {
- tldScanResourcePathsWebInf(resources, resourcePath,
- tldPaths);
- }
- }
- } catch (NamingException e) {
- ; // Silent catch: it's valid that no /WEB-INF directory exists
- }
- }
-
-
- /**
- * Scan folder containing class files.
- */
- public 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]);
- Class<?> annotated = scanClass(context, className, file, null);
- if (annotated != null) {
- annotatedClasses.add(annotated);
- }
- }
- }
- }
-
-
- /**
- * Scan all class files in the given shared JAR (shared JARs are not scanned for annotations, overlays,
- * etc, as this would be a serious security risk).
- */
- public void scanSharedJar(Context context, JarFile file) {
- // Find ServletContainerInitializer services
- JarEntry servletContainerInitializerEntry = file.getJarEntry(Globals.SERVLET_CONTAINER_INITIALIZER_SERVICE_PATH);
- String servletContainerInitializerClassName = null;
- if (servletContainerInitializerEntry != null) {
- // Read Servlet container initializer service file
- InputStream is = null;
- try {
- is = file.getInputStream(servletContainerInitializerEntry);
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
- servletContainerInitializerClassName = reader.readLine();
- int pos = servletContainerInitializerClassName.indexOf('#');
- if (pos > 0) {
- servletContainerInitializerClassName = servletContainerInitializerClassName.substring(0, pos);
- }
- servletContainerInitializerClassName = servletContainerInitializerClassName.trim();
- } catch (Exception e) {
- // FIXME: error message or exception
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- } catch (IOException e) {
- // Ignore
- }
- }
- // Load Servlet container initializer class and read HandlesTypes annotation
- Class<?> servletContainerInitializerClass = null;
- Class<?>[] typesArray = null;
- if (servletContainerInitializerClassName != null) {
- try {
- servletContainerInitializerClass = context.getLoader().getClassLoader()
- .loadClass(servletContainerInitializerClassName);
- if (servletContainerInitializerClass.isAnnotationPresent(HandlesTypes.class)) {
- HandlesTypes handlesTypes = servletContainerInitializerClass.getAnnotation(HandlesTypes.class);
- typesArray = handlesTypes.value();
- }
- } catch (Throwable t) {
- // FIXME: error message or exception
- }
- }
- // Add in jarService map, and add in the local map used to speed up lookups
- ServletContainerInitializerInfoImpl jarServletContainerInitializerService =
- new ServletContainerInitializerInfoImpl(servletContainerInitializerClass, handlesTypesArray);
- servletContainerInitializerInfos.put(file.getName(), jarServletContainerInitializerService);
- if (typesArray != null) {
- ArrayList<Class<?>> handlesTypesList = new ArrayList<Class<?>>();
- if (handlesTypesArray != null) {
- for (int i = 0; i < handlesTypesArray.length; i++) {
- handlesTypesList.add(handlesTypesArray[i]);
- }
- }
- for (int i = 0; i < typesArray.length; i++) {
- handlesTypesList.add(typesArray[i]);
- handlesTypes.put(typesArray[i], jarServletContainerInitializerService);
- }
- handlesTypesArray = handlesTypesList.toArray(handlesTypesArray);
- }
- }
- }
-
-
- /**
- * Scan all class files in the given JAR.
- */
- public void scanJar(Context context, JarFile file) {
- // Find webapp descriptor fragments
- if (file.getEntry(Globals.WEB_FRAGMENT_PATH) != null) {
- webFragments.add(file.getName());
- }
- // Find webapp overlays
- if (file.getEntry(Globals.OVERLAY_PATH) != null) {
- overlays.add(file.getName());
- }
- // Find ServletContainerInitializer services
- scanSharedJar(context, file);
- // Find tag library descriptors
- HashSet<String> jarTLDs = new HashSet<String>();
- Enumeration<JarEntry> entries = file.entries();
- while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
- String name = entry.getName();
- if (!context.getIgnoreAnnotations() && name.endsWith(".class")) {
- Class<?> annotated = scanClass(context, getClassName(entry.getName()), null, entry);
- if (annotated != null) {
- annotatedClasses.add(annotated);
- }
- } else if (name.startsWith("META-INF/") && name.endsWith(".tld")) {
- jarTLDs.add(name);
- }
- }
- if (jarTLDs.size() > 0) {
- TLDs.put(file.getName(), jarTLDs);
- }
- }
-
-
- /**
- * Get class name given a path to a classfile.
- * /my/class/MyClass.class -> my.class.MyClass
- */
- public 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 abstract Class<?> scanClass(Context context, String className, File file, JarEntry entry);
-
-
- protected class ServletContainerInitializerInfoImpl implements ServletContainerInitializerInfo {
- protected Class<?> servletContainerInitializer = null;
- protected Class<?>[] interestClasses = null;
- protected HashSet<Class<?>> startupNotifySet = new HashSet<Class<?>>();
- protected ServletContainerInitializerInfoImpl(Class<?> servletContainerInitializer, Class<?>[] interestClasses) {
- this.servletContainerInitializer = servletContainerInitializer;
- this.interestClasses = interestClasses;
- }
- public Class<?> getServletContainerInitializer() {
- return servletContainerInitializer;
- }
- public Class<?>[] getInterestClasses() {
- return interestClasses;
- }
- protected void addStartupNotifyClass(Class<?> clazz) {
- startupNotifySet.add(clazz);
- }
- public Set<Class<?>> getStartupNotifySet() {
- return startupNotifySet;
- }
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/ClassLoadingContextScanner.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ClassLoadingContextScanner.java 2009-05-11 09:35:06 UTC (rev 1046)
+++ trunk/java/org/apache/catalina/startup/ClassLoadingContextScanner.java 2009-05-11 17:10:57 UTC (rev 1047)
@@ -1,65 +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.catalina.startup;
-
-import java.io.File;
-import java.util.jar.JarEntry;
-
-import javax.servlet.annotation.MultipartConfig;
-import javax.servlet.annotation.WebFilter;
-import javax.servlet.annotation.WebInitParam;
-import javax.servlet.annotation.WebListener;
-import javax.servlet.annotation.WebServlet;
-
-import org.apache.catalina.Context;
-
-public class ClassLoadingContextScanner
- extends BaseContextScanner {
-
- /**
- * Scan class for interesting annotations.
- */
- public Class<?> scanClass(Context context, String className, File file, JarEntry entry) {
- // Load the class using the classloader, and see if it implements one of the web annotations
- try {
- Class<?> clazz = context.getLoader().getClassLoader().loadClass(className);
- if (handlesTypesArray != null) {
- for (int i = 0; i < handlesTypesArray.length; i++) {
- if (handlesTypesArray[i].isAssignableFrom(clazz)) {
- ServletContainerInitializerInfoImpl jarServletContainerInitializerService =
- handlesTypes.get(handlesTypesArray[i]);
- jarServletContainerInitializerService.addStartupNotifyClass(clazz);
- }
- }
- }
- if (clazz.isAnnotationPresent(MultipartConfig.class)
- || clazz.isAnnotationPresent(WebFilter.class)
- || clazz.isAnnotationPresent(WebInitParam.class)
- || clazz.isAnnotationPresent(WebListener.class)
- || clazz.isAnnotationPresent(WebServlet.class)) {
- return clazz;
- }
- } catch (Throwable t) {
- // Ignore classloading errors here
- }
- return null;
- }
-
-
-}
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-11 09:35:06 UTC (rev 1046)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-11 17:10:57 UTC (rev 1047)
@@ -108,10 +108,8 @@
import org.apache.catalina.deploy.SecurityConstraint;
import org.apache.catalina.deploy.WebAbsoluteOrdering;
import org.apache.catalina.deploy.WebOrdering;
-import org.apache.catalina.startup.BaseContextScanner.ServletContainerInitializerInfoImpl;
import org.apache.catalina.util.StringManager;
import org.apache.tomcat.WarComponents;
-import org.apache.tomcat.WarComponents.ServletContainerInitializerInfo;
import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
import org.xml.sax.ErrorHandler;
@@ -1084,8 +1082,8 @@
order.addAll(otherPos, jarsSet);
}
} else if (orderings.size() > 0) {
- // FIXME: Use the ordering specified by the fragments
-
+ // Resolve relative ordering
+ OrderingResolver.resolveOrder(orderings, order);
} else {
// No order specified
order.addAll(jarsSet);
@@ -1095,6 +1093,21 @@
/**
+ * Get the jar name corresponding to the ordering name.
+ */
+ protected String getJarName(List<WebOrdering> orderings, String name) {
+ Iterator<WebOrdering> orderingsIterator = orderings.iterator();
+ while (orderingsIterator.hasNext()) {
+ WebOrdering ordering = orderingsIterator.next();
+ if (name.equals(ordering.getName())) {
+ return ordering.getJar();
+ }
+ }
+ return null;
+ }
+
+
+ /**
* Process additional descriptors: TLDs, web fragments, and map overlays.
*/
protected void applicationExtraDescriptorsConfig() {
@@ -1746,15 +1759,13 @@
}
// Scan all Servlet API related annotations
if (ok && !context.getIgnoreAnnotations()) {
- // FIXME: It is likely this should be moved to after running all listeners,
- // as they can add servlets or filters
+ // FIXME: Moved to after running all listeners, as they can add servlets or filters
WebAnnotationSet.loadApplicationAnnotations(context);
}
if (ok) {
validateSecurityRoles();
}
- // FIXME: See about order
// Find webapp overlays
if (ok) {
JarRepository jarRepository = context.getJarRepository();
@@ -1777,7 +1788,6 @@
(ServletContainerInitializer) service.getServletContainerInitializer().newInstance();
servletContainerInitializer.onStartup(service.getStartupNotifySet(), context.getServletContext());
} catch (Throwable t) {
- // FIXME: error message
log.error(sm.getString("contextConfig.servletContainerInitializer",
service.getServletContainerInitializer()), t);
ok = false;
Deleted: trunk/java/org/apache/catalina/startup/JavassistContextScanner.java
===================================================================
--- trunk/java/org/apache/catalina/startup/JavassistContextScanner.java 2009-05-11 09:35:06 UTC (rev 1046)
+++ trunk/java/org/apache/catalina/startup/JavassistContextScanner.java 2009-05-11 17:10:57 UTC (rev 1047)
@@ -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.catalina.startup;
-
-import java.io.File;
-import java.util.jar.JarEntry;
-
-import org.apache.catalina.Context;
-
-public class JavassistContextScanner
- extends BaseContextScanner {
-
- /**
- * Scan class for interesting annotations.
- */
- public Class<?> scanClass(Context context, String className, File file, JarEntry entry) {
- // FIXME: Javassist impl
- return null;
- }
-
-
-}
Modified: trunk/java/org/apache/catalina/startup/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/startup/LocalStrings.properties 2009-05-11 09:35:06 UTC (rev 1046)
+++ trunk/java/org/apache/catalina/startup/LocalStrings.properties 2009-05-11 17:10:57 UTC (rev 1047)
@@ -28,6 +28,7 @@
contextConfig.role.link=WARNING: Security role name {0} used in a <role-link> without being defined in a <security-role>
contextConfig.role.runas=WARNING: Security role name {0} used in a <run-as> without being defined in a <security-role>
contextConfig.scan=Error scanning context resources
+contextConfig.servletContainerInitializer=Error running Servlet container initializer {0}
contextConfig.start=ContextConfig: Processing START
contextConfig.stop=ContextConfig: Processing STOP
contextConfig.tldEntryException=Exception processing TLD {0} in JAR at resource path {1} in context {2}
Added: trunk/java/org/apache/catalina/startup/OrderingResolver.java
===================================================================
--- trunk/java/org/apache/catalina/startup/OrderingResolver.java (rev 0)
+++ trunk/java/org/apache/catalina/startup/OrderingResolver.java 2009-05-11 17:10:57 UTC (rev 1047)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.apache.catalina.startup;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.catalina.deploy.WebOrdering;
+
+/**
+ * Resolves the relative ordering of web fragments. This is in a separate class
+ * because of the relative complexity.
+ *
+ * @author Remy Maucherat
+ */
+public class OrderingResolver {
+
+ protected class Ordering {
+ protected WebOrdering ordering;
+ protected List<WebOrdering> after = new ArrayList<WebOrdering>();
+ protected List<WebOrdering> before = new ArrayList<WebOrdering>();
+ protected boolean afterOthers = false;
+ protected boolean beforeOthers = false;
+ }
+
+ /**
+ * Generate the Jar processing order.
+ *
+ * @param webOrderings The list of orderings, as parsed from the fragments
+ * @param order The generated order list
+ */
+ public static void resolveOrder(List<WebOrdering> webOrderings, List<String> order) {
+
+ }
+
+}
Modified: trunk/java/org/apache/catalina/startup/WebOrderingRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/WebOrderingRuleSet.java 2009-05-11 09:35:06 UTC (rev 1046)
+++ trunk/java/org/apache/catalina/startup/WebOrderingRuleSet.java 2009-05-11 17:10:57 UTC (rev 1047)
@@ -99,24 +99,24 @@
digester.addCallMethod(prefix + "web-app/ordering/before/name",
"addBefore", 0);
digester.addRule(prefix + "web-app/ordering/after/others",
- new AddOthersAfterRule());
+ new SetAfterOthersRule());
digester.addRule(prefix + "web-app/ordering/before/others",
- new AddOthersBeforeRule());
+ new SetBeforeOthersRule());
}
- final class AddOthersAfterRule extends Rule {
+ final class SetAfterOthersRule extends Rule {
public void begin(String namespace, String name, Attributes attributes)
throws Exception {
WebOrdering ordering = (WebOrdering) digester.peek();
- ordering.addAfter("*");
+ ordering.setAfterOthers(true);
}
}
- final class AddOthersBeforeRule extends Rule {
+ final class SetBeforeOthersRule extends Rule {
public void begin(String namespace, String name, Attributes attributes)
throws Exception {
WebOrdering ordering = (WebOrdering) digester.peek();
- ordering.addBefore("*");
+ ordering.setBeforeOthers(true);
}
}
}
Modified: trunk/java/org/apache/naming/resources/ProxyDirContext.java
===================================================================
--- trunk/java/org/apache/naming/resources/ProxyDirContext.java 2009-05-11 09:35:06 UTC (rev 1046)
+++ trunk/java/org/apache/naming/resources/ProxyDirContext.java 2009-05-11 17:10:57 UTC (rev 1047)
@@ -1559,6 +1559,7 @@
if (object instanceof InputStream) {
entry.resource = new Resource((InputStream) object);
} else if (object instanceof DirContext) {
+ //entry.context = new ProxyDirContextFacade(this, name);
entry.context = (DirContext) object;
} else if (object instanceof Resource) {
entry.resource = (Resource) object;
Added: trunk/java/org/apache/naming/resources/ProxyDirContextFacade.java
===================================================================
--- trunk/java/org/apache/naming/resources/ProxyDirContextFacade.java (rev 0)
+++ trunk/java/org/apache/naming/resources/ProxyDirContextFacade.java 2009-05-11 17:10:57 UTC (rev 1047)
@@ -0,0 +1,1165 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 1999-2009 The Apache Software Foundation
+ *
+ * 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.naming.resources;
+
+import java.util.Hashtable;
+
+import javax.naming.Binding;
+import javax.naming.CompositeName;
+import javax.naming.Context;
+import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameClassPair;
+import javax.naming.NameNotFoundException;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.NotContextException;
+import javax.naming.OperationNotSupportedException;
+import javax.naming.directory.AttributeModificationException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InvalidAttributesException;
+import javax.naming.directory.InvalidSearchControlsException;
+import javax.naming.directory.InvalidSearchFilterException;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+
+/**
+ * Proxy Directory Context facade implementation. Used to cache nested contexts
+ * access.
+ *
+ * @author Remy Maucherat
+ * @version $Revision: 793 $ $Date: 2008-09-27 19:44:11 +0200 (Sat, 27 Sep 2008) $
+ */
+
+public class ProxyDirContextFacade implements DirContext {
+
+
+ // ----------------------------------------------------------- Constructors
+
+
+ /**
+ * Builds a proxy directory context using the given environment.
+ */
+ public ProxyDirContextFacade(ProxyDirContext dirContext, String path) {
+ this.dirContext = dirContext;
+ this.path = path;
+ try {
+ pathName = new CompositeName(path);
+ } catch (InvalidNameException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+
+ // ----------------------------------------------------- Instance Variables
+
+
+ /**
+ * Associated DirContext.
+ */
+ protected ProxyDirContext dirContext;
+
+
+ /**
+ * Path.
+ */
+ protected String path;
+
+
+ /**
+ * Path as name.
+ */
+ protected Name pathName;
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * Return the actual directory context we are wrapping.
+ */
+ public ProxyDirContext getDirContext() {
+ return this.dirContext;
+ }
+
+
+ // -------------------------------------------------------- Context Methods
+
+
+ /**
+ * Retrieves the named object. If name is empty, returns a new instance
+ * of this context (which represents the same naming context as this
+ * context, but its environment may be modified independently and it may
+ * be accessed concurrently).
+ *
+ * @param name the name of the object to look up
+ * @return the object bound to name
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Object lookup(Name name)
+ throws NamingException {
+ return dirContext.lookup(composeName(name, pathName));
+ }
+
+
+ /**
+ * Retrieves the named object.
+ *
+ * @param name the name of the object to look up
+ * @return the object bound to name
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Object lookup(String name)
+ throws NamingException {
+ return dirContext.lookup(composeName(name, path));
+ }
+
+
+ /**
+ * Binds a name to an object. All intermediate contexts and the target
+ * context (that named by all but terminal atomic component of the name)
+ * must already exist.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @exception NameAlreadyBoundException if name is already bound
+ * @exception InvalidAttributesException if object did not supply all
+ * mandatory attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void bind(Name name, Object obj)
+ throws NamingException {
+ dirContext.bind(composeName(name, pathName), obj);
+ }
+
+
+ /**
+ * Binds a name to an object.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @exception NameAlreadyBoundException if name is already bound
+ * @exception InvalidAttributesException if object did not supply all
+ * mandatory attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void bind(String name, Object obj)
+ throws NamingException {
+ dirContext.bind(composeName(name, path), obj);
+ }
+
+
+ /**
+ * Binds a name to an object, overwriting any existing binding. All
+ * intermediate contexts and the target context (that named by all but
+ * terminal atomic component of the name) must already exist.
+ * <p>
+ * If the object is a DirContext, any existing attributes associated with
+ * the name are replaced with those of the object. Otherwise, any
+ * existing attributes associated with the name remain unchanged.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @exception InvalidAttributesException if object did not supply all
+ * mandatory attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void rebind(Name name, Object obj)
+ throws NamingException {
+ dirContext.rebind(composeName(name, pathName), obj);
+ }
+
+
+ /**
+ * Binds a name to an object, overwriting any existing binding.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @exception InvalidAttributesException if object did not supply all
+ * mandatory attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void rebind(String name, Object obj)
+ throws NamingException {
+ dirContext.rebind(composeName(name, path), obj);
+ }
+
+
+ /**
+ * Unbinds the named object. Removes the terminal atomic name in name
+ * from the target context--that named by all but the terminal atomic
+ * part of name.
+ * <p>
+ * This method is idempotent. It succeeds even if the terminal atomic
+ * name is not bound in the target context, but throws
+ * NameNotFoundException if any of the intermediate contexts do not exist.
+ *
+ * @param name the name to bind; may not be empty
+ * @exception NameNotFoundException if an intermediate context does not
+ * exist
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void unbind(Name name)
+ throws NamingException {
+ dirContext.unbind(composeName(name, pathName));
+ }
+
+
+ /**
+ * Unbinds the named object.
+ *
+ * @param name the name to bind; may not be empty
+ * @exception NameNotFoundException if an intermediate context does not
+ * exist
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void unbind(String name)
+ throws NamingException {
+ dirContext.unbind(composeName(name, path));
+ }
+
+
+ /**
+ * Binds a new name to the object bound to an old name, and unbinds the
+ * old name. Both names are relative to this context. Any attributes
+ * associated with the old name become associated with the new name.
+ * Intermediate contexts of the old name are not changed.
+ *
+ * @param oldName the name of the existing binding; may not be empty
+ * @param newName the name of the new binding; may not be empty
+ * @exception NameAlreadyBoundException if newName is already bound
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void rename(Name oldName, Name newName)
+ throws NamingException {
+ dirContext.rename(composeName(oldName, pathName), composeName(newName, pathName));
+ }
+
+
+ /**
+ * Binds a new name to the object bound to an old name, and unbinds the
+ * old name.
+ *
+ * @param oldName the name of the existing binding; may not be empty
+ * @param newName the name of the new binding; may not be empty
+ * @exception NameAlreadyBoundException if newName is already bound
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void rename(String oldName, String newName)
+ throws NamingException {
+ dirContext.rename(composeName(oldName, path), composeName(newName, path));
+ }
+
+
+ /**
+ * Enumerates the names bound in the named context, along with the class
+ * names of objects bound to them. The contents of any subcontexts are
+ * not included.
+ * <p>
+ * If a binding is added to or removed from this context, its effect on
+ * an enumeration previously returned is undefined.
+ *
+ * @param name the name of the context to list
+ * @return an enumeration of the names and class names of the bindings in
+ * this context. Each element of the enumeration is of type NameClassPair.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<NameClassPair> list(Name name)
+ throws NamingException {
+ return dirContext.list(composeName(name, pathName));
+ }
+
+
+ /**
+ * Enumerates the names bound in the named context, along with the class
+ * names of objects bound to them.
+ *
+ * @param name the name of the context to list
+ * @return an enumeration of the names and class names of the bindings in
+ * this context. Each element of the enumeration is of type NameClassPair.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<NameClassPair> list(String name)
+ throws NamingException {
+ return dirContext.list(composeName(name, path));
+ }
+
+
+ /**
+ * Enumerates the names bound in the named context, along with the
+ * objects bound to them. The contents of any subcontexts are not
+ * included.
+ * <p>
+ * If a binding is added to or removed from this context, its effect on
+ * an enumeration previously returned is undefined.
+ *
+ * @param name the name of the context to list
+ * @return an enumeration of the bindings in this context.
+ * Each element of the enumeration is of type Binding.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<Binding> listBindings(Name name)
+ throws NamingException {
+ return dirContext.listBindings(composeName(name, pathName));
+ }
+
+
+ /**
+ * Enumerates the names bound in the named context, along with the
+ * objects bound to them.
+ *
+ * @param name the name of the context to list
+ * @return an enumeration of the bindings in this context.
+ * Each element of the enumeration is of type Binding.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<Binding> listBindings(String name)
+ throws NamingException {
+ return dirContext.listBindings(composeName(name, path));
+ }
+
+
+ /**
+ * Destroys the named context and removes it from the namespace. Any
+ * attributes associated with the name are also removed. Intermediate
+ * contexts are not destroyed.
+ * <p>
+ * This method is idempotent. It succeeds even if the terminal atomic
+ * name is not bound in the target context, but throws
+ * NameNotFoundException if any of the intermediate contexts do not exist.
+ *
+ * In a federated naming system, a context from one naming system may be
+ * bound to a name in another. One can subsequently look up and perform
+ * operations on the foreign context using a composite name. However, an
+ * attempt destroy the context using this composite name will fail with
+ * NotContextException, because the foreign context is not a "subcontext"
+ * of the context in which it is bound. Instead, use unbind() to remove
+ * the binding of the foreign context. Destroying the foreign context
+ * requires that the destroySubcontext() be performed on a context from
+ * the foreign context's "native" naming system.
+ *
+ * @param name the name of the context to be destroyed; may not be empty
+ * @exception NameNotFoundException if an intermediate context does not
+ * exist
+ * @exception NotContextException if the name is bound but does not name
+ * a context, or does not name a context of the appropriate type
+ */
+ public void destroySubcontext(Name name)
+ throws NamingException {
+ dirContext.destroySubcontext(composeName(name, pathName));
+ }
+
+
+ /**
+ * Destroys the named context and removes it from the namespace.
+ *
+ * @param name the name of the context to be destroyed; may not be empty
+ * @exception NameNotFoundException if an intermediate context does not
+ * exist
+ * @exception NotContextException if the name is bound but does not name
+ * a context, or does not name a context of the appropriate type
+ */
+ public void destroySubcontext(String name)
+ throws NamingException {
+ dirContext.destroySubcontext(composeName(name, path));
+ }
+
+
+ /**
+ * Creates and binds a new context. Creates a new context with the given
+ * name and binds it in the target context (that named by all but
+ * terminal atomic component of the name). All intermediate contexts and
+ * the target context must already exist.
+ *
+ * @param name the name of the context to create; may not be empty
+ * @return the newly created context
+ * @exception NameAlreadyBoundException if name is already bound
+ * @exception InvalidAttributesException if creation of the subcontext
+ * requires specification of mandatory attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Context createSubcontext(Name name)
+ throws NamingException {
+ return dirContext.createSubcontext(composeName(name, pathName));
+ }
+
+
+ /**
+ * Creates and binds a new context.
+ *
+ * @param name the name of the context to create; may not be empty
+ * @return the newly created context
+ * @exception NameAlreadyBoundException if name is already bound
+ * @exception InvalidAttributesException if creation of the subcontext
+ * requires specification of mandatory attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Context createSubcontext(String name)
+ throws NamingException {
+ return dirContext.createSubcontext(composeName(name, path));
+ }
+
+
+ /**
+ * Retrieves the named object, following links except for the terminal
+ * atomic component of the name. If the object bound to name is not a
+ * link, returns the object itself.
+ *
+ * @param name the name of the object to look up
+ * @return the object bound to name, not following the terminal link
+ * (if any).
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Object lookupLink(Name name)
+ throws NamingException {
+ return dirContext.lookupLink(composeName(name, pathName));
+ }
+
+
+ /**
+ * Retrieves the named object, following links except for the terminal
+ * atomic component of the name.
+ *
+ * @param name the name of the object to look up
+ * @return the object bound to name, not following the terminal link
+ * (if any).
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Object lookupLink(String name)
+ throws NamingException {
+ return dirContext.lookupLink(composeName(name, path));
+ }
+
+
+ /**
+ * Retrieves the parser associated with the named context. In a
+ * federation of namespaces, different naming systems will parse names
+ * differently. This method allows an application to get a parser for
+ * parsing names into their atomic components using the naming convention
+ * of a particular naming system. Within any single naming system,
+ * NameParser objects returned by this method must be equal (using the
+ * equals() test).
+ *
+ * @param name the name of the context from which to get the parser
+ * @return a name parser that can parse compound names into their atomic
+ * components
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NameParser getNameParser(Name name)
+ throws NamingException {
+ return dirContext.getNameParser(composeName(name, pathName));
+ }
+
+
+ /**
+ * Retrieves the parser associated with the named context.
+ *
+ * @param name the name of the context from which to get the parser
+ * @return a name parser that can parse compound names into their atomic
+ * components
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NameParser getNameParser(String name)
+ throws NamingException {
+ return dirContext.getNameParser(composeName(name, path));
+ }
+
+
+ /**
+ * Composes the name of this context with a name relative to this context.
+ * <p>
+ * Given a name (name) relative to this context, and the name (prefix)
+ * of this context relative to one of its ancestors, this method returns
+ * the composition of the two names using the syntax appropriate for the
+ * naming system(s) involved. That is, if name names an object relative
+ * to this context, the result is the name of the same object, but
+ * relative to the ancestor context. None of the names may be null.
+ *
+ * @param name a name relative to this context
+ * @param prefix the name of this context relative to one of its ancestors
+ * @return the composition of prefix and name
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Name composeName(Name name, Name prefix)
+ throws NamingException {
+ prefix = (Name) prefix.clone();
+ return prefix.addAll(name);
+ }
+
+
+ /**
+ * Composes the name of this context with a name relative to this context.
+ *
+ * @param name a name relative to this context
+ * @param prefix the name of this context relative to one of its ancestors
+ * @return the composition of prefix and name
+ * @exception NamingException if a naming exception is encountered
+ */
+ public String composeName(String name, String prefix)
+ throws NamingException {
+ return prefix + "/" + name;
+ }
+
+
+ /**
+ * Adds a new environment property to the environment of this context. If
+ * the property already exists, its value is overwritten.
+ *
+ * @param propName the name of the environment property to add; may not
+ * be null
+ * @param propVal the value of the property to add; may not be null
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Object addToEnvironment(String propName, Object propVal)
+ throws NamingException {
+ return dirContext.addToEnvironment(propName, propVal);
+ }
+
+
+ /**
+ * Removes an environment property from the environment of this context.
+ *
+ * @param propName the name of the environment property to remove;
+ * may not be null
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Object removeFromEnvironment(String propName)
+ throws NamingException {
+ return dirContext.removeFromEnvironment(propName);
+ }
+
+
+ /**
+ * Retrieves the environment in effect for this context. See class
+ * description for more details on environment properties.
+ * The caller should not make any changes to the object returned: their
+ * effect on the context is undefined. The environment of this context
+ * may be changed using addToEnvironment() and removeFromEnvironment().
+ *
+ * @return the environment of this context; never null
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Hashtable<?,?> getEnvironment()
+ throws NamingException {
+ return dirContext.getEnvironment();
+ }
+
+
+ /**
+ * Closes this context. This method releases this context's resources
+ * immediately, instead of waiting for them to be released automatically
+ * by the garbage collector.
+ * This method is idempotent: invoking it on a context that has already
+ * been closed has no effect. Invoking any other method on a closed
+ * context is not allowed, and results in undefined behaviour.
+ *
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void close()
+ throws NamingException {
+ }
+
+
+ /**
+ * Retrieves the full name of this context within its own namespace.
+ * <p>
+ * Many naming services have a notion of a "full name" for objects in
+ * their respective namespaces. For example, an LDAP entry has a
+ * distinguished name, and a DNS record has a fully qualified name. This
+ * method allows the client application to retrieve this name. The string
+ * returned by this method is not a JNDI composite name and should not be
+ * passed directly to context methods. In naming systems for which the
+ * notion of full name does not make sense,
+ * OperationNotSupportedException is thrown.
+ *
+ * @return this context's name in its own namespace; never null
+ * @exception OperationNotSupportedException if the naming system does
+ * not have the notion of a full name
+ * @exception NamingException if a naming exception is encountered
+ */
+ public String getNameInNamespace()
+ throws NamingException {
+ return dirContext.getNameInNamespace();
+ }
+
+
+ // ----------------------------------------------------- DirContext Methods
+
+
+ /**
+ * Retrieves all of the attributes associated with a named object.
+ *
+ * @return the set of attributes associated with name.
+ * Returns an empty attribute set if name has no attributes; never null.
+ * @param name the name of the object from which to retrieve attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Attributes getAttributes(Name name)
+ throws NamingException {
+ return dirContext.getAttributes(composeName(name, pathName));
+ }
+
+
+ /**
+ * Retrieves all of the attributes associated with a named object.
+ *
+ * @return the set of attributes associated with name
+ * @param name the name of the object from which to retrieve attributes
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Attributes getAttributes(String name)
+ throws NamingException {
+ return dirContext.getAttributes(composeName(name, path));
+ }
+
+
+ /**
+ * Retrieves selected attributes associated with a named object.
+ * See the class description regarding attribute models, attribute type
+ * names, and operational attributes.
+ *
+ * @return the requested attributes; never null
+ * @param name the name of the object from which to retrieve attributes
+ * @param attrIds the identifiers of the attributes to retrieve. null
+ * indicates that all attributes should be retrieved; an empty array
+ * indicates that none should be retrieved
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Attributes getAttributes(Name name, String[] attrIds)
+ throws NamingException {
+ return dirContext.getAttributes(composeName(name, pathName), attrIds);
+ }
+
+
+ /**
+ * Retrieves selected attributes associated with a named object.
+ *
+ * @return the requested attributes; never null
+ * @param name the name of the object from which to retrieve attributes
+ * @param attrIds the identifiers of the attributes to retrieve. null
+ * indicates that all attributes should be retrieved; an empty array
+ * indicates that none should be retrieved
+ * @exception NamingException if a naming exception is encountered
+ */
+ public Attributes getAttributes(String name, String[] attrIds)
+ throws NamingException {
+ return dirContext.getAttributes(composeName(name, path), attrIds);
+ }
+
+
+ /**
+ * Modifies the attributes associated with a named object. The order of
+ * the modifications is not specified. Where possible, the modifications
+ * are performed atomically.
+ *
+ * @param name the name of the object whose attributes will be updated
+ * @param mod_op the modification operation, one of: ADD_ATTRIBUTE,
+ * REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE
+ * @param attrs the attributes to be used for the modification; may not
+ * be null
+ * @exception AttributeModificationException if the modification cannot be
+ * completed successfully
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void modifyAttributes(Name name, int mod_op, Attributes attrs)
+ throws NamingException {
+ dirContext.modifyAttributes(composeName(name, pathName), mod_op, attrs);
+ }
+
+
+ /**
+ * Modifies the attributes associated with a named object.
+ *
+ * @param name the name of the object whose attributes will be updated
+ * @param mod_op the modification operation, one of: ADD_ATTRIBUTE,
+ * REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE
+ * @param attrs the attributes to be used for the modification; may not
+ * be null
+ * @exception AttributeModificationException if the modification cannot be
+ * completed successfully
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void modifyAttributes(String name, int mod_op, Attributes attrs)
+ throws NamingException {
+ dirContext.modifyAttributes(composeName(name, path), mod_op, attrs);
+ }
+
+
+ /**
+ * Modifies the attributes associated with a named object using an an
+ * ordered list of modifications. The modifications are performed in the
+ * order specified. Each modification specifies a modification operation
+ * code and an attribute on which to operate. Where possible, the
+ * modifications are performed atomically.
+ *
+ * @param name the name of the object whose attributes will be updated
+ * @param mods an ordered sequence of modifications to be performed; may
+ * not be null
+ * @exception AttributeModificationException if the modification cannot be
+ * completed successfully
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void modifyAttributes(Name name, ModificationItem[] mods)
+ throws NamingException {
+ dirContext.modifyAttributes(composeName(name, pathName), mods);
+ }
+
+
+ /**
+ * Modifies the attributes associated with a named object using an an
+ * ordered list of modifications.
+ *
+ * @param name the name of the object whose attributes will be updated
+ * @param mods an ordered sequence of modifications to be performed; may
+ * not be null
+ * @exception AttributeModificationException if the modification cannot be
+ * completed successfully
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void modifyAttributes(String name, ModificationItem[] mods)
+ throws NamingException {
+ dirContext.modifyAttributes(composeName(name, path), mods);
+ }
+
+
+ /**
+ * Binds a name to an object, along with associated attributes. If attrs
+ * is null, the resulting binding will have the attributes associated
+ * with obj if obj is a DirContext, and no attributes otherwise. If attrs
+ * is non-null, the resulting binding will have attrs as its attributes;
+ * any attributes associated with obj are ignored.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @param attrs the attributes to associate with the binding
+ * @exception NameAlreadyBoundException if name is already bound
+ * @exception InvalidAttributesException if some "mandatory" attributes
+ * of the binding are not supplied
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void bind(Name name, Object obj, Attributes attrs)
+ throws NamingException {
+ dirContext.bind(composeName(name, pathName), obj, attrs);
+ }
+
+
+ /**
+ * Binds a name to an object, along with associated attributes.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @param attrs the attributes to associate with the binding
+ * @exception NameAlreadyBoundException if name is already bound
+ * @exception InvalidAttributesException if some "mandatory" attributes
+ * of the binding are not supplied
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void bind(String name, Object obj, Attributes attrs)
+ throws NamingException {
+ dirContext.bind(composeName(name, path), obj, attrs);
+ }
+
+
+ /**
+ * Binds a name to an object, along with associated attributes,
+ * overwriting any existing binding. If attrs is null and obj is a
+ * DirContext, the attributes from obj are used. If attrs is null and obj
+ * is not a DirContext, any existing attributes associated with the object
+ * already bound in the directory remain unchanged. If attrs is non-null,
+ * any existing attributes associated with the object already bound in
+ * the directory are removed and attrs is associated with the named
+ * object. If obj is a DirContext and attrs is non-null, the attributes
+ * of obj are ignored.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @param attrs the attributes to associate with the binding
+ * @exception InvalidAttributesException if some "mandatory" attributes
+ * of the binding are not supplied
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void rebind(Name name, Object obj, Attributes attrs)
+ throws NamingException {
+ dirContext.rebind(composeName(name, pathName), obj, attrs);
+ }
+
+
+ /**
+ * Binds a name to an object, along with associated attributes,
+ * overwriting any existing binding.
+ *
+ * @param name the name to bind; may not be empty
+ * @param obj the object to bind; possibly null
+ * @param attrs the attributes to associate with the binding
+ * @exception InvalidAttributesException if some "mandatory" attributes
+ * of the binding are not supplied
+ * @exception NamingException if a naming exception is encountered
+ */
+ public void rebind(String name, Object obj, Attributes attrs)
+ throws NamingException {
+ dirContext.rebind(composeName(name, path), obj, attrs);
+ }
+
+
+ /**
+ * Creates and binds a new context, along with associated attributes.
+ * This method creates a new subcontext with the given name, binds it in
+ * the target context (that named by all but terminal atomic component of
+ * the name), and associates the supplied attributes with the newly
+ * created object. All intermediate and target contexts must already
+ * exist. If attrs is null, this method is equivalent to
+ * Context.createSubcontext().
+ *
+ * @param name the name of the context to create; may not be empty
+ * @param attrs the attributes to associate with the newly created context
+ * @return the newly created context
+ * @exception NameAlreadyBoundException if the name is already bound
+ * @exception InvalidAttributesException if attrs does not contain all
+ * the mandatory attributes required for creation
+ * @exception NamingException if a naming exception is encountered
+ */
+ public DirContext createSubcontext(Name name, Attributes attrs)
+ throws NamingException {
+ return dirContext.createSubcontext(composeName(name, pathName), attrs);
+ }
+
+
+ /**
+ * Creates and binds a new context, along with associated attributes.
+ *
+ * @param name the name of the context to create; may not be empty
+ * @param attrs the attributes to associate with the newly created context
+ * @return the newly created context
+ * @exception NameAlreadyBoundException if the name is already bound
+ * @exception InvalidAttributesException if attrs does not contain all
+ * the mandatory attributes required for creation
+ * @exception NamingException if a naming exception is encountered
+ */
+ public DirContext createSubcontext(String name, Attributes attrs)
+ throws NamingException {
+ return dirContext.createSubcontext(composeName(name, path), attrs);
+ }
+
+
+ /**
+ * Retrieves the schema associated with the named object. The schema
+ * describes rules regarding the structure of the namespace and the
+ * attributes stored within it. The schema specifies what types of
+ * objects can be added to the directory and where they can be added;
+ * what mandatory and optional attributes an object can have. The range
+ * of support for schemas is directory-specific.
+ *
+ * @param name the name of the object whose schema is to be retrieved
+ * @return the schema associated with the context; never null
+ * @exception OperationNotSupportedException if schema not supported
+ * @exception NamingException if a naming exception is encountered
+ */
+ public DirContext getSchema(Name name)
+ throws NamingException {
+ return dirContext.getSchema(composeName(name, pathName));
+ }
+
+
+ /**
+ * Retrieves the schema associated with the named object.
+ *
+ * @param name the name of the object whose schema is to be retrieved
+ * @return the schema associated with the context; never null
+ * @exception OperationNotSupportedException if schema not supported
+ * @exception NamingException if a naming exception is encountered
+ */
+ public DirContext getSchema(String name)
+ throws NamingException {
+ return dirContext.getSchema(composeName(name, path));
+ }
+
+
+ /**
+ * Retrieves a context containing the schema objects of the named
+ * object's class definitions.
+ *
+ * @param name the name of the object whose object class definition is to
+ * be retrieved
+ * @return the DirContext containing the named object's class
+ * definitions; never null
+ * @exception OperationNotSupportedException if schema not supported
+ * @exception NamingException if a naming exception is encountered
+ */
+ public DirContext getSchemaClassDefinition(Name name)
+ throws NamingException {
+ return dirContext.getSchemaClassDefinition(composeName(name, pathName));
+ }
+
+
+ /**
+ * Retrieves a context containing the schema objects of the named
+ * object's class definitions.
+ *
+ * @param name the name of the object whose object class definition is to
+ * be retrieved
+ * @return the DirContext containing the named object's class
+ * definitions; never null
+ * @exception OperationNotSupportedException if schema not supported
+ * @exception NamingException if a naming exception is encountered
+ */
+ public DirContext getSchemaClassDefinition(String name)
+ throws NamingException {
+ return dirContext.getSchemaClassDefinition(composeName(name, path));
+ }
+
+
+ /**
+ * Searches in a single context for objects that contain a specified set
+ * of attributes, and retrieves selected attributes. The search is
+ * performed using the default SearchControls settings.
+ *
+ * @param name the name of the context to search
+ * @param matchingAttributes the attributes to search for. If empty or
+ * null, all objects in the target context are returned.
+ * @param attributesToReturn the attributes to return. null indicates
+ * that all attributes are to be returned; an empty array indicates that
+ * none are to be returned.
+ * @return a non-null enumeration of SearchResult objects. Each
+ * SearchResult contains the attributes identified by attributesToReturn
+ * and the name of the corresponding object, named relative to the
+ * context named by name.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes,
+ String[] attributesToReturn)
+ throws NamingException {
+ return dirContext.search(composeName(name, pathName), matchingAttributes,
+ attributesToReturn);
+ }
+
+
+ /**
+ * Searches in a single context for objects that contain a specified set
+ * of attributes, and retrieves selected attributes.
+ *
+ * @param name the name of the context to search
+ * @param matchingAttributes the attributes to search for. If empty or
+ * null, all objects in the target context are returned.
+ * @param attributesToReturn the attributes to return. null indicates
+ * that all attributes are to be returned; an empty array indicates that
+ * none are to be returned.
+ * @return a non-null enumeration of SearchResult objects. Each
+ * SearchResult contains the attributes identified by attributesToReturn
+ * and the name of the corresponding object, named relative to the
+ * context named by name.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes,
+ String[] attributesToReturn)
+ throws NamingException {
+ return dirContext.search(composeName(name, path), matchingAttributes,
+ attributesToReturn);
+ }
+
+
+ /**
+ * Searches in a single context for objects that contain a specified set
+ * of attributes. This method returns all the attributes of such objects.
+ * It is equivalent to supplying null as the atributesToReturn parameter
+ * to the method search(Name, Attributes, String[]).
+ *
+ * @param name the name of the context to search
+ * @param matchingAttributes the attributes to search for. If empty or
+ * null, all objects in the target context are returned.
+ * @return a non-null enumeration of SearchResult objects. Each
+ * SearchResult contains the attributes identified by attributesToReturn
+ * and the name of the corresponding object, named relative to the
+ * context named by name.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes)
+ throws NamingException {
+ return dirContext.search(composeName(name, pathName), matchingAttributes);
+ }
+
+
+ /**
+ * Searches in a single context for objects that contain a specified set
+ * of attributes.
+ *
+ * @param name the name of the context to search
+ * @param matchingAttributes the attributes to search for. If empty or
+ * null, all objects in the target context are returned.
+ * @return a non-null enumeration of SearchResult objects. Each
+ * SearchResult contains the attributes identified by attributesToReturn
+ * and the name of the corresponding object, named relative to the
+ * context named by name.
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes)
+ throws NamingException {
+ return dirContext.search(composeName(name, path), matchingAttributes);
+ }
+
+
+ /**
+ * Searches in the named context or object for entries that satisfy the
+ * given search filter. Performs the search as specified by the search
+ * controls.
+ *
+ * @param name the name of the context or object to search
+ * @param filter the filter expression to use for the search; may not be
+ * null
+ * @param cons the search controls that control the search. If null,
+ * the default search controls are used (equivalent to
+ * (new SearchControls())).
+ * @return an enumeration of SearchResults of the objects that satisfy
+ * the filter; never null
+ * @exception InvalidSearchFilterException if the search filter specified
+ * is not supported or understood by the underlying directory
+ * @exception InvalidSearchControlsException if the search controls
+ * contain invalid settings
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(Name name, String filter,
+ SearchControls cons)
+ throws NamingException {
+ return dirContext.search(composeName(name, pathName), filter, cons);
+ }
+
+
+ /**
+ * Searches in the named context or object for entries that satisfy the
+ * given search filter. Performs the search as specified by the search
+ * controls.
+ *
+ * @param name the name of the context or object to search
+ * @param filter the filter expression to use for the search; may not be
+ * null
+ * @param cons the search controls that control the search. If null,
+ * the default search controls are used (equivalent to
+ * (new SearchControls())).
+ * @return an enumeration of SearchResults of the objects that satisfy
+ * the filter; never null
+ * @exception InvalidSearchFilterException if the search filter
+ * specified is not supported or understood by the underlying directory
+ * @exception InvalidSearchControlsException if the search controls
+ * contain invalid settings
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(String name, String filter,
+ SearchControls cons)
+ throws NamingException {
+ return dirContext.search(composeName(name, path), filter, cons);
+ }
+
+
+ /**
+ * Searches in the named context or object for entries that satisfy the
+ * given search filter. Performs the search as specified by the search
+ * controls.
+ *
+ * @param name the name of the context or object to search
+ * @param filterExpr the filter expression to use for the search.
+ * The expression may contain variables of the form "{i}" where i is a
+ * nonnegative integer. May not be null.
+ * @param filterArgs the array of arguments to substitute for the
+ * variables in filterExpr. The value of filterArgs[i] will replace each
+ * occurrence of "{i}". If null, equivalent to an empty array.
+ * @param cons the search controls that control the search. If null, the
+ * default search controls are used (equivalent to (new SearchControls())).
+ * @return an enumeration of SearchResults of the objects that satisy the
+ * filter; never null
+ * @exception ArrayIndexOutOfBoundsException if filterExpr contains {i}
+ * expressions where i is outside the bounds of the array filterArgs
+ * @exception InvalidSearchControlsException if cons contains invalid
+ * settings
+ * @exception InvalidSearchFilterException if filterExpr with filterArgs
+ * represents an invalid search filter
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(Name name, String filterExpr,
+ Object[] filterArgs, SearchControls cons)
+ throws NamingException {
+ return dirContext.search(composeName(name, pathName), filterExpr, filterArgs,
+ cons);
+ }
+
+
+ /**
+ * Searches in the named context or object for entries that satisfy the
+ * given search filter. Performs the search as specified by the search
+ * controls.
+ *
+ * @param name the name of the context or object to search
+ * @param filterExpr the filter expression to use for the search.
+ * The expression may contain variables of the form "{i}" where i is a
+ * nonnegative integer. May not be null.
+ * @param filterArgs the array of arguments to substitute for the
+ * variables in filterExpr. The value of filterArgs[i] will replace each
+ * occurrence of "{i}". If null, equivalent to an empty array.
+ * @param cons the search controls that control the search. If null, the
+ * default search controls are used (equivalent to (new SearchControls())).
+ * @return an enumeration of SearchResults of the objects that satisy the
+ * filter; never null
+ * @exception ArrayIndexOutOfBoundsException if filterExpr contains {i}
+ * expressions where i is outside the bounds of the array filterArgs
+ * @exception InvalidSearchControlsException if cons contains invalid
+ * settings
+ * @exception InvalidSearchFilterException if filterExpr with filterArgs
+ * represents an invalid search filter
+ * @exception NamingException if a naming exception is encountered
+ */
+ public NamingEnumeration<SearchResult> search(String name, String filterExpr,
+ Object[] filterArgs, SearchControls cons)
+ throws NamingException {
+ return dirContext.search(composeName(name, path), filterExpr, filterArgs,
+ cons);
+ }
+
+
+}
+
15 years, 7 months
JBossWeb SVN: r1046 - branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-05-11 05:35:06 -0400 (Mon, 11 May 2009)
New Revision: 1046
Modified:
branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Response.java
Log:
Port the fix for 43241 (See JBPAPP-1950).
Modified: branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Response.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Response.java 2009-05-11 09:32:16 UTC (rev 1045)
+++ branches/JBOSSWEB_2_0_0_GA_CP/src/share/classes/org/apache/catalina/connector/Response.java 2009-05-11 09:35:06 UTC (rev 1046)
@@ -651,6 +651,9 @@
coyoteResponse.reset();
outputBuffer.reset();
+ usingOutputStream = false;
+ usingWriter = false;
+ isCharacterEncodingSet = false;
}
15 years, 7 months
JBossWeb SVN: r1045 - sandbox/webapps/src.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2009-05-11 05:32:16 -0400 (Mon, 11 May 2009)
New Revision: 1045
Modified:
sandbox/webapps/src/TestServlet.java
Log:
Add a test for JBPAPP-1950.
Modified: sandbox/webapps/src/TestServlet.java
===================================================================
--- sandbox/webapps/src/TestServlet.java 2009-05-08 15:02:57 UTC (rev 1044)
+++ sandbox/webapps/src/TestServlet.java 2009-05-11 09:32:16 UTC (rev 1045)
@@ -82,6 +82,19 @@
out.println("<body>");
out.println("<h3>" + title + "</h3>");
+
+
+ String testValue = request.getParameter("test");
+ if (testValue != null && testValue.compareToIgnoreCase("JBPAPP-1950")==0) {
+ /* Reset the buffer and write JBPAPP-1950 back */
+ response.reset();
+ response.setContentType("plain/text");
+ ServletOutputStream responseStream = response.getOutputStream();
+ responseStream.print("ok....");
+ responseStream.close();
+ return;
+ }
+
String createValue = request.getParameter("create");
int icreate = 0;
if (createValue != null) {
15 years, 7 months
JBossWeb SVN: r1044 - in trunk/java: javax/servlet/annotation and 3 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-08 11:02:57 -0400 (Fri, 08 May 2009)
New Revision: 1044
Modified:
trunk/java/javax/servlet/FilterRegistration.java
trunk/java/javax/servlet/Registration.java
trunk/java/javax/servlet/ServletContext.java
trunk/java/javax/servlet/ServletContextAttributeListener.java
trunk/java/javax/servlet/ServletContextListener.java
trunk/java/javax/servlet/ServletRegistration.java
trunk/java/javax/servlet/ServletRequest.java
trunk/java/javax/servlet/ServletRequestAttributeListener.java
trunk/java/javax/servlet/ServletRequestListener.java
trunk/java/javax/servlet/annotation/WebListener.java
trunk/java/javax/servlet/http/HttpSessionAttributeListener.java
trunk/java/javax/servlet/http/HttpSessionListener.java
trunk/java/org/apache/catalina/core/ApplicationContext.java
trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
trunk/java/org/apache/catalina/core/ApplicationFilterConfigFacade.java
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/catalina/core/StandardWrapperFacade.java
trunk/java/org/apache/jasper/servlet/JspCServletContext.java
Log:
- Update to new Servlet API snapshot.
Modified: trunk/java/javax/servlet/FilterRegistration.java
===================================================================
--- trunk/java/javax/servlet/FilterRegistration.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/javax/servlet/FilterRegistration.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -37,6 +37,7 @@
package javax.servlet;
import java.util.EnumSet;
+import java.util.Set;
/**
* Interface through which a {@link Filter} may be further configured.
@@ -75,6 +76,15 @@
String... servletNames);
/**
+ * Gets an Iterable over the currently available servlet name mappings
+ * of the Filter represented by this FilterRegistration.
+ *
+ * @return Iterable over the currently available servlet name
+ * mappings of the Filter represented by this FilterRegistration.
+ */
+ public Iterable<String> getServletNameMappings();
+
+ /**
* Adds a filter mapping with the given url patterns and dispatcher
* types for the Filter represented by this FilterRegistration.
*
@@ -104,6 +114,15 @@
String... urlPatterns);
/**
+ * Gets an Iterable over the currently available URL pattern mappings
+ * of the Filter represented by this FilterRegistration.
+ *
+ * @return Iterable over the currently available URL pattern
+ * mappings of the Filter represented by this FilterRegistration.
+ */
+ public Iterable<String> getUrlPatternMappings();
+
+ /**
* Interface through which a {@link Filter} registered via one of the
* <tt>addFilter</tt> methods on {@link ServletContext} may be further
* configured.
Modified: trunk/java/javax/servlet/Registration.java
===================================================================
--- trunk/java/javax/servlet/Registration.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/javax/servlet/Registration.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -48,6 +48,24 @@
public interface Registration {
/**
+ * Gets the name of the Servlet or Filter that is represented by this
+ * Registration.
+ *
+ * @return the name of the Servlet or Filter that is represented by this
+ * Registration
+ */
+ public String getName();
+
+ /**
+ * Gets the fully qualified class name of the Servlet or Filter that
+ * is represented by this Registration.
+ *
+ * @return the fully qualified class name of the Servlet or Filter
+ * that is represented by this Registration
+ */
+ public String getClassName();
+
+ /**
* Sets the initialization parameter with the given name and value
* on the Servlet or Filter that is represented by this Registration.
*
@@ -66,6 +84,20 @@
public boolean setInitParameter(String name, String value);
/**
+ * Gets the value of the initialization parameter with the given name
+ * that will be used to initialize the Servlet or Filter represented
+ * by this Registration object.
+ *
+ * @param name the name of the initialization parameter whose value is
+ * requested
+ *
+ * @return the value of the initialization parameter with the given
+ * name, or <tt>null</tt> if no initialization parameter with the given
+ * name exists
+ */
+ public String getInitParameter(String name);
+
+ /**
* Sets the given initialization parameters on the Servlet or Filter
* that is represented by this Registration.
*
@@ -92,6 +124,18 @@
public Set<String> setInitParameters(Map<String, String> initParameters);
/**
+ * Gets an immutable (and possibly empty) Map containing the
+ * currently available initialization parameters that will be used to
+ * initialize the Servlet or Filter represented by this Registration
+ * object.
+ *
+ * @return Map containing the currently available initialization
+ * parameters that will be used to initialize the Servlet or Filter
+ * represented by this Registration object
+ */
+ public Map<String, String> getInitParameters();
+
+ /**
* Interface through which a {@link Servlet} or {@link Filter} registered
* via one of the <tt>addServlet</tt> or <tt>addFilter</tt> methods,
* respectively, on {@link ServletContext} may be further configured.
Modified: trunk/java/javax/servlet/ServletContext.java
===================================================================
--- trunk/java/javax/servlet/ServletContext.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/javax/servlet/ServletContext.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -773,10 +773,28 @@
*
* @since Servlet 3.0
*/
- public ServletRegistration findServletRegistration(String servletName);
+ public ServletRegistration getServletRegistration(String servletName);
/**
+ * Gets an immutable (and possibly empty) Map of the ServletRegistration
+ * objects (keyed by servlet name) corresponding to all servlets
+ * registered with this ServletContext.
+ *
+ * <p>The returned Map includes the ServletRegistration objects
+ * corresponding to all declared and annotated servlets, as well as the
+ * ServletRegistration objects corresponding to all servlets that have
+ * been added via one of the <tt>addServlet</tt> methods.
+ *
+ * @return Map of the ServletRegistration objects corresponding
+ * to all servlets currently registered with this ServletContext
+ *
+ * @since Servlet 3.0
+ */
+ public Map<String, ServletRegistration> getServletRegistrations();
+
+
+ /**
* Adds the filter with the given name and class name to this servlet
* context.
*
@@ -882,10 +900,28 @@
*
* @since Servlet 3.0
*/
- public FilterRegistration findFilterRegistration(String filterName);
+ public FilterRegistration getFilterRegistration(String filterName);
/**
+ * Gets an immutable (and possibly empty) Map of the FilterRegistration
+ * objects (keyed by filter name) corresponding to all filters
+ * registered with this ServletContext.
+ *
+ * <p>The returned Map includes the FilterRegistration objects
+ * corresponding to all declared and annotated filters, as well as the
+ * FilterRegistration objects corresponding to all filters that have
+ * been added via one of the <tt>addFilter</tt> methods.
+ *
+ * @return Map of the FilterRegistration objects corresponding
+ * to all filters currently registered with this ServletContext
+ *
+ * @since Servlet 3.0
+ */
+ public Map<String, FilterRegistration> getFilterRegistrations();
+
+
+ /**
* Gets the {@link SessionCookieConfig} object through which various
* properties of the session tracking cookies created on behalf of this
* <tt>ServletContext</tt> may be configured.
Modified: trunk/java/javax/servlet/ServletContextAttributeListener.java
===================================================================
--- trunk/java/javax/servlet/ServletContextAttributeListener.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/javax/servlet/ServletContextAttributeListener.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -56,20 +56,50 @@
import java.util.EventListener;
- /** Implementations of this interface receive notifications of
- ** changes to the attribute list on the servlet context of a web application.
- * To receive notification events, the implementation class
- * must be configured in the deployment descriptor for the web application.
- * @see ServletContextAttributeEvent
- * @since Servlet 2.3
- */
+/**
+ * Interface for receiving notification events about ServletContext
+ * attribute changes.
+ *
+ * <p>In order to receive these notification events, the implementation
+ * class must be either declared in the deployment descriptor of the web
+ * application or annotated with
+ * {@link javax.servlet.annotation.WebListener}.
+ *
+ * @see ServletContextAttributeEvent
+ *
+ * @since Servlet 2.3
+ */
public interface ServletContextAttributeListener extends EventListener {
- /** Notification that a new attribute was added to the servlet context. Called after the attribute is added.*/
-public void attributeAdded(ServletContextAttributeEvent scab);
- /** Notification that an existing attribute has been removed from the servlet context. Called after the attribute is removed.*/
-public void attributeRemoved(ServletContextAttributeEvent scab);
- /** Notification that an attribute on the servlet context has been replaced. Called after the attribute is replaced. */
-public void attributeReplaced(ServletContextAttributeEvent scab);
+
+ /**
+ * Receives notification that an attribute has been added to the
+ * ServletContext.
+ *
+ * @param event the ServletContextAttributeEvent containing the
+ * ServletContext to which the attribute was added, along with the
+ * attribute name and value
+ */
+ public void attributeAdded(ServletContextAttributeEvent event);
+
+ /**
+ * Receives notification that an attribute has been removed
+ * from the ServletContext.
+ *
+ * @param event the ServletContextAttributeEvent containing the
+ * ServletContext from which the attribute was removed, along with
+ * the attribute name and value
+ */
+ public void attributeRemoved(ServletContextAttributeEvent event);
+
+ /*
+ * Receives notification that an attribute has been replaced
+ * in the ServletContext.
+ *
+ * @param event the ServletContextAttributeEvent containing the
+ * ServletContext in which the attribute was replaced, along with
+ * the attribute name and its old value
+ */
+ public void attributeReplaced(ServletContextAttributeEvent event);
}
Modified: trunk/java/javax/servlet/ServletContextListener.java
===================================================================
--- trunk/java/javax/servlet/ServletContextListener.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/javax/servlet/ServletContextListener.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -52,41 +52,49 @@
* limitations under the License.
*/
-
-
package javax.servlet;
import java.util.EventListener;
- /**
- * Implementations of this interface receive notifications about
- * changes to the servlet context of the web application they are
- * part of.
- * To receive notification events, the implementation class
- * must be configured in the deployment descriptor for the web
- * application.
- * @see ServletContextEvent
- *
- * @since Servlet 2.3
- */
-
+/**
+ * Interface for receiving notification events about ServletContext
+ * lifecycle changes.
+ *
+ * <p>In order to receive these notification events, the implementation
+ * class must be either declared in the deployment descriptor of the web
+ * application or annotated with
+ * {@link javax.servlet.annotation.WebListener}.
+ *
+ * @see ServletContextEvent
+ *
+ * @since Servlet 2.3
+ */
public interface ServletContextListener extends EventListener {
- /**
- ** Notification that the web application initialization
- ** process is starting.
- ** All ServletContextListeners are notified of context
- ** initialization before any filter or servlet in the web
- ** application is initialized.
- */
- public void contextInitialized ( ServletContextEvent sce );
+ /**
+ * Receives notification that the web application initialization
+ * process is starting.
+ *
+ * <p>All ServletContextListeners are notified of context
+ * initialization before any filters or servlets in the web
+ * application are initialized.
+ *
+ * @param sce the ServletContextEvent containing the ServletContext
+ * that is being initialized
+ */
+ public void contextInitialized(ServletContextEvent sce);
- /**
- ** Notification that the servlet context is about to be shut down.
- ** All servlets and filters have been destroy()ed before any
- ** ServletContextListeners are notified of context
- ** destruction.
- */
- public void contextDestroyed ( ServletContextEvent sce );
+ /**
+ * Receives notification that the ServletContext is about to be
+ * shut down.
+ *
+ * <p>All servlets and filters will have been destroyed before any
+ * ServletContextListeners are notified of context
+ * destruction.
+ *
+ * @param sce the ServletContextEvent containing the ServletContext
+ * that is being destroyed
+ */
+ public void contextDestroyed(ServletContextEvent sce);
}
Modified: trunk/java/javax/servlet/ServletRegistration.java
===================================================================
--- trunk/java/javax/servlet/ServletRegistration.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/javax/servlet/ServletRegistration.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -65,6 +65,15 @@
public Set<String> addMapping(String... urlPatterns);
/**
+ * Gets an Iterable over the currently available mappings of the
+ * Servlet represented by this ServletRegistration.
+ *
+ * @return Iterable over the currently available mappings
+ * of the Servlet represented by this ServletRegistration.
+ */
+ public Iterable<String> getMappings();
+
+ /**
* Interface through which a {@link Servlet} registered via one of the
* <tt>addServlet</tt> methods on {@link ServletContext} may be further
* configured.
Modified: trunk/java/javax/servlet/ServletRequest.java
===================================================================
--- trunk/java/javax/servlet/ServletRequest.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/javax/servlet/ServletRequest.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -599,10 +599,10 @@
/**
- * Gets the servlet context to which this servlet request was last
+ * Gets the servlet context to which this ServletRequest was last
* dispatched.
*
- * @return the servlet context to which this servlet request was last
+ * @return the servlet context to which this ServletRequest was last
* dispatched
*
* @since Servlet 3.0
Modified: trunk/java/javax/servlet/ServletRequestAttributeListener.java
===================================================================
--- trunk/java/javax/servlet/ServletRequestAttributeListener.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/javax/servlet/ServletRequestAttributeListener.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -52,38 +52,58 @@
* limitations under the License.
*/
-
-
package javax.servlet;
import java.util.EventListener;
+/**
+ * Interface for receiving notification events about ServletRequest
+ * attribute changes.
+ *
+ * <p>Notifications will be generated while the request
+ * is within the scope of the web application. A ServletRequest
+ * is defined as coming into scope of a web application when it
+ * is about to enter the first servlet or filter of the web
+ * application, and as going out of scope when it exits the last
+ * servlet or the first filter in the chain.
+ *
+ * <p>In order to receive these notification events, the implementation
+ * class must be either declared in the deployment descriptor of the web
+ * application or annotated with
+ * {@link javax.servlet.annotation.WebListener}.
+ *
+ * @since Servlet 2.4
+ */
+
+public interface ServletRequestAttributeListener extends EventListener {
+
/**
- * A ServletRequestAttributeListener can be implemented by the
- * developer interested in being notified of request attribute
- * changes. Notifications will be generated while the request
- * is within the scope of the web application in which the listener
- * is registered. A request is defined as coming into scope when
- * it is about to enter the first servlet or filter in each web
- * application, as going out of scope when it exits the last servlet
- * or the first filter in the chain.
+ * Receives notification that an attribute has been added to the
+ * ServletRequest.
*
- * @since Servlet 2.4
+ * @param srae the ServletRequestAttributeEvent containing the
+ * ServletRequest and the name and value of the attribute that was
+ * added
*/
-
-public interface ServletRequestAttributeListener extends EventListener {
- /** Notification that a new attribute was added to the
- ** servlet request. Called after the attribute is added.
- */
public void attributeAdded(ServletRequestAttributeEvent srae);
- /** Notification that an existing attribute has been removed from the
- ** servlet request. Called after the attribute is removed.
+ /**
+ * Receives notification that an attribute has been removed from the
+ * ServletRequest.
+ *
+ * @param srae the ServletRequestAttributeEvent containing the
+ * ServletRequest and the name and value of the attribute that was
+ * removed
*/
public void attributeRemoved(ServletRequestAttributeEvent srae);
- /** Notification that an attribute was replaced on the
- ** servlet request. Called after the attribute is replaced.
+ /**
+ * Receives notification that an attribute has been replaced on the
+ * ServletRequest.
+ *
+ * @param srae the ServletRequestAttributeEvent containing the
+ * ServletRequest and the name and (old) value of the attribute
+ * that was replaced
*/
public void attributeReplaced(ServletRequestAttributeEvent srae);
}
Modified: trunk/java/javax/servlet/ServletRequestListener.java
===================================================================
--- trunk/java/javax/servlet/ServletRequestListener.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/javax/servlet/ServletRequestListener.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -52,29 +52,44 @@
* limitations under the License.
*/
-
-
package javax.servlet;
import java.util.EventListener;
+/**
+ * Interface for receiving notification events about requests coming
+ * into and going out of scope of a web application.
+ *
+ * <p>A ServletRequest is defined as coming into scope of a web
+ * application when it is about to enter the first servlet or filter
+ * of the web application, and as going out of scope as it exits
+ * the last servlet or the first filter in the chain.
+ *
+ * <p>In order to receive these notification events, the implementation
+ * class must be either declared in the deployment descriptor of the web
+ * application or annotated with
+ * {@link javax.servlet.annotation.WebListener}.
+ *
+ * @since Servlet 2.4
+ */
+
+public interface ServletRequestListener extends EventListener {
+
/**
- * A ServletRequestListener can be implemented by the developer
- * interested in being notified of requests coming in and out of
- * scope in a web component. A request is defined as coming into
- * scope when it is about to enter the first servlet or filter
- * in each web application, as going out of scope when it exits
- * the last servlet or the first filter in the chain.
+ * Receives notification that a ServletRequest is about to go out
+ * of scope of the web application.
*
- * @since Servlet 2.4
+ * @param sre the ServletRequestEvent containing the ServletRequest
+ * and the ServletContext representing the web application
*/
+ public void requestDestroyed(ServletRequestEvent sre);
-
-public interface ServletRequestListener extends EventListener {
-
- /** The request is about to go out of scope of the web application. */
- public void requestDestroyed ( ServletRequestEvent sre );
-
- /** The request is about to come into scope of the web application. */
- public void requestInitialized ( ServletRequestEvent sre );
+ /**
+ * Receives notification that a ServletRequest is about to come
+ * into scope of the web application.
+ *
+ * @param sre the ServletRequestEvent containing the ServletRequest
+ * and the ServletContext representing the web application
+ */
+ public void requestInitialized(ServletRequestEvent sre);
}
Modified: trunk/java/javax/servlet/annotation/WebListener.java
===================================================================
--- trunk/java/javax/servlet/annotation/WebListener.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/javax/servlet/annotation/WebListener.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -42,7 +42,15 @@
import java.lang.annotation.Target;
/**
- * This annotation is used to declare a WebListener
+ * This annotation is used to declare a WebListener.
+ *
+ * Any class annotated with WebListener must implement one or more of
+ * the {@link javax.servlet.ServletContextListener},
+ * {@link javax.servlet.ServletContextAttributeListener},
+ * {@link javax.servlet.ServletRequestListener},
+ * {@link javax.servlet.ServletRequestAttributeListener},
+ * {@link javax.servlet.http.HttpSessionListener}, or
+ * {@link javax.servlet.http.HttpSessionAttributeListener} interfaces.
*
* @since Servlet 3.0
*/
Modified: trunk/java/javax/servlet/http/HttpSessionAttributeListener.java
===================================================================
--- trunk/java/javax/servlet/http/HttpSessionAttributeListener.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/javax/servlet/http/HttpSessionAttributeListener.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -52,25 +52,50 @@
* limitations under the License.
*/
-
-
package javax.servlet.http;
import java.util.EventListener;
- /** This listener interface can be implemented in order to
- * get notifications of changes to the attribute lists of sessions within
- * this web application.
- * @since Servlet 2.3
-*/
+/**
+ * Interface for receiving notification events about HttpSession
+ * attribute changes.
+ *
+ * <p>In order to receive these notification events, the implementation
+ * class must be either declared in the deployment descriptor of the web
+ * application or annotated with
+ * {@link javax.servlet.annotation.WebListener}.
+ *
+ * @since Servlet 2.3
+ */
public interface HttpSessionAttributeListener extends EventListener {
- /** Notification that an attribute has been added to a session. Called after the attribute is added.*/
- public void attributeAdded ( HttpSessionBindingEvent se );
- /** Notification that an attribute has been removed from a session. Called after the attribute is removed. */
- public void attributeRemoved ( HttpSessionBindingEvent se );
- /** Notification that an attribute has been replaced in a session. Called after the attribute is replaced. */
- public void attributeReplaced ( HttpSessionBindingEvent se );
+ /**
+ * Receives notification that an attribute has been added to a
+ * session.
+ *
+ * @param event the HttpSessionBindingEvent containing the session
+ * and the name and value of the attribute that was added
+ */
+ public void attributeAdded(HttpSessionBindingEvent event);
+
+ /**
+ * Receives notification that an attribute has been removed from a
+ * session.
+ *
+ * @param event the HttpSessionBindingEvent containing the session
+ * and the name and value of the attribute that was removed
+ */
+ public void attributeRemoved(HttpSessionBindingEvent event);
+
+ /**
+ * Receives notification that an attribute has been replaced in a
+ * session.
+ *
+ * @param event the HttpSessionBindingEvent containing the session
+ * and the name and (old) value of the attribute that was replaced
+ */
+ public void attributeReplaced(HttpSessionBindingEvent event);
+
}
Modified: trunk/java/javax/servlet/http/HttpSessionListener.java
===================================================================
--- trunk/java/javax/servlet/http/HttpSessionListener.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/javax/servlet/http/HttpSessionListener.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -52,34 +52,38 @@
* limitations under the License.
*/
-
-
package javax.servlet.http;
import java.util.EventListener;
- /**
- * Implementations of this interface are notified of changes to the
- * list of active sessions in a web application.
- * To receive notification events, the implementation class
- * must be configured in the deployment descriptor for the web application.
- * @see HttpSessionEvent
- * @since Servlet 2.3
- */
-
+/**
+ * Interface for receiving notification events about HttpSession
+ * lifecycle changes.
+ *
+ * <p>In order to receive these notification events, the implementation
+ * class must be either declared in the deployment descriptor of the web
+ * application or annotated with
+ * {@link javax.servlet.annotation.WebListener}.
+ *
+ * @see HttpSessionEvent
+ *
+ * @since Servlet 2.3
+ */
public interface HttpSessionListener extends EventListener {
- /**
- * Notification that a session was created.
- * @param se the notification event
- */
- public void sessionCreated ( HttpSessionEvent se );
+ /**
+ * Receives notification that a session has been created.
+ *
+ * @param se the HttpSessionEvent containing the session
+ */
+ public void sessionCreated(HttpSessionEvent se);
- /**
- * Notification that a session is about to be invalidated.
- * @param se the notification event
- */
- public void sessionDestroyed ( HttpSessionEvent se );
+ /**
+ * Receives notification that a session is about to be invalidated.
+ *
+ * @param se the HttpSessionEvent containing the session
+ */
+ public void sessionDestroyed(HttpSessionEvent se);
}
Modified: trunk/java/org/apache/catalina/core/ApplicationContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/org/apache/catalina/core/ApplicationContext.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -52,7 +52,9 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -73,6 +75,7 @@
import javax.servlet.SessionCookieConfig;
import javax.servlet.SessionTrackingMode;
+import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Globals;
import org.apache.catalina.Host;
@@ -911,7 +914,7 @@
}
- public FilterRegistration findFilterRegistration(String filterName) {
+ public FilterRegistration getFilterRegistration(String filterName) {
ApplicationFilterConfig filterConfig = context.findApplicationFilterConfig(filterName);
if (filterConfig == null) {
FilterDef filterDef = context.findFilterDef(filterName);
@@ -926,7 +929,7 @@
}
- public ServletRegistration findServletRegistration(String servletName) {
+ public ServletRegistration getServletRegistration(String servletName) {
Wrapper wrapper = (Wrapper) context.findChild(servletName);
if (wrapper != null) {
return wrapper.getFacade();
@@ -936,6 +939,29 @@
}
+ public Map<String, FilterRegistration> getFilterRegistrations() {
+ HashMap<String, FilterRegistration> result =
+ new HashMap<String, FilterRegistration>();
+ ApplicationFilterConfig[] filterConfigs = context.findApplicationFilterConfigs();
+ for (int i = 0; i < filterConfigs.length; i++) {
+ result.put(filterConfigs[i].getFilterName(), filterConfigs[i].getFacade());
+ }
+ return Collections.unmodifiableMap(result);
+ }
+
+
+ public Map<String, ServletRegistration> getServletRegistrations() {
+ HashMap<String, ServletRegistration> result =
+ new HashMap<String, ServletRegistration>();
+ Container[] wrappers = context.findChildren();
+ for (int i = 0; i < wrappers.length; i++) {
+ Wrapper wrapper = (Wrapper) wrappers[i];
+ result.put(wrapper.getName(), wrapper.getFacade());
+ }
+ return Collections.unmodifiableMap(result);
+ }
+
+
/**
* By default {@link SessionTrackingMode#URL} is always supported, {@link
* SessionTrackingMode#COOKIE} is supported unless the <code>cookies</code>
Modified: trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationContextFacade.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/org/apache/catalina/core/ApplicationContextFacade.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -58,6 +58,7 @@
import java.util.EnumSet;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
import javax.servlet.Filter;
@@ -496,26 +497,46 @@
}
- public FilterRegistration findFilterRegistration(String filterName) {
+ public FilterRegistration getFilterRegistration(String filterName) {
if (SecurityUtil.isPackageProtectionEnabled()) {
- return (FilterRegistration) doPrivileged("findFilterRegistration",
+ return (FilterRegistration) doPrivileged("getFilterRegistration",
new Object[]{filterName});
} else {
- return context.findFilterRegistration(filterName);
+ return context.getFilterRegistration(filterName);
}
}
- public ServletRegistration findServletRegistration(String servletName) {
+ public ServletRegistration getServletRegistration(String servletName) {
if (SecurityUtil.isPackageProtectionEnabled()) {
- return (ServletRegistration) doPrivileged("findServletRegistration",
+ return (ServletRegistration) doPrivileged("getServletRegistration",
new Object[]{servletName});
} else {
- return context.findServletRegistration(servletName);
+ return context.getServletRegistration(servletName);
}
}
+
+
+ public Map<String, ServletRegistration> getServletRegistrations() {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ return (Map<String, ServletRegistration>) doPrivileged("getServletRegistrations",
+ new Object[]{});
+ } else {
+ return context.getServletRegistrations();
+ }
+ }
+ public Map<String, FilterRegistration> getFilterRegistrations() {
+ if (SecurityUtil.isPackageProtectionEnabled()) {
+ return (Map<String, FilterRegistration>) doPrivileged("getFilterRegistrations",
+ new Object[]{});
+ } else {
+ return context.getFilterRegistrations();
+ }
+ }
+
+
public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
if (SecurityUtil.isPackageProtectionEnabled()) {
return (EnumSet<SessionTrackingMode>)
Modified: trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -50,6 +50,7 @@
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.EnumSet;
import java.util.Enumeration;
import java.util.HashMap;
@@ -122,7 +123,7 @@
/**
* The Context with which we are associated.
*/
- private Context context = null;
+ private transient Context context = null;
/**
@@ -161,9 +162,7 @@
* Return the name of the filter we are configuring.
*/
public String getFilterName() {
-
return (filterDef.getFilterName());
-
}
@@ -175,13 +174,12 @@
* @param name Name of the requested initialization parameter
*/
public String getInitParameter(String name) {
-
- Map map = filterDef.getParameterMap();
- if (map == null)
+ Map<String, String> map = filterDef.getParameterMap();
+ if (map == null) {
return (null);
- else
- return ((String) map.get(name));
-
+ } else {
+ return map.get(name);
+ }
}
@@ -189,14 +187,13 @@
* Return an <code>Enumeration</code> of the names of the initialization
* parameters for this Filter.
*/
- public Enumeration getInitParameterNames() {
-
- Map map = filterDef.getParameterMap();
- if (map == null)
- return (new Enumerator(new ArrayList()));
- else
+ public Enumeration<String> getInitParameterNames() {
+ Map<String, String> map = filterDef.getParameterMap();
+ if (map == null) {
+ return (new Enumerator(new ArrayList<String>()));
+ } else {
return (new Enumerator(map.keySet()));
-
+ }
}
@@ -204,9 +201,7 @@
* Return the ServletContext of our associated web application.
*/
public ServletContext getServletContext() {
-
return (this.context.getServletContext());
-
}
@@ -293,6 +288,44 @@
}
+ public Iterable<String> getServletNameMappings() {
+ HashSet<String> result = new HashSet<String>();
+ FilterMap[] filterMaps = context.findFilterMaps();
+ for (int i = 0; i < filterMaps.length; i++) {
+ if (filterDef.getFilterName().equals(filterMaps[i].getFilterName())) {
+ FilterMap filterMap = filterMaps[i];
+ String[] maps = filterMap.getServletNames();
+ for (int j = 0; j < maps.length; j++) {
+ result.add(maps[j]);
+ }
+ if (filterMap.getMatchAllServletNames()) {
+ result.add("*");
+ }
+ }
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+
+ public Iterable<String> getUrlPatternMappings() {
+ HashSet<String> result = new HashSet<String>();
+ FilterMap[] filterMaps = context.findFilterMaps();
+ for (int i = 0; i < filterMaps.length; i++) {
+ if (filterDef.getFilterName().equals(filterMaps[i].getFilterName())) {
+ FilterMap filterMap = filterMaps[i];
+ String[] maps = filterMap.getURLPatterns();
+ for (int j = 0; j < maps.length; j++) {
+ result.add(maps[j]);
+ }
+ if (filterMap.getMatchAllUrlPatterns()) {
+ result.add("*");
+ }
+ }
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+
public void setAsyncSupported(boolean asyncSupported) {
filterDef.setAsyncSupported(asyncSupported);
context.addFilterDef(filterDef);
Modified: trunk/java/org/apache/catalina/core/ApplicationFilterConfigFacade.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationFilterConfigFacade.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/org/apache/catalina/core/ApplicationFilterConfigFacade.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -47,32 +47,18 @@
package org.apache.catalina.core;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.EnumSet;
import java.util.Enumeration;
-import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import javax.naming.NamingException;
import javax.servlet.DispatcherType;
-import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import org.apache.catalina.Context;
-import org.apache.catalina.Globals;
-import org.apache.catalina.deploy.FilterDef;
-import org.apache.catalina.security.SecurityUtil;
-import org.apache.catalina.util.Enumerator;
-import org.apache.catalina.util.StringManager;
-import org.apache.tomcat.InstanceManager;
-import org.apache.tomcat.util.log.SystemLogHandler;
-
/**
* Facade for AppalicationFilterConfig.
*
@@ -83,9 +69,6 @@
public class ApplicationFilterConfigFacade implements FilterConfig, FilterRegistration {
- protected static StringManager sm =
- StringManager.getManager(Constants.Package);
-
public static class Dynamic extends ApplicationFilterConfigFacade
implements FilterRegistration.Dynamic {
@@ -120,9 +103,7 @@
* Return the name of the filter we are configuring.
*/
public String getFilterName() {
-
return config.getFilterName();
-
}
@@ -134,9 +115,7 @@
* @param name Name of the requested initialization parameter
*/
public String getInitParameter(String name) {
-
return config.getInitParameter(name);
-
}
@@ -144,10 +123,8 @@
* Return an <code>Enumeration</code> of the names of the initialization
* parameters for this Filter.
*/
- public Enumeration getInitParameterNames() {
-
+ public Enumeration<String> getInitParameterNames() {
return config.getInitParameterNames();
-
}
@@ -155,9 +132,7 @@
* Return the ServletContext of our associated web application.
*/
public ServletContext getServletContext() {
-
return config.getServletContext();
-
}
@@ -193,4 +168,29 @@
config.setDescription(description);
}
+
+ public Iterable<String> getServletNameMappings() {
+ return config.getServletNameMappings();
+ }
+
+
+ public Iterable<String> getUrlPatternMappings() {
+ return config.getUrlPatternMappings();
+ }
+
+
+ public String getClassName() {
+ return config.getFilterDef().getFilterClass();
+ }
+
+
+ public Map<String, String> getInitParameters() {
+ return Collections.unmodifiableMap(config.getFilterDef().getParameterMap());
+ }
+
+
+ public String getName() {
+ return config.getFilterName();
+ }
+
}
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -2575,6 +2575,14 @@
/**
+ * Return the application filter for the given name.
+ */
+ public ApplicationFilterConfig[] findApplicationFilterConfigs() {
+ return filterConfigs.values().toArray(new ApplicationFilterConfig[0]);
+ }
+
+
+ /**
* Return the set of application listener class names configured
* for this application.
*/
Modified: trunk/java/org/apache/catalina/core/StandardWrapperFacade.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperFacade.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/org/apache/catalina/core/StandardWrapperFacade.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -47,7 +47,9 @@
package org.apache.catalina.core;
+import java.util.Collections;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
@@ -201,4 +203,34 @@
}
+ public Iterable<String> getMappings() {
+ HashSet<String> result = new HashSet<String>();
+ String[] mappings = wrapper.findMappings();
+ for (int i = 0; i < mappings.length; i++) {
+ result.add(mappings[i]);
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+
+ public String getClassName() {
+ return wrapper.getServletClass();
+ }
+
+
+ public Map<String, String> getInitParameters() {
+ HashMap<String, String> result = new HashMap<String, String>();
+ String[] names = wrapper.findInitParameters();
+ for (int i = 0; i < names.length; i++) {
+ result.put(names[i], wrapper.getInitParameter(names[i]));
+ }
+ return Collections.unmodifiableMap(result);
+ }
+
+
+ public String getName() {
+ return wrapper.getName();
+ }
+
+
}
Modified: trunk/java/org/apache/jasper/servlet/JspCServletContext.java
===================================================================
--- trunk/java/org/apache/jasper/servlet/JspCServletContext.java 2009-05-07 17:10:59 UTC (rev 1043)
+++ trunk/java/org/apache/jasper/servlet/JspCServletContext.java 2009-05-08 15:02:57 UTC (rev 1044)
@@ -27,6 +27,7 @@
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
+import java.util.Map;
import java.util.Set;
import java.util.Vector;
@@ -525,4 +526,24 @@
}
+ public FilterRegistration getFilterRegistration(String filterName) {
+ return null;
+ }
+
+
+ public Map<String, FilterRegistration> getFilterRegistrations() {
+ return null;
+ }
+
+
+ public ServletRegistration getServletRegistration(String servletName) {
+ return null;
+ }
+
+
+ public Map<String, ServletRegistration> getServletRegistrations() {
+ return null;
+ }
+
+
}
15 years, 8 months
JBossWeb SVN: r1043 - trunk/java/org/apache/naming/resources.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-07 13:10:59 -0400 (Thu, 07 May 2009)
New Revision: 1043
Modified:
trunk/java/org/apache/naming/resources/ProxyDirContext.java
Log:
- Start improving ProxyDirContext to add overlays.
Modified: trunk/java/org/apache/naming/resources/ProxyDirContext.java
===================================================================
--- trunk/java/org/apache/naming/resources/ProxyDirContext.java 2009-05-05 16:45:46 UTC (rev 1042)
+++ trunk/java/org/apache/naming/resources/ProxyDirContext.java 2009-05-07 17:10:59 UTC (rev 1043)
@@ -1,19 +1,47 @@
/*
- * 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
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*
- * 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.
- */
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 1999-2009 The Apache Software Foundation
+ *
+ * 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.naming.resources;
@@ -23,8 +51,10 @@
import java.io.InputStream;
import java.util.Hashtable;
+import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.Name;
+import javax.naming.NameClassPair;
import javax.naming.NameNotFoundException;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
@@ -33,11 +63,14 @@
import javax.naming.directory.DirContext;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
import org.apache.naming.StringManager;
/**
- * Proxy Directory Context implementation.
+ * Proxy Directory Context implementation. This implementation looks up the
+ * resources from a main DirContext, with secondary DirContext allowed
+ * to provide overlays for the main one, when caching is enabled.
*
* @author Remy Maucherat
* @version $Revision$ $Date$
@@ -59,7 +92,7 @@
/**
* Builds a proxy directory context using the given environment.
*/
- public ProxyDirContext(Hashtable env, DirContext dirContext) {
+ public ProxyDirContext(Hashtable<String, Object> env, DirContext dirContext) {
this.env = env;
this.dirContext = dirContext;
if (dirContext instanceof BaseDirContext) {
@@ -67,12 +100,15 @@
// the caching policy.
BaseDirContext baseDirContext = (BaseDirContext) dirContext;
if (baseDirContext.isCached()) {
- try {
- cache = (ResourceCache)
+ if (cacheClassName != null) {
+ try {
+ cache = (ResourceCache)
Class.forName(cacheClassName).newInstance();
- } catch (Exception e) {
- //FIXME
- e.printStackTrace();
+ } catch (Exception e) {
+ throw new IllegalArgumentException(e);
+ }
+ } else {
+ cache = new ResourceCache();
}
cache.setCacheMaxSize(baseDirContext.getCacheMaxSize());
cacheTTL = baseDirContext.getCacheTTL();
@@ -89,42 +125,13 @@
}
- /**
- * Builds a clone of this proxy dir context, wrapping the given directory
- * context, and sharing the same cache.
- */
- // TODO: Refactor using the proxy field
- /*
- protected ProxyDirContext(ProxyDirContext proxyDirContext,
- DirContext dirContext, String vPath) {
- this.env = proxyDirContext.env;
- this.dirContext = dirContext;
- this.vPath = vPath;
- this.cache = proxyDirContext.cache;
- this.cacheMaxSize = proxyDirContext.cacheMaxSize;
- this.cacheSize = proxyDirContext.cacheSize;
- this.cacheTTL = proxyDirContext.cacheTTL;
- this.cacheObjectMaxSize = proxyDirContext.cacheObjectMaxSize;
- this.notFoundCache = proxyDirContext.notFoundCache;
- this.hostName = proxyDirContext.hostName;
- this.contextName = proxyDirContext.contextName;
- }
- */
-
-
// ----------------------------------------------------- Instance Variables
/**
- * Proxy DirContext (either this or the real proxy).
- */
- protected ProxyDirContext proxy = this;
-
-
- /**
* Environment.
*/
- protected Hashtable env;
+ protected Hashtable<String, Object> env;
/**
@@ -140,9 +147,9 @@
/**
- * Virtual path.
+ * Overlay DirContexts.
*/
- protected String vPath = null;
+ protected DirContext[] overlayDirContexts;
/**
@@ -467,7 +474,8 @@
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration list(Name name)
+ // FIXME: Should use overlays
+ public NamingEnumeration<NameClassPair> list(Name name)
throws NamingException {
return dirContext.list(parseName(name));
}
@@ -482,7 +490,8 @@
* this context. Each element of the enumeration is of type NameClassPair.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration list(String name)
+ // FIXME: Should use overlays
+ public NamingEnumeration<NameClassPair> list(String name)
throws NamingException {
return dirContext.list(parseName(name));
}
@@ -501,7 +510,8 @@
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration listBindings(Name name)
+ // FIXME: Should use overlays
+ public NamingEnumeration<Binding> listBindings(Name name)
throws NamingException {
return dirContext.listBindings(parseName(name));
}
@@ -516,7 +526,8 @@
* Each element of the enumeration is of type Binding.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration listBindings(String name)
+ // FIXME: Should use overlays
+ public NamingEnumeration<Binding> listBindings(String name)
throws NamingException {
return dirContext.listBindings(parseName(name));
}
@@ -748,7 +759,7 @@
* @return the environment of this context; never null
* @exception NamingException if a naming exception is encountered
*/
- public Hashtable getEnvironment()
+ public Hashtable<?,?> getEnvironment()
throws NamingException {
return dirContext.getEnvironment();
}
@@ -1181,7 +1192,7 @@
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(Name name, Attributes matchingAttributes,
+ public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes,
String[] attributesToReturn)
throws NamingException {
return dirContext.search(parseName(name), matchingAttributes,
@@ -1205,7 +1216,7 @@
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, Attributes matchingAttributes,
+ public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes,
String[] attributesToReturn)
throws NamingException {
return dirContext.search(parseName(name), matchingAttributes,
@@ -1228,7 +1239,7 @@
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(Name name, Attributes matchingAttributes)
+ public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes)
throws NamingException {
return dirContext.search(parseName(name), matchingAttributes);
}
@@ -1247,7 +1258,7 @@
* context named by name.
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, Attributes matchingAttributes)
+ public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes)
throws NamingException {
return dirContext.search(parseName(name), matchingAttributes);
}
@@ -1272,7 +1283,7 @@
* contain invalid settings
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(Name name, String filter,
+ public NamingEnumeration<SearchResult> search(Name name, String filter,
SearchControls cons)
throws NamingException {
return dirContext.search(parseName(name), filter, cons);
@@ -1298,7 +1309,7 @@
* contain invalid settings
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, String filter,
+ public NamingEnumeration<SearchResult> search(String name, String filter,
SearchControls cons)
throws NamingException {
return dirContext.search(parseName(name), filter, cons);
@@ -1329,7 +1340,7 @@
* represents an invalid search filter
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(Name name, String filterExpr,
+ public NamingEnumeration<SearchResult> search(Name name, String filterExpr,
Object[] filterArgs, SearchControls cons)
throws NamingException {
return dirContext.search(parseName(name), filterExpr, filterArgs,
@@ -1361,7 +1372,7 @@
* represents an invalid search filter
* @exception NamingException if a naming exception is encountered
*/
- public NamingEnumeration search(String name, String filterExpr,
+ public NamingEnumeration<SearchResult> search(String name, String filterExpr,
Object[] filterArgs, SearchControls cons)
throws NamingException {
return dirContext.search(parseName(name), filterExpr, filterArgs,
@@ -1518,6 +1529,7 @@
/**
* Load entry into cache.
*/
+ // FIXME: Should use overlays
protected void cacheLoad(CacheEntry entry) {
String name = entry.name;
15 years, 8 months
JBossWeb SVN: r1042 - in trunk/java/org/apache: tomcat and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2009-05-05 12:45:46 -0400 (Tue, 05 May 2009)
New Revision: 1042
Modified:
trunk/java/org/apache/catalina/startup/BaseContextScanner.java
trunk/java/org/apache/catalina/startup/ClassLoadingContextScanner.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
trunk/java/org/apache/tomcat/WarComponents.java
Log:
- Migrate all the scanner code to ContextConfig.
- Use the order for annotations.
Modified: trunk/java/org/apache/catalina/startup/BaseContextScanner.java
===================================================================
--- trunk/java/org/apache/catalina/startup/BaseContextScanner.java 2009-05-05 00:36:22 UTC (rev 1041)
+++ trunk/java/org/apache/catalina/startup/BaseContextScanner.java 2009-05-05 16:45:46 UTC (rev 1042)
@@ -388,7 +388,7 @@
public Class<?>[] getInterestClasses() {
return interestClasses;
}
- protected void addStartupNotifySetSet(Class<?> clazz) {
+ protected void addStartupNotifyClass(Class<?> clazz) {
startupNotifySet.add(clazz);
}
public Set<Class<?>> getStartupNotifySet() {
Modified: trunk/java/org/apache/catalina/startup/ClassLoadingContextScanner.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ClassLoadingContextScanner.java 2009-05-05 00:36:22 UTC (rev 1041)
+++ trunk/java/org/apache/catalina/startup/ClassLoadingContextScanner.java 2009-05-05 16:45:46 UTC (rev 1042)
@@ -44,7 +44,7 @@
if (handlesTypesArray[i].isAssignableFrom(clazz)) {
ServletContainerInitializerInfoImpl jarServletContainerInitializerService =
handlesTypes.get(handlesTypesArray[i]);
- jarServletContainerInitializerService.addStartupNotifySetSet(clazz);
+ jarServletContainerInitializerService.addStartupNotifyClass(clazz);
}
}
}
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-05 00:36:22 UTC (rev 1041)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-05-05 16:45:46 UTC (rev 1042)
@@ -47,13 +47,17 @@
package org.apache.catalina.startup;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
@@ -61,12 +65,18 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
+import javax.naming.NameClassPair;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
import javax.servlet.DispatcherType;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
+import javax.servlet.annotation.HandlesTypes;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
@@ -76,7 +86,6 @@
import org.apache.catalina.Authenticator;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
-import org.apache.catalina.ContextScanner;
import org.apache.catalina.Engine;
import org.apache.catalina.Globals;
import org.apache.catalina.Host;
@@ -99,7 +108,9 @@
import org.apache.catalina.deploy.SecurityConstraint;
import org.apache.catalina.deploy.WebAbsoluteOrdering;
import org.apache.catalina.deploy.WebOrdering;
+import org.apache.catalina.startup.BaseContextScanner.ServletContainerInitializerInfoImpl;
import org.apache.catalina.util.StringManager;
+import org.apache.tomcat.WarComponents;
import org.apache.tomcat.WarComponents.ServletContainerInitializerInfo;
import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
@@ -117,7 +128,7 @@
*/
public class ContextConfig
- implements LifecycleListener {
+ implements LifecycleListener, WarComponents {
protected static org.jboss.logging.Logger log=
org.jboss.logging.Logger.getLogger( ContextConfig.class );
@@ -235,12 +246,6 @@
/**
- * Scanner for annotations, etc.
- */
- protected ContextScanner scanner = null;
-
-
- /**
* Deployment count.
*/
protected static long deploymentCount = 0L;
@@ -250,6 +255,21 @@
new LoginConfig("NONE", null, null, null);
+ protected ArrayList<String> overlays = new ArrayList<String>();
+ protected ArrayList<String> webFragments = new ArrayList<String>();
+ protected Map<String, Set<String>> TLDs = new HashMap<String, Set<String>>();
+ protected Map<String, ServletContainerInitializerInfo> servletContainerInitializerInfos =
+ new HashMap<String, ServletContainerInitializerInfo>();
+ protected LinkedList<String> order = new LinkedList<String>();
+
+ /**
+ * Used to speed up scanning for the services interest classes.
+ */
+ protected Class<?>[] handlesTypesArray = null;
+ protected Map<Class<?>, ServletContainerInitializerInfoImpl> handlesTypes =
+ new HashMap<Class<?>, ServletContainerInitializerInfoImpl>();
+
+
// ------------------------------------------------------------- Properties
@@ -314,6 +334,29 @@
}
+ // -------------------------------------------------- WarComponents Methods
+
+
+ public Iterator<String> getOverlays() {
+ return overlays.iterator();
+ }
+
+
+ public Iterator<String> getWebFragments() {
+ return webFragments.iterator();
+ }
+
+
+ public Map<String, Set<String>> getTLDs() {
+ return TLDs;
+ }
+
+
+ public Map<String, ServletContainerInitializerInfo> getServletContainerInitializerInfo() {
+ return servletContainerInitializerInfos;
+ }
+
+
// --------------------------------------------------------- Public Methods
@@ -360,97 +403,82 @@
}
- // -------------------------------------------------------- protected Methods
+ // -------------------------------------------------------- Protected Methods
/**
* Process the application classes annotations, if it exists.
*/
- protected void applicationAnnotationsConfig() {
-
- long t1=System.currentTimeMillis();
-
- Iterator<Class<?>> annotatedClasses = scanner.getAnnotatedClasses();
- while (annotatedClasses.hasNext()) {
- Class<?> clazz = annotatedClasses.next();
- if (clazz.isAnnotationPresent(WebInitParam.class)) {
- WebInitParam annotation = clazz.getAnnotation(WebInitParam.class);
- // Add init param
- context.addParameter(annotation.name(), annotation.value());
+ protected void processConfigAnnotations(Class<?> clazz) {
+
+ if (clazz.isAnnotationPresent(WebInitParam.class)) {
+ WebInitParam annotation = clazz.getAnnotation(WebInitParam.class);
+ // Add init param
+ context.addParameter(annotation.name(), annotation.value());
+ }
+ if (clazz.isAnnotationPresent(MultipartConfig.class)) {
+ MultipartConfig annotation = clazz.getAnnotation(MultipartConfig.class);
+ // FIXME: Do something ....
+ }
+ if (clazz.isAnnotationPresent(WebFilter.class)) {
+ WebFilter annotation = clazz.getAnnotation(WebFilter.class);
+ // Add servlet filter
+ String filterName = annotation.filterName();
+ FilterDef filterDef = new FilterDef();
+ filterDef.setFilterName(annotation.filterName());
+ filterDef.setFilterClass(clazz.getName());
+ WebInitParam[] params = annotation.initParams();
+ for (int i = 0; i < params.length; i++) {
+ filterDef.addInitParameter(params[i].name(), params[i].value());
}
- if (clazz.isAnnotationPresent(MultipartConfig.class)) {
- MultipartConfig annotation = clazz.getAnnotation(MultipartConfig.class);
- // FIXME: Do something ....
+ context.addFilterDef(filterDef);
+ FilterMap filterMap = new FilterMap();
+ filterMap.setFilterName(filterName);
+ String[] urlPatterns = annotation.urlPatterns();
+ if (urlPatterns != null) {
+ for (int i = 0; i < urlPatterns.length; i++) {
+ filterMap.addURLPattern(urlPatterns[i]);
+ }
}
- if (clazz.isAnnotationPresent(WebFilter.class)) {
- WebFilter annotation = clazz.getAnnotation(WebFilter.class);
- // Add servlet filter
- String filterName = annotation.filterName();
- FilterDef filterDef = new FilterDef();
- filterDef.setFilterName(annotation.filterName());
- filterDef.setFilterClass(clazz.getName());
- WebInitParam[] params = annotation.initParams();
- for (int i = 0; i < params.length; i++) {
- filterDef.addInitParameter(params[i].name(), params[i].value());
+ String[] servletNames = annotation.servletNames();
+ if (servletNames != null) {
+ for (int i = 0; i < servletNames.length; i++) {
+ filterMap.addServletName(servletNames[i]);
}
- context.addFilterDef(filterDef);
- FilterMap filterMap = new FilterMap();
- filterMap.setFilterName(filterName);
- String[] urlPatterns = annotation.urlPatterns();
- if (urlPatterns != null) {
- for (int i = 0; i < urlPatterns.length; i++) {
- filterMap.addURLPattern(urlPatterns[i]);
- }
+ }
+ DispatcherType[] dispatcherTypes = annotation.dispatcherTypes();
+ if (dispatcherTypes != null) {
+ for (int i = 0; i < dispatcherTypes.length; i++) {
+ filterMap.setDispatcher(dispatcherTypes[i].toString());
}
- String[] servletNames = annotation.servletNames();
- if (servletNames != null) {
- for (int i = 0; i < servletNames.length; i++) {
- filterMap.addServletName(servletNames[i]);
- }
- }
- DispatcherType[] dispatcherTypes = annotation.dispatcherTypes();
- if (dispatcherTypes != null) {
- for (int i = 0; i < dispatcherTypes.length; i++) {
- filterMap.setDispatcher(dispatcherTypes[i].toString());
- }
- }
- context.addFilterMap(filterMap);
}
- if (clazz.isAnnotationPresent(WebServlet.class)) {
- WebServlet annotation = clazz.getAnnotation(WebServlet.class);
- // Add servlet
- Wrapper wrapper = context.createWrapper();
- wrapper.setName(annotation.name());
- wrapper.setServletClass(clazz.getName());
- wrapper.setLoadOnStartup(annotation.loadOnStartup());
- WebInitParam[] params = annotation.initParams();
- for (int i = 0; i < params.length; i++) {
- wrapper.addInitParameter(params[i].name(), params[i].value());
+ context.addFilterMap(filterMap);
+ }
+ if (clazz.isAnnotationPresent(WebServlet.class)) {
+ WebServlet annotation = clazz.getAnnotation(WebServlet.class);
+ // Add servlet
+ Wrapper wrapper = context.createWrapper();
+ wrapper.setName(annotation.name());
+ wrapper.setServletClass(clazz.getName());
+ wrapper.setLoadOnStartup(annotation.loadOnStartup());
+ WebInitParam[] params = annotation.initParams();
+ for (int i = 0; i < params.length; i++) {
+ wrapper.addInitParameter(params[i].name(), params[i].value());
+ }
+ context.addChild(wrapper);
+ String[] urlPatterns = annotation.urlPatterns();
+ if (urlPatterns != null) {
+ for (int i = 0; i < urlPatterns.length; i++) {
+ context.addServletMapping(urlPatterns[i], annotation.name());
}
- context.addChild(wrapper);
- String[] urlPatterns = annotation.urlPatterns();
- if (urlPatterns != null) {
- for (int i = 0; i < urlPatterns.length; i++) {
- context.addServletMapping(urlPatterns[i], annotation.name());
- }
- }
}
- if (clazz.isAnnotationPresent(WebListener.class)) {
- WebListener annotation = clazz.getAnnotation(WebListener.class);
- // Add listener
- context.addApplicationListener(clazz.getName());
- }
}
-
- // FIXME: It is likely this should be moved to after running all listeners,
- // as they can add servlets or filters
- WebAnnotationSet.loadApplicationAnnotations(context);
-
- long t2=System.currentTimeMillis();
- if (context instanceof StandardContext) {
- ((StandardContext) context).setStartupTime(t2-t1+
- ((StandardContext) context).getStartupTime());
+ if (clazz.isAnnotationPresent(WebListener.class)) {
+ WebListener annotation = clazz.getAnnotation(WebListener.class);
+ // Add listener
+ context.addApplicationListener(clazz.getName());
}
+
}
@@ -487,8 +515,6 @@
return;
}
- long t1=System.currentTimeMillis();
-
URL url=null;
// Process the application web.xml file
synchronized (webDigester) {
@@ -543,8 +569,13 @@
}
}
+ }
+
+ // FIXME: Do TLD parsing when found
+ protected void applicationTldConfig() {
+
// Add all TLDs from explicit web config
- Map<String, Set<String>> TLDs = scanner.getTLDs();
+ Map<String, Set<String>> TLDs = getTLDs();
Set<String> warTLDs = TLDs.get("");
String taglibs[] = context.findTaglibs();
for (int i = 0; i < taglibs.length; i++) {
@@ -557,6 +588,7 @@
// Parse all TLDs from the WAR
Iterator<String> warTLDsIterator = warTLDs.iterator();
+ InputStream stream = null;
while (warTLDsIterator.hasNext()) {
String tldPath = warTLDsIterator.next();
try {
@@ -634,10 +666,6 @@
}
}
- long t2=System.currentTimeMillis();
- if (context instanceof StandardContext) {
- ((StandardContext) context).setStartupTime(t2-t1);
- }
}
@@ -968,15 +996,23 @@
/**
- * Process additional descriptors: TLDs, web fragments, and map overlays.
+ * Parse fragments order.
*/
- protected void applicationExtraDescriptorsConfig() {
+ protected void createFragmentsOrder() {
+
JarRepository jarRepository = context.getJarRepository();
+ JarFile[] jars = jarRepository.findJars();
+ for (int i = 0; i < jars.length; i++) {
+ // Find webapp descriptor fragments
+ if (jars[i].getEntry(Globals.WEB_FRAGMENT_PATH) != null) {
+ webFragments.add(jars[i].getName());
+ }
+ }
// Read order from web.xml and fragments (note: if no fragments, skip)
WebAbsoluteOrdering absoluteOrdering = context.getWebAbsoluteOrdering();
List<WebOrdering> orderings = new ArrayList<WebOrdering>();
- Iterator<String> jarsWithWebFragments = scanner.getWebFragments();
+ Iterator<String> jarsWithWebFragments = getWebFragments();
HashSet<String> jarsSet = new HashSet<String>();
// Parse the ordering defined in web fragments
@@ -1020,7 +1056,6 @@
}
// Generate web fragments parsing order
- LinkedList<String> order = new LinkedList<String>();
if (absoluteOrdering != null) {
// Absolute ordering from web.xml, any fragment ordering is ignored
List<String> fragmentNames = absoluteOrdering.getOrder();
@@ -1056,15 +1091,39 @@
order.addAll(jarsSet);
}
- // Parse fragments according to order
- // FIXME: Merging rules
+ }
+
+
+ /**
+ * Process additional descriptors: TLDs, web fragments, and map overlays.
+ */
+ protected void applicationExtraDescriptorsConfig() {
+
+ JarRepository jarRepository = context.getJarRepository();
+
+ HashSet<String> warTLDs = new HashSet<String>();
+
+ // Find any TLD file in /WEB-INF
+ DirContext resources = context.getResources();
+ if (resources != null) {
+ tldScanResourcePathsWebInf(resources, "/WEB-INF", warTLDs);
+ }
+ TLDs.put("", warTLDs);
+
+ File[] explodedJars = jarRepository.findExplodedJars();
+ for (int i = 0; i < explodedJars.length; i++) {
+ scanClasses(explodedJars[i], "", !context.getIgnoreAnnotations());
+ }
+
Iterator<String> orderIterator = order.iterator();
while (orderIterator.hasNext()) {
String jar = orderIterator.next();
- JarFile jarFile = null;
+ JarFile jarFile = jarRepository.findJar(jar);
+
+ // Parse web fragment according to order
+ // FIXME: Merging rules
InputStream is = null;
try {
- jarFile = jarRepository.findJar(jar);
ZipEntry entry = jarFile.getEntry(Globals.WEB_FRAGMENT_PATH);
if (entry != null) {
is = jarFile.getInputStream(entry);
@@ -1097,12 +1156,232 @@
// Ignore
}
}
+
+ scanJar(jarFile, true);
}
+ // Process any Jar not in the order, without annotations
+ JarFile[] jarFiles = jarRepository.findJars();
+ for (int i = 0; i < jarFiles.length; i++) {
+ if (!order.contains(jarFiles[i].getName())) {
+ scanJar(jarFiles[i], false);
+ }
+ }
+
}
+
+ protected void scanJar(JarFile jarFile, boolean annotations) {
+
+ // Scan Jar for annotations and TLDs
+ HashSet<String> jarTLDs = new HashSet<String>();
+ Enumeration<JarEntry> entries = jarFile.entries();
+ while (entries.hasMoreElements()) {
+ JarEntry entry = entries.nextElement();
+ String name = entry.getName();
+ if (name.endsWith(".class")) {
+ String className = getClassName(entry.getName());
+ scanClass(className, annotations);
+ } else if (name.startsWith("META-INF/") && name.endsWith(".tld")) {
+ jarTLDs.add(name);
+ }
+ }
+ if (jarTLDs.size() > 0) {
+ TLDs.put(jarFile.getName(), jarTLDs);
+ }
+ }
+
+
/**
+ * Scans the web application's subdirectory identified by rootPath,
+ * along with its subdirectories, for TLDs.
+ *
+ * Initially, rootPath equals /WEB-INF. The /WEB-INF/classes and
+ * /WEB-INF/lib subdirectories are excluded from the search, as per the
+ * JSP 2.0 spec.
+ *
+ * @param resources The web application's resources
+ * @param rootPath The path whose subdirectories are to be searched for
+ * TLDs
+ * @param tldPaths The set of TLD resource paths to add to
+ */
+ protected void tldScanResourcePathsWebInf(DirContext resources,
+ String rootPath,
+ HashSet<String> tldPaths) {
+ try {
+ NamingEnumeration<NameClassPair> items = resources.list(rootPath);
+ while (items.hasMoreElements()) {
+ NameClassPair item = items.nextElement();
+ String resourcePath = rootPath + "/" + item.getName();
+ if (!resourcePath.endsWith(".tld")
+ && (resourcePath.startsWith("/WEB-INF/classes")
+ || resourcePath.startsWith("/WEB-INF/lib"))) {
+ continue;
+ }
+ if (resourcePath.endsWith(".tld")) {
+ tldPaths.add(resourcePath);
+ } else {
+ tldScanResourcePathsWebInf(resources, resourcePath,
+ tldPaths);
+ }
+ }
+ } catch (NamingException e) {
+ ; // Silent catch: it's valid that no /WEB-INF directory exists
+ }
+ }
+
+
+ /**
+ * Scan folder containing class files.
+ */
+ protected void scanClasses(File folder, String path, boolean annotations) {
+ String[] files = folder.list();
+ for (int i = 0; i < files.length; i++) {
+ File file = new File(folder, files[i]);
+ if (file.isDirectory()) {
+ scanClasses(file, path + "/" + files[i], annotations);
+ } else if (files[i].endsWith(".class")) {
+ String className = getClassName(path + "/" + files[i]);
+ scanClass(className, annotations);
+ }
+ }
+ }
+
+
+ protected void scanClass(String className, boolean annotations) {
+ if (!annotations && (handlesTypesArray == null)) {
+ return;
+ }
+ try {
+ Class<?> clazz = context.getLoader().getClassLoader().loadClass(className);
+ if (handlesTypesArray != null) {
+ for (int i = 0; i < handlesTypesArray.length; i++) {
+ if (handlesTypesArray[i].isAssignableFrom(clazz)) {
+ ServletContainerInitializerInfoImpl jarServletContainerInitializerService =
+ handlesTypes.get(handlesTypesArray[i]);
+ jarServletContainerInitializerService.addStartupNotifyClass(clazz);
+ }
+ }
+ }
+ if (annotations &&
+ (clazz.isAnnotationPresent(MultipartConfig.class)
+ || clazz.isAnnotationPresent(WebFilter.class)
+ || clazz.isAnnotationPresent(WebInitParam.class)
+ || clazz.isAnnotationPresent(WebListener.class)
+ || clazz.isAnnotationPresent(WebServlet.class))) {
+ processConfigAnnotations(clazz);
+ }
+ } catch (Throwable t) {
+ // Ignore classloading errors here
+ }
+ }
+
+
+ /**
+ * Get class name given a path to a classfile.
+ * /my/class/MyClass.class -> my.class.MyClass
+ */
+ protected 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('/', '.');
+ }
+
+
+ /**
+ * Find and parse ServletContainerInitializer service in specified JAR.
+ */
+ public void applicationServletContainerInitializerConfig() {
+ JarRepository jarRepository = context.getJarRepository();
+ if (jarRepository != null) {
+ JarFile[] jars = jarRepository.findJars();
+ for (int i = 0; i < jars.length; i++) {
+ scanJarForServletContainerInitializer(jars[i]);
+ }
+ }
+ // Do the same for the context parent
+ jarRepository = context.getParent().getJarRepository();
+ if (jarRepository != null) {
+ JarFile[] jars = jarRepository.findJars();
+ for (int i = 0; i < jars.length; i++) {
+ scanJarForServletContainerInitializer(jars[i]);
+ }
+ }
+ }
+
+
+ /**
+ * Find and parse ServletContainerInitializer service in specified JAR.
+ */
+ public void scanJarForServletContainerInitializer(JarFile file) {
+ // Find ServletContainerInitializer services
+ JarEntry servletContainerInitializerEntry = file.getJarEntry(Globals.SERVLET_CONTAINER_INITIALIZER_SERVICE_PATH);
+ String servletContainerInitializerClassName = null;
+ if (servletContainerInitializerEntry != null) {
+ // Read Servlet container initializer service file
+ InputStream is = null;
+ try {
+ is = file.getInputStream(servletContainerInitializerEntry);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ servletContainerInitializerClassName = reader.readLine();
+ int pos = servletContainerInitializerClassName.indexOf('#');
+ if (pos > 0) {
+ servletContainerInitializerClassName = servletContainerInitializerClassName.substring(0, pos);
+ }
+ servletContainerInitializerClassName = servletContainerInitializerClassName.trim();
+ } catch (Exception e) {
+ // FIXME: error message or exception
+ } finally {
+ try {
+ if (is != null) {
+ is.close();
+ }
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ // Load Servlet container initializer class and read HandlesTypes annotation
+ Class<?> servletContainerInitializerClass = null;
+ Class<?>[] typesArray = null;
+ if (servletContainerInitializerClassName != null) {
+ try {
+ servletContainerInitializerClass = context.getLoader().getClassLoader()
+ .loadClass(servletContainerInitializerClassName);
+ if (servletContainerInitializerClass.isAnnotationPresent(HandlesTypes.class)) {
+ HandlesTypes handlesTypes = servletContainerInitializerClass.getAnnotation(HandlesTypes.class);
+ typesArray = handlesTypes.value();
+ }
+ } catch (Throwable t) {
+ // FIXME: error message or exception
+ }
+ }
+ // Add in jarService map, and add in the local map used to speed up lookups
+ ServletContainerInitializerInfoImpl jarServletContainerInitializerService =
+ new ServletContainerInitializerInfoImpl(servletContainerInitializerClass, handlesTypesArray);
+ servletContainerInitializerInfos.put(file.getName(), jarServletContainerInitializerService);
+ if (typesArray != null) {
+ ArrayList<Class<?>> handlesTypesList = new ArrayList<Class<?>>();
+ if (handlesTypesArray != null) {
+ for (int i = 0; i < handlesTypesArray.length; i++) {
+ handlesTypesList.add(handlesTypesArray[i]);
+ }
+ }
+ for (int i = 0; i < typesArray.length; i++) {
+ handlesTypesList.add(typesArray[i]);
+ handlesTypes.put(typesArray[i], jarServletContainerInitializerService);
+ }
+ handlesTypesArray = handlesTypesList.toArray(handlesTypesArray);
+ }
+ }
+ }
+
+
+ /**
* Process the default configuration file, if it exists.
*/
protected void contextConfig() {
@@ -1441,37 +1720,56 @@
if (log.isDebugEnabled())
log.debug(sm.getString("contextConfig.start"));
- scanner = new ClassLoadingContextScanner();
-
// Process the default and application web.xml files
- defaultWebConfig();
- try {
- scanner.scan(context);
- } catch (Throwable t) {
- log.error(sm.getString("contextConfig.scan"), t);
- ok = false;
+ if (ok) {
+ defaultWebConfig();
}
// Scan the main descriptors
- applicationWebConfig();
- // Parse fragments
- if (!context.getIgnoreAnnotations()) {
+ if (ok) {
+ applicationWebConfig();
+ }
+ // Parse any Servlet context initializer defined in a Jar
+ if (ok) {
+ applicationServletContainerInitializerConfig();
+ }
+ // Parse fragment order
+ if (ok && !context.getIgnoreAnnotations()) {
+ createFragmentsOrder();
+ }
+ // Scan fragments, TLDs and annotations
+ if (ok) {
applicationExtraDescriptorsConfig();
}
+ // Parse any TLDs found for listeners
+ if (ok) {
+ applicationTldConfig();
+ }
// Scan all Servlet API related annotations
- if (!context.getIgnoreAnnotations()) {
- applicationAnnotationsConfig();
+ if (ok && !context.getIgnoreAnnotations()) {
+ // FIXME: It is likely this should be moved to after running all listeners,
+ // as they can add servlets or filters
+ WebAnnotationSet.loadApplicationAnnotations(context);
}
if (ok) {
validateSecurityRoles();
}
- // FIXME: Add overlays, and see about order
- scanner.getOverlays();
+ // FIXME: See about order
+ // Find webapp overlays
+ if (ok) {
+ JarRepository jarRepository = context.getJarRepository();
+ JarFile[] jars = jarRepository.findJars();
+ for (int i = 0; i < jars.length; i++) {
+ if (jars[i].getEntry(Globals.OVERLAY_PATH) != null) {
+ overlays.add(jars[i].getName());
+ }
+ }
+ }
// Invoke Servlet container initializer: instantiate and call onStartup
if (ok) {
Iterator<ServletContainerInitializerInfo> initializers =
- scanner.getServletContainerInitializerInfo().values().iterator();
+ getServletContainerInitializerInfo().values().iterator();
while (initializers.hasNext()) {
ServletContainerInitializerInfo service = initializers.next();
try {
@@ -1488,8 +1786,9 @@
}
// Configure an authenticator if we need one
- if (ok)
+ if (ok) {
authenticatorConfig();
+ }
// Dump the contents of this pipeline if requested
if ((log.isDebugEnabled()) && (context instanceof ContainerBase)) {
@@ -1507,9 +1806,9 @@
}
// Make our application available if no problems were encountered
- if (ok)
+ if (ok) {
context.setConfigured(true);
- else {
+ } else {
log.error(sm.getString("contextConfig.unavailable"));
context.setConfigured(false);
}
@@ -1525,8 +1824,6 @@
if (log.isDebugEnabled())
log.debug(sm.getString("contextConfig.stop"));
- scanner = null;
-
int i;
// Removing children
@@ -1680,6 +1977,14 @@
ExpandWar.delete(docBaseFile);
}
+ overlays.clear();
+ webFragments.clear();
+ TLDs.clear();
+ servletContainerInitializerInfos.clear();
+ order.clear();
+ handlesTypesArray = null;
+ handlesTypes.clear();
+
ok = true;
}
@@ -1799,4 +2104,27 @@
}
+ protected class ServletContainerInitializerInfoImpl implements ServletContainerInitializerInfo {
+ protected Class<?> servletContainerInitializer = null;
+ protected Class<?>[] interestClasses = null;
+ protected HashSet<Class<?>> startupNotifySet = new HashSet<Class<?>>();
+ protected ServletContainerInitializerInfoImpl(Class<?> servletContainerInitializer, Class<?>[] interestClasses) {
+ this.servletContainerInitializer = servletContainerInitializer;
+ this.interestClasses = interestClasses;
+ }
+ public Class<?> getServletContainerInitializer() {
+ return servletContainerInitializer;
+ }
+ public Class<?>[] getInterestClasses() {
+ return interestClasses;
+ }
+ protected void addStartupNotifyClass(Class<?> clazz) {
+ startupNotifySet.add(clazz);
+ }
+ public Set<Class<?>> getStartupNotifySet() {
+ return startupNotifySet;
+ }
+ }
+
+
}
Modified: trunk/java/org/apache/tomcat/WarComponents.java
===================================================================
--- trunk/java/org/apache/tomcat/WarComponents.java 2009-05-05 00:36:22 UTC (rev 1041)
+++ trunk/java/org/apache/tomcat/WarComponents.java 2009-05-05 16:45:46 UTC (rev 1042)
@@ -36,11 +36,6 @@
}
/**
- * Find annotated classes for this context.
- */
- public Iterator<Class<?>> getAnnotatedClasses();
-
- /**
* Find JAR files containing an overlay.
*/
public Iterator<String> getOverlays();
15 years, 8 months