Author: remy.maucherat(a)jboss.com
Date: 2010-03-12 12:44:17 -0500 (Fri, 12 Mar 2010)
New Revision: 1409
Removed:
trunk/java/org/apache/catalina/util/Queue.java
Modified:
trunk/java/org/apache/catalina/core/mbeans-descriptors.xml
trunk/java/org/apache/catalina/startup/ExpandWar.java
trunk/java/org/apache/catalina/startup/mbeans-descriptors.xml
Log:
- Part 3.
- Drop some useless code and descriptors.
Modified: trunk/java/org/apache/catalina/core/mbeans-descriptors.xml
===================================================================
--- trunk/java/org/apache/catalina/core/mbeans-descriptors.xml 2010-03-12 15:42:13 UTC
(rev 1408)
+++ trunk/java/org/apache/catalina/core/mbeans-descriptors.xml 2010-03-12 17:44:17 UTC
(rev 1409)
@@ -24,19 +24,6 @@
</mbean>
- <mbean name="NamingContextListener"
- description="Helper class used to initialize and populate the JNDI context
associated with each context and server"
- domain="Catalina"
- group="Listener"
- type="org.apache.catalina.core.NamingContextListener">
-
- <attribute name="className"
- description="Fully qualified class name of the managed object"
- type="java.lang.String"
- writeable="false"/>
-
- </mbean>
-
<mbean name="StandardContext"
description="Standard Context Component"
domain="Catalina"
@@ -433,23 +420,10 @@
description="The application root for this Host"
type="java.lang.String"/>
- <attribute name="autoDeploy"
- description="The auto deploy flag for this Host"
- type="boolean"/>
-
<attribute name="configClass"
description="The configuration class for contexts"
type="java.lang.String"/>
- <attribute name="deployOnStartup"
- description="The deploy on startup flag for this Host"
- type="boolean"/>
-
- <attribute name="deployXML"
- description="deploy Context XML config files property"
- is="true"
- type="boolean"/>
-
<attribute name="managedResource"
description="The managed resource this MBean is associated
with"
type="java.lang.Object"/>
@@ -463,14 +437,6 @@
is="true"
type="boolean"/>
- <attribute name="xmlNamespaceAware"
- description="Attribute value used to turn on/off XML namespace
awareness"
- type="boolean"/>
-
- <attribute name="xmlValidation"
- description="Attribute value used to turn on/off XML
validation"
- type="boolean"/>
-
<attribute name="children"
description="Object names of all children"
type="[Ljavax.management.ObjectName;"/>
Modified: trunk/java/org/apache/catalina/startup/ExpandWar.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ExpandWar.java 2010-03-12 15:42:13 UTC (rev
1408)
+++ trunk/java/org/apache/catalina/startup/ExpandWar.java 2010-03-12 17:44:17 UTC (rev
1409)
@@ -22,19 +22,12 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.InputStream;
import java.io.IOException;
-import java.net.JarURLConnection;
-import java.net.URL;
+import java.io.InputStream;
import java.nio.channels.FileChannel;
-import java.util.Enumeration;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import org.apache.catalina.Host;
import org.apache.catalina.util.StringManager;
import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
/**
* Expand out a WAR in a Host's appBase.
@@ -57,225 +50,6 @@
/**
- * Expand the WAR file found at the specified URL into an unpacked
- * directory structure, and return the absolute pathname to the expanded
- * directory.
- *
- * @param host Host war is being installed for
- * @param war URL of the web application archive to be expanded
- * (must start with "jar:")
- *
- * @exception IllegalArgumentException if this is not a "jar:" URL
- * @exception IOException if an input/output error was encountered
- * during expansion
- */
- public static String expand(Host host, URL war)
- throws IOException {
-
- // Calculate the directory name of the expanded directory
- if (host.getLogger().isDebugEnabled()) {
- host.getLogger().debug("expand(" + war.toString() +
")");
- }
- String pathname = war.toString().replace('\\', '/');
- if (pathname.endsWith("!/")) {
- pathname = pathname.substring(0, pathname.length() - 2);
- }
- int period = pathname.lastIndexOf('.');
- if (period >= pathname.length() - 4)
- pathname = pathname.substring(0, period);
- int slash = pathname.lastIndexOf('/');
- if (slash >= 0) {
- pathname = pathname.substring(slash + 1);
- }
- if (host.getLogger().isDebugEnabled()) {
- host.getLogger().debug(" Proposed directory name: " + pathname);
- }
- return expand(host, war, pathname);
-
- }
-
-
- /**
- * Expand the WAR file found at the specified URL into an unpacked
- * directory structure, and return the absolute pathname to the expanded
- * directory.
- *
- * @param host Host war is being installed for
- * @param war URL of the web application archive to be expanded
- * (must start with "jar:")
- * @param pathname Context path name for web application
- *
- * @exception IllegalArgumentException if this is not a "jar:" URL or if
the
- * WAR file is invalid
- * @exception IOException if an input/output error was encountered
- * during expansion
- */
- public static String expand(Host host, URL war, String pathname)
- throws IOException {
-
- // Make sure that there is no such directory already existing
- File appBase = new File(host.getAppBase());
- if (!appBase.isAbsolute()) {
- appBase = new File(System.getProperty("catalina.base"),
- host.getAppBase());
- }
- if (!appBase.exists() || !appBase.isDirectory()) {
- throw new IOException
- (sm.getString("hostConfig.appBase",
- appBase.getAbsolutePath()));
- }
-
- File docBase = new File(appBase, pathname);
- if (docBase.exists()) {
- // War file is already installed
- return (docBase.getAbsolutePath());
- }
-
- // Create the new document base directory
- docBase.mkdir();
-
- // Expand the WAR into the new document base directory
- String canonicalDocBasePrefix = docBase.getCanonicalPath();
- if (!canonicalDocBasePrefix.endsWith(File.separator)) {
- canonicalDocBasePrefix += File.separator;
- }
- JarURLConnection juc = (JarURLConnection) war.openConnection();
- juc.setUseCaches(false);
- JarFile jarFile = null;
- InputStream input = null;
- boolean success = false;
- try {
- jarFile = juc.getJarFile();
- Enumeration jarEntries = jarFile.entries();
- while (jarEntries.hasMoreElements()) {
- JarEntry jarEntry = (JarEntry) jarEntries.nextElement();
- String name = jarEntry.getName();
- File expandedFile = new File(docBase, name);
- if (!expandedFile.getCanonicalPath().startsWith(
- canonicalDocBasePrefix)) {
- // Trying to expand outside the docBase
- // Throw an exception to stop the deployment
- throw new IllegalArgumentException(
- sm.getString("expandWar.illegalPath",war, name));
- }
- int last = name.lastIndexOf('/');
- if (last >= 0) {
- File parent = new File(docBase,
- name.substring(0, last));
- parent.mkdirs();
- }
- if (name.endsWith("/")) {
- continue;
- }
- input = jarFile.getInputStream(jarEntry);
-
- // Bugzilla 33636
- expand(input, expandedFile);
- long lastModified = jarEntry.getTime();
- if ((lastModified != -1) && (lastModified != 0)) {
- expandedFile.setLastModified(lastModified);
- }
-
- input.close();
- input = null;
- }
- success = true;
- } catch (IOException e) {
- throw e;
- } finally {
- if (!success) {
- // If something went wrong, delete expanded dir to keep things
- // clean
- deleteDir(docBase);
- }
- if (input != null) {
- try {
- input.close();
- } catch (Throwable t) {
- ;
- }
- input = null;
- }
- if (jarFile != null) {
- try {
- jarFile.close();
- } catch (Throwable t) {
- ;
- }
- jarFile = null;
- }
- }
-
- // Return the absolute path to our new document base directory
- return (docBase.getAbsolutePath());
-
- }
-
-
- /**
- * Validate the WAR file found at the specified URL.
- *
- * @param host Host war is being installed for
- * @param war URL of the web application archive to be validated
- * (must start with "jar:")
- * @param pathname Context path name for web application
- *
- * @exception IllegalArgumentException if this is not a "jar:" URL or if
the
- * WAR file is invalid
- * @exception IOException if an input/output error was encountered
- * during validation
- */
- public static void validate(Host host, URL war, String pathname)
- throws IOException {
-
- // Make the appBase absolute
- File appBase = new File(host.getAppBase());
- if (!appBase.isAbsolute()) {
- appBase = new File(System.getProperty("catalina.base"),
- host.getAppBase());
- }
-
- File docBase = new File(appBase, pathname);
-
- // Calculate the document base directory
- String canonicalDocBasePrefix = docBase.getCanonicalPath();
- if (!canonicalDocBasePrefix.endsWith(File.separator)) {
- canonicalDocBasePrefix += File.separator;
- }
- JarURLConnection juc = (JarURLConnection) war.openConnection();
- juc.setUseCaches(false);
- JarFile jarFile = null;
- try {
- jarFile = juc.getJarFile();
- Enumeration<JarEntry> jarEntries = jarFile.entries();
- while (jarEntries.hasMoreElements()) {
- JarEntry jarEntry = jarEntries.nextElement();
- String name = jarEntry.getName();
- File expandedFile = new File(docBase, name);
- if (!expandedFile.getCanonicalPath().startsWith(
- canonicalDocBasePrefix)) {
- // Entry located outside the docBase
- // Throw an exception to stop the deployment
- throw new IllegalArgumentException(
- sm.getString("expandWar.illegalPath",war, name));
- }
- }
- } catch (IOException e) {
- throw e;
- } finally {
- if (jarFile != null) {
- try {
- jarFile.close();
- } catch (Throwable t) {
- // Ignore
- }
- jarFile = null;
- }
- }
- }
-
-
- /**
* Copy the specified file or directory to the destination.
*
* @param src File object representing the source
@@ -421,58 +195,4 @@
}
- /**
- * Expand the specified input stream into the specified directory, creating
- * a file named from the specified relative path.
- *
- * @param input InputStream to be copied
- * @param docBase Document base directory into which we are expanding
- * @param name Relative pathname of the file to be created
- * @return A handle to the expanded File
- *
- * @exception IOException if an input/output error occurs
- *
- * @deprecated
- */
- protected static File expand(InputStream input, File docBase, String name)
- throws IOException {
- File file = new File(docBase, name);
- expand(input, file);
- return file;
- }
-
-
- /**
- * Expand the specified input stream into the specified file.
- *
- * @param input InputStream to be copied
- * @param file The file to be created
- *
- * @exception IOException if an input/output error occurs
- */
- private static void expand(InputStream input, File file)
- throws IOException {
- BufferedOutputStream output = null;
- try {
- output =
- new BufferedOutputStream(new FileOutputStream(file));
- byte buffer[] = new byte[2048];
- while (true) {
- int n = input.read(buffer);
- if (n <= 0)
- break;
- output.write(buffer, 0, n);
- }
- } finally {
- if (output != null) {
- try {
- output.close();
- } catch (IOException e) {
- // Ignore
- }
- }
- }
- }
-
-
}
Modified: trunk/java/org/apache/catalina/startup/mbeans-descriptors.xml
===================================================================
--- trunk/java/org/apache/catalina/startup/mbeans-descriptors.xml 2010-03-12 15:42:13 UTC
(rev 1408)
+++ trunk/java/org/apache/catalina/startup/mbeans-descriptors.xml 2010-03-12 17:44:17 UTC
(rev 1409)
@@ -52,69 +52,6 @@
description="The Java class name of the Context implementation we
should use"
type="java.lang.String"/>
- <operation name="check"
- description="Check a web application name for updates"
- impact="ACTION"
- returnType="void">
- <parameter name="name"
- description="Application name"
- type="java.lang.String"/>
- </operation>
-
- <operation name="addServiced"
- description="Add a web application name to the serviced list"
- impact="ACTION"
- returnType="void">
- <parameter name="name"
- description="Application name"
- type="java.lang.String"/>
- </operation>
-
- <operation name="isServiced"
- description="Add a web application name to the serviced list"
- impact="ACTION"
- returnType="boolean">
- <parameter name="name"
- description="Application name"
- type="java.lang.String"/>
- </operation>
-
- <operation name="isDeployed"
- description="Was this web application deployed by this
component"
- impact="ACTION"
- returnType="boolean">
- <parameter name="name"
- description="Application name"
- type="java.lang.String"/>
- </operation>
-
- <operation name="manageApp"
- description="Add a web application managed externally"
- impact="ACTION"
- returnType="void">
- <parameter name="context"
- description="Context to add"
- type="org.apache.catalina.Context" />
- </operation>
-
- <operation name="removeServiced"
- description="Add a web application name to the serviced list"
- impact="ACTION"
- returnType="void">
- <parameter name="name"
- description="Application name"
- type="java.lang.String"/>
- </operation>
-
- <operation name="unmanageApp"
- description="Remove a web application from checks"
- impact="ACTION"
- returnType="void">
- <parameter name="contextPath"
- description="The application path"
- type="java.lang.String" />
- </operation>
-
</mbean>
</mbeans-descriptors>
Deleted: trunk/java/org/apache/catalina/util/Queue.java
===================================================================
--- trunk/java/org/apache/catalina/util/Queue.java 2010-03-12 15:42:13 UTC (rev 1408)
+++ trunk/java/org/apache/catalina/util/Queue.java 2010-03-12 17:44:17 UTC (rev 1409)
@@ -1,88 +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.util;
-
-import java.util.Vector;
-
-/**
- * A simple FIFO queue class which causes the calling thread to wait
- * if the queue is empty and notifies threads that are waiting when it
- * is not empty.
- *
- * @author Anil V (akv(a)eng.sun.com)
- */
-public class Queue {
- private Vector vector = new Vector();
-
- /**
- * Put the object into the queue.
- *
- * @param object the object to be appended to the
- * queue.
- */
- public synchronized void put(Object object) {
- vector.addElement(object);
- notify();
- }
-
- /**
- * Pull the first object out of the queue. Wait if the queue is
- * empty.
- */
- public synchronized Object pull() {
- while (isEmpty())
- try {
- wait();
- } catch (InterruptedException ex) {
- }
- return get();
- }
-
- /**
- * Get the first object out of the queue. Return null if the queue
- * is empty.
- */
- public synchronized Object get() {
- Object object = peek();
- if (object != null)
- vector.removeElementAt(0);
- return object;
- }
-
- /**
- * Peek to see if something is available.
- */
- public Object peek() {
- if (isEmpty())
- return null;
- return vector.elementAt(0);
- }
-
- /**
- * Is the queue empty?
- */
- public boolean isEmpty() {
- return vector.isEmpty();
- }
-
- /**
- * How many elements are there in this queue?
- */
- public int size() {
- return vector.size();
- }
-}