JBossWeb SVN: r1407 - in trunk: java/javax and 16 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-03-12 07:52:22 -0500 (Fri, 12 Mar 2010)
New Revision: 1407
Added:
trunk/java/org/apache/catalina/connector/ConnectorMBean.java
Removed:
trunk/java/javax/annotation/Generated.java
trunk/java/javax/annotation/ManagedBean.java
trunk/java/javax/annotation/Named.java
trunk/java/javax/annotation/NonBinding.java
trunk/java/javax/annotation/PostConstruct.java
trunk/java/javax/annotation/PreDestroy.java
trunk/java/javax/annotation/Resource.java
trunk/java/javax/annotation/Resources.java
trunk/java/javax/annotation/Stereotype.java
trunk/java/javax/annotation/package.html
trunk/java/javax/annotation/security/DeclareRoles.java
trunk/java/javax/annotation/security/DenyAll.java
trunk/java/javax/annotation/security/PermitAll.java
trunk/java/javax/annotation/security/RolesAllowed.java
trunk/java/javax/annotation/security/RunAs.java
trunk/java/javax/annotation/security/TransportProtected.java
trunk/java/javax/annotation/security/package.html
trunk/java/javax/annotation/sql/
trunk/java/javax/ejb/
trunk/java/javax/persistence/
trunk/java/javax/xml/ws/
trunk/java/org/apache/catalina/JarRepository.java
trunk/java/org/apache/catalina/ant/AbstractCatalinaTask.java
trunk/java/org/apache/catalina/ant/BaseRedirectorHelperTask.java
trunk/java/org/apache/catalina/ant/DeployTask.java
trunk/java/org/apache/catalina/ant/InstallTask.java
trunk/java/org/apache/catalina/ant/JKStatusUpdateTask.java
trunk/java/org/apache/catalina/ant/JMXGetTask.java
trunk/java/org/apache/catalina/ant/JMXQueryTask.java
trunk/java/org/apache/catalina/ant/JMXSetTask.java
trunk/java/org/apache/catalina/ant/ListTask.java
trunk/java/org/apache/catalina/ant/ReloadTask.java
trunk/java/org/apache/catalina/ant/RemoveTask.java
trunk/java/org/apache/catalina/ant/ResourcesTask.java
trunk/java/org/apache/catalina/ant/ServerinfoTask.java
trunk/java/org/apache/catalina/ant/SessionsTask.java
trunk/java/org/apache/catalina/ant/StartTask.java
trunk/java/org/apache/catalina/ant/StopTask.java
trunk/java/org/apache/catalina/ant/UndeployTask.java
trunk/java/org/apache/catalina/ant/ValidatorTask.java
trunk/java/org/apache/catalina/ant/antlib.xml
trunk/java/org/apache/catalina/ant/catalina.tasks
trunk/java/org/apache/catalina/ant/jmx/
trunk/java/org/apache/catalina/ant/package.html
trunk/java/org/apache/catalina/core/ContextJarRepository.java
trunk/java/org/apache/catalina/core/DefaultInstanceManager.java
trunk/java/org/apache/catalina/core/NamingContextListener.java
trunk/java/org/apache/catalina/core/ServerJarRepository.java
trunk/java/org/apache/catalina/deploy/ContextEjb.java
trunk/java/org/apache/catalina/deploy/ContextEnvironment.java
trunk/java/org/apache/catalina/deploy/ContextHandler.java
trunk/java/org/apache/catalina/deploy/ContextLocalEjb.java
trunk/java/org/apache/catalina/deploy/ContextResource.java
trunk/java/org/apache/catalina/deploy/ContextResourceEnvRef.java
trunk/java/org/apache/catalina/deploy/ContextResourceLink.java
trunk/java/org/apache/catalina/deploy/ContextService.java
trunk/java/org/apache/catalina/deploy/ContextTransaction.java
trunk/java/org/apache/catalina/deploy/Injectable.java
trunk/java/org/apache/catalina/deploy/InjectionTarget.java
trunk/java/org/apache/catalina/deploy/MessageDestination.java
trunk/java/org/apache/catalina/deploy/MessageDestinationRef.java
trunk/java/org/apache/catalina/deploy/NamingResources.java
trunk/java/org/apache/catalina/deploy/ResourceBase.java
trunk/java/org/apache/catalina/deploy/WebAbsoluteOrdering.java
trunk/java/org/apache/catalina/deploy/WebOrder.java
trunk/java/org/apache/catalina/deploy/WebOrdering.java
trunk/java/org/apache/catalina/loader/Constants.java
trunk/java/org/apache/catalina/loader/JdbcLeakPrevention.java
trunk/java/org/apache/catalina/loader/LegacyWebappClassLoader.java
trunk/java/org/apache/catalina/loader/LegacyWebappLoader.java
trunk/java/org/apache/catalina/loader/LocaStrings_fr.properties
trunk/java/org/apache/catalina/loader/LocalStrings.properties
trunk/java/org/apache/catalina/loader/LocalStrings_es.properties
trunk/java/org/apache/catalina/loader/LocalStrings_ja.properties
trunk/java/org/apache/catalina/loader/Reloader.java
trunk/java/org/apache/catalina/loader/ResourceEntry.java
trunk/java/org/apache/catalina/loader/StandardClassLoader.java
trunk/java/org/apache/catalina/loader/StandardClassLoaderMBean.java
trunk/java/org/apache/catalina/loader/WebappClassLoader.java
trunk/java/org/apache/catalina/loader/WebappLoader.java
trunk/java/org/apache/catalina/loader/mbeans-descriptors.xml
trunk/java/org/apache/catalina/manager/HTMLManagerServlet.java
trunk/java/org/apache/catalina/manager/JMXProxyServlet.java
trunk/java/org/apache/catalina/manager/JspHelper.java
trunk/java/org/apache/catalina/manager/ManagerServlet.java
trunk/java/org/apache/catalina/manager/host/Constants.java
trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java
trunk/java/org/apache/catalina/manager/host/HostManagerServlet.java
trunk/java/org/apache/catalina/manager/host/LocalStrings.properties
trunk/java/org/apache/catalina/manager/host/LocalStrings_es.properties
trunk/java/org/apache/catalina/manager/util/
trunk/java/org/apache/catalina/mbeans/ClassNameMBean.java
trunk/java/org/apache/catalina/mbeans/ConnectorMBean.java
trunk/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java
trunk/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java
trunk/java/org/apache/catalina/mbeans/ContextResourceMBean.java
trunk/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java
trunk/java/org/apache/catalina/mbeans/MBeanFactory.java
trunk/java/org/apache/catalina/mbeans/MBeanUtils.java
trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java
trunk/java/org/apache/catalina/mbeans/ServerLifecycleListener.java
trunk/java/org/apache/catalina/mbeans/mbeans-descriptors.xml
trunk/java/org/apache/catalina/startup/Bootstrap.java
trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java
trunk/java/org/apache/catalina/startup/ConnectorCreateRule.java
trunk/java/org/apache/catalina/startup/ContextRuleSet.java
trunk/java/org/apache/catalina/startup/CopyParentClassLoaderRule.java
trunk/java/org/apache/catalina/startup/DigesterFactory.java
trunk/java/org/apache/catalina/startup/EngineRuleSet.java
trunk/java/org/apache/catalina/startup/HostRuleSet.java
trunk/java/org/apache/catalina/startup/LifecycleListenerRule.java
trunk/java/org/apache/catalina/startup/NamingRuleSet.java
trunk/java/org/apache/catalina/startup/OrderingResolver.java
trunk/java/org/apache/catalina/startup/RealmRuleSet.java
trunk/java/org/apache/catalina/startup/SetAllPropertiesRule.java
trunk/java/org/apache/catalina/startup/SetContextPropertiesRule.java
trunk/java/org/apache/catalina/startup/SetNextNamingRule.java
trunk/java/org/apache/catalina/startup/TldRuleSet.java
trunk/java/org/apache/catalina/startup/Tomcat.java
trunk/java/org/apache/catalina/startup/Tool.java
trunk/java/org/apache/catalina/startup/WebAnnotationSet.java
trunk/java/org/apache/catalina/startup/WebOrderingRuleSet.java
trunk/java/org/apache/catalina/startup/WebRuleSet.java
trunk/res/jboss/org/apache/catalina/startup/catalina.properties
Modified:
trunk/build.xml
trunk/java/org/apache/catalina/Container.java
trunk/java/org/apache/catalina/Context.java
trunk/java/org/apache/catalina/Host.java
trunk/java/org/apache/catalina/Server.java
trunk/java/org/apache/catalina/connector/mbeans-descriptors.xml
trunk/java/org/apache/catalina/core/ContainerBase.java
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/catalina/core/StandardHost.java
trunk/java/org/apache/catalina/core/StandardServer.java
trunk/java/org/apache/catalina/core/StandardService.java
trunk/java/org/apache/catalina/realm/DataSourceRealm.java
trunk/java/org/apache/catalina/startup/Catalina.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
trunk/java/org/apache/catalina/startup/Embedded.java
trunk/java/org/apache/catalina/startup/HostConfig.java
trunk/java/org/apache/catalina/startup/catalina.properties
trunk/webapps/docs/changelog.xml
Log:
- Drop accessory EE APIs.
- Drop standalone code.
- Drop annotation processing code.
- Drop naming code.
- Drop JMX code.
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/build.xml 2010-03-12 12:52:22 UTC (rev 1407)
@@ -583,7 +583,6 @@
<!-- Temp EE class -->
<include name="org/apache/catalina/**" />
<include name="org/apache/catalina/ha/backend/**" />
- <exclude name="org/apache/catalina/startup/catalina.properties" />
<include name="org/apache/naming/**" />
<include name="org/apache/comet/**" />
<include name="org/apache/coyote/**" />
@@ -596,9 +595,6 @@
<!-- Javadoc and i18n exclusions -->
<exclude name="**/package.html" />
</fileset>
- <fileset dir="${basedir}/res/jboss">
- <include name="org/apache/catalina/startup/catalina.properties" />
- </fileset>
</jar>
<!-- Servlet 3.0 Implementation JAR File -->
Deleted: trunk/java/javax/annotation/Generated.java
===================================================================
--- trunk/java/javax/annotation/Generated.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/Generated.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,73 +0,0 @@
-/*
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the "License"). You may not use this file except
- * in compliance with the License.
- *
- * You can obtain a copy of the license at
- * glassfish/bootstrap/legal/CDDLv1.0.txt or
- * https://glassfish.dev.java.net/public/CDDLv1.0.html.
- * See the License for the specific language governing
- * permissions and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * HEADER in each file and include the License file at
- * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
- * add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your
- * own identifying information: Portions Copyright [yyyy]
- * [name of copyright owner]
- */
-
-/*
- *
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-
-package javax.annotation;
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-/**
- * The Generated annoation is used to mark source code that has been generated.
- * It can also be used to differentiate user written code from generated code
- * in a single file. When used, the value element must have the name of the
- * code generator. The recommended convention is to use the fully qualified
- * name of the code generator in the value field .
- * For example: com.company.package.classname.
- * The date element is used to indicate the date the source was generated.
- * The date element must follow the ISO 8601 standard. For example the date
- * element would have the following value 2001-07-04T12:08:56.235-0700
- * which represents 2001-07-04 12:08:56 local time in the U.S. Pacific
- * Time time zone.
- * The comment element is a place holder for any comments that the code
- * generator may want to include in the generated code.
- *
- * @since Common Annotations 1.0
- */
-
-@Documented
-@Retention(SOURCE)
-@Target({PACKAGE, TYPE, ANNOTATION_TYPE, METHOD, CONSTRUCTOR, FIELD,
- LOCAL_VARIABLE, PARAMETER})
-public @interface Generated {
- /**
- * This is used by the code generator to mark the generated classes
- * and methods.
- */
- String[] value();
-
- /**
- * Date when the source was generated.
- */
- String date() default "";
-
- /**
- * A place holder for any comments that the code generator may want to
- * include in the generated code.
- */
- String comments() default "";
-}
-
Deleted: trunk/java/javax/annotation/ManagedBean.java
===================================================================
--- trunk/java/javax/annotation/ManagedBean.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/ManagedBean.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,56 +0,0 @@
-/*
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the "License"). You may not use this file except
- * in compliance with the License.
- *
- * You can obtain a copy of the license at
- * glassfish/bootstrap/legal/CDDLv1.0.txt or
- * https://glassfish.dev.java.net/public/CDDLv1.0.html.
- * See the License for the specific language governing
- * permissions and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * HEADER in each file and include the License file at
- * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
- * add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your
- * own identifying information: Portions Copyright [yyyy]
- * [name of copyright owner]
- */
-
-/*
- *
- * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-package javax.annotation;
-
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-/**
- * The ManagedBean annotation marks a POJO (Plain Old Java Object) as a
- * ManagedBean.A ManagedBean supports a small set of basic services such as
- * resource injection, lifecycle callbacks and interceptors.
- *
- * @since Common Annotations 1.1
- */
-@Target(TYPE)
-@Retention(RUNTIME)
-public @interface ManagedBean {
- /**
- * The name of the Managed Bean. Managed Bean names must be unique within a
- * Java EE module. For each named Managed Bean, Java EE containers must make
- * available the following entries in JNDI, using the same naming scheme used
- * for EJB components.
- * <p>
- * In the application namespace: <p>
- * java:app/<module-name>/<bean-name> <p>
- * In the module namespace of the module containing the Managed Bean:
- * <p> java:module/<bean-name>
- *
- */
- public String value() default "";
-}
Deleted: trunk/java/javax/annotation/Named.java
===================================================================
--- trunk/java/javax/annotation/Named.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/Named.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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 javax.annotation;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Specifies the name of a bean.
- *
- * @author Gavin King
- * @author Pete Muir
- */
-
-@Target( { TYPE, METHOD, FIELD })
-@Retention(RUNTIME)
-@Documented
-public @interface Named
-{
-
- /**
- * If no name is explicitly specified, the default name is used.
- *
- * For simple beans and session beans the default name is the unqualified
- * class name of the bean class, after converting the first character to
- * lower case.
- *
- * For producer methods the default name is the method name, unless the
- * method follows the JavaBeans property getter naming convention, in which
- * case the default name is the JavaBeans property name.
- *
- * @return the bean name
- */
- public String value() default "";
-
-}
Deleted: trunk/java/javax/annotation/NonBinding.java
===================================================================
--- trunk/java/javax/annotation/NonBinding.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/NonBinding.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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 javax.annotation;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Specifies that a member of a binding type or interceptor binding type is to
- * be ignored for the purposes of resolution.
- *
- * @author Gavin King
- *
- */
-@Retention(RUNTIME)
-@Target(METHOD)
-public @interface NonBinding
-{
-}
Deleted: trunk/java/javax/annotation/PostConstruct.java
===================================================================
--- trunk/java/javax/annotation/PostConstruct.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/PostConstruct.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,64 +0,0 @@
-/*
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the "License"). You may not use this file except
- * in compliance with the License.
- *
- * You can obtain a copy of the license at
- * glassfish/bootstrap/legal/CDDLv1.0.txt or
- * https://glassfish.dev.java.net/public/CDDLv1.0.html.
- * See the License for the specific language governing
- * permissions and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * HEADER in each file and include the License file at
- * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
- * add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your
- * own identifying information: Portions Copyright [yyyy]
- * [name of copyright owner]
- */
-
-/*
- *
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-
-package javax.annotation;
-
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-/**
- * The PostConstruct annotation is used on a method that needs to be executed
- * after dependency injection is done to perform any initialization. This
- * method MUST be invoked before the class is put into service. This
- * annotation MUST be supported on all classes that support dependency
- * injection. The method annotated with PostConstruct MUST be invoked even
- * if the class does not request any resources to be injected. Only one
- * method can be annotated with this annotation. The method on which the
- * PostConstruct annotation is applied MUST fulfill all of the following
- * criteria -
-- The method MUST NOT have any parameters except in the case of EJB
- * interceptors in which case it takes an InvocationC ontext object as
- * defined by the EJB specification.
- * - The return type of the method MUST be void.
- * - The method MUST NOT throw a checked exception.
- * - The method on which PostConstruct is applied MAY be public, protected,
- * package private or private.
- * - The method MUST NOT be static except for the application client.
- * - The method MAY be final.
- * - If the method throws an unchecked exception the class MUST NOT be put into
- * service except in the case of EJBs where the EJB can handle exceptions and
- * even recover from them.
- * @since Common Annotations 1.0
- * @see javax.annotation.PreDestroy
- * @see javax.annotation.Resource
- */
-@Documented
-@Retention (RUNTIME)
-@Target(METHOD)
-public @interface PostConstruct {
-}
Deleted: trunk/java/javax/annotation/PreDestroy.java
===================================================================
--- trunk/java/javax/annotation/PreDestroy.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/PreDestroy.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,64 +0,0 @@
-/*
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the "License"). You may not use this file except
- * in compliance with the License.
- *
- * You can obtain a copy of the license at
- * glassfish/bootstrap/legal/CDDLv1.0.txt or
- * https://glassfish.dev.java.net/public/CDDLv1.0.html.
- * See the License for the specific language governing
- * permissions and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * HEADER in each file and include the License file at
- * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
- * add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your
- * own identifying information: Portions Copyright [yyyy]
- * [name of copyright owner]
- */
-
-/*
- *
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-
-package javax.annotation;
-
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-/**
- * The PreDestroy annotation is used on methods as a callback notification to
- * signal that the instance is in the process of being removed by the
- * container. The method annotated with PreDestroy is typically used to
- * release resources that it has been holding. This annotation MUST be
- * supported by all container managed objects that support PostConstruct
- * except the application client container in Java EE 5. The method on which
- * the PreDestroy annotation is applied MUST fulfill all of the following
- * criteria -
- * - The method MUST NOT have any parameters except in the case of EJB
- * interceptors in which case it takes an InvocationContext object as defined
- * by the EJB specification.
- * - The return type of the method MUST be void.
- * - The method MUST NOT throw a checked exception.
- * - The method on which PreDestroy is applied MAY be public, protected,
- * package private or private.
- * - The method MUST NOT be static.
- * - The method MAY be final.
- * - If the method throws an unchecked exception it is ignored except in the
- * case of EJBs where the EJB can handle exceptions.
- *
- * @see javax.annotation.PostConstruct
- * @see javax.annotation.Resource
- * @since Common Annotations 1.0
- */
-
-@Documented
-@Retention (RUNTIME)
-@Target(METHOD)
-public @interface PreDestroy {
-}
Deleted: trunk/java/javax/annotation/Resource.java
===================================================================
--- trunk/java/javax/annotation/Resource.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/Resource.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,132 +0,0 @@
-/*
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the "License"). You may not use this file except
- * in compliance with the License.
- *
- * You can obtain a copy of the license at
- * glassfish/bootstrap/legal/CDDLv1.0.txt or
- * https://glassfish.dev.java.net/public/CDDLv1.0.html.
- * See the License for the specific language governing
- * permissions and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * HEADER in each file and include the License file at
- * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
- * add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your
- * own identifying information: Portions Copyright [yyyy]
- * [name of copyright owner]
- */
-
-/*
- *
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-
-package javax.annotation;
-
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-/**
- * The Resource annotation marks a resource that is needed
- * by the application. This annotation may be applied to an
- * application component class, or to fields or methods of the
- * component class. When the annotation is applied to a
- * field or method, the container will inject an instance
- * of the requested resource into the application component
- * when the component is initialized. If the annotation is
- * applied to the component class, the annotation declares a
- * resource that the application will look up at runtime. <p>
- *
- * Even though this annotation is not marked Inherited, deployment
- * tools are required to examine all superclasses of any component
- * class to discover all uses of this annotation in all superclasses.
- * All such annotation instances specify resources that are needed
- * by the application component. Note that this annotation may
- * appear on private fields and methods of superclasses; the container
- * is required to perform injection in these cases as well.
- *
- * @since Common Annotations 1.0
- */
-@Target({TYPE, FIELD, METHOD})
-@Retention(RUNTIME)
-public @interface Resource {
- /**
- * The JNDI name of the resource. For field annotations,
- * the default is the field name. For method annotations,
- * the default is the JavaBeans property name corresponding
- * to the method. For class annotations, there is no default
- * and this must be specified.
- */
- String name() default "";
-
- /**
- * The name of the resource that the reference points to. It can
- * link to any compatible resource using the global JNDI names.
- */
-
- String lookup() default "";
-
- /**
- * The Java type of the resource. For field annotations,
- * the default is the type of the field. For method annotations,
- * the default is the type of the JavaBeans property.
- * For class annotations, there is no default and this must be
- * specified.
- */
- Class type() default java.lang.Object.class;
-
- /**
- * The two possible authentication types for a resource.
- */
- enum AuthenticationType {
- CONTAINER,
- APPLICATION
- }
-
- /**
- * The authentication type to use for this resource.
- * This may be specified for resources representing a
- * connection factory of any supported type, and must
- * not be specified for resources of other types.
- */
- AuthenticationType authenticationType() default AuthenticationType.CONTAINER;
-
- /**
- * Indicates whether this resource can be shared between
- * this component and other components.
- * This may be specified for resources representing a
- * connection factory of any supported type, and must
- * not be specified for resources of other types.
- */
- boolean shareable() default true;
-
- /**
- * A product specific name that this resource should be mapped to.
- * The name of this resource, as defined by the <code>name</code>
- * element or defaulted, is a name that is local to the application
- * component using the resource. (It's a name in the JNDI
- * <code>java:comp/env</code> namespace.) Many application servers
- * provide a way to map these local names to names of resources
- * known to the application server. This mapped name is often a
- * <i>global</i> JNDI name, but may be a name of any form. <p>
- *
- * Application servers are not required to support any particular
- * form or type of mapped name, nor the ability to use mapped names.
- * The mapped name is product-dependent and often installation-dependent.
- * No use of a mapped name is portable.
- */
- String mappedName() default "";
-
- /**
- * Description of this resource. The description is expected
- * to be in the default language of the system on which the
- * application is deployed. The description can be presented
- * to the Deployer to help in choosing the correct resource.
- */
- String description() default "";
-}
Deleted: trunk/java/javax/annotation/Resources.java
===================================================================
--- trunk/java/javax/annotation/Resources.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/Resources.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,48 +0,0 @@
-/*
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the "License"). You may not use this file except
- * in compliance with the License.
- *
- * You can obtain a copy of the license at
- * glassfish/bootstrap/legal/CDDLv1.0.txt or
- * https://glassfish.dev.java.net/public/CDDLv1.0.html.
- * See the License for the specific language governing
- * permissions and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * HEADER in each file and include the License file at
- * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
- * add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your
- * own identifying information: Portions Copyright [yyyy]
- * [name of copyright owner]
- */
-
-/*
- *
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-
-package javax.annotation;
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-/**
- * This class is used to allow multiple resources declarations.
- *
- * @see javax.annotation.Resource
- * @since Common Annotations 1.0
- */
-
-@Documented
-@Retention(RUNTIME)
-@Target(TYPE)
-public @interface Resources {
- /**
- * Array used for multiple resource declarations.
- */
- Resource[] value();
-}
Deleted: trunk/java/javax/annotation/Stereotype.java
===================================================================
--- trunk/java/javax/annotation/Stereotype.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/Stereotype.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,55 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed 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 javax.annotation;
-
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Annotation;
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Specifies that an annotation type is a stereotype.
- *
- * @author Pete Muir
- * @author Gavin King
- */
-
-@Retention(RUNTIME)
-@Target(ANNOTATION_TYPE)
-@Documented
-public @interface Stereotype
-{
-
- /**
- * Restrict the scope of the stereotyped bean
- *
- * @return the allowed scopes
- */
- public Class<? extends Annotation>[] supportedScopes() default {};
-
- /**
- * Require that stereotype beans have certain API types
- *
- * @return the required types
- */
- public Class<?>[] requiredTypes() default {};
-
-}
Deleted: trunk/java/javax/annotation/package.html
===================================================================
--- trunk/java/javax/annotation/package.html 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/package.html 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,29 +0,0 @@
-<!--
-
- The contents of this file are subject to the terms
- of the Common Development and Distribution License
- (the "License"). You may not use this file except
- in compliance with the License.
-
- You can obtain a copy of the license at
- glassfish/bootstrap/legal/CDDLv1.0.txt or
- https://glassfish.dev.java.net/public/CDDLv1.0.html.
- See the License for the specific language governing
- permissions and limitations under the License.
-
- When distributing Covered Code, include this CDDL
- HEADER in each file and include the License file at
- glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
- add the following below this CDDL HEADER, with the
- fields enclosed by brackets "[]" replaced with your
- own identifying information: Portions Copyright [yyyy]
- [name of copyright owner]
-
- Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
--->
-
-<html>
-<body>
- This package defines the common annotations.
-</body>
-</html>
Deleted: trunk/java/javax/annotation/security/DeclareRoles.java
===================================================================
--- trunk/java/javax/annotation/security/DeclareRoles.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/security/DeclareRoles.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,44 +0,0 @@
-/*
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the "License"). You may not use this file except
- * in compliance with the License.
- *
- * You can obtain a copy of the license at
- * glassfish/bootstrap/legal/CDDLv1.0.txt or
- * https://glassfish.dev.java.net/public/CDDLv1.0.html.
- * See the License for the specific language governing
- * permissions and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * HEADER in each file and include the License file at
- * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
- * add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your
- * own identifying information: Portions Copyright [yyyy]
- * [name of copyright owner]
- */
-
-/*
- *
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-
-package javax.annotation.security;
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-/**
- * Used by application to declare roles. It can be
- * specified on a class.
- *
- * @since Common Annotations 1.0
- */
-@Documented
-@Retention (RUNTIME)
-@Target(TYPE)
-public @interface DeclareRoles {
- String[] value();
-}
Deleted: trunk/java/javax/annotation/security/DenyAll.java
===================================================================
--- trunk/java/javax/annotation/security/DenyAll.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/security/DenyAll.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,46 +0,0 @@
-/*
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the "License"). You may not use this file except
- * in compliance with the License.
- *
- * You can obtain a copy of the license at
- * glassfish/bootstrap/legal/CDDLv1.0.txt or
- * https://glassfish.dev.java.net/public/CDDLv1.0.html.
- * See the License for the specific language governing
- * permissions and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * HEADER in each file and include the License file at
- * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
- * add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your
- * own identifying information: Portions Copyright [yyyy]
- * [name of copyright owner]
- */
-
-/*
- *
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-
-package javax.annotation.security;
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-/**
- * Specifies that no security roles are allowed to invoke the specified
- * method(s) - i.e that the methods are to be excluded from execution in
- * the J2EE container.
- *
- * @see javax.annotation.security.RolesAllowed
- * @see javax.annotation.security.PermitAll
- * @since Common Annotations 1.0
- */
-@Documented
-@Retention (RUNTIME)
-@Target({TYPE, METHOD})
-public @interface DenyAll {
-}
Deleted: trunk/java/javax/annotation/security/PermitAll.java
===================================================================
--- trunk/java/javax/annotation/security/PermitAll.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/security/PermitAll.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,51 +0,0 @@
-/*
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the "License"). You may not use this file except
- * in compliance with the License.
- *
- * You can obtain a copy of the license at
- * glassfish/bootstrap/legal/CDDLv1.0.txt or
- * https://glassfish.dev.java.net/public/CDDLv1.0.html.
- * See the License for the specific language governing
- * permissions and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * HEADER in each file and include the License file at
- * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
- * add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your
- * own identifying information: Portions Copyright [yyyy]
- * [name of copyright owner]
- */
-
-/*
- *
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-
-package javax.annotation.security;
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-/**
- * Specifies that all security roles are allowed to invoke the specified
- * method(s) i.e that the specified method(s) are "unchecked". It can be
- * specified on a class or on methods. Specifying it on the class means that
- * it applies to all methods of the class. If specified at the method level,
- * it only affects that method. If the RolesAllowed is specified at the class
- * level and this annotation is applied at the method level, the PermitAll
- * annotation overrides the RolesAllowed for the specified method.
- *
- * @see javax.annotation.security.RolesAllowed
- * @see javax.annotation.security.DenyAll
- *
- * @since Common Annotations 1.0
- */
-@Documented
-@Retention (RUNTIME)
-@Target({TYPE, METHOD})
-public @interface PermitAll {
-}
Deleted: trunk/java/javax/annotation/security/RolesAllowed.java
===================================================================
--- trunk/java/javax/annotation/security/RolesAllowed.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/security/RolesAllowed.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,49 +0,0 @@
-/*
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the "License"). You may not use this file except
- * in compliance with the License.
- *
- * You can obtain a copy of the license at
- * glassfish/bootstrap/legal/CDDLv1.0.txt or
- * https://glassfish.dev.java.net/public/CDDLv1.0.html.
- * See the License for the specific language governing
- * permissions and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * HEADER in each file and include the License file at
- * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
- * add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your
- * own identifying information: Portions Copyright [yyyy]
- * [name of copyright owner]
- */
-
-/*
- *
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-
-package javax.annotation.security;
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-/**
- * Specifies the list of roles permitted to access method(s) in an application.
- * The value of the RolesAllowed annotation is a list of security role names.
- * This annotation can be specified on a class or on method(s). Specifying it
- * at a class level means that it applies to all the methods in the class.
- * Specifying it on a method means that it is applicable to that method only.
- * If applied at both the class and methods level , the method value overrides
- * the class value if the two conflict.
- *
- * @since Common Annotations 1.0
- */
-@Documented
-@Retention (RUNTIME)
-@Target({TYPE, METHOD})
-public @interface RolesAllowed {
- String[] value();
-}
Deleted: trunk/java/javax/annotation/security/RunAs.java
===================================================================
--- trunk/java/javax/annotation/security/RunAs.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/security/RunAs.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,46 +0,0 @@
-/*
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the "License"). You may not use this file except
- * in compliance with the License.
- *
- * You can obtain a copy of the license at
- * glassfish/bootstrap/legal/CDDLv1.0.txt or
- * https://glassfish.dev.java.net/public/CDDLv1.0.html.
- * See the License for the specific language governing
- * permissions and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * HEADER in each file and include the License file at
- * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
- * add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your
- * own identifying information: Portions Copyright [yyyy]
- * [name of copyright owner]
- */
-
-/*
- *
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
- */
-
-
-package javax.annotation.security;
-import java.lang.annotation.*;
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-/**
- * Defines the identity of the application during execution in a J2EE
- * container. This allows developers to execute under a particular role.
- * The role must map to the user / group information in the containers
- * security realm. It's value is the name of a security role.
- *
- * @since Common Annotations 1.0
- */
-@Documented
-@Retention (RUNTIME)
-@Target(TYPE)
-public @interface RunAs {
- String value();
-}
Deleted: trunk/java/javax/annotation/security/TransportProtected.java
===================================================================
--- trunk/java/javax/annotation/security/TransportProtected.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/security/TransportProtected.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,31 +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 javax.annotation.security;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-(a)Target({ElementType.TYPE, ElementType.METHOD})
-(a)Retention(RetentionPolicy.RUNTIME)
-
-public @interface TransportProtected {
- public boolean value() default true;
-}
Deleted: trunk/java/javax/annotation/security/package.html
===================================================================
--- trunk/java/javax/annotation/security/package.html 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/javax/annotation/security/package.html 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,28 +0,0 @@
-<!--
-
- The contents of this file are subject to the terms
- of the Common Development and Distribution License
- (the "License"). You may not use this file except
- in compliance with the License.
-
- You can obtain a copy of the license at
- glassfish/bootstrap/legal/CDDLv1.0.txt or
- https://glassfish.dev.java.net/public/CDDLv1.0.html.
- See the License for the specific language governing
- permissions and limitations under the License.
-
- When distributing Covered Code, include this CDDL
- HEADER in each file and include the License file at
- glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
- add the following below this CDDL HEADER, with the
- fields enclosed by brackets "[]" replaced with your
- own identifying information: Portions Copyright [yyyy]
- [name of copyright owner]
-
- Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
--->
-<html>
-<body>
- This package contains the security common annotations.
-</body>
-</html>
Modified: trunk/java/org/apache/catalina/Container.java
===================================================================
--- trunk/java/org/apache/catalina/Container.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/Container.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -335,23 +335,6 @@
public void setResources(DirContext resources);
- /**
- * Return the JarRepository with which this Container is associated.
- * If there is no associated JarRepository, return the JarRepository
- * associated with our parent Container (if any);
- * otherwise return <code>null</code>.
- */
- public JarRepository getJarRepository();
-
-
- /**
- * Set the JarRepository with which this Container is associated.
- *
- * @param jarRepository The newly associated JarRepository
- */
- public void setJarRepository(JarRepository jarRepository);
-
-
// --------------------------------------------------------- Public Methods
Modified: trunk/java/org/apache/catalina/Context.java
===================================================================
--- trunk/java/org/apache/catalina/Context.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/Context.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -29,10 +29,8 @@
import org.apache.catalina.deploy.FilterMap;
import org.apache.catalina.deploy.JspPropertyGroup;
import org.apache.catalina.deploy.LoginConfig;
-import org.apache.catalina.deploy.NamingResources;
import org.apache.catalina.deploy.SecurityConstraint;
import org.apache.catalina.deploy.SessionCookie;
-import org.apache.catalina.deploy.WebAbsoluteOrdering;
import org.apache.catalina.deploy.jsp.TagLibraryInfo;
import org.apache.catalina.util.CharsetMapper;
import org.apache.tomcat.InstanceManager;
@@ -88,21 +86,6 @@
/**
- * Return the absolute ordering that is configured for this context, or
- * null if no absolute ordering has been defined.
- */
- public WebAbsoluteOrdering getWebAbsoluteOrdering();
-
-
- /**
- * Set the absolute ordering for this context.
- *
- * @param webAbsoluteOrdering the new absolute ordering for this context
- */
- public void setWebAbsoluteOrdering(WebAbsoluteOrdering webAbsoluteOrdering);
-
-
- /**
* Return the authenticator that is configured for this context, or
* null if no authenticator has been configured.
*/
@@ -421,20 +404,6 @@
/**
- * Return the naming resources associated with this web application.
- */
- public NamingResources getNamingResources();
-
-
- /**
- * Set the naming resources for this web application.
- *
- * @param namingResources The new naming resources
- */
- public void setNamingResources(NamingResources namingResources);
-
-
- /**
* Return the context path for this web application.
*/
public String getPath();
Modified: trunk/java/org/apache/catalina/Host.java
===================================================================
--- trunk/java/org/apache/catalina/Host.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/Host.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -84,22 +84,6 @@
/**
- * Return the value of the auto deploy flag. If true, it indicates that
- * this host's child webapps should be discovred and automatically
- * deployed dynamically.
- */
- public boolean getAutoDeploy();
-
-
- /**
- * Set the auto deploy flag value for this host.
- *
- * @param autoDeploy The new auto deploy flag
- */
- public void setAutoDeploy(boolean autoDeploy);
-
-
- /**
* Return the Java class name of the context configuration class
* for new web applications.
*/
@@ -116,22 +100,6 @@
/**
- * Return the value of the deploy on startup flag. If true, it indicates
- * that this host's child webapps should be discovred and automatically
- * deployed.
- */
- public boolean getDeployOnStartup();
-
-
- /**
- * Set the deploy on startup flag value for this host.
- *
- * @param deployOnStartup The new deploy on startup flag
- */
- public void setDeployOnStartup(boolean deployOnStartup);
-
-
- /**
* Return the canonical, fully qualified, name of the virtual host
* this Container represents.
*/
Deleted: trunk/java/org/apache/catalina/JarRepository.java
===================================================================
--- trunk/java/org/apache/catalina/JarRepository.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/JarRepository.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,117 +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 java.io.File;
-import java.util.Map;
-import java.util.jar.JarFile;
-
-
-/**
- * A JarRepository manages a set of Jars associated with a Context, and
- * allows efficient access to them.
- *
- * @author Remy Maucherat
- * @version $Revision: 515 $ $Date: 2008-03-17 22:02:23 +0100 (Mon, 17 Mar 2008) $
- */
-public interface JarRepository {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return the Container with which this JARRepository has been associated.
- */
- public Container getContainer();
-
-
- /**
- * Set the Container with which this JARRepository has been associated.
- *
- * @param container The associated Container
- */
- public void setContainer(Container container);
-
-
- /**
- * Return descriptive information about this JARRepository implementation and
- * the corresponding version number, in the format
- * <code><description>/<version></code>.
- */
- public String getInfo();
-
-
- // --------------------------------------------------------- Public 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();
-
-
- /**
- * Find the JarFile corresponding to the path.
- *
- * @return the JarFile, or null if not found
- */
- public JarFile findJar(String path);
-
-
- /**
- * Find all JarFile managed by the JARRepository.
- *
- * @return All JarFile
- */
- public JarFile[] findJars();
-
-
- /**
- * Find all exploded Jars managed by the JARRepository.
- *
- * @return All exploded File
- */
- public File[] findExplodedJars();
-
-
- /**
- * Get the exploded Jar map.
- *
- * @return the Jar map, associating logical name with File
- */
- public Map<String, File> getExplodedJars();
-
-
-}
Modified: trunk/java/org/apache/catalina/Server.java
===================================================================
--- trunk/java/org/apache/catalina/Server.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/Server.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -18,7 +18,6 @@
package org.apache.catalina;
-import org.apache.catalina.deploy.NamingResources;
/**
* A <code>Server</code> element represents the entire Catalina
@@ -60,21 +59,6 @@
/**
- * Return the global naming resources.
- */
- public NamingResources getGlobalNamingResources();
-
-
- /**
- * Set the global naming resources.
- *
- * @param globalNamingResources The new global naming resources
- */
- public void setGlobalNamingResources
- (NamingResources globalNamingResources);
-
-
- /**
* Return the port number we listen to for shutdown commands.
*/
public int getPort();
Deleted: trunk/java/org/apache/catalina/ant/AbstractCatalinaTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/AbstractCatalinaTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/AbstractCatalinaTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,289 +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.ant;
-
-
-import java.io.BufferedOutputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import org.apache.catalina.util.Base64;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-
-
-/**
- * Abstract base class for Ant tasks that interact with the
- * <em>Manager</em> web application for dynamically deploying and
- * undeploying applications. These tasks require Ant 1.4 or later.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * @since 4.1
- */
-
-public abstract class AbstractCatalinaTask extends BaseRedirectorHelperTask {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * manager webapp's encoding.
- */
- private static String CHARSET = "utf-8";
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The charset used during URL encoding.
- */
- protected String charset = "ISO-8859-1";
-
- public String getCharset() {
- return (this.charset);
- }
-
- public void setCharset(String charset) {
- this.charset = charset;
- }
-
-
- /**
- * The login password for the <code>Manager</code> application.
- */
- protected String password = null;
-
- public String getPassword() {
- return (this.password);
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
-
- /**
- * The URL of the <code>Manager</code> application to be used.
- */
- protected String url = "http://localhost:8080/manager";
-
- public String getUrl() {
- return (this.url);
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
-
- /**
- * The login username for the <code>Manager</code> application.
- */
- protected String username = null;
-
- public String getUsername() {
- return (this.username);
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Execute the specified command. This logic only performs the common
- * attribute validation required by all subclasses; it does not perform
- * any functional logic directly.
- *
- * @exception BuildException if a validation error occurs
- */
- public void execute() throws BuildException {
-
- if ((username == null) || (password == null) || (url == null)) {
- throw new BuildException
- ("Must specify all of 'username', 'password', and 'url'");
- }
-
- }
-
-
- // ------------------------------------------------------ Protected Methods
-
-
- /**
- * Execute the specified command, based on the configured properties.
- *
- * @param command Command to be executed
- *
- * @exception BuildException if an error occurs
- */
- public void execute(String command) throws BuildException {
-
- execute(command, null, null, -1);
-
- }
-
-
- /**
- * Execute the specified command, based on the configured properties.
- * The input stream will be closed upon completion of this task, whether
- * it was executed successfully or not.
- *
- * @param command Command to be executed
- * @param istream InputStream to include in an HTTP PUT, if any
- * @param contentType Content type to specify for the input, if any
- * @param contentLength Content length to specify for the input, if any
- *
- * @exception BuildException if an error occurs
- */
- public void execute(String command, InputStream istream,
- String contentType, int contentLength)
- throws BuildException {
-
- URLConnection conn = null;
- InputStreamReader reader = null;
- try {
-
- // Create a connection for this command
- conn = (new URL(url + command)).openConnection();
- HttpURLConnection hconn = (HttpURLConnection) conn;
-
- // Set up standard connection characteristics
- hconn.setAllowUserInteraction(false);
- hconn.setDoInput(true);
- hconn.setUseCaches(false);
- if (istream != null) {
- hconn.setDoOutput(true);
- hconn.setRequestMethod("PUT");
- if (contentType != null) {
- hconn.setRequestProperty("Content-Type", contentType);
- }
- if (contentLength >= 0) {
- hconn.setRequestProperty("Content-Length",
- "" + contentLength);
- }
- } else {
- hconn.setDoOutput(false);
- hconn.setRequestMethod("GET");
- }
- hconn.setRequestProperty("User-Agent",
- "Catalina-Ant-Task/1.0");
-
- // Set up an authorization header with our credentials
- String input = username + ":" + password;
- String output = new String(Base64.encode(input.getBytes()));
- hconn.setRequestProperty("Authorization",
- "Basic " + output);
-
- // Establish the connection with the server
- hconn.connect();
-
- // Send the request data (if any)
- if (istream != null) {
- BufferedOutputStream ostream =
- new BufferedOutputStream(hconn.getOutputStream(), 1024);
- byte buffer[] = new byte[1024];
- while (true) {
- int n = istream.read(buffer);
- if (n < 0) {
- break;
- }
- ostream.write(buffer, 0, n);
- }
- ostream.flush();
- ostream.close();
- istream.close();
- }
-
- // Process the response message
- reader = new InputStreamReader(hconn.getInputStream(), CHARSET);
- StringBuffer buff = new StringBuffer();
- String error = null;
- int msgPriority = Project.MSG_INFO;
- boolean first = true;
- while (true) {
- int ch = reader.read();
- if (ch < 0) {
- break;
- } else if ((ch == '\r') || (ch == '\n')) {
- // in Win \r\n would cause handleOutput() to be called
- // twice, the second time with an empty string,
- // producing blank lines
- if (buff.length() > 0) {
- String line = buff.toString();
- buff.setLength(0);
- if (first) {
- if (!line.startsWith("OK -")) {
- error = line;
- msgPriority = Project.MSG_ERR;
- }
- first = false;
- }
- handleOutput(line, msgPriority);
- }
- } else {
- buff.append((char) ch);
- }
- }
- if (buff.length() > 0) {
- handleOutput(buff.toString(), msgPriority);
- }
- if (error != null && isFailOnError()) {
- // exception should be thrown only if failOnError == true
- // or error line will be logged twice
- throw new BuildException(error);
- }
- } catch (Throwable t) {
- if (isFailOnError()) {
- throw new BuildException(t);
- } else {
- handleErrorOutput(t.getMessage());
- }
- } finally {
- closeRedirector();
- if (reader != null) {
- try {
- reader.close();
- } catch (Throwable u) {
- ;
- }
- reader = null;
- }
- if (istream != null) {
- try {
- istream.close();
- } catch (Throwable u) {
- ;
- }
- istream = null;
- }
- }
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/ant/BaseRedirectorHelperTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/BaseRedirectorHelperTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/BaseRedirectorHelperTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,371 +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.ant;
-
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.taskdefs.Redirector;
-import org.apache.tools.ant.types.RedirectorElement;
-
-
-/**
- * Abstract base class to add output redirection support for Catalina
- * Ant tasks. These tasks require Ant 1.5 or later.
- * <br>
- * <strong>WARNING:</strong> due to depends chain, Ant could call a Task
- * more than once and this can affect the output redirection when configured.
- * If you are collecting the output in a property, it will collect the output
- * of only the first run, since Ant properties are immutable and once created
- * they cannot be changed.
- * <br>
- * If you are collecting output in a file the file will be overwritten with the
- * output of the last run, unless you set append="true", in which case each run
- * will append it's output to the file.
- *
- *
- * @author Gabriele Garuglieri
- * @version $Revision$ $Date$
- * @since 5.5
- */
-
-public abstract class BaseRedirectorHelperTask extends Task {
-
- // ------------------------------------------------------------- Properties
-
- /** Redirector helper */
- protected Redirector redirector = new Redirector(this);
- //protected Redirector redirector = null;
- /** Redirector element for this task */
- protected RedirectorElement redirectorElement = null;
- /** The stream for info output */
- protected OutputStream redirectOutStream = null;
- /** The stream for error output */
- protected OutputStream redirectErrStream = null;
- /** The print stream for info output */
- PrintStream redirectOutPrintStream = null;
- /** The print stream for error output */
- PrintStream redirectErrPrintStream = null;
-
- /**
- * Whether to fail (with a BuildException) if
- * ManagerServlet returns an error. The default behavior is
- * to do so.
- * <b>
- * This flag does not control parameters checking. If the task is called
- * with wrong or invalid parameters, it will throw BuildException
- * independently from the setting of this flag.
- */
- protected boolean failOnError = true;
-
- /**
- * <code>true</code> true when output redirection is requested for this task .
- * Default is to log on Ant log.
- */
- protected boolean redirectOutput = false;
-
- /**
- * will be set to <code>true</code> when the configuration of the Redirector is
- * complete.
- */
- protected boolean redirectorConfigured = false;
-
- /**
- * Flag which indicates that, if redirected, output should also be
- * always sent to the log. Default is that otput is sent only to
- * redirected streams.
- */
- protected boolean alwaysLog = false;
-
- /**
- * Whether to fail (with a BuildException) if
- * ManagerServlet returns an error. The default behavior is
- * to do so.
- */
- public void setFailonerror(boolean fail) {
- failOnError = fail;
- }
-
- /**
- * Returns the value of the failOnError
- * property.
- */
- public boolean isFailOnError() {
- return failOnError;
- }
-
-
- /**
- * File the output of the task is redirected to.
- *
- * @param out name of the output file
- */
- public void setOutput(File out) {
- redirector.setOutput(out);
- redirectOutput = true;
- }
-
- /**
- * File the error output of the task is redirected to.
- *
- * @param error name of the error file
- *
- */
- public void setError(File error) {
- redirector.setError(error);
- redirectOutput = true;
- }
-
- /**
- * Controls whether error output is logged. This is only useful
- * when output is being redirected and error output is desired in the
- * Ant log
- *
- * @param logError if true the standard error is sent to the Ant log system
- * and not sent to output stream.
- */
- public void setLogError(boolean logError) {
- redirector.setLogError(logError);
- redirectOutput = true;
- }
-
- /**
- * Property name whose value should be set to the output of
- * the task.
- *
- * @param outputProperty property name
- *
- */
- public void setOutputproperty(String outputProperty) {
- redirector.setOutputProperty(outputProperty);
- redirectOutput = true;
- }
-
- /**
- * Property name whose value should be set to the error of
- * the task..
- *
- * @param errorProperty property name
- *
- */
- public void setErrorProperty(String errorProperty) {
- redirector.setErrorProperty(errorProperty);
- redirectOutput = true;
- }
-
- /**
- * If true, append output to existing file.
- *
- * @param append if true, append output to existing file
- *
- */
- public void setAppend(boolean append) {
- redirector.setAppend(append);
- redirectOutput = true;
- }
-
- /**
- * If true, (error and non-error) output will be redirected
- * as specified while being sent to Ant's logging mechanism as if no
- * redirection had taken place. Defaults to false.
- * <br>
- * Actually handled internally, with Ant 1.6.3 it will be handled by
- * the <code>Redirector</code> itself.
- * @param alwaysLog <code>boolean</code>
- */
- public void setAlwaysLog(boolean alwaysLog) {
- this.alwaysLog = alwaysLog;
- //redirector.setAlwaysLog(alwaysLog);
- redirectOutput = true;
- }
-
- /**
- * Whether output and error files should be created even when empty.
- * Defaults to true.
- * @param createEmptyFiles <CODE>boolean</CODE>.
- */
- public void setCreateEmptyFiles(boolean createEmptyFiles) {
- redirector.setCreateEmptyFiles(createEmptyFiles);
- redirectOutput = true;
- }
-
- /**
- * Add a <CODE>RedirectorElement</CODE> to this task.
- * @param redirectorElement <CODE>RedirectorElement</CODE>.
- */
- public void addConfiguredRedirector(RedirectorElement redirectorElement) {
- if (this.redirectorElement != null) {
- throw new BuildException("Cannot have > 1 nested <redirector>s");
- } else {
- this.redirectorElement = redirectorElement;
- }
- }
-
- /**
- * Set up properties on the Redirector from RedirectorElement if present.
- */
- private void configureRedirector() {
- if (redirectorElement != null) {
- redirectorElement.configure(redirector);
- redirectOutput = true;
- }
- /*
- * Due to depends chain, Ant could call the Task more than once,
- * this is to prevent that we attempt to configure uselessly
- * more than once the Redirector.
- */
- redirectorConfigured = true;
- }
-
- /**
- * Set up properties on the Redirector and create output streams.
- */
- protected void openRedirector() {
- if (! redirectorConfigured) {
- configureRedirector();
- }
- if (redirectOutput) {
- redirector.createStreams();
- redirectOutStream = redirector.getOutputStream();
- redirectOutPrintStream = new PrintStream(redirectOutStream);
- redirectErrStream = redirector.getErrorStream();
- redirectErrPrintStream = new PrintStream(redirectErrStream);
- }
- }
-
- /**
- * Ask redirector to close all the streams. It is necessary to call this method
- * before leaving the Task to have the Streams flush their contents. If you are
- * collecting output in a property, it will be created only if this method is
- * called, otherwise you'll find it unset.
- */
- protected void closeRedirector() {
- try {
- if (redirectOutput) {
- redirector.complete();
- }
- } catch (IOException ioe) {
- log("Error closing redirector: "
- + ioe.getMessage(), Project.MSG_ERR);
- }
- /*
- * Due to depends chain, Ant could call the Task more than once,
- * this is to prevent that we attempt to reuse the previuosly
- * closed Streams.
- */
- redirectOutStream = null;
- redirectOutPrintStream = null;
- redirectErrStream = null;
- redirectErrPrintStream = null;
- }
-
- /**
- * Handles output with the INFO priority.
- *
- * @param output The output to log. Should not be <code>null</code>.
- */
- protected void handleOutput(String output) {
- if (redirectOutput) {
- if (redirectOutPrintStream == null) {
- openRedirector();
- }
- redirectOutPrintStream.println(output);
- if (alwaysLog) {
- log(output, Project.MSG_INFO);
- }
- } else {
- log(output, Project.MSG_INFO);
- }
- }
-
- /**
- * Handles output with the INFO priority and flushes the stream.
- *
- * @param output The output to log. Should not be <code>null</code>.
- *
- */
- protected void handleFlush(String output) {
- handleOutput(output);
- redirectOutPrintStream.flush();
- }
-
- /**
- * Handles error output with the ERR priority.
- *
- * @param output The error output to log. Should not be <code>null</code>.
- */
- protected void handleErrorOutput(String output) {
- if (redirectOutput) {
- if (redirectErrPrintStream == null) {
- openRedirector();
- }
- redirectErrPrintStream.println(output);
- if (alwaysLog) {
- log(output, Project.MSG_ERR);
- }
- } else {
- log(output, Project.MSG_ERR);
- }
- }
-
- /**
- * Handles error output with the ERR priority and flushes the stream.
- *
- * @param output The error output to log. Should not be <code>null</code>.
- *
- */
- protected void handleErrorFlush(String output) {
- handleErrorOutput(output);
- redirectErrPrintStream.flush();
- }
-
- /**
- * Handles output with ERR priority to error stream and all other
- * pritorities to output stream.
- *
- * @param output The output to log. Should not be <code>null</code>.
- */
- protected void handleOutput(String output, int priority) {
- if (priority == Project.MSG_ERR) {
- handleErrorOutput(output);
- } else {
- handleOutput(output);
- }
- }
-
- /**
- * Handles output with ERR priority to error stream and all other
- * pritorities to output stream, then flushes the stream.
- *
- * @param output The output to log. Should not be <code>null</code>.
- */
- protected void handleFlush(String output, int priority) {
- if (priority == Project.MSG_ERR) {
- handleErrorFlush(output);
- } else {
- handleFlush(output);
- }
- }
-
-}
Deleted: trunk/java/org/apache/catalina/ant/DeployTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/DeployTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/DeployTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,206 +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.ant;
-
-
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLEncoder;
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the <code>/deploy</code> command, supported by
- * the Tomcat manager application.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * @since 4.1
- */
-public class DeployTask extends AbstractCatalinaTask {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * URL of the context configuration file for this application, if any.
- */
- protected String config = null;
-
- public String getConfig() {
- return (this.config);
- }
-
- public void setConfig(String config) {
- this.config = config;
- }
-
-
- /**
- * URL of the server local web application archive (WAR) file
- * to be deployed.
- */
- protected String localWar = null;
-
- public String getLocalWar() {
- return (this.localWar);
- }
-
- public void setLocalWar(String localWar) {
- this.localWar = localWar;
- }
-
-
- /**
- * The context path of the web application we are managing.
- */
- protected String path = null;
-
- public String getPath() {
- return (this.path);
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
- /**
- * Tag to associate with this to be deployed webapp.
- */
- protected String tag = null;
-
- public String getTag() {
- return (this.tag);
- }
-
- public void setTag(String tag) {
- this.tag = tag;
- }
-
-
- /**
- * Update existing webapps.
- */
- protected boolean update = false;
-
- public boolean getUpdate() {
- return (this.update);
- }
-
- public void setUpdate(boolean update) {
- this.update = update;
- }
-
-
- /**
- * URL of the web application archive (WAR) file to be deployed.
- */
- protected String war = null;
-
- public String getWar() {
- return (this.war);
- }
-
- public void setWar(String war) {
- this.war = war;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
-
- super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
- if ((war == null) && (localWar == null) && (config == null) && (tag == null)) {
- throw new BuildException
- ("Must specify either 'war', 'localWar', 'config', or 'tag' attribute");
- }
-
- // Building an input stream on the WAR to upload, if any
- BufferedInputStream stream = null;
- String contentType = null;
- int contentLength = -1;
- if (war != null) {
- if (war.startsWith("file:")) {
- try {
- URL url = new URL(war);
- URLConnection conn = url.openConnection();
- contentLength = conn.getContentLength();
- stream = new BufferedInputStream
- (conn.getInputStream(), 1024);
- } catch (IOException e) {
- throw new BuildException(e);
- }
- } else {
- try {
- stream = new BufferedInputStream
- (new FileInputStream(war), 1024);
- } catch (IOException e) {
- throw new BuildException(e);
- }
- }
- contentType = "application/octet-stream";
- }
-
- // Building URL
- StringBuffer sb = new StringBuffer("/deploy?path=");
- try {
- sb.append(URLEncoder.encode(this.path, getCharset()));
- if ((war == null) && (config != null)) {
- sb.append("&config=");
- sb.append(URLEncoder.encode(config, getCharset()));
- }
- if ((war == null) && (localWar != null)) {
- sb.append("&war=");
- sb.append(URLEncoder.encode(localWar, getCharset()));
- }
- if (update) {
- sb.append("&update=true");
- }
- if (tag != null) {
- sb.append("&tag=");
- sb.append(URLEncoder.encode(tag, getCharset()));
- }
- } catch (UnsupportedEncodingException e) {
- throw new BuildException("Invalid 'charset' attribute: " + getCharset());
- }
-
- execute(sb.toString(), stream, contentType, contentLength);
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/ant/InstallTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/InstallTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/InstallTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,119 +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.ant;
-
-
-import java.net.URLEncoder;
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the <code>/install</code> command, supported by the
- * Tomcat manager application.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * @since 4.1
- * @deprecated Replaced by DeployTask
- */
-public class InstallTask extends AbstractCatalinaTask {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * URL of the context configuration file for this application, if any.
- */
- protected String config = null;
-
- public String getConfig() {
- return (this.config);
- }
-
- public void setConfig(String config) {
- this.config = config;
- }
-
-
- /**
- * The context path of the web application we are managing.
- */
- protected String path = null;
-
- public String getPath() {
- return (this.path);
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
- /**
- * URL of the web application archive (WAR) file, or the unpacked directory
- * containing this application, if any.
- */
- protected String war = null;
-
- public String getWar() {
- return (this.war);
- }
-
- public void setWar(String war) {
- this.war = war;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
-
- super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
- if ((config == null) && (war == null)) {
- throw new BuildException
- ("Must specify at least one of 'config' and 'war'");
- }
- StringBuffer sb = new StringBuffer("/install?path=");
- sb.append(URLEncoder.encode(this.path));
- if (config != null) {
- sb.append("&config=");
- sb.append(URLEncoder.encode(config));
- }
- if (war != null) {
- sb.append("&war=");
- sb.append(URLEncoder.encode(war));
- }
- execute(sb.toString());
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/ant/JKStatusUpdateTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/JKStatusUpdateTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/JKStatusUpdateTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,416 +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.ant;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import org.apache.tools.ant.BuildException;
-
-/**
- * Ant task that implements the <code>/status</code> command, supported by the
- * mod_jk status (1.2.9) application.
- *
- * @author Peter Rossbach
- * @version $Revision$
- * @since 5.5.9
- */
-public class JKStatusUpdateTask extends AbstractCatalinaTask {
-
- private String worker = "lb";
-
- private String workerType = "lb";
-
- private int internalid = 0;
-
- private Integer lbRetries;
-
- private Integer lbRecovertime;
-
- private Boolean lbStickySession = Boolean.TRUE;
-
- private Boolean lbForceSession = Boolean.FALSE;
-
- private Integer workerLoadFactor;
-
- private String workerRedirect;
-
- private String workerClusterDomain;
-
- private Boolean workerDisabled = Boolean.FALSE;
-
- private Boolean workerStopped = Boolean.FALSE;
-
- private boolean isLBMode = true;
-
- private String workerLb;
-
- /**
- *
- */
- public JKStatusUpdateTask() {
- super();
- setUrl("http://localhost/status");
- }
-
- /**
- * @return Returns the internalid.
- */
- public int getInternalid() {
- return internalid;
- }
-
- /**
- * @param internalid
- * The internalid to set.
- */
- public void setInternalid(int internalid) {
- this.internalid = internalid;
- }
-
- /**
- * @return Returns the lbForceSession.
- */
- public Boolean getLbForceSession() {
- return lbForceSession;
- }
-
- /**
- * @param lbForceSession
- * The lbForceSession to set.
- */
- public void setLbForceSession(Boolean lbForceSession) {
- this.lbForceSession = lbForceSession;
- }
-
- /**
- * @return Returns the lbRecovertime.
- */
- public Integer getLbRecovertime() {
- return lbRecovertime;
- }
-
- /**
- * @param lbRecovertime
- * The lbRecovertime to set.
- */
- public void setLbRecovertime(Integer lbRecovertime) {
- this.lbRecovertime = lbRecovertime;
- }
-
- /**
- * @return Returns the lbRetries.
- */
- public Integer getLbRetries() {
- return lbRetries;
- }
-
- /**
- * @param lbRetries
- * The lbRetries to set.
- */
- public void setLbRetries(Integer lbRetries) {
- this.lbRetries = lbRetries;
- }
-
- /**
- * @return Returns the lbStickySession.
- */
- public Boolean getLbStickySession() {
- return lbStickySession;
- }
-
- /**
- * @param lbStickySession
- * The lbStickySession to set.
- */
- public void setLbStickySession(Boolean lbStickySession) {
- this.lbStickySession = lbStickySession;
- }
-
- /**
- * @return Returns the worker.
- */
- public String getWorker() {
- return worker;
- }
-
- /**
- * @param worker
- * The worker to set.
- */
- public void setWorker(String worker) {
- this.worker = worker;
- }
-
- /**
- * @return Returns the workerType.
- */
- public String getWorkerType() {
- return workerType;
- }
-
- /**
- * @param workerType
- * The workerType to set.
- */
- public void setWorkerType(String workerType) {
- this.workerType = workerType;
- }
-
- /**
- * @return Returns the workerLb.
- */
- public String getWorkerLb() {
- return workerLb;
- }
-
- /**
- * @param workerLb
- * The workerLb to set.
- */
- public void setWorkerLb(String workerLb) {
- this.workerLb = workerLb;
- }
-
- /**
- * @return Returns the workerClusterDomain.
- */
- public String getWorkerClusterDomain() {
- return workerClusterDomain;
- }
-
- /**
- * @param workerClusterDomain
- * The workerClusterDomain to set.
- */
- public void setWorkerClusterDomain(String workerClusterDomain) {
- this.workerClusterDomain = workerClusterDomain;
- }
-
- /**
- * @return Returns the workerDisabled.
- */
- public Boolean getWorkerDisabled() {
- return workerDisabled;
- }
-
- /**
- * @param workerDisabled
- * The workerDisabled to set.
- */
- public void setWorkerDisabled(Boolean workerDisabled) {
- this.workerDisabled = workerDisabled;
- }
-
- /**
- * @return Returns the workerStopped.
- */
- public Boolean getWorkerStopped() {
- return workerStopped;
- }
-
- /**
- * @param workerStopped The workerStopped to set.
- */
- public void setWorkerStopped(Boolean workerStopped) {
- this.workerStopped = workerStopped;
- }
-
- /**
- * @return Returns the workerLoadFactor.
- */
- public Integer getWorkerLoadFactor() {
- return workerLoadFactor;
- }
-
- /**
- * @param workerLoadFactor
- * The workerLoadFactor to set.
- */
- public void setWorkerLoadFactor(Integer workerLoadFactor) {
- this.workerLoadFactor = workerLoadFactor;
- }
-
- /**
- * @return Returns the workerRedirect.
- */
- public String getWorkerRedirect() {
- return workerRedirect;
- }
-
- /**
- * @param workerRedirect
- * The workerRedirect to set.
- */
- public void setWorkerRedirect(String workerRedirect) {
- this.workerRedirect = workerRedirect;
- }
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException
- * if an error occurs
- */
- public void execute() throws BuildException {
-
- super.execute();
- checkParameter();
- StringBuffer sb = createLink();
- execute(sb.toString(), null, null, -1);
-
- }
-
- /**
- * Create JkStatus link
- * <ul>
- * <li><b>load balance example:
- * </b>http://localhost/status?cmd=update&mime=txt&w=lb&lf=false&ls=true</li>
- * <li><b>worker example:
- * </b>http://localhost/status?cmd=update&mime=txt&w=node1&l=lb&wf=1&wd=false&ws...
- * </li>
- * </ul>
- *
- * @return create jkstatus link
- */
- private StringBuffer createLink() {
- // Building URL
- StringBuffer sb = new StringBuffer();
- try {
- sb.append("?cmd=update&mime=txt");
- sb.append("&w=");
- sb.append(URLEncoder.encode(worker, getCharset()));
-
- if (isLBMode) {
- //http://localhost/status?cmd=update&mime=txt&w=lb&lf=false&ls=true
- if ((lbRetries != null)) { // > 0
- sb.append("&lr=");
- sb.append(lbRetries);
- }
- if ((lbRecovertime != null)) { // > 59
- sb.append("<=");
- sb.append(lbRecovertime);
- }
- if ((lbStickySession != null)) {
- sb.append("&ls=");
- sb.append(lbStickySession);
- }
- if ((lbForceSession != null)) {
- sb.append("&lf=");
- sb.append(lbForceSession);
- }
- } else {
- //http://localhost/status?cmd=update&mime=txt&w=node1&l=lb&wf=1&wd=false&ws=false
- if ((workerLb != null)) { // must be configured
- sb.append("&l=");
- sb.append(URLEncoder.encode(workerLb, getCharset()));
- }
- if ((workerLoadFactor != null)) { // >= 1
- sb.append("&wf=");
- sb.append(workerLoadFactor);
- }
- if ((workerDisabled != null)) {
- sb.append("&wd=");
- sb.append(workerDisabled);
- }
- if ((workerStopped != null)) {
- sb.append("&ws=");
- sb.append(workerStopped);
- }
- if ((workerRedirect != null)) { // other worker conrecte lb's
- sb.append("&wr=");
- }
- if ((workerClusterDomain != null)) {
- sb.append("&wc=");
- sb.append(URLEncoder.encode(workerClusterDomain,
- getCharset()));
- }
- }
-
- } catch (UnsupportedEncodingException e) {
- throw new BuildException("Invalid 'charset' attribute: "
- + getCharset());
- }
- return sb;
- }
-
- /**
- * check correct lb and worker pararmeter
- */
- protected void checkParameter() {
- if (worker == null) {
- throw new BuildException("Must specify 'worker' attribute");
- }
- if (workerType == null) {
- throw new BuildException("Must specify 'workerType' attribute");
- }
- if ("lb".equals(workerType)) {
- if (lbRecovertime == null && lbRetries == null) {
- throw new BuildException(
- "Must specify at a lb worker either 'lbRecovertime' or"
- + "'lbRetries' attribute");
- }
- if (lbStickySession == null || lbForceSession == null) {
- throw new BuildException("Must specify at a lb worker either"
- + "'lbStickySession' and 'lbForceSession' attribute");
- }
- if (null != lbRecovertime && 60 < lbRecovertime.intValue()) {
- throw new BuildException(
- "The 'lbRecovertime' must be greater than 59");
- }
- if (null != lbRetries && 1 < lbRetries.intValue()) {
- throw new BuildException(
- "The 'lbRetries' must be greater than 1");
- }
- isLBMode = true;
- } else if ("worker".equals(workerType)) {
- if (workerDisabled == null) {
- throw new BuildException(
- "Must specify at a node worker 'workerDisabled' attribute");
- }
- if (workerStopped == null) {
- throw new BuildException(
- "Must specify at a node worker 'workerStopped' attribute");
- }
- if (workerLoadFactor == null ) {
- throw new BuildException(
- "Must specify at a node worker 'workerLoadFactor' attribute");
- }
- if (workerClusterDomain == null) {
- throw new BuildException(
- "Must specify at a node worker 'workerClusterDomain' attribute");
- }
- if (workerRedirect == null) {
- throw new BuildException(
- "Must specify at a node worker 'workerRedirect' attribute");
- }
- if (workerLb == null) {
- throw new BuildException("Must specify 'workerLb' attribute");
- }
- if (workerLoadFactor.intValue() < 1) {
- throw new BuildException(
- "The 'workerLoadFactor' must be greater or equal 1");
- }
- isLBMode = false;
- } else {
- throw new BuildException(
- "Only 'lb' and 'worker' supported as workerType attribute");
- }
- }
-}
\ No newline at end of file
Deleted: trunk/java/org/apache/catalina/ant/JMXGetTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/JMXGetTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/JMXGetTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,96 +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.ant;
-
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the JMX Get command (<code>/jmxproxy/?get</code>)
- * supported by the Tomcat manager application.
- *
- * @author Peter Rossbach
- * @version $Revision$
- */
-public class JMXGetTask extends AbstractCatalinaTask {
-
- // Properties
-
- /**
- * The full bean name
- */
- protected String bean = null;
-
- /**
- * The attribute you wish to alter
- */
- protected String attribute = null;
-
- // Public Methods
-
- /**
- * Get method for the bean name
- * @return Bean name
- */
- public String getBean () {
- return this.bean;
- }
-
- /**
- * Set method for the bean name
- * @param bean Bean name
- */
- public void setBean (String bean) {
- this.bean = bean;
- }
-
- /**
- * Get method for the attribute name
- * @return Attribute name
- */
- public String getAttribute () {
- return this.attribute;
- }
-
- /**
- * Set method for the attribute name
- * @param attribute Attribute name
- */
- public void setAttribute (String attribute) {
- this.attribute = attribute;
- }
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
- super.execute();
- if (bean == null || attribute == null) {
- throw new BuildException
- ("Must specify 'bean' and 'attribute' attributes");
- }
- log("Getting attribute " + attribute +
- " in bean " + bean );
- execute("/jmxproxy/?get=" + bean
- + "&att=" + attribute );
- }
-}
Deleted: trunk/java/org/apache/catalina/ant/JMXQueryTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/JMXQueryTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/JMXQueryTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,79 +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.ant;
-
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the JMX Query command
- * (<code>/jmxproxy/?qry</code>) supported by the Tomcat manager application.
- *
- * @author Vivek Chopra
- * @version $Revision$
- */
-public class JMXQueryTask extends AbstractCatalinaTask {
-
- // Properties
-
- /**
- * The JMX query string
- * @see #setQuery(String)
- */
- protected String query = null;
-
- // Public Methods
-
- /**
- * Get method for the JMX query string
- * @return Query string
- */
- public String getQuery () {
- return this.query;
- }
-
- /**
- * Set method for the JMX query string.
- * <P>Examples of query format:
- * <UL>
- * <LI>*:*</LI>
- * <LI>*:type=RequestProcessor,*</LI>
- * <LI>*:j2eeType=Servlet,*</LI>
- * <LI>Catalina:type=Environment,resourcetype=Global,name=simpleValue</LI>
- * </UL>
- * </P>
- * @param query JMX Query string
- */
- public void setQuery (String query) {
- this.query = query;
- }
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
- super.execute();
- String queryString = (query == null) ? "":("?qry="+query);
- log("Query string is " + queryString);
- execute ("/jmxproxy/" + queryString);
- }
-}
Deleted: trunk/java/org/apache/catalina/ant/JMXSetTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/JMXSetTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/JMXSetTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,119 +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.ant;
-
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the JMX Set command (<code>/jmxproxy/?set</code>)
- * supported by the Tomcat manager application.
- *
- * @author Vivek Chopra
- * @version $Revision$
- */
-public class JMXSetTask extends AbstractCatalinaTask {
-
- // Properties
-
- /**
- * The full bean name
- */
- protected String bean = null;
-
- /**
- * The attribute you wish to alter
- */
- protected String attribute = null;
-
- /**
- * The new value for the attribute
- */
- protected String value = null;
-
- // Public Methods
-
- /**
- * Get method for the bean name
- * @return Bean name
- */
- public String getBean () {
- return this.bean;
- }
-
- /**
- * Set method for the bean name
- * @param bean Bean name
- */
- public void setBean (String bean) {
- this.bean = bean;
- }
-
- /**
- * Get method for the attribute name
- * @return Attribute name
- */
- public String getAttribute () {
- return this.attribute;
- }
-
- /**
- * Set method for the attribute name
- * @param attribute Attribute name
- */
- public void setAttribute (String attribute) {
- this.attribute = attribute;
- }
-
- /**
- * Get method for the attribute value
- * @return Attribute value
- */
- public String getValue () {
- return this.value;
- }
-
- /**
- * Set method for the attribute value.
- * @param value Attribute value
- */
- public void setValue (String value) {
- this.value = value;
- }
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
- super.execute();
- if (bean == null || attribute == null || value == null) {
- throw new BuildException
- ("Must specify 'bean', 'attribute' and 'value' attributes");
- }
- log("Setting attribute " + attribute +
- " in bean " + bean +
- " to " + value);
- execute("/jmxproxy/?set=" + bean
- + "&att=" + attribute
- + "&val=" + value);
- }
-}
Deleted: trunk/java/org/apache/catalina/ant/ListTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/ListTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/ListTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,55 +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.ant;
-
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the <code>/list</code> command, supported by the
- * Tomcat manager application.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * @since 4.1
- */
-public class ListTask extends AbstractCatalinaTask {
-
-
- // ------------------------------------------------------------- Properties
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
-
- super.execute();
- execute("/list");
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/ant/ReloadTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/ReloadTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/ReloadTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,82 +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.ant;
-
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the <code>/reload</code> command, supported by the
- * Tomcat manager application.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * @since 4.1
- */
-public class ReloadTask extends AbstractCatalinaTask {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The context path of the web application we are managing.
- */
- protected String path = null;
-
- public String getPath() {
- return (this.path);
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
-
- super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
- try {
- execute("/reload?path=" + URLEncoder.encode(this.path, getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new BuildException
- ("Invalid 'charset' attribute: " + getCharset());
- }
-
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/ant/RemoveTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/RemoveTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/RemoveTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,75 +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.ant;
-
-
-import java.net.URLEncoder;
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the <code>/remove</code> command, supported by the
- * Tomcat manager application.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * @deprecated Replaced by UndeployTask
- */
-public class RemoveTask extends AbstractCatalinaTask {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The context path of the web application we are managing.
- */
- protected String path = null;
-
- public String getPath() {
- return (this.path);
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
-
- super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
- execute("/remove?path=" + URLEncoder.encode(this.path));
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/ant/ResourcesTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/ResourcesTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/ResourcesTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,74 +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.ant;
-
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the <code>/resources</code> command, supported by
- * the Tomcat manager application.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * @since 4.1
- */
-public class ResourcesTask extends AbstractCatalinaTask {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The fully qualified class name of the resource type being requested
- * (if any).
- */
- protected String type = null;
-
- public String getType() {
- return (this.type);
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
-
- super.execute();
- if (type != null) {
- execute("/resources?type=" + type);
- } else {
- execute("/resources");
- }
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/ant/ServerinfoTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/ServerinfoTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/ServerinfoTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,48 +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.ant;
-
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the <code>/serverinfo</code> command
- * supported by the Tomcat manager application.
- *
- * @author Vivek Chopra
- * @version $Revision$ $Date$
- */
-public class ServerinfoTask extends AbstractCatalinaTask {
-
- // Public Methods
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
-
- super.execute();
- execute("/serverinfo");
-
- }
-
-}
Deleted: trunk/java/org/apache/catalina/ant/SessionsTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/SessionsTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/SessionsTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,76 +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.ant;
-
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the <code>/sessions</code> command
- * supported by the Tomcat manager application.
- *
- * @author Vivek Chopra
- * @version $Revision$
- */
-public class SessionsTask extends AbstractCatalinaTask {
-
- // Properties
-
- /**
- * The context path of the web application we are managing.
- */
- protected String path = null;
-
- public String getPath() {
- return (this.path);
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
- // Public Methods
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
-
- super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
-
- try {
- execute("/sessions?path=" + URLEncoder.encode(this.path, getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new BuildException
- ("Invalid 'charset' attribute: " + getCharset());
- }
-
- }
-
-}
Deleted: trunk/java/org/apache/catalina/ant/StartTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/StartTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/StartTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,81 +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.ant;
-
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the <code>/start</code> command, supported by the
- * Tomcat manager application.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * @since 4.1
- */
-public class StartTask extends AbstractCatalinaTask {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The context path of the web application we are managing.
- */
- protected String path = null;
-
- public String getPath() {
- return (this.path);
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
-
- super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
- try {
- execute("/start?path=" + URLEncoder.encode(this.path, getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new BuildException
- ("Invalid 'charset' attribute: " + getCharset());
- }
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/ant/StopTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/StopTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/StopTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,81 +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.ant;
-
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the <code>/stop</code> command, supported by the
- * Tomcat manager application.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * @since 4.1
- */
-public class StopTask extends AbstractCatalinaTask {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The context path of the web application we are managing.
- */
- protected String path = null;
-
- public String getPath() {
- return (this.path);
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
-
- super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
- try {
- execute("/stop?path=" + URLEncoder.encode(this.path, getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new BuildException
- ("Invalid 'charset' attribute: " + getCharset());
- }
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/ant/UndeployTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/UndeployTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/UndeployTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,72 +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.ant;
-
-
-import org.apache.tools.ant.BuildException;
-
-
-/**
- * Ant task that implements the <code>/undeploy</code> command, supported by
- * the Tomcat manager application.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * @since 4.1
- */
-public class UndeployTask extends AbstractCatalinaTask {
-
-
- // ------------------------------------------------------------- Properties
-
- /**
- * The context path of the web application we are managing.
- */
- protected String path = null;
-
- public String getPath() {
- return (this.path);
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Execute the requested operation.
- *
- * @exception BuildException if an error occurs
- */
- public void execute() throws BuildException {
-
- super.execute();
- if (path == null) {
- throw new BuildException
- ("Must specify 'path' attribute");
- }
-
- execute("/undeploy?path=" + this.path);
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/ant/ValidatorTask.java
===================================================================
--- trunk/java/org/apache/catalina/ant/ValidatorTask.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/ValidatorTask.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,115 +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.ant;
-
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-
-import org.apache.catalina.startup.Constants;
-import org.apache.catalina.startup.DigesterFactory;
-import org.apache.tomcat.util.digester.Digester;
-import org.apache.tools.ant.BuildException;
-import org.xml.sax.InputSource;
-
-
-/**
- * Task for validating a web application deployment descriptor, using XML
- * schema validation.
- *
- * @author Remy Maucherat
- * @version $Revision$ $Date$
- * @since 5.0
- */
-
-public class ValidatorTask extends BaseRedirectorHelperTask {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The path to the webapp directory.
- */
- protected String path = null;
-
- public String getPath() {
- return (this.path);
- }
-
- public void setPath(String path) {
- this.path = path;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Execute the specified command. This logic only performs the common
- * attribute validation required by all subclasses; it does not perform
- * any functional logic directly.
- *
- * @exception BuildException if a validation error occurs
- */
- public void execute() throws BuildException {
-
- if (path == null) {
- throw new BuildException("Must specify 'path'");
- }
-
- File file = new File(path, Constants.ApplicationWebXml);
- if ((!file.exists()) || (!file.canRead())) {
- throw new BuildException("Cannot find web.xml");
- }
-
- // Commons-logging likes having the context classloader set
- ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader
- (ValidatorTask.class.getClassLoader());
-
- Digester digester = DigesterFactory.newDigester(true, true, null);
- try {
- file = file.getCanonicalFile();
- InputStream stream =
- new BufferedInputStream(new FileInputStream(file));
- InputSource is = new InputSource(file.toURL().toExternalForm());
- is.setByteStream(stream);
- digester.parse(is);
- handleOutput("web.xml validated");
- } catch (Throwable t) {
- if (isFailOnError()) {
- throw new BuildException("Validation failure", t);
- } else {
- handleErrorOutput("Validation failure: " + t);
- }
- } finally {
- Thread.currentThread().setContextClassLoader(oldCL);
- closeRedirector();
- }
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/ant/antlib.xml
===================================================================
--- trunk/java/org/apache/catalina/ant/antlib.xml 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/antlib.xml 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<antlib>
- <typedef
- name="list"
- classname="org.apache.catalina.ant.ListTask" />
- <typedef
- name="deploy"
- classname="org.apache.catalina.ant.DeployTask" />
- <typedef
- name="start"
- classname="org.apache.catalina.ant.StartTask" />
- <typedef
- name="reload"
- classname="org.apache.catalina.ant.ReloadTask" />
- <typedef
- name="stop"
- classname="org.apache.catalina.ant.StopTask" />
- <typedef
- name="undeploy"
- classname="org.apache.catalina.ant.UndeployTask" />
- <typedef
- name="roles"
- classname="org.apache.catalina.ant.RolesTask" />
- <typedef
- name="resources"
- classname="org.apache.catalina.ant.ResourcesTask" />
- <typedef
- name="sessions"
- classname="org.apache.catalina.ant.SessionsTask" />
- <typedef
- name="jkupdate"
- classname="org.apache.catalina.ant.JKStatusUpdateTask" />
- <typedef
- name="jmxManagerSet"
- classname="org.apache.catalina.ant.JMXSetTask" />
- <typedef
- name="jmxManagerGet"
- classname="org.apache.catalina.ant.JMXGetTask" />
- <typedef
- name="jmxManagerQuery"
- classname="org.apache.catalina.ant.JMXQueryTask" />
-</antlib>
\ No newline at end of file
Deleted: trunk/java/org/apache/catalina/ant/catalina.tasks
===================================================================
--- trunk/java/org/apache/catalina/ant/catalina.tasks 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/catalina.tasks 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,22 +0,0 @@
-# Pure catalina tasks
-deploy=org.apache.catalina.ant.DeployTask
-list=org.apache.catalina.ant.ListTask
-reload=org.apache.catalina.ant.ReloadTask
-sessions=org.apache.catalina.ant.SessionsTask
-resources=org.apache.catalina.ant.ResourcesTask
-start=org.apache.catalina.ant.StartTask
-stop=org.apache.catalina.ant.StopTask
-undeploy=org.apache.catalina.ant.UndeployTask
-validator=org.apache.catalina.ant.ValidatorTask
-
-#Jk Task
-jkstatus=org.apache.catalina.ant.JKStatusUpdateTask
-
-# Manager JMX
-jmxManagerSet=org.apache.catalina.ant.JMXSetTask
-jmxManagerGet=org.apache.catalina.ant.JMXGetTask
-jmxManagerQuery=org.apache.catalina.ant.JMXQueryTask
-
-# Jasper tasks
-jasper=org.apache.jasper.JspC
-jasper2=org.apache.jasper.JspC
Deleted: trunk/java/org/apache/catalina/ant/package.html
===================================================================
--- trunk/java/org/apache/catalina/ant/package.html 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/ant/package.html 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,86 +0,0 @@
-<body>
-
-<p>This package contains a set of <code>Task</code> implementations for
-<em>Ant (version 1.6.x or later)</em> that can be used to interact with the
-Manager application to deploy, undeploy, list, reload, start and stop web applications
-from a running instance of Tomcat. For more information, see
-<a href="http://jakarta.apache.org/tomcat/tomcat-5.5-doc/manager-howto.html">
-http://jakarta.apache.org/tomcat/tomcat-5.5-doc/manager-howto.html</a>.</p>
-
-<p>The attributes of each task element correspond
-exactly to the request parameters that are included with an HTTP request
-sent directly to the Manager application. They are summarized as follows:
-</p>
-
-<table>
- <tr>
- <th align="center" width="15%">Attribute</th>
- <th align="center" width="85%">Description</th>
- </tr>
- <tr>
- <td align="center">url</td>
- <td>
- The URL of the Manager web application you will use to
- perform the requested operations. If not specified, defaults to
- <code>http://localhost:8080/manager</code> (which corresponds
- to a standard installation of Tomcat 5).
- </td>
- </tr>
- <tr>
- <td align="center">username</td>
- <td>
- The username of a Tomcat user that has been configured with the
- <code>manager</code> role, as required to execute Manager
- application commands. This attribute is required.
- </td>
- </tr>
- <tr>
- <td align="center">password</td>
- <td>
- The password of a Tomcat user that has been configured with the
- <code>manager</code> role, as required to execute Manager
- application commands. This attribute is required.
- </td>
- </tr>
- <tr>
- <td align="center">config</td>
- <td>
- A URL pointing at the context configuration file (i.e. a file
- containing only the <code><Context></code> element, and
- its nested elements, from <code>server.xml</code> for a particular
- web application). This attribute is supported only on the
- <code>install</code> target, and is required only if you wish to
- install an application with non-default configuration characteristics.
- </td>
- </tr>
- <tr>
- <td align="center">path</td>
- <td>
- The context path (including the leading slash) of the web application
- this command is intended to manage, or a zero-length string for the
- ROOT web application. This attribute is valid for the
- <code>install</code>, <code>reload</code>, <code>remove</code>,
- <code>start</code>, and <code>stop</code> tasks only, and is
- required in all of those cases.
- </td>
- </tr>
- <tr>
- <td align="center">war</td>
- <td>
- A <code>jar:</code> URL that points at a web application archive (WAR)
- file, or a <code>file:</code> URL that points at an unpacked directory
- containing the web application. This attribute is supported only on
- the <code>install</code> target. You must specify at least one of the
- <code>config</code> and <code>war</code> attributes; if you specify
- both, the <code>war</code> attribute overrides the <code>docBase</code>
- attribute in the context configuration file.
- </td>
- </tr>
-</table>
-
-<p><strong>NOTE</strong> - Commands executed through the <em>Manager</em>
-application are <strong>NOT</strong> reflected in updates to the Tomcat
-<code>server.xml</code> configuration file, so they do not persist past the
-next time you restart the entire Tomcat container.</p>
-
-</body>
Added: trunk/java/org/apache/catalina/connector/ConnectorMBean.java
===================================================================
--- trunk/java/org/apache/catalina/connector/ConnectorMBean.java (rev 0)
+++ trunk/java/org/apache/catalina/connector/ConnectorMBean.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -0,0 +1,152 @@
+/*
+ * 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.connector;
+
+import javax.management.Attribute;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.ReflectionException;
+import javax.management.RuntimeOperationsException;
+import javax.management.modelmbean.InvalidTargetObjectTypeException;
+
+import org.apache.catalina.connector.Connector;
+import org.apache.tomcat.util.IntrospectionUtils;
+import org.apache.tomcat.util.modeler.BaseModelMBean;
+
+
+/**
+ * <p>A <strong>ModelMBean</strong> implementation for the
+ * <code>org.apache.coyote.tomcat5.CoyoteConnector</code> component.</p>
+ *
+ * @author Amy Roh
+ * @version $Revision: 515 $ $Date: 2008-03-17 22:02:23 +0100 (Mon, 17 Mar 2008) $
+ */
+
+public class ConnectorMBean extends BaseModelMBean {
+
+
+ // ----------------------------------------------------------- Constructors
+
+
+ /**
+ * Construct a <code>ModelMBean</code> with default
+ * <code>ModelMBeanInfo</code> information.
+ *
+ * @exception MBeanException if the initializer of an object
+ * throws an exception
+ * @exception RuntimeOperationsException if an IllegalArgumentException
+ * occurs
+ */
+ public ConnectorMBean()
+ throws MBeanException, RuntimeOperationsException {
+
+ super();
+
+ }
+
+
+ // ------------------------------------------------------------- Attributes
+
+
+ /**
+ * Obtain and return the value of a specific attribute of this MBean.
+ *
+ * @param name Name of the requested attribute
+ *
+ * @exception AttributeNotFoundException if this attribute is not
+ * supported by this MBean
+ * @exception MBeanException if the initializer of an object
+ * throws an exception
+ * @exception ReflectionException if a Java reflection exception
+ * occurs when invoking the getter
+ */
+ public Object getAttribute(String name) throws AttributeNotFoundException,
+ MBeanException, ReflectionException {
+
+ // Validate the input parameters
+ if (name == null)
+ throw new RuntimeOperationsException(new IllegalArgumentException(
+ "Attribute name is null"), "Attribute name is null");
+
+ Object result = null;
+ try {
+ Connector connector = (Connector) getManagedResource();
+ result = IntrospectionUtils.getProperty(connector, name);
+ } catch (InstanceNotFoundException e) {
+ throw new MBeanException(e);
+ } catch (InvalidTargetObjectTypeException e) {
+ throw new MBeanException(e);
+ }
+
+ return result;
+
+ }
+
+
+ /**
+ * Set the value of a specific attribute of this MBean.
+ *
+ * @param attribute The identification of the attribute to be set
+ * and the new value
+ *
+ * @exception AttributeNotFoundException if this attribute is not
+ * supported by this MBean
+ * @exception MBeanException if the initializer of an object
+ * throws an exception
+ * @exception ReflectionException if a Java reflection exception
+ * occurs when invoking the getter
+ */
+ public void setAttribute(Attribute attribute)
+ throws AttributeNotFoundException, MBeanException,
+ ReflectionException {
+
+ // Validate the input parameters
+ if (attribute == null)
+ throw new RuntimeOperationsException(new IllegalArgumentException(
+ "Attribute is null"), "Attribute is null");
+ String name = attribute.getName();
+ Object value = attribute.getValue();
+ if (name == null)
+ throw new RuntimeOperationsException(new IllegalArgumentException(
+ "Attribute name is null"), "Attribute name is null");
+
+ try {
+ Connector connector = (Connector) getManagedResource();
+ IntrospectionUtils.setProperty(connector, name, String.valueOf(value));
+ } catch (InstanceNotFoundException e) {
+ throw new MBeanException(e);
+ } catch (InvalidTargetObjectTypeException e) {
+ throw new MBeanException(e);
+ }
+
+ }
+
+
+ /**
+ * Return the fully qualified Java class name of the managed object
+ * for this MBean.
+ */
+ public String getClassName() {
+
+ return (this.resource.getClass().getName());
+
+ }
+
+
+}
Modified: trunk/java/org/apache/catalina/connector/mbeans-descriptors.xml
===================================================================
--- trunk/java/org/apache/catalina/connector/mbeans-descriptors.xml 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/connector/mbeans-descriptors.xml 2010-03-12 12:52:22 UTC (rev 1407)
@@ -2,7 +2,7 @@
<mbeans-descriptors>
<mbean name="CoyoteConnector"
- className="org.apache.catalina.mbeans.ConnectorMBean"
+ className="org.apache.catalina.connector.ConnectorMBean"
description="Implementation of a Coyote connector"
domain="Catalina"
group="Connector"
Modified: trunk/java/org/apache/catalina/core/ContainerBase.java
===================================================================
--- trunk/java/org/apache/catalina/core/ContainerBase.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/core/ContainerBase.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -43,7 +43,6 @@
import org.apache.catalina.ContainerEvent;
import org.apache.catalina.ContainerListener;
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;
@@ -256,12 +255,6 @@
/**
- * The JarRepository with which this Container is associated.
- */
- protected JarRepository jarRepository = null;
-
-
- /**
* The string manager for this package.
*/
protected static StringManager sm =
@@ -729,63 +722,6 @@
/**
- * Return the JarRepository with which this Container is associated. If there is
- * no associated JarRepository, return the JarRepository associated with our parent
- * Container (if any); otherwise return <code>null</code>.
- */
- public JarRepository getJarRepository() {
-
- if (jarRepository != null)
- return (jarRepository);
- if (parent != null)
- return (parent.getJarRepository());
- return (null);
-
- }
-
-
- /**
- * Set the JarRepository with which this Container is associated.
- *
- * @param jarRepository The newly associated JarRepository
- */
- public synchronized void setJarRepository(JarRepository jarRepository) {
-
- // Change components if necessary
- JarRepository oldJarRepository = this.jarRepository;
- if (oldJarRepository == jarRepository)
- return;
- this.jarRepository = jarRepository;
-
- // Stop the old component if necessary
- if (started && (oldJarRepository != null) &&
- (oldJarRepository instanceof Lifecycle)) {
- try {
- ((Lifecycle) oldJarRepository).stop();
- } catch (LifecycleException e) {
- log.error("ContainerBase.setJarRepository: stop: ", e);
- }
- }
-
- // Start the new component if necessary
- if (jarRepository != null)
- jarRepository.setContainer(this);
- if (started && (jarRepository != null) &&
- (jarRepository instanceof Lifecycle)) {
- try {
- ((Lifecycle) jarRepository).start();
- } catch (LifecycleException e) {
- log.error("ContainerBase.setJarRepository: start: ", e);
- }
- }
-
- // Report this property change to interested listeners
- support.firePropertyChange("jarRepository", oldJarRepository, this.jarRepository);
-
- }
-
-
- /**
* Return the resources DirContext object with which this Container is
* associated. If there is no associated resources object, return the
* resources associated with our parent Container (if any); otherwise
@@ -1085,8 +1021,6 @@
started = true;
// Start our subordinate components, if any
- if ((jarRepository != null) && (jarRepository instanceof Lifecycle))
- ((Lifecycle) jarRepository).start();
if ((loader != null) && (loader instanceof Lifecycle))
((Lifecycle) loader).start();
logger = null;
@@ -1186,9 +1120,6 @@
if ((loader != null) && (loader instanceof Lifecycle)) {
((Lifecycle) loader).stop();
}
- if ((jarRepository != null) && (jarRepository instanceof Lifecycle)) {
- ((Lifecycle) jarRepository).stop();
- }
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
@@ -1392,13 +1323,6 @@
log.warn(sm.getString("containerBase.backgroundProcess.realm", realm), e);
}
}
- if (jarRepository != null) {
- try {
- jarRepository.backgroundProcess();
- } catch (Exception e) {
- log.warn(sm.getString("containerBase.backgroundProcess.jarRepository", jarRepository), e);
- }
- }
Valve current = pipeline.getFirst();
while (current != null) {
try {
Deleted: trunk/java/org/apache/catalina/core/ContextJarRepository.java
===================================================================
--- trunk/java/org/apache/catalina/core/ContextJarRepository.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/core/ContextJarRepository.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,592 +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.
- *
- *
- * 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.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.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;
-
-
-/**
- * Context specific implementation for a JAR repository, which will manage
- * JARs from /WEB-INF/lib in an efficient way.
- *
- * @author Remy Maucherat
- */
-public class ContextJarRepository
- implements JarRepository, Contained, Lifecycle {
-
- private static Logger log = Logger.getLogger(ContextJarRepository.class);
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a new ContextJarRepository instance with no associated Container.
- */
- public ContextJarRepository() {
-
- this(null);
-
- }
-
-
- /**
- * Construct a new ContextJarRepository instance that is associated with the
- * specified Container.
- *
- * @param container The container we should be associated with
- */
- public ContextJarRepository(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.ContextJarRepository/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;
-
-
- /**
- * Classes path, which is essentially an exploded Jar.
- */
- protected String classesPath = "/WEB-INF/classes";
-
-
- /**
- * Library path.
- */
- protected String libPath = "/WEB-INF/lib";
-
-
- /**
- * Map for the JarFile instances.
- */
- protected Map<String, JarFile> jarFiles = new HashMap<String, JarFile>();
-
-
- /**
- * Array of the JarFiles, as convenience.
- */
- protected JarFile[] jarFilesArray = new JarFile[0];
-
-
- /**
- * Map for the File instances.
- */
- protected Map<String, File> explodedJars = new HashMap<String, File>();
-
-
- /**
- * Array of the exploded Jars, as convenience.
- */
- protected File[] explodedJarsArray = new File[0];
-
-
- /**
- * Delete temp Jars.
- */
- protected boolean tempJars = false;
-
-
- /**
- * Delete temp exploded Jars.
- */
- protected boolean tempExplodedJars = 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;
-
- if (!(container instanceof Context))
- throw new IllegalStateException("");
- DirContext resources = container.getResources();
- ServletContext servletContext = ((Context) container).getServletContext();
- if (servletContext == null)
- return;
-
- // Access work directory
- File workDir = (File) servletContext.getAttribute(ServletContext.TEMPDIR);
- if (workDir == null) {
- // FIXME: this is actually an error
- log.info("No work dir for " + servletContext);
- }
-
- // Looking up directory /WEB-INF/lib in the context
- NamingEnumeration<Binding> libPathListing = null;
- try {
- libPathListing = resources.listBindings(libPath);
- } catch (NamingException e) {
- // Silent catch: it's valid that no /WEB-INF/lib collection exists
- }
- if (libPathListing != null) {
- String absoluteLibPath = servletContext.getRealPath(libPath);
- File destDir = null;
- if (absoluteLibPath != null) {
- destDir = new File(absoluteLibPath);
- } else {
- tempJars = true;
- destDir = new File(workDir, libPath);
- destDir.mkdirs();
- }
- while (libPathListing.hasMoreElements()) {
- Binding binding = libPathListing.nextElement();
- String logicalName = libPath + "/" + binding.getName();
- if (!logicalName.endsWith(".jar"))
- continue;
- // Copy JAR in the work directory, always (the JAR file
- // would get locked otherwise, which would make it
- // impossible to update it or remove it at runtime)
- File destFile = new File(destDir, binding.getName());
- Object obj = binding.getObject();
- if (!(obj instanceof Resource))
- continue;
- Resource jarResource = (Resource) obj;
- try {
- if (tempJars) {
- InputStream is = null;
- OutputStream os = null;
- try {
- is = jarResource.streamContent();
- os = new FileOutputStream(destFile);
- IOTools.flow(is, os);
- // Don't catch IOE - let the outer try/catch handle it
- } finally {
- try {
- if (is != null) is.close();
- } catch (IOException e){
- // Ignore
- }
- try {
- if (os != null) os.close();
- } catch (IOException e){
- // Ignore
- }
- }
- }
- JarFile jarFile = new JarFile(destFile);
- jarFiles.put(logicalName, jarFile);
- } catch (IOException ex) {
- // Catch the exception if there is an empty jar file,
- // or if the JAR cannot be copied to temp
- // FIXME: throw an error, as the webapp will not run
- }
- }
-
- }
- jarFilesArray = jarFiles.values().toArray(jarFilesArray);
-
- // Setting up the class repository (/WEB-INF/classes), if it exists
- DirContext classes = null;
- try {
- Object object = resources.lookup(classesPath);
- if (object instanceof DirContext) {
- classes = (DirContext) object;
- }
- } catch(NamingException e) {
- // Silent catch: it's valid that no /WEB-INF/classes collection
- // exists
- }
- if (classes != null) {
- File classRepository = null;
- String absoluteClassesPath = servletContext.getRealPath(classesPath);
- if (absoluteClassesPath != null) {
- classRepository = new File(absoluteClassesPath);
- } else {
- classRepository = new File(workDir, classesPath);
- classRepository.mkdirs();
- tempExplodedJars = true;
- try {
- copyDirContext(classes, classRepository);
- } catch (NamingException ex) {
- // Catch the exception if there is an empty jar file,
- // or if the JAR cannot be copied to temp
- // FIXME: throw an error, as the webapp will not run
- } catch (IOException ex) {
- // Catch the exception if there is an empty jar file,
- // or if the JAR cannot be copied to temp
- // FIXME: throw an error, as the webapp will not run
- }
- }
- // Adding the repository to the class loader
- explodedJarsArray = new File[] { classRepository };
- explodedJars.put(classesPath + "/", classRepository);
- }
-
- // 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;
-
- // Close JARs and delete temporary copies if needed
- try {
- for (int i = 0; i < jarFilesArray.length; i++) {
- jarFilesArray[i].close();
- if (tempJars) {
- (new File(jarFilesArray[i].getName())).delete();
- }
- }
- } catch (IOException ex) {
- // Catch the exception if there is an empty jar file,
- // or if the JAR cannot be copied to temp
- // FIXME: throw an error, as webapp will not run
- }
- jarFiles.clear();
- jarFilesArray = new JarFile[0];
- tempJars = false;
- explodedJars.clear();
- explodedJarsArray = new File[0];
- // FIXME: delete exploded copy
- tempExplodedJars = 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 jarFiles;
- }
-
-
- /**
- * Find the JarFile corresponding to the path.
- *
- * @return the JarFile, or null if not found
- */
- public JarFile findJar(String path) {
- for (int i = 0; i < jarFilesArray.length; i++) {
- if (jarFilesArray[i].getName().equals(path)) {
- return jarFilesArray[i];
- }
- }
- return null;
- }
-
-
- /**
- * Find all JarFile managed by the JARRepository.
- *
- * @return All JarFile
- */
- public JarFile[] findJars() {
- return jarFilesArray;
- }
-
-
- /**
- * Get the exploded Jar map.
- *
- * @return the Jar map, associating logical name with File
- */
- public Map<String, File> getExplodedJars() {
- return explodedJars;
- }
-
-
- /**
- * Find all exploded Jars managed by the JARRepository.
- *
- * @return All exploded File
- */
- public File[] findExplodedJars() {
- return explodedJarsArray;
- }
-
-
- /**
- * Copy directory.
- */
- protected void copyDirContext(DirContext srcDir, File destDir)
- throws IOException, NamingException {
- InputStream is = null;
- OutputStream os = null;
- NamingEnumeration<NameClassPair> enumeration = srcDir.list("");
- while (enumeration.hasMoreElements()) {
- NameClassPair ncPair = enumeration.nextElement();
- String name = ncPair.getName();
- Object object = srcDir.lookup(name);
- File currentFile = new File(destDir, name);
- if (object instanceof Resource) {
- try {
- is = ((Resource) object).streamContent();
- os = new FileOutputStream(currentFile);
- IOTools.flow(is, os);
- // Don't catch IOE - let the outer try/catch handle it
- } finally {
- try {
- if (is != null) is.close();
- } catch (IOException e){
- // Ignore
- }
- try {
- if (os != null) os.close();
- } catch (IOException e){
- // Ignore
- }
- }
- } else if (object instanceof InputStream) {
- try {
- is = (InputStream) object;
- os = new FileOutputStream(currentFile);
- IOTools.flow(is, os);
- // Don't catch IOE - let the outer try/catch handle it
- } finally {
- try {
- if (is != null) is.close();
- } catch (IOException e){
- // Ignore
- }
- try {
- if (os != null) os.close();
- } catch (IOException e){
- // Ignore
- }
- }
- } else if (object instanceof DirContext) {
- currentFile.mkdir();
- copyDirContext((DirContext) object, currentFile);
- }
- }
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/core/DefaultInstanceManager.java
===================================================================
--- trunk/java/org/apache/catalina/core/DefaultInstanceManager.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/core/DefaultInstanceManager.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,505 +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.core;
-
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Map;
-import java.util.Properties;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedExceptionAction;
-import java.security.PrivilegedActionException;
-import java.io.InputStream;
-import java.io.IOException;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.annotation.Resource;
-import javax.ejb.EJB;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceUnit;
-import javax.xml.ws.WebServiceRef;
-import javax.servlet.Filter;
-import javax.servlet.Servlet;
-
-import org.apache.catalina.security.SecurityUtil;
-import org.apache.catalina.ContainerServlet;
-import org.apache.catalina.Globals;
-import org.apache.catalina.core.Constants;
-import org.apache.catalina.util.StringManager;
-import org.apache.tomcat.InstanceManager;
-
-/**
- * @version $Rev$ $Date$
- */
-public class DefaultInstanceManager implements InstanceManager {
-
- private final Context context;
- private final Map<String, Map<String, String>> injectionMap;
- protected final ClassLoader classLoader;
- protected final ClassLoader containerClassLoader;
- protected boolean privileged;
- protected boolean ignoreAnnotations;
- private Properties restrictedFilters = new Properties();
- private Properties restrictedListeners = new Properties();
- private Properties restrictedServlets = new Properties();
-
- public DefaultInstanceManager(Context context, Map<String, Map<String, String>> injectionMap, org.apache.catalina.Context catalinaContext, ClassLoader containerClassLoader) {
- classLoader = catalinaContext.getLoader().getClassLoader();
- privileged = catalinaContext.getPrivileged();
- this.containerClassLoader = containerClassLoader;
- ignoreAnnotations = catalinaContext.getIgnoreAnnotations();
- StringManager sm = StringManager.getManager(Constants.Package);
- try {
- InputStream is =
- this.getClass().getClassLoader().getResourceAsStream
- ("org/apache/catalina/core/RestrictedServlets.properties");
- if (is != null) {
- restrictedServlets.load(is);
- } else {
- catalinaContext.getLogger().error(sm.getString("defaultInstanceManager.restrictedServletsResource"));
- }
- } catch (IOException e) {
- catalinaContext.getLogger().error(sm.getString("defaultInstanceManager.restrictedServletsResource"), e);
- }
-
- try {
- InputStream is =
- this.getClass().getClassLoader().getResourceAsStream
- ("org/apache/catalina/core/RestrictedListeners.properties");
- if (is != null) {
- restrictedListeners.load(is);
- } else {
- catalinaContext.getLogger().error(sm.getString("defaultInstanceManager.restrictedListenersResources"));
- }
- } catch (IOException e) {
- catalinaContext.getLogger().error(sm.getString("defaultInstanceManager.restrictedListenersResources"), e);
- }
- try {
- InputStream is =
- this.getClass().getClassLoader().getResourceAsStream
- ("org/apache/catalina/core/RestrictedFilters.properties");
- if (is != null) {
- restrictedFilters.load(is);
- } else {
- catalinaContext.getLogger().error(sm.getString("defaultInstanceManager.restrictedFiltersResources"));
- }
- } catch (IOException e) {
- catalinaContext.getLogger().error(sm.getString("defaultInstanceManager.restrictedServletsResources"), e);
- }
- this.context = context;
- this.injectionMap = injectionMap;
- }
-
- public Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException {
- Class<?> clazz = loadClassMaybePrivileged(className, classLoader);
- return newInstance(clazz.newInstance(), clazz);
- }
-
- public Object newInstance(final String className, final ClassLoader classLoader) throws IllegalAccessException, NamingException, InvocationTargetException, InstantiationException, ClassNotFoundException {
- Class<?> clazz = classLoader.loadClass(className);
- return newInstance(clazz.newInstance(), clazz);
- }
-
- public Object newInstance(Class<?> c) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException {
- return newInstance(c.newInstance(), c);
- }
-
- public void newInstance(Object o)
- throws IllegalAccessException, InvocationTargetException, NamingException {
- newInstance(o, o.getClass());
- }
-
- private Object newInstance(Object instance, Class<?> clazz) throws IllegalAccessException, InvocationTargetException, NamingException {
- if (!ignoreAnnotations) {
- Map<String, String> injections = injectionMap.get(clazz.getName());
- processAnnotations(instance, injections);
- postConstruct(instance, clazz);
- }
- return instance;
- }
-
- public void destroyInstance(Object instance) throws IllegalAccessException, InvocationTargetException {
- if (!ignoreAnnotations) {
- preDestroy(instance, instance.getClass());
- }
- }
-
- /**
- * Call postConstruct method on the specified instance recursively from deepest superclass to actual class.
- *
- * @param instance object to call postconstruct methods on
- * @param clazz (super) class to examine for postConstruct annotation.
- * @throws IllegalAccessException if postConstruct method is inaccessible.
- * @throws java.lang.reflect.InvocationTargetException
- * if call fails
- */
- protected void postConstruct(Object instance, final Class<?> clazz)
- throws IllegalAccessException, InvocationTargetException {
- Class<?> superClass = clazz.getSuperclass();
- if (superClass != Object.class) {
- postConstruct(instance, superClass);
- }
-
- Method[] methods = null;
- if (Globals.IS_SECURITY_ENABLED) {
- methods = AccessController.doPrivileged(
- new PrivilegedAction<Method[]>(){
- public Method[] run(){
- return clazz.getDeclaredMethods();
- }
- });
- } else {
- methods = clazz.getDeclaredMethods();
- }
- Method postConstruct = null;
- for (Method method : methods) {
- if (method.isAnnotationPresent(PostConstruct.class)) {
- if ((postConstruct != null)
- || (method.getParameterTypes().length != 0)
- || (Modifier.isStatic(method.getModifiers()))
- || (method.getExceptionTypes().length > 0)
- || (!method.getReturnType().getName().equals("void"))) {
- throw new IllegalArgumentException("Invalid PostConstruct annotation");
- }
- postConstruct = method;
- }
- }
-
- // At the end the postconstruct annotated
- // method is invoked
- if (postConstruct != null) {
- boolean accessibility = postConstruct.isAccessible();
- postConstruct.setAccessible(true);
- postConstruct.invoke(instance);
- postConstruct.setAccessible(accessibility);
- }
-
- }
-
-
- /**
- * Call preDestroy method on the specified instance recursively from deepest superclass to actual class.
- *
- * @param instance object to call preDestroy methods on
- * @param clazz (super) class to examine for preDestroy annotation.
- * @throws IllegalAccessException if preDestroy method is inaccessible.
- * @throws java.lang.reflect.InvocationTargetException
- * if call fails
- */
- protected void preDestroy(Object instance, final Class<?> clazz)
- throws IllegalAccessException, InvocationTargetException {
- Class<?> superClass = clazz.getSuperclass();
- if (superClass != Object.class) {
- preDestroy(instance, superClass);
- }
-
- Method[] methods;
- if (Globals.IS_SECURITY_ENABLED) {
- methods = AccessController.doPrivileged(
- new PrivilegedAction<Method[]>(){
- public Method[] run(){
- return clazz.getDeclaredMethods();
- }
- });
- } else {
- methods = clazz.getDeclaredMethods();
- }
- Method preDestroy = null;
- for (Method method : methods) {
- if (method.isAnnotationPresent(PreDestroy.class)) {
- if ((method.getParameterTypes().length != 0)
- || (Modifier.isStatic(method.getModifiers()))
- || (method.getExceptionTypes().length > 0)
- || (!method.getReturnType().getName().equals("void"))) {
- throw new IllegalArgumentException("Invalid PreDestroy annotation");
- }
- preDestroy = method;
- break;
- }
- }
-
- // At the end the postconstruct annotated
- // method is invoked
- if (preDestroy != null) {
- boolean accessibility = preDestroy.isAccessible();
- preDestroy.setAccessible(true);
- preDestroy.invoke(instance);
- preDestroy.setAccessible(accessibility);
- }
-
- }
-
-
- /**
- * Inject resources in specified instance.
- *
- * @param instance instance to inject into
- * @param injections map of injections for this class from xml deployment descriptor
- * @throws IllegalAccessException if injection target is inaccessible
- * @throws javax.naming.NamingException if value cannot be looked up in jndi
- * @throws java.lang.reflect.InvocationTargetException
- * if injection fails
- */
- protected void processAnnotations(Object instance, Map<String, String> injections)
- throws IllegalAccessException, InvocationTargetException, NamingException {
-
- if (context == null) {
- // No resource injection
- return;
- }
-
- Class<?> clazz = instance.getClass();
-
- while (clazz != null) {
- // Initialize fields annotations
- Field[] fields = null;
- if (Globals.IS_SECURITY_ENABLED) {
- final Class<?> clazz2 = clazz;
- fields = AccessController.doPrivileged(
- new PrivilegedAction<Field[]>(){
- public Field[] run(){
- return clazz2.getDeclaredFields();
- }
- });
- } else {
- fields = clazz.getDeclaredFields();
- }
- for (Field field : fields) {
- if (injections != null && injections.containsKey(field.getName())) {
- lookupFieldResource(context, instance, field,
- injections.get(field.getName()), clazz);
- } else if (field.isAnnotationPresent(Resource.class)) {
- Resource annotation = field.getAnnotation(Resource.class);
- lookupFieldResource(context, instance, field,
- annotation.name(), clazz);
- } else if (field.isAnnotationPresent(EJB.class)) {
- EJB annotation = field.getAnnotation(EJB.class);
- lookupFieldResource(context, instance, field,
- annotation.name(), clazz);
- } else if (field.isAnnotationPresent(WebServiceRef.class)) {
- WebServiceRef annotation =
- field.getAnnotation(WebServiceRef.class);
- lookupFieldResource(context, instance, field,
- annotation.name(), clazz);
- } else if (field.isAnnotationPresent(PersistenceContext.class)) {
- PersistenceContext annotation =
- field.getAnnotation(PersistenceContext.class);
- lookupFieldResource(context, instance, field,
- annotation.name(), clazz);
- } else if (field.isAnnotationPresent(PersistenceUnit.class)) {
- PersistenceUnit annotation =
- field.getAnnotation(PersistenceUnit.class);
- lookupFieldResource(context, instance, field,
- annotation.name(), clazz);
- }
- }
-
- // Initialize methods annotations
- Method[] methods = null;
- if (Globals.IS_SECURITY_ENABLED) {
- final Class<?> clazz2 = clazz;
- methods = AccessController.doPrivileged(
- new PrivilegedAction<Method[]>(){
- public Method[] run(){
- return clazz2.getDeclaredMethods();
- }
- });
- } else {
- methods = clazz.getDeclaredMethods();
- }
- for (Method method : methods) {
- String methodName = method.getName();
- if (injections != null && methodName.startsWith("set") && methodName.length() > 3) {
- String fieldName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4);
- if (injections.containsKey(fieldName)) {
- lookupMethodResource(context, instance, method,
- injections.get(fieldName), clazz);
- break;
- }
- }
- if (method.isAnnotationPresent(Resource.class)) {
- Resource annotation = method.getAnnotation(Resource.class);
- lookupMethodResource(context, instance, method,
- annotation.name(), clazz);
- } else if (method.isAnnotationPresent(EJB.class)) {
- EJB annotation = method.getAnnotation(EJB.class);
- lookupMethodResource(context, instance, method,
- annotation.name(), clazz);
- } else if (method.isAnnotationPresent(WebServiceRef.class)) {
- WebServiceRef annotation =
- method.getAnnotation(WebServiceRef.class);
- lookupMethodResource(context, instance, method,
- annotation.name(), clazz);
- } else if (method.isAnnotationPresent(PersistenceContext.class)) {
- PersistenceContext annotation =
- method.getAnnotation(PersistenceContext.class);
- lookupMethodResource(context, instance, method,
- annotation.name(), clazz);
- } else if (method.isAnnotationPresent(PersistenceUnit.class)) {
- PersistenceUnit annotation =
- method.getAnnotation(PersistenceUnit.class);
- lookupMethodResource(context, instance, method,
- annotation.name(), clazz);
- }
- }
- clazz = clazz.getSuperclass();
- }
-
- }
-
-
- protected Class<?> loadClassMaybePrivileged(final String className, final ClassLoader classLoader) throws ClassNotFoundException {
- Class<?> clazz;
- if (SecurityUtil.isPackageProtectionEnabled()) {
- try {
- clazz = AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
-
- public Class<?> run() throws Exception {
- return loadClass(className, classLoader);
- }
- });
- } catch (PrivilegedActionException e) {
- Throwable t = e.getCause();
- if (t instanceof ClassNotFoundException) {
- throw (ClassNotFoundException) t;
- }
- throw new RuntimeException(t);
- }
- } else {
- clazz = loadClass(className, classLoader);
- }
- checkAccess(clazz);
- return clazz;
- }
-
- protected Class<?> loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
- if (className.startsWith("org.apache.catalina")) {
- return containerClassLoader.loadClass(className);
- }
- try {
- Class<?> clazz = containerClassLoader.loadClass(className);
- if (ContainerServlet.class.isAssignableFrom(clazz)) {
- return clazz;
- }
- } catch (Throwable t) {
- //ignore
- }
- return classLoader.loadClass(className);
- }
-
- private void checkAccess(Class<?> clazz) {
- if (privileged) return;
- if (Filter.class.isAssignableFrom(clazz)) {
- checkAccess(clazz, restrictedFilters);
- } else if (Servlet.class.isAssignableFrom(clazz)) {
- checkAccess(clazz, restrictedServlets);
- } else {
- checkAccess(clazz, restrictedListeners);
- }
- }
-
- private void checkAccess(Class<?> clazz, Properties restricted) {
- while (clazz != null) {
- if ("restricted".equals(restricted.getProperty(clazz.getName()))) {
- throw new SecurityException("Restricted class" + clazz);
- }
- clazz = clazz.getSuperclass();
- }
-
- }
-
- /**
- * Inject resources in specified field.
- *
- * @param context jndi context to extract value from
- * @param instance object to inject into
- * @param field field target for injection
- * @param name jndi name value is bound under
- * @param clazz class annotation is defined in
- * @throws IllegalAccessException if field is inaccessible
- * @throws javax.naming.NamingException if value is not accessible in naming context
- */
- protected static void lookupFieldResource(Context context,
- Object instance, Field field, String name, Class<?> clazz)
- throws NamingException, IllegalAccessException {
-
- Object lookedupResource;
- boolean accessibility;
-
- if ((name != null) &&
- (name.length() > 0)) {
- lookedupResource = context.lookup(name);
- } else {
- lookedupResource =
- context.lookup(clazz.getName() + "/" + field.getName());
- }
-
- accessibility = field.isAccessible();
- field.setAccessible(true);
- field.set(instance, lookedupResource);
- field.setAccessible(accessibility);
- }
-
- /**
- * Inject resources in specified method.
- *
- * @param context jndi context to extract value from
- * @param instance object to inject into
- * @param method field target for injection
- * @param name jndi name value is bound under
- * @param clazz class annotation is defined in
- * @throws IllegalAccessException if method is inaccessible
- * @throws javax.naming.NamingException if value is not accessible in naming context
- * @throws java.lang.reflect.InvocationTargetException
- * if setter call fails
- */
- protected static void lookupMethodResource(Context context,
- Object instance, Method method, String name, Class<?> clazz)
- throws NamingException, IllegalAccessException, InvocationTargetException {
-
- if (!method.getName().startsWith("set")
- || method.getParameterTypes().length != 1
- || !method.getReturnType().getName().equals("void")) {
- throw new IllegalArgumentException("Invalid method resource injection annotation");
- }
-
- Object lookedupResource;
- boolean accessibility;
-
- if ((name != null) &&
- (name.length() > 0)) {
- lookedupResource = context.lookup(name);
- } else {
- lookedupResource = context.lookup(
- clazz.getName() + "/" + method.getName().substring(3));
- }
-
- accessibility = method.isAccessible();
- method.setAccessible(true);
- method.invoke(instance, lookedupResource);
- method.setAccessible(accessibility);
- }
-}
Deleted: trunk/java/org/apache/catalina/core/NamingContextListener.java
===================================================================
--- trunk/java/org/apache/catalina/core/NamingContextListener.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/core/NamingContextListener.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,1211 +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.core;
-
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.StringTokenizer;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.naming.NameAlreadyBoundException;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.ContainerEvent;
-import org.apache.catalina.ContainerListener;
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Host;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.Server;
-import org.apache.catalina.Service;
-import org.apache.catalina.deploy.ContextEjb;
-import org.apache.catalina.deploy.ContextEnvironment;
-import org.apache.catalina.deploy.ContextHandler;
-import org.apache.catalina.deploy.ContextLocalEjb;
-import org.apache.catalina.deploy.ContextResource;
-import org.apache.catalina.deploy.ContextResourceEnvRef;
-import org.apache.catalina.deploy.ContextResourceLink;
-import org.apache.catalina.deploy.ContextService;
-import org.apache.catalina.deploy.ContextTransaction;
-import org.apache.catalina.deploy.NamingResources;
-import org.apache.catalina.util.StringManager;
-import org.apache.naming.ContextAccessController;
-import org.apache.naming.ContextBindings;
-import org.apache.naming.EjbRef;
-import org.apache.naming.HandlerRef;
-import org.apache.naming.NamingContext;
-import org.apache.naming.ResourceEnvRef;
-import org.apache.naming.ResourceLinkRef;
-import org.apache.naming.ResourceRef;
-import org.apache.naming.ServiceRef;
-import org.apache.naming.TransactionRef;
-import org.apache.tomcat.util.modeler.Registry;
-import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
-
-
-/**
- * Helper class used to initialize and populate the JNDI context associated
- * with each context and server.
- *
- * @author Remy Maucherat
- * @version $Revision$ $Date$
- */
-
-public class NamingContextListener
- implements LifecycleListener, ContainerListener, PropertyChangeListener {
-
- private static Logger log = Logger.getLogger(NamingContextListener.class);
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- protected Logger logger = log;
-
-
- /**
- * Name of the associated naming context.
- */
- protected String name = "/";
-
-
- /**
- * Associated container.
- */
- protected Object container = null;
-
-
- /**
- * Initialized flag.
- */
- protected boolean initialized = false;
-
-
- /**
- * Associated naming resources.
- */
- protected NamingResources namingResources = null;
-
-
- /**
- * Associated JNDI context.
- */
- protected NamingContext namingContext = null;
-
-
- /**
- * Comp context.
- */
- protected javax.naming.Context compCtx = null;
-
-
- /**
- * Env context.
- */
- protected javax.naming.Context envCtx = null;
-
-
- /**
- * Objectnames hashtable.
- */
- protected HashMap objectNames = new HashMap();
-
-
- /**
- * The string manager for this package.
- */
- protected static StringManager sm =
- StringManager.getManager(Constants.Package);
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return the "name" property.
- */
- public String getName() {
- return (this.name);
- }
-
-
- /**
- * Set the "name" property.
- *
- * @param name The new name
- */
- public void setName(String name) {
- this.name = name;
- }
-
-
- /**
- * Return the comp context.
- */
- public javax.naming.Context getCompContext() {
- return this.compCtx;
- }
-
-
- /**
- * Return the env context.
- */
- public javax.naming.Context getEnvContext() {
- return this.envCtx;
- }
-
-
- /**
- * Return the associated naming context.
- */
- public NamingContext getNamingContext() {
- return (this.namingContext);
- }
-
-
- // ---------------------------------------------- LifecycleListener Methods
-
-
- /**
- * Acknowledge the occurrence of the specified event.
- *
- * @param event LifecycleEvent that has occurred
- */
- public void lifecycleEvent(LifecycleEvent event) {
-
- container = event.getLifecycle();
-
- if (container instanceof Context) {
- namingResources = ((Context) container).getNamingResources();
- logger = log;
- } else if (container instanceof Server) {
- namingResources = ((Server) container).getGlobalNamingResources();
- } else {
- return;
- }
-
- if (event.getType() == Lifecycle.START_EVENT) {
-
- if (initialized)
- return;
-
- Hashtable contextEnv = new Hashtable();
- try {
- namingContext = new NamingContext(contextEnv, getName());
- } catch (NamingException e) {
- // Never happens
- }
- ContextAccessController.setSecurityToken(getName(), container);
- ContextBindings.bindContext(container, namingContext, container);
- if( log.isDebugEnabled() ) {
- log.debug("Bound " + container );
- }
-
- // Setting the context in read/write mode
- ContextAccessController.setWritable(getName(), container);
-
- try {
- createNamingContext();
- } catch (NamingException e) {
- logger.error
- (sm.getString("naming.namingContextCreationFailed", e));
- }
-
- // Binding the naming context to the class loader
- if (container instanceof Context) {
- // Setting the context in read only mode
- ContextAccessController.setReadOnly(getName());
- try {
- ContextBindings.bindClassLoader
- (container, container,
- ((Container) container).getLoader().getClassLoader());
- } catch (NamingException e) {
- logger.error(sm.getString("naming.bindFailed", e));
- }
- }
-
- if (container instanceof Server) {
- namingResources.addPropertyChangeListener(this);
- org.apache.naming.factory.ResourceLinkFactory.setGlobalContext
- (namingContext);
- try {
- ContextBindings.bindClassLoader
- (container, container,
- this.getClass().getClassLoader());
- } catch (NamingException e) {
- logger.error(sm.getString("naming.bindFailed", e));
- }
- if (container instanceof StandardServer) {
- ((StandardServer) container).setGlobalNamingContext
- (namingContext);
- }
- }
-
- initialized = true;
-
- } else if (event.getType() == Lifecycle.STOP_EVENT) {
-
- if (!initialized)
- return;
-
- // Setting the context in read/write mode
- ContextAccessController.setWritable(getName(), container);
- ContextBindings.unbindContext(container, container);
-
- if (container instanceof Context) {
- ContextBindings.unbindClassLoader
- (container, container,
- ((Container) container).getLoader().getClassLoader());
- }
-
- if (container instanceof Server) {
- namingResources.removePropertyChangeListener(this);
- ContextBindings.unbindClassLoader
- (container, container,
- this.getClass().getClassLoader());
- }
-
- ContextAccessController.unsetSecurityToken(getName(), container);
-
- namingContext = null;
- envCtx = null;
- compCtx = null;
- initialized = false;
-
- }
-
- }
-
-
- // ---------------------------------------------- ContainerListener Methods
-
-
- /**
- * Acknowledge the occurrence of the specified event.
- * Note: Will never be called when the listener is associated to a Server,
- * since it is not a Container.
- *
- * @param event ContainerEvent that has occurred
- */
- public void containerEvent(ContainerEvent event) {
-
- if (!initialized)
- return;
-
- // Setting the context in read/write mode
- ContextAccessController.setWritable(getName(), container);
-
- String type = event.getType();
-
- if (type.equals("addEjb")) {
-
- String ejbName = (String) event.getData();
- if (ejbName != null) {
- ContextEjb ejb = namingResources.findEjb(ejbName);
- addEjb(ejb);
- }
-
- } else if (type.equals("addEnvironment")) {
-
- String environmentName = (String) event.getData();
- if (environmentName != null) {
- ContextEnvironment env =
- namingResources.findEnvironment(environmentName);
- addEnvironment(env);
- }
-
- } else if (type.equals("addLocalEjb")) {
-
- String localEjbName = (String) event.getData();
- if (localEjbName != null) {
- ContextLocalEjb localEjb =
- namingResources.findLocalEjb(localEjbName);
- addLocalEjb(localEjb);
- }
-
- } else if (type.equals("addResource")) {
-
- String resourceName = (String) event.getData();
- if (resourceName != null) {
- ContextResource resource =
- namingResources.findResource(resourceName);
- addResource(resource);
- }
-
- } else if (type.equals("addResourceLink")) {
-
- String resourceLinkName = (String) event.getData();
- if (resourceLinkName != null) {
- ContextResourceLink resourceLink =
- namingResources.findResourceLink(resourceLinkName);
- addResourceLink(resourceLink);
- }
-
- } else if (type.equals("addResourceEnvRef")) {
-
- String resourceEnvRefName = (String) event.getData();
- if (resourceEnvRefName != null) {
- ContextResourceEnvRef resourceEnvRef =
- namingResources.findResourceEnvRef(resourceEnvRefName);
- addResourceEnvRef(resourceEnvRef);
- }
-
- } else if (type.equals("addService")) {
-
- String serviceName = (String) event.getData();
- if (serviceName != null) {
- ContextService service =
- namingResources.findService(serviceName);
- addService(service);
- }
-
- } else if (type.equals("removeEjb")) {
-
- String ejbName = (String) event.getData();
- if (ejbName != null) {
- removeEjb(ejbName);
- }
-
- } else if (type.equals("removeEnvironment")) {
-
- String environmentName = (String) event.getData();
- if (environmentName != null) {
- removeEnvironment(environmentName);
- }
-
- } else if (type.equals("removeLocalEjb")) {
-
- String localEjbName = (String) event.getData();
- if (localEjbName != null) {
- removeLocalEjb(localEjbName);
- }
-
- } else if (type.equals("removeResource")) {
-
- String resourceName = (String) event.getData();
- if (resourceName != null) {
- removeResource(resourceName);
- }
-
- } else if (type.equals("removeResourceLink")) {
-
- String resourceLinkName = (String) event.getData();
- if (resourceLinkName != null) {
- removeResourceLink(resourceLinkName);
- }
-
- } else if (type.equals("removeResourceEnvRef")) {
-
- String resourceEnvRefName = (String) event.getData();
- if (resourceEnvRefName != null) {
- removeResourceEnvRef(resourceEnvRefName);
- }
-
- } else if (type.equals("removeService")) {
-
- String serviceName = (String) event.getData();
- if (serviceName != null) {
- removeService(serviceName);
- }
-
- }
-
- // Setting the context in read only mode
- ContextAccessController.setReadOnly(getName());
-
- }
-
-
- // ----------------------------------------- PropertyChangeListener Methods
-
-
- /**
- * Process property change events. Currently, only listens to such events
- * on the <code>NamingResources</code> instance for the global naming
- * resources.
- *
- * @param event The property change event that has occurred
- */
- public void propertyChange(PropertyChangeEvent event) {
-
- if (!initialized)
- return;
-
- Object source = event.getSource();
- if (source == namingResources) {
-
- // Setting the context in read/write mode
- ContextAccessController.setWritable(getName(), container);
-
- processGlobalResourcesChange(event.getPropertyName(),
- event.getOldValue(),
- event.getNewValue());
-
- // Setting the context in read only mode
- ContextAccessController.setReadOnly(getName());
-
- }
-
- }
-
-
- // -------------------------------------------------------- Private Methods
-
-
- /**
- * Process a property change on the global naming resources, by making the
- * corresponding addition or removal to the associated JNDI context.
- *
- * @param name Property name of the change to be processed
- * @param oldValue The old value (or <code>null</code> if adding)
- * @param newValue The new value (or <code>null</code> if removing)
- */
- private void processGlobalResourcesChange(String name,
- Object oldValue,
- Object newValue) {
-
- // NOTE - It seems that the Context for global JNDI resources
- // is left in read-write mode, so we do not have to change it here
-
- if (name.equals("ejb")) {
- if (oldValue != null) {
- ContextEjb ejb = (ContextEjb) oldValue;
- if (ejb.getName() != null) {
- removeEjb(ejb.getName());
- }
- }
- if (newValue != null) {
- ContextEjb ejb = (ContextEjb) newValue;
- if (ejb.getName() != null) {
- addEjb(ejb);
- }
- }
- } else if (name.equals("environment")) {
- if (oldValue != null) {
- ContextEnvironment env = (ContextEnvironment) oldValue;
- if (env.getName() != null) {
- removeEnvironment(env.getName());
- }
- }
- if (newValue != null) {
- ContextEnvironment env = (ContextEnvironment) newValue;
- if (env.getName() != null) {
- addEnvironment(env);
- }
- }
- } else if (name.equals("localEjb")) {
- if (oldValue != null) {
- ContextLocalEjb ejb = (ContextLocalEjb) oldValue;
- if (ejb.getName() != null) {
- removeLocalEjb(ejb.getName());
- }
- }
- if (newValue != null) {
- ContextLocalEjb ejb = (ContextLocalEjb) newValue;
- if (ejb.getName() != null) {
- addLocalEjb(ejb);
- }
- }
- } else if (name.equals("resource")) {
- if (oldValue != null) {
- ContextResource resource = (ContextResource) oldValue;
- if (resource.getName() != null) {
- removeResource(resource.getName());
- }
- }
- if (newValue != null) {
- ContextResource resource = (ContextResource) newValue;
- if (resource.getName() != null) {
- addResource(resource);
- }
- }
- } else if (name.equals("resourceEnvRef")) {
- if (oldValue != null) {
- ContextResourceEnvRef resourceEnvRef =
- (ContextResourceEnvRef) oldValue;
- if (resourceEnvRef.getName() != null) {
- removeResourceEnvRef(resourceEnvRef.getName());
- }
- }
- if (newValue != null) {
- ContextResourceEnvRef resourceEnvRef =
- (ContextResourceEnvRef) newValue;
- if (resourceEnvRef.getName() != null) {
- addResourceEnvRef(resourceEnvRef);
- }
- }
- } else if (name.equals("resourceLink")) {
- if (oldValue != null) {
- ContextResourceLink rl = (ContextResourceLink) oldValue;
- if (rl.getName() != null) {
- removeResourceLink(rl.getName());
- }
- }
- if (newValue != null) {
- ContextResourceLink rl = (ContextResourceLink) newValue;
- if (rl.getName() != null) {
- addResourceLink(rl);
- }
- }
- } else if (name.equals("service")) {
- if (oldValue != null) {
- ContextService service = (ContextService) oldValue;
- if (service.getName() != null) {
- removeService(service.getName());
- }
- }
- if (newValue != null) {
- ContextService service = (ContextService) newValue;
- if (service.getName() != null) {
- addService(service);
- }
- }
- }
-
-
- }
-
-
- /**
- * Create and initialize the JNDI naming context.
- */
- private void createNamingContext()
- throws NamingException {
-
- // Creating the comp subcontext
- if (container instanceof Server) {
- compCtx = namingContext;
- envCtx = namingContext;
- } else {
- compCtx = namingContext.createSubcontext("comp");
- envCtx = compCtx.createSubcontext("env");
- }
-
- int i;
-
- if (log.isDebugEnabled())
- log.debug("Creating JNDI naming context");
-
- if (namingResources == null) {
- namingResources = new NamingResources();
- namingResources.setContainer(container);
- }
-
- // Resource links
- ContextResourceLink[] resourceLinks =
- namingResources.findResourceLinks();
- for (i = 0; i < resourceLinks.length; i++) {
- addResourceLink(resourceLinks[i]);
- }
-
- // Resources
- ContextResource[] resources = namingResources.findResources();
- for (i = 0; i < resources.length; i++) {
- addResource(resources[i]);
- }
-
- // Resources Env
- ContextResourceEnvRef[] resourceEnvRefs = namingResources.findResourceEnvRefs();
- for (i = 0; i < resourceEnvRefs.length; i++) {
- addResourceEnvRef(resourceEnvRefs[i]);
- }
-
- // Environment entries
- ContextEnvironment[] contextEnvironments =
- namingResources.findEnvironments();
- for (i = 0; i < contextEnvironments.length; i++) {
- addEnvironment(contextEnvironments[i]);
- }
-
- // EJB references
- ContextEjb[] ejbs = namingResources.findEjbs();
- for (i = 0; i < ejbs.length; i++) {
- addEjb(ejbs[i]);
- }
-
- // WebServices references
- ContextService[] services = namingResources.findServices();
- for (i = 0; i < services.length; i++) {
- addService(services[i]);
- }
-
- // Binding a User Transaction reference
- if (container instanceof Context) {
- try {
- Reference ref = new TransactionRef();
- compCtx.bind("UserTransaction", ref);
- ContextTransaction transaction = namingResources.getTransaction();
- if (transaction != null) {
- Iterator params = transaction.listProperties();
- while (params.hasNext()) {
- String paramName = (String) params.next();
- String paramValue = (String) transaction.getProperty(paramName);
- StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
- ref.add(refAddr);
- }
- }
- } catch (NameAlreadyBoundException e) {
- // Ignore because UserTransaction was obviously
- // added via ResourceLink
- } catch (NamingException e) {
- logger.error(sm.getString("naming.bindFailed", e));
- }
- }
-
- // Binding the resources directory context
- if (container instanceof Context) {
- try {
- compCtx.bind("Resources",
- ((Container) container).getResources());
- } catch (NamingException e) {
- logger.error(sm.getString("naming.bindFailed", e));
- }
- }
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>ContextResource</code> object.
- *
- * @param resource The resource
- * @return ObjectName The object name
- * @exception MalformedObjectNameException if a name cannot be created
- */
- protected ObjectName createObjectName(ContextResource resource)
- throws MalformedObjectNameException {
-
- String domain = null;
- if (container instanceof StandardServer) {
- domain = ((StandardServer) container).getDomain();
- } else if (container instanceof ContainerBase) {
- domain = ((ContainerBase) container).getDomain();
- }
- if (domain == null) {
- domain = "Catalina";
- }
-
- ObjectName name = null;
- String quotedResourceName = ObjectName.quote(resource.getName());
- if (container instanceof Server) {
- name = new ObjectName(domain + ":type=DataSource" +
- ",class=" + resource.getType() +
- ",name=" + quotedResourceName);
- } else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1)
- path = "/";
- Host host = (Host) ((Context)container).getParent();
- Engine engine = (Engine) host.getParent();
- Service service = engine.getService();
- name = new ObjectName(domain + ":type=DataSource" +
- ",path=" + path +
- ",host=" + host.getName() +
- ",class=" + resource.getType() +
- ",name=" + quotedResourceName);
- }
-
- return (name);
-
- }
-
-
- /**
- * Set the specified EJBs in the naming context.
- */
- public void addEjb(ContextEjb ejb) {
-
- // Create a reference to the EJB.
- Reference ref = new EjbRef
- (ejb.getType(), ejb.getHome(), ejb.getRemote(), ejb.getLink());
- // Adding the additional parameters, if any
- Iterator params = ejb.listProperties();
- while (params.hasNext()) {
- String paramName = (String) params.next();
- String paramValue = (String) ejb.getProperty(paramName);
- StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
- ref.add(refAddr);
- }
- try {
- createSubcontexts(envCtx, ejb.getName());
- envCtx.bind(ejb.getName(), ref);
- } catch (NamingException e) {
- logger.error(sm.getString("naming.bindFailed", e));
- }
-
- }
-
-
- /**
- * Set the specified environment entries in the naming context.
- */
- public void addEnvironment(ContextEnvironment env) {
-
- Object value = null;
- // Instantiating a new instance of the correct object type, and
- // initializing it.
- String type = env.getType();
- try {
- if (type.equals("java.lang.String")) {
- value = env.getValue();
- } else if (type.equals("java.lang.Byte")) {
- if (env.getValue() == null) {
- value = new Byte((byte) 0);
- } else {
- value = Byte.decode(env.getValue());
- }
- } else if (type.equals("java.lang.Short")) {
- if (env.getValue() == null) {
- value = new Short((short) 0);
- } else {
- value = Short.decode(env.getValue());
- }
- } else if (type.equals("java.lang.Integer")) {
- if (env.getValue() == null) {
- value = new Integer(0);
- } else {
- value = Integer.decode(env.getValue());
- }
- } else if (type.equals("java.lang.Long")) {
- if (env.getValue() == null) {
- value = new Long(0);
- } else {
- value = Long.decode(env.getValue());
- }
- } else if (type.equals("java.lang.Boolean")) {
- value = Boolean.valueOf(env.getValue());
- } else if (type.equals("java.lang.Double")) {
- if (env.getValue() == null) {
- value = new Double(0);
- } else {
- value = Double.valueOf(env.getValue());
- }
- } else if (type.equals("java.lang.Float")) {
- if (env.getValue() == null) {
- value = new Float(0);
- } else {
- value = Float.valueOf(env.getValue());
- }
- } else if (type.equals("java.lang.Character")) {
- if (env.getValue() == null) {
- value = new Character((char) 0);
- } else {
- if (env.getValue().length() == 1) {
- value = new Character(env.getValue().charAt(0));
- } else {
- throw new IllegalArgumentException();
- }
- }
- } else {
- logger.error(sm.getString("naming.invalidEnvEntryType", env.getName()));
- }
- } catch (NumberFormatException e) {
- logger.error(sm.getString("naming.invalidEnvEntryValue", env.getName()));
- } catch (IllegalArgumentException e) {
- logger.error(sm.getString("naming.invalidEnvEntryValue", env.getName()));
- }
-
- // Binding the object to the appropriate name
- if (value != null) {
- try {
- if (logger.isDebugEnabled())
- logger.debug(" Adding environment entry " + env.getName());
- createSubcontexts(envCtx, env.getName());
- envCtx.bind(env.getName(), value);
- } catch (NamingException e) {
- logger.error(sm.getString("naming.invalidEnvEntryValue", e));
- }
- }
-
- }
-
-
- /**
- * Set the specified local EJBs in the naming context.
- */
- public void addLocalEjb(ContextLocalEjb localEjb) {
-
-
-
- }
-
-
- /**
- * Set the specified web service in the naming context.
- */
- public void addService(ContextService service) {
-
- if (service.getWsdlfile() != null) {
- URL wsdlURL = null;
-
- try {
- wsdlURL = new URL(service.getWsdlfile());
- } catch (MalformedURLException e) {
- wsdlURL = null;
- }
- if (wsdlURL == null) {
- try {
- wsdlURL = ((Context) container).
- getServletContext().
- getResource(service.getWsdlfile());
- } catch (MalformedURLException e) {
- wsdlURL = null;
- }
- }
- if (wsdlURL == null) {
- try {
- wsdlURL = ((Context) container).
- getServletContext().
- getResource("/" + service.getWsdlfile());
- logger.debug(" Changing service ref wsdl file for /"
- + service.getWsdlfile());
- } catch (MalformedURLException e) {
- logger.error(sm.getString("naming.wsdlFailed", e));
- }
- }
- if (wsdlURL == null)
- service.setWsdlfile(null);
- else
- service.setWsdlfile(wsdlURL.toString());
- }
-
- if (service.getJaxrpcmappingfile() != null) {
- URL jaxrpcURL = null;
-
- try {
- jaxrpcURL = new URL(service.getJaxrpcmappingfile());
- } catch (MalformedURLException e) {
- jaxrpcURL = null;
- }
- if (jaxrpcURL == null) {
- try {
- jaxrpcURL = ((Context) container).
- getServletContext().
- getResource(service.getJaxrpcmappingfile());
- } catch (MalformedURLException e) {
- jaxrpcURL = null;
- }
- }
- if (jaxrpcURL == null) {
- try {
- jaxrpcURL = ((Context) container).
- getServletContext().
- getResource("/" + service.getJaxrpcmappingfile());
- logger.debug(" Changing service ref jaxrpc file for /"
- + service.getJaxrpcmappingfile());
- } catch (MalformedURLException e) {
- logger.error(sm.getString("naming.wsdlFailed", e));
- }
- }
- if (jaxrpcURL == null)
- service.setJaxrpcmappingfile(null);
- else
- service.setJaxrpcmappingfile(jaxrpcURL.toString());
- }
-
- // Create a reference to the resource.
- Reference ref = new ServiceRef
- (service.getName(), service.getType(), service.getServiceqname(),
- service.getWsdlfile(), service.getJaxrpcmappingfile());
- // Adding the additional port-component-ref, if any
- Iterator portcomponent = service.getServiceendpoints();
- while (portcomponent.hasNext()) {
- String serviceendpoint = (String) portcomponent.next();
- StringRefAddr refAddr = new StringRefAddr(ServiceRef.SERVICEENDPOINTINTERFACE, serviceendpoint);
- ref.add(refAddr);
- String portlink = (String) service.getPortlink(serviceendpoint);
- refAddr = new StringRefAddr(ServiceRef.PORTCOMPONENTLINK, portlink);
- ref.add(refAddr);
- }
- // Adding the additional parameters, if any
- Iterator handlers = service.getHandlers();
- while (handlers.hasNext()) {
- String handlername = (String) handlers.next();
- ContextHandler handler = (ContextHandler) service.getHandler(handlername);
- HandlerRef handlerRef = new HandlerRef(handlername, handler.getHandlerclass());
- Iterator localParts = handler.getLocalparts();
- while (localParts.hasNext()) {
- String localPart = (String) localParts.next();
- String namespaceURI = (String) handler.getNamespaceuri(localPart);
- handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_LOCALPART, localPart));
- handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_NAMESPACE, namespaceURI));
- }
- Iterator params = handler.listProperties();
- while (params.hasNext()) {
- String paramName = (String) params.next();
- String paramValue = (String) handler.getProperty(paramName);
- handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_PARAMNAME, paramName));
- handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_PARAMVALUE, paramValue));
- }
- for (int i = 0; i < handler.getSoapRolesSize(); i++) {
- handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_SOAPROLE, handler.getSoapRole(i)));
- }
- for (int i = 0; i < handler.getPortNamesSize(); i++) {
- handlerRef.add(new StringRefAddr(HandlerRef.HANDLER_PORTNAME, handler.getPortName(i)));
- }
- ((ServiceRef) ref).addHandler(handlerRef);
- }
-
- try {
- if (logger.isDebugEnabled()) {
- logger.debug(" Adding service ref "
- + service.getName() + " " + ref);
- }
- createSubcontexts(envCtx, service.getName());
- envCtx.bind(service.getName(), ref);
- } catch (NamingException e) {
- logger.error(sm.getString("naming.bindFailed", e));
- }
-
- }
-
-
- /**
- * Set the specified resources in the naming context.
- */
- public void addResource(ContextResource resource) {
-
- // Create a reference to the resource.
- Reference ref = new ResourceRef
- (resource.getType(), resource.getDescription(),
- resource.getScope(), resource.getAuth());
- // Adding the additional parameters, if any
- Iterator params = resource.listProperties();
- while (params.hasNext()) {
- String paramName = (String) params.next();
- String paramValue = (String) resource.getProperty(paramName);
- StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
- ref.add(refAddr);
- }
- try {
- if (logger.isDebugEnabled()) {
- logger.debug(" Adding resource ref "
- + resource.getName() + " " + ref);
- }
- createSubcontexts(envCtx, resource.getName());
- envCtx.bind(resource.getName(), ref);
- } catch (NamingException e) {
- logger.error(sm.getString("naming.bindFailed", e));
- }
-
- if ("javax.sql.DataSource".equals(ref.getClassName())) {
- try {
- ObjectName on = createObjectName(resource);
- Object actualResource = envCtx.lookup(resource.getName());
- Registry.getRegistry(null, null).registerComponent(actualResource, on, null);
- objectNames.put(resource.getName(), on);
- } catch (Exception e) {
- logger.warn(sm.getString("naming.jmxRegistrationFailed", e));
- }
- }
-
- }
-
-
- /**
- * Set the specified resources in the naming context.
- */
- public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef) {
-
- // Create a reference to the resource env.
- Reference ref = new ResourceEnvRef(resourceEnvRef.getType());
- // Adding the additional parameters, if any
- Iterator params = resourceEnvRef.listProperties();
- while (params.hasNext()) {
- String paramName = (String) params.next();
- String paramValue = (String) resourceEnvRef.getProperty(paramName);
- StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
- ref.add(refAddr);
- }
- try {
- if (logger.isDebugEnabled())
- log.debug(" Adding resource env ref " + resourceEnvRef.getName());
- createSubcontexts(envCtx, resourceEnvRef.getName());
- envCtx.bind(resourceEnvRef.getName(), ref);
- } catch (NamingException e) {
- logger.error(sm.getString("naming.bindFailed", e));
- }
-
- }
-
-
- /**
- * Set the specified resource link in the naming context.
- */
- public void addResourceLink(ContextResourceLink resourceLink) {
-
- // Create a reference to the resource.
- Reference ref = new ResourceLinkRef
- (resourceLink.getType(), resourceLink.getGlobal());
- javax.naming.Context ctx =
- "UserTransaction".equals(resourceLink.getName())
- ? compCtx : envCtx;
- try {
- if (logger.isDebugEnabled())
- log.debug(" Adding resource link " + resourceLink.getName());
- createSubcontexts(envCtx, resourceLink.getName());
- ctx.bind(resourceLink.getName(), ref);
- } catch (NamingException e) {
- logger.error(sm.getString("naming.bindFailed", e));
- }
-
- }
-
-
- /**
- * Set the specified EJBs in the naming context.
- */
- public void removeEjb(String name) {
-
- try {
- envCtx.unbind(name);
- } catch (NamingException e) {
- logger.error(sm.getString("naming.unbindFailed", e));
- }
-
- }
-
-
- /**
- * Set the specified environment entries in the naming context.
- */
- public void removeEnvironment(String name) {
-
- try {
- envCtx.unbind(name);
- } catch (NamingException e) {
- logger.error(sm.getString("naming.unbindFailed", e));
- }
-
- }
-
-
- /**
- * Set the specified local EJBs in the naming context.
- */
- public void removeLocalEjb(String name) {
-
- try {
- envCtx.unbind(name);
- } catch (NamingException e) {
- logger.error(sm.getString("naming.unbindFailed", e));
- }
-
- }
-
-
- /**
- * Set the specified web services in the naming context.
- */
- public void removeService(String name) {
-
- try {
- envCtx.unbind(name);
- } catch (NamingException e) {
- logger.error(sm.getString("naming.unbindFailed", e));
- }
-
- }
-
-
- /**
- * Set the specified resources in the naming context.
- */
- public void removeResource(String name) {
-
- try {
- envCtx.unbind(name);
- } catch (NamingException e) {
- logger.error(sm.getString("naming.unbindFailed", e));
- }
-
- ObjectName on = (ObjectName) objectNames.get(name);
- if (on != null) {
- Registry.getRegistry(null, null).unregisterComponent(on);
- }
-
- }
-
-
- /**
- * Set the specified resources in the naming context.
- */
- public void removeResourceEnvRef(String name) {
-
- try {
- envCtx.unbind(name);
- } catch (NamingException e) {
- logger.error(sm.getString("naming.unbindFailed", e));
- }
-
- }
-
-
- /**
- * Set the specified resources in the naming context.
- */
- public void removeResourceLink(String name) {
-
- try {
- envCtx.unbind(name);
- } catch (NamingException e) {
- logger.error(sm.getString("naming.unbindFailed", e));
- }
-
- }
-
-
- /**
- * Create all intermediate subcontexts.
- */
- private void createSubcontexts(javax.naming.Context ctx, String name)
- throws NamingException {
- javax.naming.Context currentContext = ctx;
- StringTokenizer tokenizer = new StringTokenizer(name, "/");
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- if ((!token.equals("")) && (tokenizer.hasMoreTokens())) {
- try {
- currentContext = currentContext.createSubcontext(token);
- } catch (NamingException e) {
- // Silent catch. Probably an object is already bound in
- // the context.
- currentContext =
- (javax.naming.Context) currentContext.lookup(token);
- }
- }
- }
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/core/ServerJarRepository.java
===================================================================
--- trunk/java/org/apache/catalina/core/ServerJarRepository.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/core/ServerJarRepository.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,403 +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.
- *
- *
- * 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/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -33,8 +33,6 @@
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
@@ -51,7 +49,6 @@
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
import javax.management.ObjectName;
-import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
@@ -83,26 +80,18 @@
import org.apache.catalina.deploy.ErrorPage;
import org.apache.catalina.deploy.FilterDef;
import org.apache.catalina.deploy.FilterMap;
-import org.apache.catalina.deploy.Injectable;
-import org.apache.catalina.deploy.InjectionTarget;
import org.apache.catalina.deploy.JspPropertyGroup;
import org.apache.catalina.deploy.LoginConfig;
-import org.apache.catalina.deploy.MessageDestination;
-import org.apache.catalina.deploy.MessageDestinationRef;
-import org.apache.catalina.deploy.NamingResources;
import org.apache.catalina.deploy.SecurityCollection;
import org.apache.catalina.deploy.SecurityConstraint;
import org.apache.catalina.deploy.SessionCookie;
-import org.apache.catalina.deploy.WebAbsoluteOrdering;
import org.apache.catalina.deploy.jsp.TagLibraryInfo;
-import org.apache.catalina.loader.WebappLoader;
import org.apache.catalina.session.StandardManager;
import org.apache.catalina.startup.ContextConfig;
import org.apache.catalina.util.CharsetMapper;
import org.apache.catalina.util.ExtensionValidator;
import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.URLEncoder;
-import org.apache.naming.ContextBindings;
import org.apache.naming.resources.BaseDirContext;
import org.apache.naming.resources.DirContextURLStreamHandler;
import org.apache.naming.resources.FileDirContext;
@@ -129,7 +118,7 @@
protected static Logger log = Logger.getLogger(StandardContext.class);
public static final boolean CONFIGBASE_MKDIRS =
- Boolean.valueOf(System.getProperty("org.apache.catalina.core.CONFIGBASE_MKDIRS", "true")).booleanValue();
+ Boolean.valueOf(System.getProperty("org.apache.catalina.core.CONFIGBASE_MKDIRS", "false")).booleanValue();
// ----------------------------------------------------------- Constructors
@@ -270,11 +259,6 @@
protected Authenticator authenticator = null;
/**
- * The absolute ordering used for this Context.
- */
- protected WebAbsoluteOrdering webAbsoluteOrdering = null;
-
- /**
* The application available flag for this Context.
*/
protected boolean available = false;
@@ -488,24 +472,6 @@
/**
- * The naming context listener for this web application.
- */
- protected NamingContextListener namingContextListener = null;
-
-
- /**
- * The naming resources for this web application.
- */
- protected NamingResources namingResources = null;
-
-
- /**
- * The message destinations for this web application.
- */
- protected HashMap<String, MessageDestination> messageDestinations = new HashMap<String, MessageDestination>();
-
-
- /**
* The MIME mappings for this web application, keyed by extension.
*/
protected HashMap<String, String> mimeMappings = new HashMap<String, String>();
@@ -698,12 +664,6 @@
/**
- * JNDI use flag.
- */
- protected boolean useNaming = true;
-
-
- /**
* Filesystem based flag.
*/
protected boolean filesystemBased = false;
@@ -913,22 +873,6 @@
/**
- * Returns true if the internal naming support is used.
- */
- public boolean isUseNaming() {
- return (useNaming);
- }
-
-
- /**
- * Enables or disables naming.
- */
- public void setUseNaming(boolean useNaming) {
- this.useNaming = useNaming;
- }
-
-
- /**
* Returns true if the resources associated with this context are
* filesystem based.
*/
@@ -1063,28 +1007,6 @@
/**
- * Return the absolute ordering that is configured for this context, or
- * null if no absolute ordering has been defined.
- */
- public WebAbsoluteOrdering getWebAbsoluteOrdering() {
- return webAbsoluteOrdering;
- }
-
-
- /**
- * Set the absolute ordering for this context.
- *
- * @param webAbsoluteOrdering the new absolute ordering for this context
- */
- public void setWebAbsoluteOrdering(WebAbsoluteOrdering webAbsoluteOrdering) {
- WebAbsoluteOrdering oldWebAbsoluteOrdering = this.webAbsoluteOrdering;
- this.webAbsoluteOrdering = webAbsoluteOrdering;
- support.firePropertyChange("webAbsoluteOrdering", oldWebAbsoluteOrdering,
- this.webAbsoluteOrdering);
- }
-
-
- /**
* Return the application authenticator for this Context.
*/
public Authenticator getAuthenticator() {
@@ -1610,32 +1532,6 @@
/**
- * Return the naming resources associated with this web application.
- */
- public NamingResources getNamingResources() {
- if (namingResources == null) {
- setNamingResources(new NamingResources());
- }
- return (namingResources);
- }
-
-
- /**
- * Set the naming resources for this web application.
- *
- * @param namingResources The new naming resources
- */
- public void setNamingResources(NamingResources namingResources) {
- // Process the property setting change
- NamingResources oldNamingResources = this.namingResources;
- this.namingResources = namingResources;
- namingResources.setContainer(this);
- support.firePropertyChange("namingResources",
- oldNamingResources, this.namingResources);
- }
-
-
- /**
* Return the context path for this Context.
*/
public String getPath() {
@@ -2539,28 +2435,6 @@
/**
- * Add a message destination for this web application.
- *
- * @param md New message destination
- */
- public void addMessageDestination(MessageDestination md) {
- messageDestinations.put(md.getName(), md);
- fireContainerEvent("addMessageDestination", md.getName());
- }
-
-
- /**
- * Add a message destination reference for this web application.
- *
- * @param mdr New message destination reference
- */
- public void addMessageDestinationRef(MessageDestinationRef mdr) {
- namingResources.addMessageDestinationRef(mdr);
- fireContainerEvent("addMessageDestinationRef", mdr.getName());
- }
-
-
- /**
* Add a new MIME mapping, replacing any existing mapping for
* the specified extension.
*
@@ -2978,51 +2852,6 @@
/**
- * Return the message destination with the specified name, if any;
- * otherwise, return <code>null</code>.
- *
- * @param name Name of the desired message destination
- */
- public MessageDestination findMessageDestination(String name) {
- return ((MessageDestination) messageDestinations.get(name));
- }
-
-
- /**
- * Return the set of defined message destinations for this web
- * application. If none have been defined, a zero-length array
- * is returned.
- */
- public MessageDestination[] findMessageDestinations() {
- MessageDestination results[] =
- new MessageDestination[messageDestinations.size()];
- return ((MessageDestination[])
- messageDestinations.values().toArray(results));
- }
-
-
- /**
- * Return the message destination ref with the specified name, if any;
- * otherwise, return <code>null</code>.
- *
- * @param name Name of the desired message destination ref
- */
- public MessageDestinationRef findMessageDestinationRef(String name) {
- return namingResources.findMessageDestinationRef(name);
- }
-
-
- /**
- * Return the set of defined message destination refs for this web
- * application. If none have been defined, a zero-length array
- * is returned.
- */
- public MessageDestinationRef[] findMessageDestinationRefs() {
- return namingResources.findMessageDestinationRefs();
- }
-
-
- /**
* Return the MIME type to which the specified extension is mapped,
* if any; otherwise return <code>null</code>.
*
@@ -3487,28 +3316,6 @@
/**
- * Remove any message destination with the specified name.
- *
- * @param name Name of the message destination to remove
- */
- public void removeMessageDestination(String name) {
- messageDestinations.remove(name);
- fireContainerEvent("removeMessageDestination", name);
- }
-
-
- /**
- * Remove any message destination ref with the specified name.
- *
- * @param name Name of the message destination ref to remove
- */
- public void removeMessageDestinationRef(String name) {
- namingResources.removeMessageDestinationRef(name);
- fireContainerEvent("removeMessageDestinationRef", name);
- }
-
-
- /**
* Remove the MIME mapping for the specified extension, if it exists;
* otherwise, no action is taken.
*
@@ -4279,12 +4086,6 @@
}
}
- if (getLoader() == null) {
- WebappLoader webappLoader = new WebappLoader(getParentClassLoader());
- webappLoader.setDelegate(getDelegate());
- setLoader(webappLoader);
- }
-
// Initialize character set mapper
getCharsetMapper();
@@ -4306,21 +4107,6 @@
ok = false;
}
- // Reading the "catalina.useNaming" environment variable
- String useNamingProperty = System.getProperty("catalina.useNaming");
- if ((useNamingProperty != null)
- && (useNamingProperty.equals("false"))) {
- useNaming = false;
- }
-
- if (ok && isUseNaming()) {
- if (namingContextListener == null) {
- namingContextListener = new NamingContextListener();
- namingContextListener.setName(getNamingContextName());
- addLifecycleListener(namingContextListener);
- }
- }
-
// Standard container startup
if (log.isDebugEnabled())
log.debug("Processing standard container startup");
@@ -4336,8 +4122,6 @@
started = true;
// Start our subordinate components, if any
- if ((jarRepository != null) && (jarRepository instanceof Lifecycle))
- ((Lifecycle) jarRepository).start();
if ((loader != null) && (loader instanceof Lifecycle))
((Lifecycle) loader).start();
@@ -4416,20 +4200,6 @@
// Binding thread
oldCCL = bindThread();
- // Annotation processor setup
- if (ok) {
- if (instanceManager == null) {
- javax.naming.Context context = null;
- if (isUseNaming() && namingContextListener != null) {
- context = namingContextListener.getEnvContext();
- }
- Map<String, Map<String, String>> injectionMap =
- buildInjectionMap(getIgnoreAnnotations() ? new NamingResources(): getNamingResources());
- instanceManager = new DefaultInstanceManager
- (context, injectionMap, this, this.getClass().getClassLoader());
- }
- }
-
try {
// Create context attributes that will be required
@@ -4540,48 +4310,6 @@
//cacheContext();
}
- protected Map<String, Map<String, String>> buildInjectionMap(NamingResources namingResources) {
- Map<String, Map<String, String>> injectionMap = new HashMap<String, Map<String, String>>();
- for (Injectable resource: namingResources.findLocalEjbs()) {
- addInjectionTarget(resource, injectionMap);
- }
- for (Injectable resource: namingResources.findEjbs()) {
- addInjectionTarget(resource, injectionMap);
- }
- for (Injectable resource: namingResources.findEnvironments()) {
- addInjectionTarget(resource, injectionMap);
- }
- for (Injectable resource: namingResources.findMessageDestinationRefs()) {
- addInjectionTarget(resource, injectionMap);
- }
- for (Injectable resource: namingResources.findResourceEnvRefs()) {
- addInjectionTarget(resource, injectionMap);
- }
- for (Injectable resource: namingResources.findResources()) {
- addInjectionTarget(resource, injectionMap);
- }
- for (Injectable resource: namingResources.findServices()) {
- addInjectionTarget(resource, injectionMap);
- }
- return injectionMap;
- }
-
- protected void addInjectionTarget(Injectable resource, Map<String, Map<String, String>> injectionMap) {
- List<InjectionTarget> injectionTargets = resource.getInjectionTargets();
- if (injectionTargets != null && injectionTargets.size() > 0) {
- String jndiName = resource.getName();
- for (InjectionTarget injectionTarget: injectionTargets) {
- String clazz = injectionTarget.getTargetClass();
- Map<String, String> injections = injectionMap.get(clazz);
- if (injections == null) {
- injections = new HashMap<String, String>();
- injectionMap.put(clazz, injections);
- }
- injections.put(injectionTarget.getTargetName(), jndiName);
- }
- }
- }
-
/**
* Stop this Context component.
*
@@ -4870,15 +4598,6 @@
DirContextURLStreamHandler.bind(getResources());
- if (isUseNaming()) {
- try {
- ContextBindings.bindThread(this, this);
- } catch (NamingException e) {
- // Silent catch, as this is a normal case during the early
- // startup stages
- }
- }
-
return oldContextClassLoader;
}
@@ -4893,10 +4612,6 @@
oldContextClassLoader = null;
- if (isUseNaming()) {
- ContextBindings.unbindThread(this, this);
- }
-
DirContextURLStreamHandler.unbind();
}
@@ -5065,22 +4780,6 @@
/**
- * Naming context listener accessor.
- */
- public NamingContextListener getNamingContextListener() {
- return namingContextListener;
- }
-
-
- /**
- * Naming context listener setter.
- */
- public void setNamingContextListener(NamingContextListener namingContextListener) {
- this.namingContextListener = namingContextListener;
- }
-
-
- /**
* Return the request processing paused flag for this Context.
*/
public boolean getPaused() {
@@ -5409,7 +5108,6 @@
log.debug("No host, creating one " + parentName);
StandardHost host=new StandardHost();
host.setName(hostName);
- host.setAutoDeploy(false);
Registry.getRegistry(null, null)
.registerComponent(host, parentName, null);
// We could do it the hard way...
Modified: trunk/java/org/apache/catalina/core/StandardHost.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardHost.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/core/StandardHost.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -62,7 +62,7 @@
super();
pipeline.setBasic(new StandardHostValve());
startChildren =
- Boolean.valueOf(System.getProperty("org.apache.catalina.core.StandardHost.startChildren", "true")).booleanValue();
+ Boolean.valueOf(System.getProperty("org.apache.catalina.core.StandardHost.startChildren", "false")).booleanValue();
}
@@ -83,13 +83,6 @@
/**
- * The auto deploy flag for this Host.
- */
- private boolean autoDeploy =
- Boolean.valueOf(System.getProperty("org.apache.catalina.core.StandardHost.autoDeploy", "true")).booleanValue();
-
-
- /**
* The Java class name of the default context configuration class
* for deployed web applications.
*/
@@ -106,20 +99,6 @@
/**
- * The deploy on startup flag for this Host.
- */
- private boolean deployOnStartup =
- Boolean.valueOf(System.getProperty("org.apache.catalina.core.StandardHost.deployOnStartup", "true")).booleanValue();
-
-
- /**
- * deploy Context XML config files property.
- */
- private boolean deployXML =
- Boolean.valueOf(System.getProperty("org.apache.catalina.core.StandardHost.deployXML", "true")).booleanValue();
-
-
- /**
* The Java class name of the default error reporter implementation class
* for deployed web applications.
*/
@@ -139,12 +118,6 @@
/**
- * Unpack WARs property.
- */
- private boolean unpackWARs = true;
-
-
- /**
* Work Directory base for applications.
*/
private String workDir = null;
@@ -180,32 +153,6 @@
/**
- * Return the value of the auto deploy flag. If true, it indicates that
- * this host's child webapps will be dynamically deployed.
- */
- public boolean getAutoDeploy() {
-
- return (this.autoDeploy);
-
- }
-
-
- /**
- * Set the auto deploy flag value for this host.
- *
- * @param autoDeploy The new auto deploy flag
- */
- public void setAutoDeploy(boolean autoDeploy) {
-
- boolean oldAutoDeploy = this.autoDeploy;
- this.autoDeploy = autoDeploy;
- support.firePropertyChange("autoDeploy", oldAutoDeploy,
- this.autoDeploy);
-
- }
-
-
- /**
* Return the Java class name of the context configuration class
* for new web applications.
*/
@@ -260,75 +207,6 @@
/**
- * Return the value of the deploy on startup flag. If true, it indicates
- * that this host's child webapps should be discovred and automatically
- * deployed at startup time.
- */
- public boolean getDeployOnStartup() {
-
- return (this.deployOnStartup);
-
- }
-
-
- /**
- * Set the deploy on startup flag value for this host.
- *
- * @param deployOnStartup The new deploy on startup flag
- */
- public void setDeployOnStartup(boolean deployOnStartup) {
-
- boolean oldDeployOnStartup = this.deployOnStartup;
- this.deployOnStartup = deployOnStartup;
- support.firePropertyChange("deployOnStartup", oldDeployOnStartup,
- this.deployOnStartup);
-
- }
-
-
- /**
- * Deploy XML Context config files flag accessor.
- */
- public boolean isDeployXML() {
-
- return (deployXML);
-
- }
-
-
- /**
- * Deploy XML Context config files flag mutator.
- */
- public void setDeployXML(boolean deployXML) {
-
- this.deployXML = deployXML;
-
- }
-
-
- /**
- * Return the value of the live deploy flag. If true, it indicates that
- * a background thread should be started that looks for web application
- * context files, WAR files, or unpacked directories being dropped in to
- * the <code>appBase</code> directory, and deploys new ones as they are
- * encountered.
- */
- public boolean getLiveDeploy() {
- return (this.autoDeploy);
- }
-
-
- /**
- * Set the live deploy flag value for this host.
- *
- * @param liveDeploy The new live deploy flag
- */
- public void setLiveDeploy(boolean liveDeploy) {
- setAutoDeploy(liveDeploy);
- }
-
-
- /**
* Return the Java class name of the error report valve class
* for new web applications.
*/
@@ -391,25 +269,6 @@
/**
- * Unpack WARs flag accessor.
- */
- public boolean isUnpackWARs() {
-
- return (unpackWARs);
-
- }
-
-
- /**
- * Unpack WARs flag mutator.
- */
- public void setUnpackWARs(boolean unpackWARs) {
-
- this.unpackWARs = unpackWARs;
-
- }
-
- /**
* Host work directory base.
*/
public String getWorkDir() {
Modified: trunk/java/org/apache/catalina/core/StandardServer.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardServer.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/core/StandardServer.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -39,7 +39,6 @@
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Server;
import org.apache.catalina.Service;
-import org.apache.catalina.deploy.NamingResources;
import org.apache.catalina.util.LifecycleSupport;
import org.apache.catalina.util.ServerInfo;
import org.apache.catalina.util.StringManager;
@@ -69,17 +68,6 @@
* Construct a default instance of this class.
*/
public StandardServer() {
-
- globalNamingResources = new NamingResources();
- globalNamingResources.setContainer(this);
-
- if (isUseNaming()) {
- if (namingContextListener == null) {
- namingContextListener = new NamingContextListener();
- addLifecycleListener(namingContextListener);
- }
- }
-
}
@@ -87,18 +75,6 @@
/**
- * Global naming resources context.
- */
- private javax.naming.Context globalNamingContext = null;
-
-
- /**
- * Global naming resources.
- */
- private NamingResources globalNamingResources = null;
-
-
- /**
* Descriptive information about this Server implementation.
*/
private static final String info =
@@ -112,12 +88,6 @@
/**
- * The naming context listener for this web application.
- */
- private NamingContextListener namingContextListener = null;
-
-
- /**
* The port number on which we wait for shutdown commands.
*/
private int port = 8005;
@@ -177,58 +147,6 @@
/**
- * Return the global naming resources context.
- */
- public javax.naming.Context getGlobalNamingContext() {
-
- return (this.globalNamingContext);
-
- }
-
-
- /**
- * Set the global naming resources context.
- *
- * @param globalNamingContext The new global naming resource context
- */
- public void setGlobalNamingContext
- (javax.naming.Context globalNamingContext) {
-
- this.globalNamingContext = globalNamingContext;
-
- }
-
-
- /**
- * Return the global naming resources.
- */
- public NamingResources getGlobalNamingResources() {
-
- return (this.globalNamingResources);
-
- }
-
-
- /**
- * Set the global naming resources.
- *
- * @param globalNamingResources The new global naming resources
- */
- public void setGlobalNamingResources
- (NamingResources globalNamingResources) {
-
- NamingResources oldGlobalNamingResources =
- this.globalNamingResources;
- this.globalNamingResources = globalNamingResources;
- this.globalNamingResources.setContainer(this);
- support.firePropertyChange("globalNamingResources",
- oldGlobalNamingResources,
- this.globalNamingResources);
-
- }
-
-
- /**
* Return descriptive information about this Server implementation and
* the corresponding version number, in the format
* <code><description>/<version></code>.
@@ -639,21 +557,6 @@
}
- /**
- * Return true if naming should be used.
- */
- private boolean isUseNaming() {
- boolean useNaming = true;
- // Reading the "catalina.useNaming" environment variable
- String useNamingProperty = System.getProperty("catalina.useNaming");
- if ((useNamingProperty != null)
- && (useNamingProperty.equals("false"))) {
- useNaming = false;
- }
- return useNaming;
- }
-
-
// ------------------------------------------------------ Lifecycle Methods
Modified: trunk/java/org/apache/catalina/core/StandardService.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardService.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/core/StandardService.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -61,7 +61,7 @@
* Alternate flag to enable delaying startup of connectors in embedded mode.
*/
public static final boolean DELAY_CONNECTOR_STARTUP =
- Boolean.valueOf(System.getProperty("org.apache.catalina.core.StandardService.DELAY_CONNECTOR_STARTUP", "false")).booleanValue();
+ Boolean.valueOf(System.getProperty("org.apache.catalina.core.StandardService.DELAY_CONNECTOR_STARTUP", "true")).booleanValue();
// ----------------------------------------------------- Instance Variables
Deleted: trunk/java/org/apache/catalina/deploy/ContextEjb.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/ContextEjb.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/ContextEjb.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,119 +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.deploy;
-
-import java.io.Serializable;
-
-
-/**
- * Representation of an EJB resource reference for a web application, as
- * represented in a <code><ejb-ref></code> element in the
- * deployment descriptor.
- *
- * @author Craig R. McClanahan
- * @author Peter Rossbach (pero(a)apache.org)
- * @version $Revision$ $Date$
- */
-
-public class ContextEjb extends ResourceBase implements Serializable {
-
-
- // ------------------------------------------------------------- Properties
-
-
-
- /**
- * The name of the EJB home implementation class.
- */
- private String home = null;
-
- public String getHome() {
- return (this.home);
- }
-
- public void setHome(String home) {
- this.home = home;
- }
-
-
- /**
- * The link to a J2EE EJB definition.
- */
- private String link = null;
-
- public String getLink() {
- return (this.link);
- }
-
- public void setLink(String link) {
- this.link = link;
- }
-
- /**
- * The name of the EJB remote implementation class.
- */
- private String remote = null;
-
- public String getRemote() {
- return (this.remote);
- }
-
- public void setRemote(String remote) {
- this.remote = remote;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Return a String representation of this object.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("ContextEjb[");
- sb.append("name=");
- sb.append(getName());
- if (getDescription() != null) {
- sb.append(", description=");
- sb.append(getDescription());
- }
- if (getType() != null) {
- sb.append(", type=");
- sb.append(getType());
- }
- if (home != null) {
- sb.append(", home=");
- sb.append(home);
- }
- if (remote != null) {
- sb.append(", remote=");
- sb.append(remote);
- }
- if (link != null) {
- sb.append(", link=");
- sb.append(link);
- }
- sb.append("]");
- return (sb.toString());
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/ContextEnvironment.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/ContextEnvironment.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/ContextEnvironment.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,170 +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.deploy;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * Representation of an application environment entry, as represented in
- * an <code><env-entry></code> element in the deployment descriptor.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public class ContextEnvironment implements Serializable, Injectable {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The description of this environment entry.
- */
- private String description = null;
-
- public String getDescription() {
- return (this.description);
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
-
- /**
- * The name of this environment entry.
- */
- private String name = null;
-
- public String getName() {
- return (this.name);
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-
- /**
- * Does this environment entry allow overrides by the application
- * deployment descriptor?
- */
- private boolean override = true;
-
- public boolean getOverride() {
- return (this.override);
- }
-
- public void setOverride(boolean override) {
- this.override = override;
- }
-
-
- /**
- * The type of this environment entry.
- */
- private String type = null;
-
- public String getType() {
- return (this.type);
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
-
- /**
- * The value of this environment entry.
- */
- private String value = null;
-
- public String getValue() {
- return (this.value);
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
-
- private List<InjectionTarget> injectionTargets = new ArrayList<InjectionTarget>();
-
- public void addInjectionTarget(String injectionTargetName, String jndiName) {
- InjectionTarget target = new InjectionTarget(injectionTargetName, jndiName);
- injectionTargets.add(target);
- }
-
- public List<InjectionTarget> getInjectionTargets() {
- return injectionTargets;
- }
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Return a String representation of this object.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("ContextEnvironment[");
- sb.append("name=");
- sb.append(name);
- if (description != null) {
- sb.append(", description=");
- sb.append(description);
- }
- if (type != null) {
- sb.append(", type=");
- sb.append(type);
- }
- if (value != null) {
- sb.append(", value=");
- sb.append(value);
- }
- sb.append(", override=");
- sb.append(override);
- sb.append("]");
- return (sb.toString());
-
- }
-
-
- // -------------------------------------------------------- Package Methods
-
-
- /**
- * The NamingResources with which we are associated (if any).
- */
- protected NamingResources resources = null;
-
- public NamingResources getNamingResources() {
- return (this.resources);
- }
-
- void setNamingResources(NamingResources resources) {
- this.resources = resources;
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/ContextHandler.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/ContextHandler.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/ContextHandler.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,154 +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.deploy;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.HashMap;
-
-/**
- * Representation of a handler reference for a web service, as
- * represented in a <code><handler></code> element in the
- * deployment descriptor.
- *
- * @author Fabien Carrion
- */
-
-public class ContextHandler extends ResourceBase implements Serializable {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The Handler reference class.
- */
- private String handlerclass = null;
-
- public String getHandlerclass() {
- return (this.handlerclass);
- }
-
- public void setHandlerclass(String handlerclass) {
- this.handlerclass = handlerclass;
- }
-
- /**
- * A list of QName specifying the SOAP Headers the handler will work on.
- * -namespace and locapart values must be found inside the WSDL.
- *
- * A service-qname is composed by a namespaceURI and a localpart.
- *
- * soapHeader[0] : namespaceURI
- * soapHeader[1] : localpart
- */
- private HashMap soapHeaders = new HashMap();
-
- public Iterator getLocalparts() {
- return soapHeaders.keySet().iterator();
- }
-
- public String getNamespaceuri(String localpart) {
- return (String) soapHeaders.get(localpart);
- }
-
- public void addSoapHeaders(String localpart, String namespaceuri) {
- soapHeaders.put(localpart, namespaceuri);
- }
-
- /**
- * Set a configured property.
- */
- public void setProperty(String name, String value) {
- this.setProperty(name, (Object) value);
- }
-
- /**
- * The soapRole.
- */
- private ArrayList<String> soapRoles = new ArrayList();
-
- public String getSoapRole(int i) {
- return this.soapRoles.get(i);
- }
-
- public int getSoapRolesSize() {
- return this.soapRoles.size();
- }
-
- public void addSoapRole(String soapRole) {
- this.soapRoles.add(soapRole);
- }
-
- /**
- * The portName.
- */
- private ArrayList<String> portNames = new ArrayList();
-
- public String getPortName(int i) {
- return this.portNames.get(i);
- }
-
- public int getPortNamesSize() {
- return this.portNames.size();
- }
-
- public void addPortName(String portName) {
- this.portNames.add(portName);
- }
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Return a String representation of this object.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("ContextHandler[");
- sb.append("name=");
- sb.append(getName());
- if (handlerclass != null) {
- sb.append(", class=");
- sb.append(handlerclass);
- }
- if (this.soapHeaders != null) {
- sb.append(", soap-headers=");
- sb.append(this.soapHeaders);
- }
- if (this.getSoapRolesSize() > 0) {
- sb.append(", soap-roles=");
- sb.append(soapRoles);
- }
- if (this.getPortNamesSize() > 0) {
- sb.append(", port-name=");
- sb.append(portNames);
- }
- if (this.listProperties() != null) {
- sb.append(", init-param=");
- sb.append(this.listProperties());
- }
- sb.append("]");
- return (sb.toString());
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/ContextLocalEjb.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/ContextLocalEjb.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/ContextLocalEjb.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,116 +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.deploy;
-
-import java.io.Serializable;
-
-
-/**
- * Representation of a local EJB resource reference for a web application, as
- * represented in a <code><ejb-local-ref></code> element in the
- * deployment descriptor.
- *
- * @author Craig R. McClanahan
- * @author Peter Rossbach (pero(a)apache.org)
- * @version $Revision$ $Date$
- */
-
-public class ContextLocalEjb extends ResourceBase implements Serializable {
-
-
- // ------------------------------------------------------------- Properties
-
- /**
- * The name of the EJB home implementation class.
- */
- private String home = null;
-
- public String getHome() {
- return (this.home);
- }
-
- public void setHome(String home) {
- this.home = home;
- }
-
-
- /**
- * The link to a J2EE EJB definition.
- */
- private String link = null;
-
- public String getLink() {
- return (this.link);
- }
-
- public void setLink(String link) {
- this.link = link;
- }
-
-
- /**
- * The name of the EJB local implementation class.
- */
- private String local = null;
-
- public String getLocal() {
- return (this.local);
- }
-
- public void setLocal(String local) {
- this.local = local;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Return a String representation of this object.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("ContextLocalEjb[");
- sb.append("name=");
- sb.append(getName());
- if (getDescription() != null) {
- sb.append(", description=");
- sb.append(getDescription());
- }
- if (getType() != null) {
- sb.append(", type=");
- sb.append(getType());
- }
- if (home != null) {
- sb.append(", home=");
- sb.append(home);
- }
- if (link != null) {
- sb.append(", link=");
- sb.append(link);
- }
- if (local != null) {
- sb.append(", local=");
- sb.append(local);
- }
- sb.append("]");
- return (sb.toString());
-
- }
-}
Deleted: trunk/java/org/apache/catalina/deploy/ContextResource.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/ContextResource.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/ContextResource.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,100 +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.deploy;
-
-import java.io.Serializable;
-
-/**
- * Representation of a resource reference for a web application, as
- * represented in a <code><resource-ref></code> element in the
- * deployment descriptor.
- *
- * @author Craig R. McClanahan
- * @author Peter Rossbach (pero(a)apache.org)
- * @version $Revision$ $Date$
- */
-
-public class ContextResource extends ResourceBase implements Serializable {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The authorization requirement for this resource
- * (<code>Application</code> or <code>Container</code>).
- */
- private String auth = null;
-
- public String getAuth() {
- return (this.auth);
- }
-
- public void setAuth(String auth) {
- this.auth = auth;
- }
-
- /**
- * The sharing scope of this resource factory (<code>Shareable</code>
- * or <code>Unshareable</code>).
- */
- private String scope = "Shareable";
-
- public String getScope() {
- return (this.scope);
- }
-
- public void setScope(String scope) {
- this.scope = scope;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Return a String representation of this object.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("ContextResource[");
- sb.append("name=");
- sb.append(getName());
- if (getDescription() != null) {
- sb.append(", description=");
- sb.append(getDescription());
- }
- if (getType() != null) {
- sb.append(", type=");
- sb.append(getType());
- }
- if (auth != null) {
- sb.append(", auth=");
- sb.append(auth);
- }
- if (scope != null) {
- sb.append(", scope=");
- sb.append(scope);
- }
- sb.append("]");
- return (sb.toString());
-
- }
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/ContextResourceEnvRef.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/ContextResourceEnvRef.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/ContextResourceEnvRef.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,76 +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.deploy;
-
-import java.io.Serializable;
-
-
-/**
- * Representation of an application resource reference, as represented in
- * an <code><res-env-refy></code> element in the deployment descriptor.
- *
- * @author Craig R. McClanahan
- * @author Peter Rossbach (pero(a)apache.org)
- * @version $Revision$ $Date$
- */
-
-public class ContextResourceEnvRef extends ResourceBase implements Serializable {
-
-
- // ------------------------------------------------------------- Properties
-
- /**
- * Does this environment entry allow overrides by the application
- * deployment descriptor?
- */
- private boolean override = true;
-
- public boolean getOverride() {
- return (this.override);
- }
-
- public void setOverride(boolean override) {
- this.override = override;
- }
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Return a String representation of this object.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("ContextResourceEnvRef[");
- sb.append("name=");
- sb.append(getName());
- if (getType() != null) {
- sb.append(", type=");
- sb.append(getType());
- }
- sb.append(", override=");
- sb.append(override);
- sb.append("]");
- return (sb.toString());
-
- }
-
-
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/ContextResourceLink.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/ContextResourceLink.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/ContextResourceLink.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,77 +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.deploy;
-
-import java.io.Serializable;
-
-
-/**
- * Representation of a resource link for a web application, as
- * represented in a <code><ResourceLink></code> element in the
- * server configuration file.
- *
- * @author Remy Maucherat
- * @author Peter Rossbach (Peter Rossbach (pero(a)apache.org))
- * @version $Revision$ $Date$
- */
-
-public class ContextResourceLink extends ResourceBase implements Serializable {
-
-
- // ------------------------------------------------------------- Properties
-
- /**
- * The global name of this resource.
- */
- private String global = null;
-
- public String getGlobal() {
- return (this.global);
- }
-
- public void setGlobal(String global) {
- this.global = global;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Return a String representation of this object.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("ContextResourceLink[");
- sb.append("name=");
- sb.append(getName());
- if (getType() != null) {
- sb.append(", type=");
- sb.append(getType());
- }
- if (getGlobal() != null) {
- sb.append(", global=");
- sb.append(getGlobal());
- }
- sb.append("]");
- return (sb.toString());
-
- }
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/ContextService.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/ContextService.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/ContextService.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,236 +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.deploy;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.HashMap;
-
-/**
- * Representation of a web service reference for a web application, as
- * represented in a <code><service-ref></code> element in the
- * deployment descriptor.
- *
- * @author Fabien Carrion
- * @version $Revision$ $Date$
- */
-
-public class ContextService extends ResourceBase implements Serializable {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The WebService reference name.
- */
- private String displayname = null;
-
- public String getDisplayname() {
- return (this.displayname);
- }
-
- public void setDisplayname(String displayname) {
- this.displayname = displayname;
- }
-
- /**
- * An icon for this WebService.
- */
- private String icon = null;
-
- public String getIcon() {
- return (this.icon);
- }
-
- public void setIcon(String icon) {
- this.icon = icon;
- }
-
- /**
- * Contains the location (relative to the root of
- * the module) of the web service WSDL description.
- */
- private String wsdlfile = null;
-
- public String getWsdlfile() {
- return (this.wsdlfile);
- }
-
- public void setWsdlfile(String wsdlfile) {
- this.wsdlfile = wsdlfile;
- }
-
- /**
- * A file specifying the correlation of the WSDL definition
- * to the interfaces (Service Endpoint Interface, Service Interface).
- */
- private String jaxrpcmappingfile = null;
-
- public String getJaxrpcmappingfile() {
- return (this.jaxrpcmappingfile);
- }
-
- public void setJaxrpcmappingfile(String jaxrpcmappingfile) {
- this.jaxrpcmappingfile = jaxrpcmappingfile;
- }
-
- /**
- * Declares the specific WSDL service element that is being referred to.
- * It is not specified if no wsdl-file is declared or if WSDL contains only
- * 1 service element.
- *
- * A service-qname is composed by a namespaceURI and a localpart.
- * It must be defined if more than 1 service is declared in the WSDL.
- *
- * serviceqname[0] : namespaceURI
- * serviceqname[1] : localpart
- */
- private String[] serviceqname = new String[2];
-
- public String[] getServiceqname() {
- return (this.serviceqname);
- }
-
- public String getServiceqname(int i) {
- return this.serviceqname[i];
- }
-
- public String getServiceqnameNamespaceURI() {
- return this.serviceqname[0];
- }
-
- public String getServiceqnameLocalpart() {
- return this.serviceqname[1];
- }
-
- public void setServiceqname(String[] serviceqname) {
- this.serviceqname = serviceqname;
- }
-
- public void setServiceqname(String serviceqname, int i) {
- this.serviceqname[i] = serviceqname;
- }
-
- public void setServiceqnameNamespaceURI(String namespaceuri) {
- this.serviceqname[0] = namespaceuri;
- }
-
- public void setServiceqnameLocalpart(String localpart) {
- this.serviceqname[1] = localpart;
- }
-
- /**
- * Declares a client dependency on the container to resolving a Service Endpoint Interface
- * to a WSDL port. It optionally associates the Service Endpoint Interface with a
- * particular port-component.
- *
- */
- public Iterator getServiceendpoints() {
- return this.listProperties();
- }
-
- public String getPortlink(String serviceendpoint) {
- return (String) this.getProperty(serviceendpoint);
- }
-
- public void addPortcomponent(String serviceendpoint, String portlink) {
- if (portlink == null)
- portlink = "";
- this.setProperty(serviceendpoint, portlink);
- }
-
- /**
- * A list of Handlers to use for this service-ref.
- *
- * The instanciation of the handler have to be done.
- */
- private HashMap handlers = new HashMap();
-
- public Iterator getHandlers() {
- return handlers.keySet().iterator();
- }
-
- public ContextHandler getHandler(String handlername) {
- return (ContextHandler) handlers.get(handlername);
- }
-
- public void addHandler(ContextHandler handler) {
- handlers.put(handler.getName(), handler);
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Return a String representation of this object.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("ContextService[");
- sb.append("name=");
- sb.append(getName());
- if (getDescription() != null) {
- sb.append(", description=");
- sb.append(getDescription());
- }
- if (getType() != null) {
- sb.append(", type=");
- sb.append(getType());
- }
- if (displayname != null) {
- sb.append(", displayname=");
- sb.append(displayname);
- }
- if (icon != null) {
- sb.append(", icon=");
- sb.append(icon);
- }
- if (wsdlfile != null) {
- sb.append(", wsdl-file=");
- sb.append(wsdlfile);
- }
- if (jaxrpcmappingfile != null) {
- sb.append(", jaxrpc-mapping-file=");
- sb.append(jaxrpcmappingfile);
- }
- if (serviceqname[0] != null) {
- sb.append(", service-qname/namespaceURI=");
- sb.append(serviceqname[0]);
- }
- if (serviceqname[1] != null) {
- sb.append(", service-qname/localpart=");
- sb.append(serviceqname[1]);
- }
- if (this.getServiceendpoints() != null) {
- sb.append(", port-component/service-endpoint-interface=");
- sb.append(this.getServiceendpoints());
- }
- if (handlers != null) {
- sb.append(", handler=");
- sb.append(handlers);
- }
- sb.append("]");
- return (sb.toString());
-
- }
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/ContextTransaction.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/ContextTransaction.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/ContextTransaction.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,106 +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.deploy;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-
-
-/**
- * Representation of an application resource reference, as represented in
- * an <code><res-env-refy></code> element in the deployment descriptor.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public class ContextTransaction implements Serializable {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Holder for our configured properties.
- */
- private HashMap properties = new HashMap();
-
- /**
- * Return a configured property.
- */
- public Object getProperty(String name) {
- return properties.get(name);
- }
-
- /**
- * Set a configured property.
- */
- public void setProperty(String name, Object value) {
- properties.put(name, value);
- }
-
- /**
- * remove a configured property.
- */
- public void removeProperty(String name) {
- properties.remove(name);
- }
-
- /**
- * List properties.
- */
- public Iterator listProperties() {
- return properties.keySet().iterator();
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Return a String representation of this object.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("Transaction[");
- sb.append("]");
- return (sb.toString());
-
- }
-
-
- // -------------------------------------------------------- Package Methods
-
-
- /**
- * The NamingResources with which we are associated (if any).
- */
- protected NamingResources resources = null;
-
- public NamingResources getNamingResources() {
- return (this.resources);
- }
-
- void setNamingResources(NamingResources resources) {
- this.resources = resources;
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/Injectable.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/Injectable.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/Injectable.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,29 +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.deploy;
-
-import java.util.List;
-
-public interface Injectable {
- public String getName();
- public void addInjectionTarget(String injectionTargetName, String jndiName);
- public List<InjectionTarget> getInjectionTargets();
-}
Deleted: trunk/java/org/apache/catalina/deploy/InjectionTarget.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/InjectionTarget.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/InjectionTarget.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,55 +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.deploy;
-
-/**
- * @version $Rev:$ $Date:$
- */
-public class InjectionTarget {
- private String targetClass;
- private String targetName;
-
-
- public InjectionTarget() {
- }
-
- public InjectionTarget(String targetClass, String targetName) {
- this.targetClass = targetClass;
- this.targetName = targetName;
- }
-
- public String getTargetClass() {
- return targetClass;
- }
-
- public void setTargetClass(String targetClass) {
- this.targetClass = targetClass;
- }
-
- public String getTargetName() {
- return targetName;
- }
-
- public void setTargetName(String targetName) {
- this.targetName = targetName;
- }
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/MessageDestination.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/MessageDestination.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/MessageDestination.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,141 +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.deploy;
-
-
-/**
- * <p>Representation of a message destination for a web application, as
- * represented in a <code><message-destination></code> element
- * in the deployment descriptor.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * @since Tomcat 5.0
- */
-
-public class MessageDestination {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The description of this destination.
- */
- private String description = null;
-
- public String getDescription() {
- return (this.description);
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
-
- /**
- * The display name of this destination.
- */
- private String displayName = null;
-
- public String getDisplayName() {
- return (this.displayName);
- }
-
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
-
-
- /**
- * The large icon of this destination.
- */
- private String largeIcon = null;
-
- public String getLargeIcon() {
- return (this.largeIcon);
- }
-
- public void setLargeIcon(String largeIcon) {
- this.largeIcon = largeIcon;
- }
-
-
- /**
- * The name of this destination.
- */
- private String name = null;
-
- public String getName() {
- return (this.name);
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-
- /**
- * The small icon of this destination.
- */
- private String smallIcon = null;
-
- public String getSmallIcon() {
- return (this.smallIcon);
- }
-
- public void setSmallIcon(String smallIcon) {
- this.smallIcon = smallIcon;
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Return a String representation of this object.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("MessageDestination[");
- sb.append("name=");
- sb.append(name);
- if (displayName != null) {
- sb.append(", displayName=");
- sb.append(displayName);
- }
- if (largeIcon != null) {
- sb.append(", largeIcon=");
- sb.append(largeIcon);
- }
- if (smallIcon != null) {
- sb.append(", smallIcon=");
- sb.append(smallIcon);
- }
- if (description != null) {
- sb.append(", description=");
- sb.append(description);
- }
- sb.append("]");
- return (sb.toString());
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/MessageDestinationRef.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/MessageDestinationRef.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/MessageDestinationRef.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,172 +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.deploy;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * <p>Representation of a message destination reference for a web application,
- * as represented in a <code><message-destination-ref></code> element
- * in the deployment descriptor.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * @since Tomcat 5.0
- */
-
-public class MessageDestinationRef implements Serializable, Injectable {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The description of this destination ref.
- */
- private String description = null;
-
- public String getDescription() {
- return (this.description);
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
-
- /**
- * The link of this destination ref.
- */
- private String link = null;
-
- public String getLink() {
- return (this.link);
- }
-
- public void setLink(String link) {
- this.link = link;
- }
-
-
- /**
- * The name of this destination ref.
- */
- private String name = null;
-
- public String getName() {
- return (this.name);
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-
- /**
- * The type of this destination ref.
- */
- private String type = null;
-
- public String getType() {
- return (this.type);
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
-
- /**
- * The usage of this destination ref.
- */
- private String usage = null;
-
- public String getUsage() {
- return (this.usage);
- }
-
- public void setUsage(String usage) {
- this.usage = usage;
- }
-
- private List<InjectionTarget> injectionTargets = new ArrayList<InjectionTarget>();
-
- public void addInjectionTarget(String injectionTargetName, String jndiName) {
- InjectionTarget target = new InjectionTarget(injectionTargetName, jndiName);
- injectionTargets.add(target);
- }
-
- public List<InjectionTarget> getInjectionTargets() {
- return injectionTargets;
- }
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Return a String representation of this object.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("MessageDestination[");
- sb.append("name=");
- sb.append(name);
- if (link != null) {
- sb.append(", link=");
- sb.append(link);
- }
- if (type != null) {
- sb.append(", type=");
- sb.append(type);
- }
- if (usage != null) {
- sb.append(", usage=");
- sb.append(usage);
- }
- if (description != null) {
- sb.append(", description=");
- sb.append(description);
- }
- sb.append("]");
- return (sb.toString());
-
- }
-
-
- // -------------------------------------------------------- Package Methods
-
-
- /**
- * The NamingResources with which we are associated (if any).
- */
- protected NamingResources resources = null;
-
- public NamingResources getNamingResources() {
- return (this.resources);
- }
-
- void setNamingResources(NamingResources resources) {
- this.resources = resources;
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/NamingResources.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/NamingResources.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/NamingResources.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,827 +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.deploy;
-
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Hashtable;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Server;
-
-
-/**
- * Holds and manages the naming resources defined in the J2EE Enterprise
- * Naming Context and their associated JNDI context.
- *
- * @author Remy Maucherat
- * @version $Revision$ $Date$
- */
-
-public class NamingResources implements Serializable {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Create a new NamingResources instance.
- */
- public NamingResources() {
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * Associated container object.
- */
- private Object container = null;
-
-
- /**
- * List of naming entries, keyed by name. The value is the entry type, as
- * declared by the user.
- */
- private Hashtable entries = new Hashtable();
-
-
- /**
- * The EJB resource references for this web application, keyed by name.
- */
- private HashMap ejbs = new HashMap();
-
-
- /**
- * The environment entries for this web application, keyed by name.
- */
- private HashMap envs = new HashMap();
-
-
- /**
- * The local EJB resource references for this web application, keyed by
- * name.
- */
- private HashMap localEjbs = new HashMap();
-
-
- /**
- * The message destination referencess for this web application,
- * keyed by name.
- */
- private HashMap mdrs = new HashMap();
-
-
- /**
- * The resource environment references for this web application,
- * keyed by name.
- */
- private HashMap resourceEnvRefs = new HashMap();
-
-
- /**
- * The resource references for this web application, keyed by name.
- */
- private HashMap resources = new HashMap();
-
-
- /**
- * The resource links for this web application, keyed by name.
- */
- private HashMap resourceLinks = new HashMap();
-
-
- /**
- * The web service references for this web application, keyed by name.
- */
- private HashMap services = new HashMap();
-
-
- /**
- * The transaction for this webapp.
- */
- private ContextTransaction transaction = null;
-
-
- /**
- * The property change support for this component.
- */
- protected PropertyChangeSupport support = new PropertyChangeSupport(this);
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Get the container with which the naming resources are associated.
- */
- public Object getContainer() {
- return container;
- }
-
-
- /**
- * Set the container with which the naming resources are associated.
- */
- public void setContainer(Object container) {
- this.container = container;
- }
-
-
- /**
- * Set the transaction object.
- */
- public void setTransaction(ContextTransaction transaction) {
- this.transaction = transaction;
- }
-
-
- /**
- * Get the transaction object.
- */
- public ContextTransaction getTransaction() {
- return transaction;
- }
-
-
- /**
- * Add an EJB resource reference for this web application.
- *
- * @param ejb New EJB resource reference
- */
- public void addEjb(ContextEjb ejb) {
-
- if (entries.containsKey(ejb.getName())) {
- return;
- } else {
- entries.put(ejb.getName(), ejb.getType());
- }
-
- synchronized (ejbs) {
- ejb.setNamingResources(this);
- ejbs.put(ejb.getName(), ejb);
- }
- support.firePropertyChange("ejb", null, ejb);
-
- }
-
-
- /**
- * Add an environment entry for this web application.
- *
- * @param environment New environment entry
- */
- public void addEnvironment(ContextEnvironment environment) {
-
- if (entries.containsKey(environment.getName())) {
- ContextEnvironment ce = findEnvironment(environment.getName());
- ContextResourceLink rl = findResourceLink(environment.getName());
- if (ce != null) {
- if (ce.getOverride()) {
- removeEnvironment(environment.getName());
- } else {
- return;
- }
- } else if (rl != null) {
- // Link. Need to look at the global resources
- NamingResources global = getServer().getGlobalNamingResources();
- if (global.findEnvironment(rl.getGlobal()) != null) {
- if (global.findEnvironment(rl.getGlobal()).getOverride()) {
- removeResourceLink(environment.getName());
- } else {
- return;
- }
- }
- } else {
- // It exists but it isn't an env or a res link...
- return;
- }
- }
-
- entries.put(environment.getName(), environment.getType());
-
- synchronized (envs) {
- environment.setNamingResources(this);
- envs.put(environment.getName(), environment);
- }
- support.firePropertyChange("environment", null, environment);
-
- }
-
- // Container should be an instance of Server or Context. If it is anything
- // else, return null which will trigger a NPE.
- private Server getServer() {
- if (container instanceof Server) {
- return (Server) container;
- }
- if (container instanceof Context) {
- // Could do this in one go. Lots of casts so split out for clarity
- Engine engine =
- (Engine) ((Context) container).getParent().getParent();
- return engine.getService().getServer();
- }
- return null;
- }
-
- /**
- * Add a local EJB resource reference for this web application.
- *
- * @param ejb New EJB resource reference
- */
- public void addLocalEjb(ContextLocalEjb ejb) {
-
- if (entries.containsKey(ejb.getName())) {
- return;
- } else {
- entries.put(ejb.getName(), ejb.getType());
- }
-
- synchronized (localEjbs) {
- ejb.setNamingResources(this);
- localEjbs.put(ejb.getName(), ejb);
- }
- support.firePropertyChange("localEjb", null, ejb);
-
- }
-
-
- /**
- * Add a message destination reference for this web application.
- *
- * @param mdr New message destination reference
- */
- public void addMessageDestinationRef(MessageDestinationRef mdr) {
-
- if (entries.containsKey(mdr.getName())) {
- return;
- } else {
- entries.put(mdr.getName(), mdr.getType());
- }
-
- synchronized (mdrs) {
- mdr.setNamingResources(this);
- mdrs.put(mdr.getName(), mdr);
- }
- support.firePropertyChange("messageDestinationRef", null, mdr);
-
- }
-
-
- /**
- * Add a property change listener to this component.
- *
- * @param listener The listener to add
- */
- public void addPropertyChangeListener(PropertyChangeListener listener) {
-
- support.addPropertyChangeListener(listener);
-
- }
-
-
- /**
- * Add a resource reference for this web application.
- *
- * @param resource New resource reference
- */
- public void addResource(ContextResource resource) {
-
- if (entries.containsKey(resource.getName())) {
- return;
- } else {
- entries.put(resource.getName(), resource.getType());
- }
-
- synchronized (resources) {
- resource.setNamingResources(this);
- resources.put(resource.getName(), resource);
- }
- support.firePropertyChange("resource", null, resource);
-
- }
-
-
- /**
- * Add a resource environment reference for this web application.
- *
- * @param resource The resource
- */
- public void addResourceEnvRef(ContextResourceEnvRef resource) {
-
- if (entries.containsKey(resource.getName())) {
- return;
- } else {
- entries.put(resource.getName(), resource.getType());
- }
-
- synchronized (resourceEnvRefs) {
- resource.setNamingResources(this);
- resourceEnvRefs.put(resource.getName(), resource);
- }
- support.firePropertyChange("resourceEnvRef", null, resource);
-
- }
-
-
- /**
- * Add a resource link for this web application.
- *
- * @param resourceLink New resource link
- */
- public void addResourceLink(ContextResourceLink resourceLink) {
-
- if (entries.containsKey(resourceLink.getName())) {
- return;
- } else {
- Object value = resourceLink.getType();
- if (value == null) {
- value = "";
- }
- entries.put(resourceLink.getName(), value);
- }
-
- synchronized (resourceLinks) {
- resourceLink.setNamingResources(this);
- resourceLinks.put(resourceLink.getName(), resourceLink);
- }
- support.firePropertyChange("resourceLink", null, resourceLink);
-
- }
-
-
- /**
- * Add a web service reference for this web application.
- *
- * @param service New web service reference
- */
- public void addService(ContextService service) {
-
- if (entries.containsKey(service.getName())) {
- return;
- } else {
- Object value = service.getType();
- if (value == null) {
- value = "";
- }
- entries.put(service.getName(), value);
- }
-
- synchronized (services) {
- service.setNamingResources(this);
- services.put(service.getName(), service);
- }
- support.firePropertyChange("service", null, service);
-
- }
-
-
- /**
- * Return the EJB resource reference with the specified name, if any;
- * otherwise, return <code>null</code>.
- *
- * @param name Name of the desired EJB resource reference
- */
- public ContextEjb findEjb(String name) {
-
- synchronized (ejbs) {
- return ((ContextEjb) ejbs.get(name));
- }
-
- }
-
-
- /**
- * Return the defined EJB resource references for this application.
- * If there are none, a zero-length array is returned.
- */
- public ContextEjb[] findEjbs() {
-
- synchronized (ejbs) {
- ContextEjb results[] = new ContextEjb[ejbs.size()];
- return ((ContextEjb[]) ejbs.values().toArray(results));
- }
-
- }
-
-
- /**
- * Return the environment entry with the specified name, if any;
- * otherwise, return <code>null</code>.
- *
- * @param name Name of the desired environment entry
- */
- public ContextEnvironment findEnvironment(String name) {
-
- synchronized (envs) {
- return ((ContextEnvironment) envs.get(name));
- }
-
- }
-
-
- /**
- * Return the set of defined environment entries for this web
- * application. If none have been defined, a zero-length array
- * is returned.
- */
- public ContextEnvironment[] findEnvironments() {
-
- synchronized (envs) {
- ContextEnvironment results[] = new ContextEnvironment[envs.size()];
- return ((ContextEnvironment[]) envs.values().toArray(results));
- }
-
- }
-
-
- /**
- * Return the local EJB resource reference with the specified name, if any;
- * otherwise, return <code>null</code>.
- *
- * @param name Name of the desired EJB resource reference
- */
- public ContextLocalEjb findLocalEjb(String name) {
-
- synchronized (localEjbs) {
- return ((ContextLocalEjb) localEjbs.get(name));
- }
-
- }
-
-
- /**
- * Return the defined local EJB resource references for this application.
- * If there are none, a zero-length array is returned.
- */
- public ContextLocalEjb[] findLocalEjbs() {
-
- synchronized (localEjbs) {
- ContextLocalEjb results[] = new ContextLocalEjb[localEjbs.size()];
- return ((ContextLocalEjb[]) localEjbs.values().toArray(results));
- }
-
- }
-
-
- /**
- * Return the message destination reference with the specified name,
- * if any; otherwise, return <code>null</code>.
- *
- * @param name Name of the desired message destination reference
- */
- public MessageDestinationRef findMessageDestinationRef(String name) {
-
- synchronized (mdrs) {
- return ((MessageDestinationRef) mdrs.get(name));
- }
-
- }
-
-
- /**
- * Return the defined message destination references for this application.
- * If there are none, a zero-length array is returned.
- */
- public MessageDestinationRef[] findMessageDestinationRefs() {
-
- synchronized (mdrs) {
- MessageDestinationRef results[] =
- new MessageDestinationRef[mdrs.size()];
- return ((MessageDestinationRef[]) mdrs.values().toArray(results));
- }
-
- }
-
-
- /**
- * Return the resource reference with the specified name, if any;
- * otherwise return <code>null</code>.
- *
- * @param name Name of the desired resource reference
- */
- public ContextResource findResource(String name) {
-
- synchronized (resources) {
- return ((ContextResource) resources.get(name));
- }
-
- }
-
-
- /**
- * Return the resource link with the specified name, if any;
- * otherwise return <code>null</code>.
- *
- * @param name Name of the desired resource link
- */
- public ContextResourceLink findResourceLink(String name) {
-
- synchronized (resourceLinks) {
- return ((ContextResourceLink) resourceLinks.get(name));
- }
-
- }
-
-
- /**
- * Return the defined resource links for this application. If
- * none have been defined, a zero-length array is returned.
- */
- public ContextResourceLink[] findResourceLinks() {
-
- synchronized (resourceLinks) {
- ContextResourceLink results[] =
- new ContextResourceLink[resourceLinks.size()];
- return ((ContextResourceLink[]) resourceLinks.values()
- .toArray(results));
- }
-
- }
-
-
- /**
- * Return the defined resource references for this application. If
- * none have been defined, a zero-length array is returned.
- */
- public ContextResource[] findResources() {
-
- synchronized (resources) {
- ContextResource results[] = new ContextResource[resources.size()];
- return ((ContextResource[]) resources.values().toArray(results));
- }
-
- }
-
-
- /**
- * Return the resource environment reference type for the specified
- * name, if any; otherwise return <code>null</code>.
- *
- * @param name Name of the desired resource environment reference
- */
- public ContextResourceEnvRef findResourceEnvRef(String name) {
-
- synchronized (resourceEnvRefs) {
- return ((ContextResourceEnvRef) resourceEnvRefs.get(name));
- }
-
- }
-
-
- /**
- * Return the set of resource environment reference names for this
- * web application. If none have been specified, a zero-length
- * array is returned.
- */
- public ContextResourceEnvRef[] findResourceEnvRefs() {
-
- synchronized (resourceEnvRefs) {
- ContextResourceEnvRef results[] = new ContextResourceEnvRef[resourceEnvRefs.size()];
- return ((ContextResourceEnvRef[]) resourceEnvRefs.values().toArray(results));
- }
-
- }
-
-
- /**
- * Return the web service reference for the specified
- * name, if any; otherwise return <code>null</code>.
- *
- * @param name Name of the desired web service
- */
- public ContextService findService(String name) {
-
- synchronized (services) {
- return ((ContextService) services.get(name));
- }
-
- }
-
-
- /**
- * Return the defined web service references for this application. If
- * none have been defined, a zero-length array is returned.
- */
- public ContextService[] findServices() {
-
- synchronized (services) {
- ContextService results[] = new ContextService[services.size()];
- return ((ContextService[]) services.values().toArray(results));
- }
-
- }
-
-
- /**
- * Return true if the name specified already exists.
- */
- public boolean exists(String name) {
-
- return (entries.containsKey(name));
-
- }
-
-
- /**
- * Remove any EJB resource reference with the specified name.
- *
- * @param name Name of the EJB resource reference to remove
- */
- public void removeEjb(String name) {
-
- entries.remove(name);
-
- ContextEjb ejb = null;
- synchronized (ejbs) {
- ejb = (ContextEjb) ejbs.remove(name);
- }
- if (ejb != null) {
- support.firePropertyChange("ejb", ejb, null);
- ejb.setNamingResources(null);
- }
-
- }
-
-
- /**
- * Remove any environment entry with the specified name.
- *
- * @param name Name of the environment entry to remove
- */
- public void removeEnvironment(String name) {
-
- entries.remove(name);
-
- ContextEnvironment environment = null;
- synchronized (envs) {
- environment = (ContextEnvironment) envs.remove(name);
- }
- if (environment != null) {
- support.firePropertyChange("environment", environment, null);
- environment.setNamingResources(null);
- }
-
- }
-
-
- /**
- * Remove any local EJB resource reference with the specified name.
- *
- * @param name Name of the EJB resource reference to remove
- */
- public void removeLocalEjb(String name) {
-
- entries.remove(name);
-
- ContextLocalEjb localEjb = null;
- synchronized (localEjbs) {
- localEjb = (ContextLocalEjb) localEjbs.remove(name);
- }
- if (localEjb != null) {
- support.firePropertyChange("localEjb", localEjb, null);
- localEjb.setNamingResources(null);
- }
-
- }
-
-
- /**
- * Remove any message destination reference with the specified name.
- *
- * @param name Name of the message destination resource reference to remove
- */
- public void removeMessageDestinationRef(String name) {
-
- entries.remove(name);
-
- MessageDestinationRef mdr = null;
- synchronized (mdrs) {
- mdr = (MessageDestinationRef) mdrs.remove(name);
- }
- if (mdr != null) {
- support.firePropertyChange("messageDestinationRef",
- mdr, null);
- mdr.setNamingResources(null);
- }
-
- }
-
-
- /**
- * Remove a property change listener from this component.
- *
- * @param listener The listener to remove
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
-
- support.removePropertyChangeListener(listener);
-
- }
-
-
- /**
- * Remove any resource reference with the specified name.
- *
- * @param name Name of the resource reference to remove
- */
- public void removeResource(String name) {
-
- entries.remove(name);
-
- ContextResource resource = null;
- synchronized (resources) {
- resource = (ContextResource) resources.remove(name);
- }
- if (resource != null) {
- support.firePropertyChange("resource", resource, null);
- resource.setNamingResources(null);
- }
-
- }
-
-
- /**
- * Remove any resource environment reference with the specified name.
- *
- * @param name Name of the resource environment reference to remove
- */
- public void removeResourceEnvRef(String name) {
-
- entries.remove(name);
-
- ContextResourceEnvRef resourceEnvRef = null;
- synchronized (resourceEnvRefs) {
- resourceEnvRef = (ContextResourceEnvRef) resourceEnvRefs.remove(name);
- }
- if (resourceEnvRef != null) {
- support.firePropertyChange("resourceEnvRef", resourceEnvRef, null);
- resourceEnvRef.setNamingResources(null);
- }
-
- }
-
-
- /**
- * Remove any resource link with the specified name.
- *
- * @param name Name of the resource link to remove
- */
- public void removeResourceLink(String name) {
-
- entries.remove(name);
-
- ContextResourceLink resourceLink = null;
- synchronized (resourceLinks) {
- resourceLink = (ContextResourceLink) resourceLinks.remove(name);
- }
- if (resourceLink != null) {
- support.firePropertyChange("resourceLink", resourceLink, null);
- resourceLink.setNamingResources(null);
- }
-
- }
-
-
- /**
- * Remove any web service reference with the specified name.
- *
- * @param name Name of the web service reference to remove
- */
- public void removeService(String name) {
-
- entries.remove(name);
-
- ContextService service = null;
- synchronized (services) {
- service = (ContextService) services.remove(name);
- }
- if (service != null) {
- support.firePropertyChange("service", service, null);
- service.setNamingResources(null);
- }
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/ResourceBase.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/ResourceBase.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/ResourceBase.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,145 +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.deploy;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ArrayList;
-
-
-/**
- * Representation of an Context element
- *
- * @author Peter Rossbach (pero(a)apache.org)
- * @version $Revision$ $Date$
- */
-
-public class ResourceBase implements Serializable, Injectable {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * The description of this Context Element.
- */
- private String description = null;
-
- public String getDescription() {
- return (this.description);
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
-
-
- /**
- * The name of this context Element.
- */
- private String name = null;
-
- public String getName() {
- return (this.name);
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-
- /**
- * The name of the EJB bean implementation class.
- */
- private String type = null;
-
- public String getType() {
- return (this.type);
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
-
- /**
- * Holder for our configured properties.
- */
- private HashMap properties = new HashMap();
-
- /**
- * Return a configured property.
- */
- public Object getProperty(String name) {
- return properties.get(name);
- }
-
- /**
- * Set a configured property.
- */
- public void setProperty(String name, Object value) {
- properties.put(name, value);
- }
-
- /**
- * remove a configured property.
- */
- public void removeProperty(String name) {
- properties.remove(name);
- }
-
- /**
- * List properties.
- */
- public Iterator listProperties() {
- return properties.keySet().iterator();
- }
-
- private List<InjectionTarget> injectionTargets = new ArrayList<InjectionTarget>();
-
- public void addInjectionTarget(String injectionTargetName, String jndiName) {
- InjectionTarget target = new InjectionTarget(injectionTargetName, jndiName);
- injectionTargets.add(target);
- }
-
- public List<InjectionTarget> getInjectionTargets() {
- return injectionTargets;
- }
-
- // -------------------------------------------------------- Package Methods
-
-
- /**
- * The NamingResources with which we are associated (if any).
- */
- protected NamingResources resources = null;
-
- public NamingResources getNamingResources() {
- return (this.resources);
- }
-
- void setNamingResources(NamingResources resources) {
- this.resources = resources;
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/WebAbsoluteOrdering.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/WebAbsoluteOrdering.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/WebAbsoluteOrdering.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,49 +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.deploy;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-public class WebAbsoluteOrdering implements Serializable {
-
- protected String name = null;
- protected List<String> order = new ArrayList<String>();
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List<String> getOrder() {
- return order;
- }
-
- public void addName(String name) {
- order.add(name);
- }
-}
Deleted: trunk/java/org/apache/catalina/deploy/WebOrder.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/WebOrder.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/WebOrder.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,47 +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.deploy;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-public class WebOrder implements Serializable {
-
- protected WebAbsoluteOrdering web = null;
- protected Map<String, WebOrdering> fragments = new HashMap<String, WebOrdering>();
-
- public Map<String, WebOrdering> getFragments() {
- return fragments;
- }
- public void setFragments(Map<String, WebOrdering> fragments) {
- this.fragments = fragments;
- }
- public WebAbsoluteOrdering getWeb() {
- return web;
- }
- public void addFragment(String name, WebOrdering ordering) {
- fragments.put(name, ordering);
- }
-
-}
Deleted: trunk/java/org/apache/catalina/deploy/WebOrdering.java
===================================================================
--- trunk/java/org/apache/catalina/deploy/WebOrdering.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/deploy/WebOrdering.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,88 +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.deploy;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-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;
- }
-
- public List<String> getAfter() {
- return after;
- }
-
- public void addAfter(String name) {
- after.add(name);
- }
-
- public List<String> getBefore() {
- return before;
- }
-
- 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;
- }
-
-}
Deleted: trunk/java/org/apache/catalina/loader/Constants.java
===================================================================
--- trunk/java/org/apache/catalina/loader/Constants.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/Constants.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,26 +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.loader;
-
-
-public class Constants {
-
- public static final String Package = "org.apache.catalina.loader";
-
-}
Deleted: trunk/java/org/apache/catalina/loader/JdbcLeakPrevention.java
===================================================================
--- trunk/java/org/apache/catalina/loader/JdbcLeakPrevention.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/JdbcLeakPrevention.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,64 +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.loader;
-
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.Enumeration;
-
-import org.apache.catalina.util.StringManager;
-
-/**
- * This class is loaded by the {@link WebappClassLoader} to enable it to
- * deregister JDBC drivers forgotten by the web application. There are some
- * classloading hacks involved - see {@link WebappClassLoader#clearReferences()}
- * for details - but the short version is do not just create a new instance of
- * this class with the new keyword.
- */
-public class JdbcLeakPrevention {
-
- /**
- * The logger for this class.
- */
- protected static org.jboss.logging.Logger log=
- org.jboss.logging.Logger.getLogger( JdbcLeakPrevention.class );
-
- /**
- * The string manager for this package.
- */
- protected static final StringManager sm =
- StringManager.getManager(Constants.Package);
-
- public void clearJdbcDriverRegistrations() {
- // Unregister any JDBC drivers loaded by the class loader that loaded
- // this class - ie the webapp class loader
- Enumeration<Driver> drivers = DriverManager.getDrivers();
- while (drivers.hasMoreElements()) {
- Driver driver = drivers.nextElement();
- try {
- DriverManager.deregisterDriver(driver);
- } catch (SQLException sqle) {
- log.warn(sm.getString("jdbcLeakPrevention.jdbcRemoveFailed",
- driver.toString()), sqle);
- }
- }
-
- }
-}
Deleted: trunk/java/org/apache/catalina/loader/LegacyWebappClassLoader.java
===================================================================
--- trunk/java/org/apache/catalina/loader/LegacyWebappClassLoader.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/LegacyWebappClassLoader.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,2354 +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.loader;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FilePermission;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.security.AccessControlException;
-import java.security.AccessController;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Policy;
-import java.security.PrivilegedAction;
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Vector;
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-import java.util.jar.Attributes.Name;
-
-import javax.naming.NameClassPair;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.DirContext;
-
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.util.StringManager;
-import org.apache.naming.JndiPermission;
-import org.apache.naming.resources.Resource;
-import org.apache.naming.resources.ResourceAttributes;
-import org.apache.tomcat.util.IntrospectionUtils;
-
-/**
- * Specialized web application class loader.
- * <p>
- * This class loader is a full reimplementation of the
- * <code>URLClassLoader</code> from the JDK. It is desinged to be fully
- * compatible with a normal <code>URLClassLoader</code>, although its internal
- * behavior may be completely different.
- * <p>
- * <strong>IMPLEMENTATION NOTE</strong> - This class loader faithfully follows
- * the delegation model recommended in the specification. The system class
- * loader will be queried first, then the local repositories, and only then
- * delegation to the parent class loader will occur. This allows the web
- * application to override any shared class except the classes from J2SE.
- * Special handling is provided from the JAXP XML parser interfaces, the JNDI
- * interfaces, and the classes from the servlet API, which are never loaded
- * from the webapp repository.
- * <p>
- * <strong>IMPLEMENTATION NOTE</strong> - Due to limitations in Jasper
- * compilation technology, any repository which contains classes from
- * the servlet API will be ignored by the class loader.
- * <p>
- * <strong>IMPLEMENTATION NOTE</strong> - The class loader generates source
- * URLs which include the full JAR URL when a class is loaded from a JAR file,
- * which allows setting security permission at the class level, even when a
- * class is contained inside a JAR.
- * <p>
- * <strong>IMPLEMENTATION NOTE</strong> - Local repositories are searched in
- * the order they are added via the initial constructor and/or any subsequent
- * calls to <code>addRepository()</code> or <code>addJar()</code>.
- * <p>
- * <strong>IMPLEMENTATION NOTE</strong> - No check for sealing violations or
- * security is made unless a security manager is present.
- *
- * @author Remy Maucherat
- * @author Craig R. McClanahan
- * @version $Revision: 1061 $ $Date: 2009-05-25 16:32:03 +0200 (Mon, 25 May 2009) $
- */
-public class LegacyWebappClassLoader
- extends URLClassLoader
- implements Reloader, Lifecycle
- {
-
- protected static org.jboss.logging.Logger log=
- org.jboss.logging.Logger.getLogger( LegacyWebappClassLoader.class );
-
- public static final boolean ENABLE_CLEAR_REFERENCES =
- Boolean.valueOf(System.getProperty("org.apache.catalina.loader.LegacyWebappClassLoader.ENABLE_CLEAR_REFERENCES", "true")).booleanValue();
-
- public static final boolean SYSTEM_CL_DELEGATION =
- Boolean.valueOf(System.getProperty("org.apache.catalina.loader.LegacyWebappClassLoader.SYSTEM_CL_DELEGATION", "true")).booleanValue();
-
- protected class PrivilegedFindResource
- implements PrivilegedAction {
-
- protected File file;
- protected String path;
-
- PrivilegedFindResource(File file, String path) {
- this.file = file;
- this.path = path;
- }
-
- public Object run() {
- return findResourceInternal(file, path);
- }
-
- }
-
-
- // ------------------------------------------------------- Static Variables
-
-
- /**
- * The set of trigger classes that will cause a proposed repository not
- * to be added if this class is visible to the class loader that loaded
- * this factory class. Typically, trigger classes will be listed for
- * components that have been integrated into the JDK for later versions,
- * but where the corresponding JAR files are required to run on
- * earlier versions.
- */
- protected static final String[] triggers = {
- "javax.servlet.Servlet" // Servlet API
- };
-
-
- /**
- * Set of package names which are not allowed to be loaded from a webapp
- * class loader without delegating first.
- */
- protected static final String[] packageTriggers = {
- };
-
-
- /**
- * The string manager for this package.
- */
- protected static final StringManager sm =
- StringManager.getManager(Constants.Package);
-
-
- /**
- * Use anti JAR locking code, which does URL rerouting when accessing
- * resources.
- */
- boolean antiJARLocking = false;
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a new ClassLoader with no defined repositories and no
- * parent ClassLoader.
- */
- public LegacyWebappClassLoader() {
-
- super(new URL[0]);
- this.parent = getParent();
- system = getSystemClassLoader();
- securityManager = System.getSecurityManager();
-
- if (securityManager != null) {
- refreshPolicy();
- }
-
- }
-
-
- /**
- * Construct a new ClassLoader with no defined repositories and no
- * parent ClassLoader.
- */
- public LegacyWebappClassLoader(ClassLoader parent) {
-
- super(new URL[0], parent);
-
- this.parent = getParent();
-
- system = getSystemClassLoader();
- securityManager = System.getSecurityManager();
-
- if (securityManager != null) {
- refreshPolicy();
- }
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * Associated directory context giving access to the resources in this
- * webapp.
- */
- protected DirContext resources = null;
-
-
- /**
- * The cache of ResourceEntry for classes and resources we have loaded,
- * keyed by resource name.
- */
- protected HashMap resourceEntries = new HashMap();
-
-
- /**
- * The list of not found resources.
- */
- protected HashMap notFoundResources = new HashMap();
-
-
- /**
- * Should this class loader delegate to the parent class loader
- * <strong>before</strong> searching its own repositories (i.e. the
- * usual Java2 delegation model)? If set to <code>false</code>,
- * this class loader will search its own repositories first, and
- * delegate to the parent only if the class or resource is not
- * found locally.
- */
- protected boolean delegate = false;
-
-
- /**
- * Last time a JAR was accessed.
- */
- protected long lastJarAccessed = 0L;
-
-
- /**
- * The list of local repositories, in the order they should be searched
- * for locally loaded classes or resources.
- */
- protected String[] repositories = new String[0];
-
-
- /**
- * Repositories URLs, used to cache the result of getURLs.
- */
- protected URL[] repositoryURLs = null;
-
-
- /**
- * Repositories translated as path in the work directory (for Jasper
- * originally), but which is used to generate fake URLs should getURLs be
- * called.
- */
- protected File[] files = new File[0];
-
-
- /**
- * The list of JARs, in the order they should be searched
- * for locally loaded classes or resources.
- */
- protected JarFile[] jarFiles = new JarFile[0];
-
-
- /**
- * The list of JARs, in the order they should be searched
- * for locally loaded classes or resources.
- */
- protected File[] jarRealFiles = new File[0];
-
-
- /**
- * The path which will be monitored for added Jar files.
- */
- protected String jarPath = null;
-
-
- /**
- * The list of JARs, in the order they should be searched
- * for locally loaded classes or resources.
- */
- protected String[] jarNames = new String[0];
-
-
- /**
- * The list of JARs last modified dates, in the order they should be
- * searched for locally loaded classes or resources.
- */
- protected long[] lastModifiedDates = new long[0];
-
-
- /**
- * The list of resources which should be checked when checking for
- * modifications.
- */
- protected String[] paths = new String[0];
-
-
- /**
- * A list of read File and Jndi Permission's required if this loader
- * is for a web application context.
- */
- protected ArrayList permissionList = new ArrayList();
-
-
- /**
- * Path where resources loaded from JARs will be extracted.
- */
- protected File loaderDir = null;
-
-
- /**
- * The PermissionCollection for each CodeSource for a web
- * application context.
- */
- protected HashMap loaderPC = new HashMap();
-
-
- /**
- * Instance of the SecurityManager installed.
- */
- protected SecurityManager securityManager = null;
-
-
- /**
- * The parent class loader.
- */
- protected ClassLoader parent = null;
-
-
- /**
- * The system class loader.
- */
- protected ClassLoader system = null;
-
-
- /**
- * Has this component been started?
- */
- protected boolean started = false;
-
-
- /**
- * Has external repositories.
- */
- protected boolean hasExternalRepositories = false;
-
- /**
- * need conversion for properties files
- */
- protected boolean needConvert = false;
-
-
- /**
- * All permission.
- */
- protected Permission allPermission = new java.security.AllPermission();
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Get associated resources.
- */
- public DirContext getResources() {
-
- return this.resources;
-
- }
-
-
- /**
- * Set associated resources.
- */
- public void setResources(DirContext resources) {
-
- this.resources = resources;
-
- }
-
-
- /**
- * Return the "delegate first" flag for this class loader.
- */
- public boolean getDelegate() {
-
- return (this.delegate);
-
- }
-
-
- /**
- * Set the "delegate first" flag for this class loader.
- *
- * @param delegate The new "delegate first" flag
- */
- public void setDelegate(boolean delegate) {
-
- this.delegate = delegate;
-
- }
-
-
- /**
- * @return Returns the antiJARLocking.
- */
- public boolean getAntiJARLocking() {
- return antiJARLocking;
- }
-
-
- /**
- * @param antiJARLocking The antiJARLocking to set.
- */
- public void setAntiJARLocking(boolean antiJARLocking) {
- this.antiJARLocking = antiJARLocking;
- }
-
-
- /**
- * If there is a Java SecurityManager create a read FilePermission
- * or JndiPermission for the file directory path.
- *
- * @param path file directory path
- */
- public void addPermission(String path) {
- if (path == null) {
- return;
- }
-
- if (securityManager != null) {
- Permission permission = null;
- if( path.startsWith("jndi:") || path.startsWith("jar:jndi:") ) {
- if (!path.endsWith("/")) {
- path = path + "/";
- }
- permission = new JndiPermission(path + "*");
- addPermission(permission);
- } else {
- if (!path.endsWith(File.separator)) {
- permission = new FilePermission(path, "read");
- addPermission(permission);
- path = path + File.separator;
- }
- permission = new FilePermission(path + "-", "read");
- addPermission(permission);
- }
- }
- }
-
-
- /**
- * If there is a Java SecurityManager create a read FilePermission
- * or JndiPermission for URL.
- *
- * @param url URL for a file or directory on local system
- */
- public void addPermission(URL url) {
- if (url != null) {
- addPermission(url.toString());
- }
- }
-
-
- /**
- * If there is a Java SecurityManager create a Permission.
- *
- * @param permission The permission
- */
- public void addPermission(Permission permission) {
- if ((securityManager != null) && (permission != null)) {
- permissionList.add(permission);
- }
- }
-
-
- /**
- * Return the JAR path.
- */
- public String getJarPath() {
-
- return this.jarPath;
-
- }
-
-
- /**
- * Change the Jar path.
- */
- public void setJarPath(String jarPath) {
-
- this.jarPath = jarPath;
-
- }
-
-
- /**
- * Change the work directory.
- */
- public void setWorkDir(File workDir) {
- this.loaderDir = new File(workDir, "loader");
- }
-
- /**
- * Utility method for use in subclasses.
- * Must be called before Lifecycle methods to have any effect.
- */
- protected void setParentClassLoader(ClassLoader pcl) {
- parent = pcl;
- }
-
- // ------------------------------------------------------- Reloader Methods
-
-
- /**
- * Add a new repository to the set of places this ClassLoader can look for
- * classes to be loaded.
- *
- * @param repository Name of a source of classes to be loaded, such as a
- * directory pathname, a JAR file pathname, or a ZIP file pathname
- *
- * @exception IllegalArgumentException if the specified repository is
- * invalid or does not exist
- */
- public void addRepository(String repository) {
-
- // Ignore any of the standard repositories, as they are set up using
- // either addJar or addRepository
- if (repository.startsWith("/WEB-INF/lib")
- || repository.startsWith("/WEB-INF/classes"))
- return;
-
- // Add this repository to our underlying class loader
- try {
- URL url = new URL(repository);
- super.addURL(url);
- hasExternalRepositories = true;
- repositoryURLs = null;
- } catch (MalformedURLException e) {
- IllegalArgumentException iae = new IllegalArgumentException
- ("Invalid repository: " + repository);
- iae.initCause(e);
- throw iae;
- }
-
- }
-
-
- /**
- * Add a new repository to the set of places this ClassLoader can look for
- * classes to be loaded.
- *
- * @param repository Name of a source of classes to be loaded, such as a
- * directory pathname, a JAR file pathname, or a ZIP file pathname
- *
- * @exception IllegalArgumentException if the specified repository is
- * invalid or does not exist
- */
- synchronized void addRepository(String repository, File file) {
-
- // Note : There should be only one (of course), but I think we should
- // keep this a bit generic
-
- if (repository == null)
- return;
-
- if (log.isDebugEnabled())
- log.debug("addRepository(" + repository + ")");
-
- int i;
-
- // Add this repository to our internal list
- String[] result = new String[repositories.length + 1];
- for (i = 0; i < repositories.length; i++) {
- result[i] = repositories[i];
- }
- result[repositories.length] = repository;
- repositories = result;
-
- // Add the file to the list
- File[] result2 = new File[files.length + 1];
- for (i = 0; i < files.length; i++) {
- result2[i] = files[i];
- }
- result2[files.length] = file;
- files = result2;
-
- }
-
-
- synchronized void addJar(String jar, JarFile jarFile, File file)
- throws IOException {
-
- if (jar == null)
- return;
- if (jarFile == null)
- return;
- if (file == null)
- return;
-
- if (log.isDebugEnabled())
- log.debug("addJar(" + jar + ")");
-
- int i;
-
- if ((jarPath != null) && (jar.startsWith(jarPath))) {
-
- String jarName = jar.substring(jarPath.length());
- while (jarName.startsWith("/"))
- jarName = jarName.substring(1);
-
- String[] result = new String[jarNames.length + 1];
- for (i = 0; i < jarNames.length; i++) {
- result[i] = jarNames[i];
- }
- result[jarNames.length] = jarName;
- jarNames = result;
-
- }
-
- try {
-
- // Register the JAR for tracking
-
- long lastModified =
- ((ResourceAttributes) resources.getAttributes(jar))
- .getLastModified();
-
- String[] result = new String[paths.length + 1];
- for (i = 0; i < paths.length; i++) {
- result[i] = paths[i];
- }
- result[paths.length] = jar;
- paths = result;
-
- long[] result3 = new long[lastModifiedDates.length + 1];
- for (i = 0; i < lastModifiedDates.length; i++) {
- result3[i] = lastModifiedDates[i];
- }
- result3[lastModifiedDates.length] = lastModified;
- lastModifiedDates = result3;
-
- } catch (NamingException e) {
- // Ignore
- }
-
- // If the JAR currently contains invalid classes, don't actually use it
- // for classloading
- if (!validateJarFile(file))
- return;
-
- JarFile[] result2 = new JarFile[jarFiles.length + 1];
- for (i = 0; i < jarFiles.length; i++) {
- result2[i] = jarFiles[i];
- }
- result2[jarFiles.length] = jarFile;
- jarFiles = result2;
-
- // Add the file to the list
- File[] result4 = new File[jarRealFiles.length + 1];
- for (i = 0; i < jarRealFiles.length; i++) {
- result4[i] = jarRealFiles[i];
- }
- result4[jarRealFiles.length] = file;
- jarRealFiles = result4;
- }
-
-
- /**
- * Return a String array of the current repositories for this class
- * loader. If there are no repositories, a zero-length array is
- * returned.For security reason, returns a clone of the Array (since
- * String are immutable).
- */
- public String[] findRepositories() {
-
- return ((String[])repositories.clone());
-
- }
-
-
- /**
- * Have one or more classes or resources been modified so that a reload
- * is appropriate?
- */
- public boolean modified() {
-
- if (log.isDebugEnabled())
- log.debug("modified()");
-
- // Checking for modified loaded resources
- int length = paths.length;
-
- // A rare race condition can occur in the updates of the two arrays
- // It's totally ok if the latest class added is not checked (it will
- // be checked the next time
- int length2 = lastModifiedDates.length;
- if (length > length2)
- length = length2;
-
- for (int i = 0; i < length; i++) {
- try {
- long lastModified =
- ((ResourceAttributes) resources.getAttributes(paths[i]))
- .getLastModified();
- if (lastModified != lastModifiedDates[i]) {
- if( log.isDebugEnabled() )
- log.debug(" Resource '" + paths[i]
- + "' was modified; Date is now: "
- + new java.util.Date(lastModified) + " Was: "
- + new java.util.Date(lastModifiedDates[i]));
- return (true);
- }
- } catch (NamingException e) {
- log.error(" Resource '" + paths[i] + "' is missing");
- return (true);
- }
- }
-
- length = jarNames.length;
-
- // Check if JARs have been added or removed
- if (getJarPath() != null) {
-
- try {
- NamingEnumeration enumeration = resources.list(getJarPath());
- int i = 0;
- while (enumeration.hasMoreElements() && (i < length)) {
- NameClassPair ncPair = (NameClassPair) enumeration.nextElement();
- String name = ncPair.getName();
- // Ignore non JARs present in the lib folder
- if (!name.endsWith(".jar"))
- continue;
- if (!name.equals(jarNames[i])) {
- // Missing JAR
- log.info(" Additional JARs have been added : '"
- + name + "'");
- return (true);
- }
- i++;
- }
- if (enumeration.hasMoreElements()) {
- while (enumeration.hasMoreElements()) {
- NameClassPair ncPair =
- (NameClassPair) enumeration.nextElement();
- String name = ncPair.getName();
- // Additional non-JAR files are allowed
- if (name.endsWith(".jar")) {
- // There was more JARs
- log.info(" Additional JARs have been added");
- return (true);
- }
- }
- } else if (i < jarNames.length) {
- // There was less JARs
- log.info(" Additional JARs have been added");
- return (true);
- }
- } catch (NamingException e) {
- if (log.isDebugEnabled())
- log.debug(" Failed tracking modifications of '"
- + getJarPath() + "'");
- } catch (ClassCastException e) {
- log.error(" Failed tracking modifications of '"
- + getJarPath() + "' : " + e.getMessage());
- }
-
- }
-
- // No classes have been modified
- return (false);
-
- }
-
-
- /**
- * Render a String representation of this object.
- */
- public String toString() {
-
- StringBuffer sb = new StringBuffer("LegacyWebappClassLoader\r\n");
- sb.append(" delegate: ");
- sb.append(delegate);
- sb.append("\r\n");
- sb.append(" repositories:\r\n");
- if (repositories != null) {
- for (int i = 0; i < repositories.length; i++) {
- sb.append(" ");
- sb.append(repositories[i]);
- sb.append("\r\n");
- }
- }
- if (this.parent != null) {
- sb.append("----------> Parent Classloader:\r\n");
- sb.append(this.parent.toString());
- sb.append("\r\n");
- }
- return (sb.toString());
-
- }
-
-
- // ---------------------------------------------------- ClassLoader Methods
-
-
- /**
- * Add the specified URL to the classloader.
- */
- protected void addURL(URL url) {
- super.addURL(url);
- hasExternalRepositories = true;
- repositoryURLs = null;
- }
-
-
- /**
- * Find the specified class in our local repositories, if possible. If
- * not found, throw <code>ClassNotFoundException</code>.
- *
- * @param name Name of the class to be loaded
- *
- * @exception ClassNotFoundException if the class was not found
- */
- public Class findClass(String name) throws ClassNotFoundException {
-
- if (log.isDebugEnabled())
- log.debug(" findClass(" + name + ")");
-
- // Cannot load anything from local repositories if class loader is stopped
- if (!started) {
- throw new ClassNotFoundException(name);
- }
-
- // (1) Permission to define this class when using a SecurityManager
- if (securityManager != null) {
- int i = name.lastIndexOf('.');
- if (i >= 0) {
- try {
- if (log.isTraceEnabled())
- log.trace(" securityManager.checkPackageDefinition");
- securityManager.checkPackageDefinition(name.substring(0,i));
- } catch (Exception se) {
- if (log.isTraceEnabled())
- log.trace(" -->Exception-->ClassNotFoundException", se);
- throw new ClassNotFoundException(name, se);
- }
- }
- }
-
- // Ask our superclass to locate this class, if possible
- // (throws ClassNotFoundException if it is not found)
- Class clazz = null;
- try {
- if (log.isTraceEnabled())
- log.trace(" findClassInternal(" + name + ")");
- try {
- clazz = findClassInternal(name);
- } catch(ClassNotFoundException cnfe) {
- if (!hasExternalRepositories) {
- throw cnfe;
- }
- } catch(AccessControlException ace) {
- throw new ClassNotFoundException(name, ace);
- } catch (RuntimeException e) {
- if (log.isTraceEnabled())
- log.trace(" -->RuntimeException Rethrown", e);
- throw e;
- }
- if ((clazz == null) && hasExternalRepositories) {
- try {
- synchronized (this) {
- clazz = super.findClass(name);
- }
- } catch(AccessControlException ace) {
- throw new ClassNotFoundException(name, ace);
- } catch (RuntimeException e) {
- if (log.isTraceEnabled())
- log.trace(" -->RuntimeException Rethrown", e);
- throw e;
- }
- }
- if (clazz == null) {
- if (log.isDebugEnabled())
- log.debug(" --> Returning ClassNotFoundException");
- throw new ClassNotFoundException(name);
- }
- } catch (ClassNotFoundException e) {
- if (log.isTraceEnabled())
- log.trace(" --> Passing on ClassNotFoundException");
- throw e;
- }
-
- // Return the class we have located
- if (log.isTraceEnabled())
- log.debug(" Returning class " + clazz);
- if ((log.isTraceEnabled()) && (clazz != null))
- log.debug(" Loaded by " + clazz.getClassLoader());
- return (clazz);
-
- }
-
-
- /**
- * Find the specified resource in our local repository, and return a
- * <code>URL</code> refering to it, or <code>null</code> if this resource
- * cannot be found.
- *
- * @param name Name of the resource to be found
- */
- public URL findResource(final String name) {
-
- if (log.isDebugEnabled())
- log.debug(" findResource(" + name + ")");
-
- URL url = null;
-
- ResourceEntry entry = (ResourceEntry) resourceEntries.get(name);
- if (entry == null) {
- entry = findResourceInternal(name, name);
- }
- if (entry != null) {
- url = entry.source;
- }
-
- if ((url == null) && hasExternalRepositories)
- url = super.findResource(name);
-
- if (log.isDebugEnabled()) {
- if (url != null)
- log.debug(" --> Returning '" + url.toString() + "'");
- else
- log.debug(" --> Resource not found, returning null");
- }
- return (url);
-
- }
-
-
- /**
- * Return an enumeration of <code>URLs</code> representing all of the
- * resources with the given name. If no resources with this name are
- * found, return an empty enumeration.
- *
- * @param name Name of the resources to be found
- *
- * @exception IOException if an input/output error occurs
- */
- public Enumeration findResources(String name) throws IOException {
-
- if (log.isDebugEnabled())
- log.debug(" findResources(" + name + ")");
-
- Vector result = new Vector();
-
- int jarFilesLength = jarFiles.length;
- int repositoriesLength = repositories.length;
-
- int i;
-
- // Looking at the repositories
- for (i = 0; i < repositoriesLength; i++) {
- try {
- String fullPath = repositories[i] + name;
- resources.lookup(fullPath);
- // Note : Not getting an exception here means the resource was
- // found
- try {
- result.addElement(getURI(new File(files[i], name)));
- } catch (MalformedURLException e) {
- // Ignore
- }
- } catch (NamingException e) {
- }
- }
-
- // Looking at the JAR files
- synchronized (jarFiles) {
- if (openJARs()) {
- for (i = 0; i < jarFilesLength; i++) {
- JarEntry jarEntry = jarFiles[i].getJarEntry(name);
- if (jarEntry != null) {
- try {
- String jarFakeUrl = getURI(jarRealFiles[i]).toString();
- jarFakeUrl = "jar:" + jarFakeUrl + "!/" + name;
- result.addElement(new URL(jarFakeUrl));
- } catch (MalformedURLException e) {
- // Ignore
- }
- }
- }
- }
- }
-
- // Adding the results of a call to the superclass
- if (hasExternalRepositories) {
-
- Enumeration otherResourcePaths = super.findResources(name);
-
- while (otherResourcePaths.hasMoreElements()) {
- result.addElement(otherResourcePaths.nextElement());
- }
-
- }
-
- return result.elements();
-
- }
-
-
- /**
- * Find the resource with the given name. A resource is some data
- * (images, audio, text, etc.) that can be accessed by class code in a
- * way that is independent of the location of the code. The name of a
- * resource is a "/"-separated path name that identifies the resource.
- * If the resource cannot be found, return <code>null</code>.
- * <p>
- * This method searches according to the following algorithm, returning
- * as soon as it finds the appropriate URL. If the resource cannot be
- * found, returns <code>null</code>.
- * <ul>
- * <li>If the <code>delegate</code> property is set to <code>true</code>,
- * call the <code>getResource()</code> method of the parent class
- * loader, if any.</li>
- * <li>Call <code>findResource()</code> to find this resource in our
- * locally defined repositories.</li>
- * <li>Call the <code>getResource()</code> method of the parent class
- * loader, if any.</li>
- * </ul>
- *
- * @param name Name of the resource to return a URL for
- */
- public URL getResource(String name) {
-
- if (log.isDebugEnabled())
- log.debug("getResource(" + name + ")");
- URL url = null;
-
- // (1) Delegate to parent if requested
- if (delegate) {
- if (log.isDebugEnabled())
- log.debug(" Delegating to parent classloader " + parent);
- ClassLoader loader = parent;
- if (loader == null)
- loader = system;
- url = loader.getResource(name);
- if (url != null) {
- if (log.isDebugEnabled())
- log.debug(" --> Returning '" + url.toString() + "'");
- return (url);
- }
- }
-
- // (2) Search local repositories
- url = findResource(name);
- if (url != null) {
- // Locating the repository for special handling in the case
- // of a JAR
- if (antiJARLocking) {
- ResourceEntry entry = (ResourceEntry) resourceEntries.get(name);
- try {
- String repository = entry.codeBase.toString();
- if ((repository.endsWith(".jar"))
- && (!(name.endsWith(".class")))) {
- // Copy binary content to the work directory if not present
- File resourceFile = new File(loaderDir, name);
- url = getURI(resourceFile);
- }
- } catch (Exception e) {
- // Ignore
- }
- }
- if (log.isDebugEnabled())
- log.debug(" --> Returning '" + url.toString() + "'");
- return (url);
- }
-
- // (3) Delegate to parent unconditionally if not already attempted
- if( !delegate ) {
- ClassLoader loader = parent;
- if (loader == null)
- loader = system;
- url = loader.getResource(name);
- if (url != null) {
- if (log.isDebugEnabled())
- log.debug(" --> Returning '" + url.toString() + "'");
- return (url);
- }
- }
-
- // (4) Resource was not found
- if (log.isDebugEnabled())
- log.debug(" --> Resource not found, returning null");
- return (null);
-
- }
-
-
- /**
- * Find the resource with the given name, and return an input stream
- * that can be used for reading it. The search order is as described
- * for <code>getResource()</code>, after checking to see if the resource
- * data has been previously cached. If the resource cannot be found,
- * return <code>null</code>.
- *
- * @param name Name of the resource to return an input stream for
- */
- public InputStream getResourceAsStream(String name) {
-
- if (log.isDebugEnabled())
- log.debug("getResourceAsStream(" + name + ")");
- InputStream stream = null;
-
- // (0) Check for a cached copy of this resource
- stream = findLoadedResource(name);
- if (stream != null) {
- if (log.isDebugEnabled())
- log.debug(" --> Returning stream from cache");
- return (stream);
- }
-
- // (1) Delegate to parent if requested
- if (delegate) {
- if (log.isDebugEnabled())
- log.debug(" Delegating to parent classloader " + parent);
- ClassLoader loader = parent;
- if (loader == null)
- loader = system;
- stream = loader.getResourceAsStream(name);
- if (stream != null) {
- // FIXME - cache???
- if (log.isDebugEnabled())
- log.debug(" --> Returning stream from parent");
- return (stream);
- }
- }
-
- // (2) Search local repositories
- if (log.isDebugEnabled())
- log.debug(" Searching local repositories");
- URL url = findResource(name);
- if (url != null) {
- // FIXME - cache???
- if (log.isDebugEnabled())
- log.debug(" --> Returning stream from local");
- stream = findLoadedResource(name);
- try {
- if (hasExternalRepositories && (stream == null))
- stream = url.openStream();
- } catch (IOException e) {
- ; // Ignore
- }
- if (stream != null)
- return (stream);
- }
-
- // (3) Delegate to parent unconditionally
- if (!delegate) {
- if (log.isDebugEnabled())
- log.debug(" Delegating to parent classloader unconditionally " + parent);
- ClassLoader loader = parent;
- if (loader == null)
- loader = system;
- stream = loader.getResourceAsStream(name);
- if (stream != null) {
- // FIXME - cache???
- if (log.isDebugEnabled())
- log.debug(" --> Returning stream from parent");
- return (stream);
- }
- }
-
- // (4) Resource was not found
- if (log.isDebugEnabled())
- log.debug(" --> Resource not found, returning null");
- return (null);
-
- }
-
-
- /**
- * Load the class with the specified name. This method searches for
- * classes in the same manner as <code>loadClass(String, boolean)</code>
- * with <code>false</code> as the second argument.
- *
- * @param name Name of the class to be loaded
- *
- * @exception ClassNotFoundException if the class was not found
- */
- public Class loadClass(String name) throws ClassNotFoundException {
-
- return (loadClass(name, false));
-
- }
-
-
- /**
- * Load the class with the specified name, searching using the following
- * algorithm until it finds and returns the class. If the class cannot
- * be found, returns <code>ClassNotFoundException</code>.
- * <ul>
- * <li>Call <code>findLoadedClass(String)</code> to check if the
- * class has already been loaded. If it has, the same
- * <code>Class</code> object is returned.</li>
- * <li>If the <code>delegate</code> property is set to <code>true</code>,
- * call the <code>loadClass()</code> method of the parent class
- * loader, if any.</li>
- * <li>Call <code>findClass()</code> to find this class in our locally
- * defined repositories.</li>
- * <li>Call the <code>loadClass()</code> method of our parent
- * class loader, if any.</li>
- * </ul>
- * If the class was found using the above steps, and the
- * <code>resolve</code> flag is <code>true</code>, this method will then
- * call <code>resolveClass(Class)</code> on the resulting Class object.
- *
- * @param name Name of the class to be loaded
- * @param resolve If <code>true</code> then resolve the class
- *
- * @exception ClassNotFoundException if the class was not found
- */
- public Class loadClass(String name, boolean resolve)
- throws ClassNotFoundException {
-
- if (log.isDebugEnabled())
- log.debug("loadClass(" + name + ", " + resolve + ")");
- Class clazz = null;
-
- // Log access to stopped classloader
- if (!started) {
- try {
- throw new IllegalStateException();
- } catch (IllegalStateException e) {
- log.info(sm.getString("WebappClassLoader.stopped", name), e);
- }
- }
-
- // (0) Check our previously loaded local class cache
- clazz = findLoadedClass0(name);
- if (clazz != null) {
- if (log.isDebugEnabled())
- log.debug(" Returning class from cache");
- if (resolve)
- resolveClass(clazz);
- return (clazz);
- }
-
- // (0.1) Check our previously loaded class cache
- clazz = findLoadedClass(name);
- if (clazz != null) {
- if (log.isDebugEnabled())
- log.debug(" Returning class from cache");
- if (resolve)
- resolveClass(clazz);
- return (clazz);
- }
-
- // (0.2) Try loading the class with the system class loader, to prevent
- // the webapp from overriding J2SE classes
- if (SYSTEM_CL_DELEGATION) {
- try {
- clazz = Class.forName(name, false, system);
- if (clazz != null) {
- if (resolve)
- resolveClass(clazz);
- return (clazz);
- }
- } catch (ClassNotFoundException e) {
- // Ignore
- }
- }
-
- // (0.5) Permission to access this class when using a SecurityManager
- if (securityManager != null) {
- int i = name.lastIndexOf('.');
- if (i >= 0) {
- try {
- securityManager.checkPackageAccess(name.substring(0,i));
- } catch (SecurityException se) {
- String error = "Security Violation, attempt to use " +
- "Restricted Class: " + name;
- log.info(error, se);
- throw new ClassNotFoundException(error, se);
- }
- }
- }
-
- boolean delegateLoad = delegate || filter(name);
-
- // (1) Delegate to our parent if requested
- if (delegateLoad) {
- if (log.isDebugEnabled())
- log.debug(" Delegating to parent classloader1 " + parent);
- ClassLoader loader = parent;
- if (loader == null)
- loader = system;
- try {
- clazz = Class.forName(name, false, loader);
- if (clazz != null) {
- if (log.isDebugEnabled())
- log.debug(" Loading class from parent");
- if (resolve)
- resolveClass(clazz);
- return (clazz);
- }
- } catch (ClassNotFoundException e) {
- ;
- }
- }
-
- // (2) Search local repositories
- if (log.isDebugEnabled())
- log.debug(" Searching local repositories");
- try {
- clazz = findClass(name);
- if (clazz != null) {
- if (log.isDebugEnabled())
- log.debug(" Loading class from local repository");
- if (resolve)
- resolveClass(clazz);
- return (clazz);
- }
- } catch (ClassNotFoundException e) {
- ;
- }
-
- // (3) Delegate to parent unconditionally
- if (!delegateLoad) {
- if (log.isDebugEnabled())
- log.debug(" Delegating to parent classloader at end: " + parent);
- ClassLoader loader = parent;
- if (loader == null)
- loader = system;
- try {
- clazz = Class.forName(name, false, loader);
- if (clazz != null) {
- if (log.isDebugEnabled())
- log.debug(" Loading class from parent");
- if (resolve)
- resolveClass(clazz);
- return (clazz);
- }
- } catch (ClassNotFoundException e) {
- ;
- }
- }
-
- throw new ClassNotFoundException(name);
- }
-
-
- /**
- * Get the Permissions for a CodeSource. If this instance
- * of LegacyWebappClassLoader is for a web application context,
- * add read FilePermission or JndiPermissions for the base
- * directory (if unpacked),
- * the context URL, and jar file resources.
- *
- * @param codeSource where the code was loaded from
- * @return PermissionCollection for CodeSource
- */
- protected PermissionCollection getPermissions(CodeSource codeSource) {
-
- String codeUrl = codeSource.getLocation().toString();
- PermissionCollection pc;
- if ((pc = (PermissionCollection)loaderPC.get(codeUrl)) == null) {
- pc = super.getPermissions(codeSource);
- if (pc != null) {
- Iterator perms = permissionList.iterator();
- while (perms.hasNext()) {
- Permission p = (Permission)perms.next();
- pc.add(p);
- }
- loaderPC.put(codeUrl,pc);
- }
- }
- return (pc);
-
- }
-
-
- /**
- * Returns the search path of URLs for loading classes and resources.
- * This includes the original list of URLs specified to the constructor,
- * along with any URLs subsequently appended by the addURL() method.
- * @return the search path of URLs for loading classes and resources.
- */
- public URL[] getURLs() {
-
- if (repositoryURLs != null) {
- return repositoryURLs;
- }
-
- URL[] external = super.getURLs();
-
- int filesLength = files.length;
- int jarFilesLength = jarRealFiles.length;
- int length = filesLength + jarFilesLength + external.length;
- int i;
-
- try {
-
- URL[] urls = new URL[length];
- for (i = 0; i < length; i++) {
- if (i < filesLength) {
- urls[i] = getURL(files[i], true);
- } else if (i < filesLength + jarFilesLength) {
- urls[i] = getURL(jarRealFiles[i - filesLength], true);
- } else {
- urls[i] = external[i - filesLength - jarFilesLength];
- }
- }
-
- repositoryURLs = urls;
-
- } catch (MalformedURLException e) {
- repositoryURLs = new URL[0];
- }
-
- return repositoryURLs;
-
- }
-
-
- // ------------------------------------------------------ Lifecycle Methods
-
-
- /**
- * Add a lifecycle event listener to this component.
- *
- * @param listener The listener to add
- */
- public void addLifecycleListener(LifecycleListener 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 new LifecycleListener[0];
- }
-
-
- /**
- * Remove a lifecycle event listener from this component.
- *
- * @param listener The listener to remove
- */
- public void removeLifecycleListener(LifecycleListener listener) {
- }
-
-
- /**
- * Start the class loader.
- *
- * @exception LifecycleException if a lifecycle error occurs
- */
- public void start() throws LifecycleException {
-
- started = true;
- String encoding = null;
- try {
- encoding = System.getProperty("file.encoding");
- } catch (Exception e) {
- return;
- }
- if (encoding.indexOf("EBCDIC")!=-1) {
- needConvert = true;
- }
-
- }
-
-
- /**
- * Stop the class loader.
- *
- * @exception LifecycleException if a lifecycle error occurs
- */
- public void stop() throws LifecycleException {
-
- // Clearing references should be done before setting started to
- // false, due to possible side effects
- clearReferences();
-
- started = false;
-
- int length = files.length;
- for (int i = 0; i < length; i++) {
- files[i] = null;
- }
-
- length = jarFiles.length;
- for (int i = 0; i < length; i++) {
- try {
- if (jarFiles[i] != null) {
- jarFiles[i].close();
- }
- } catch (IOException e) {
- // Ignore
- }
- jarFiles[i] = null;
- }
-
- notFoundResources.clear();
- resourceEntries.clear();
- resources = null;
- repositories = null;
- repositoryURLs = null;
- files = null;
- jarFiles = null;
- jarRealFiles = null;
- jarPath = null;
- jarNames = null;
- lastModifiedDates = null;
- paths = null;
- hasExternalRepositories = false;
- parent = null;
-
- permissionList.clear();
- loaderPC.clear();
-
- if (loaderDir != null) {
- deleteDir(loaderDir);
- }
-
- }
-
-
- /**
- * Used to periodically signal to the classloader to release
- * JAR resources.
- */
- public void closeJARs(boolean force) {
- if (jarFiles.length > 0) {
- synchronized (jarFiles) {
- if (force || (System.currentTimeMillis()
- > (lastJarAccessed + 90000))) {
- for (int i = 0; i < jarFiles.length; i++) {
- try {
- if (jarFiles[i] != null) {
- jarFiles[i].close();
- jarFiles[i] = null;
- }
- } catch (IOException e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed to close JAR", e);
- }
- }
- }
- }
- }
- }
- }
-
-
- // ------------------------------------------------------ Protected Methods
-
-
- /**
- * Clear references.
- */
- protected void clearReferences() {
-
- // Unregister any JDBC drivers loaded by this classloader
- Enumeration drivers = DriverManager.getDrivers();
- while (drivers.hasMoreElements()) {
- Driver driver = (Driver) drivers.nextElement();
- if (driver.getClass().getClassLoader() == this) {
- try {
- DriverManager.deregisterDriver(driver);
- } catch (SQLException e) {
- log.warn("SQL driver deregistration failed", e);
- }
- }
- }
-
- // Null out any static or final fields from loaded classes,
- // as a workaround for apparent garbage collection bugs
- if (ENABLE_CLEAR_REFERENCES) {
- Iterator loadedClasses = ((HashMap) resourceEntries.clone()).values().iterator();
- while (loadedClasses.hasNext()) {
- ResourceEntry entry = (ResourceEntry) loadedClasses.next();
- if (entry.loadedClass != null) {
- Class clazz = entry.loadedClass;
- try {
- Field[] fields = clazz.getDeclaredFields();
- for (int i = 0; i < fields.length; i++) {
- Field field = fields[i];
- int mods = field.getModifiers();
- if (field.getType().isPrimitive()
- || (field.getName().indexOf("$") != -1)) {
- continue;
- }
- if (Modifier.isStatic(mods)) {
- try {
- field.setAccessible(true);
- if (Modifier.isFinal(mods)) {
- if (!((field.getType().getName().startsWith("java."))
- || (field.getType().getName().startsWith("javax.")))) {
- nullInstance(field.get(null));
- }
- } else {
- field.set(null, null);
- if (log.isDebugEnabled()) {
- log.debug("Set field " + field.getName()
- + " to null in class " + clazz.getName());
- }
- }
- } catch (Throwable t) {
- if (log.isDebugEnabled()) {
- log.debug("Could not set field " + field.getName()
- + " to null in class " + clazz.getName(), t);
- }
- }
- }
- }
- } catch (Throwable t) {
- if (log.isDebugEnabled()) {
- log.debug("Could not clean fields for class " + clazz.getName(), t);
- }
- }
- }
- }
- }
-
- // Clear the IntrospectionUtils cache.
- IntrospectionUtils.clear();
-
- // Clear the classloader reference in the VM's bean introspector
- java.beans.Introspector.flushCaches();
-
- }
-
-
- protected void nullInstance(Object instance) {
- if (instance == null) {
- return;
- }
- Field[] fields = instance.getClass().getDeclaredFields();
- for (int i = 0; i < fields.length; i++) {
- Field field = fields[i];
- int mods = field.getModifiers();
- if (field.getType().isPrimitive()
- || (field.getName().indexOf("$") != -1)) {
- continue;
- }
- try {
- field.setAccessible(true);
- if (Modifier.isStatic(mods) && Modifier.isFinal(mods)) {
- // Doing something recursively is too risky
- continue;
- } else {
- Object value = field.get(instance);
- if (null != value) {
- Class valueClass = value.getClass();
- if (!loadedByThisOrChild(valueClass)) {
- if (log.isDebugEnabled()) {
- log.debug("Not setting field " + field.getName() +
- " to null in object of class " +
- instance.getClass().getName() +
- " because the referenced object was of type " +
- valueClass.getName() +
- " which was not loaded by this LegacyWebappClassLoader.");
- }
- } else {
- field.set(instance, null);
- if (log.isDebugEnabled()) {
- log.debug("Set field " + field.getName()
- + " to null in class " + instance.getClass().getName());
- }
- }
- }
- }
- } catch (Throwable t) {
- if (log.isDebugEnabled()) {
- log.debug("Could not set field " + field.getName()
- + " to null in object instance of class "
- + instance.getClass().getName(), t);
- }
- }
- }
- }
-
-
- /**
- * Determine whether a class was loaded by this class loader or one of
- * its child class loaders.
- */
- protected boolean loadedByThisOrChild(Class clazz)
- {
- boolean result = false;
- for (ClassLoader classLoader = clazz.getClassLoader();
- null != classLoader; classLoader = classLoader.getParent()) {
- if (classLoader.equals(this)) {
- result = true;
- break;
- }
- }
- return result;
- }
-
-
- /**
- * Used to periodically signal to the classloader to release JAR resources.
- */
- protected boolean openJARs() {
- if (started && (jarFiles.length > 0)) {
- lastJarAccessed = System.currentTimeMillis();
- if (jarFiles[0] == null) {
- for (int i = 0; i < jarFiles.length; i++) {
- try {
- jarFiles[i] = new JarFile(jarRealFiles[i]);
- } catch (IOException e) {
- if (log.isDebugEnabled()) {
- log.debug("Failed to open JAR", e);
- }
- return false;
- }
- }
- }
- }
- return true;
- }
-
-
- /**
- * Find specified class in local repositories.
- *
- * @return the loaded class, or null if the class isn't found
- */
- protected Class findClassInternal(String name)
- throws ClassNotFoundException {
-
- if (!validate(name))
- throw new ClassNotFoundException(name);
-
- String tempPath = name.replace('.', '/');
- String classPath = tempPath + ".class";
-
- ResourceEntry entry = null;
-
- entry = findResourceInternal(name, classPath);
-
- if (entry == null)
- throw new ClassNotFoundException(name);
-
- Class clazz = entry.loadedClass;
- if (clazz != null)
- return clazz;
-
- synchronized (this) {
- clazz = entry.loadedClass;
- if (clazz != null)
- return clazz;
-
- if (entry.binaryContent == null)
- throw new ClassNotFoundException(name);
-
- // Looking up the package
- String packageName = null;
- int pos = name.lastIndexOf('.');
- if (pos != -1)
- packageName = name.substring(0, pos);
-
- Package pkg = null;
-
- if (packageName != null) {
- pkg = getPackage(packageName);
- // Define the package (if null)
- if (pkg == null) {
- try {
- if (entry.manifest == null) {
- definePackage(packageName, null, null, null, null,
- null, null, null);
- } else {
- definePackage(packageName, entry.manifest,
- entry.codeBase);
- }
- } catch (IllegalArgumentException e) {
- // Ignore: normal error due to dual definition of package
- }
- pkg = getPackage(packageName);
- }
- }
-
- if (securityManager != null) {
-
- // Checking sealing
- if (pkg != null) {
- boolean sealCheck = true;
- if (pkg.isSealed()) {
- sealCheck = pkg.isSealed(entry.codeBase);
- } else {
- sealCheck = (entry.manifest == null)
- || !isPackageSealed(packageName, entry.manifest);
- }
- if (!sealCheck)
- throw new SecurityException
- ("Sealing violation loading " + name + " : Package "
- + packageName + " is sealed.");
- }
-
- }
-
- clazz = defineClass(name, entry.binaryContent, 0,
- entry.binaryContent.length,
- new CodeSource(entry.codeBase, entry.certificates));
- entry.loadedClass = clazz;
- entry.binaryContent = null;
- entry.source = null;
- entry.codeBase = null;
- entry.manifest = null;
- entry.certificates = null;
- }
-
- return clazz;
-
- }
-
- /**
- * Find specified resource in local repositories. This block
- * will execute under an AccessControl.doPrivilege block.
- *
- * @return the loaded resource, or null if the resource isn't found
- */
- protected ResourceEntry findResourceInternal(File file, String path){
- ResourceEntry entry = new ResourceEntry();
- try {
- entry.source = getURI(new File(file, path));
- entry.codeBase = getURL(new File(file, path), false);
- } catch (MalformedURLException e) {
- return null;
- }
- return entry;
- }
-
-
- /**
- * Find specified resource in local repositories.
- *
- * @return the loaded resource, or null if the resource isn't found
- */
- protected ResourceEntry findResourceInternal(String name, String path) {
-
- if (!started) {
- log.info(sm.getString("webappClassLoader.stopped", name));
- return null;
- }
-
- if ((name == null) || (path == null))
- return null;
-
- ResourceEntry entry = (ResourceEntry) resourceEntries.get(name);
- if (entry != null)
- return entry;
-
- int contentLength = -1;
- InputStream binaryStream = null;
-
- int jarFilesLength = jarFiles.length;
- int repositoriesLength = repositories.length;
-
- int i;
-
- Resource resource = null;
-
- boolean fileNeedConvert = false;
-
- for (i = 0; (entry == null) && (i < repositoriesLength); i++) {
- try {
-
- String fullPath = repositories[i] + path;
-
- Object lookupResult = resources.lookup(fullPath);
- if (lookupResult instanceof Resource) {
- resource = (Resource) lookupResult;
- }
-
- // Note : Not getting an exception here means the resource was
- // found
- if (securityManager != null) {
- PrivilegedAction dp =
- new PrivilegedFindResource(files[i], path);
- entry = (ResourceEntry)AccessController.doPrivileged(dp);
- } else {
- entry = findResourceInternal(files[i], path);
- }
-
- ResourceAttributes attributes =
- (ResourceAttributes) resources.getAttributes(fullPath);
- contentLength = (int) attributes.getContentLength();
- entry.lastModified = attributes.getLastModified();
-
- if (resource != null) {
-
-
- try {
- binaryStream = resource.streamContent();
- } catch (IOException e) {
- return null;
- }
-
- if (needConvert) {
- if (path.endsWith(".properties")) {
- fileNeedConvert = true;
- }
- }
-
- // Register the full path for modification checking
- // Note: Only syncing on a 'constant' object is needed
- synchronized (allPermission) {
-
- int j;
-
- long[] result2 =
- new long[lastModifiedDates.length + 1];
- for (j = 0; j < lastModifiedDates.length; j++) {
- result2[j] = lastModifiedDates[j];
- }
- result2[lastModifiedDates.length] = entry.lastModified;
- lastModifiedDates = result2;
-
- String[] result = new String[paths.length + 1];
- for (j = 0; j < paths.length; j++) {
- result[j] = paths[j];
- }
- result[paths.length] = fullPath;
- paths = result;
-
- }
-
- }
-
- } catch (NamingException e) {
- }
- }
-
- if ((entry == null) && (notFoundResources.containsKey(name)))
- return null;
-
- JarEntry jarEntry = null;
-
- synchronized (jarFiles) {
-
- if (!openJARs()) {
- return null;
- }
- for (i = 0; (entry == null) && (i < jarFilesLength); i++) {
-
- jarEntry = jarFiles[i].getJarEntry(path);
-
- if (jarEntry != null) {
-
- entry = new ResourceEntry();
- try {
- entry.codeBase = getURL(jarRealFiles[i], false);
- String jarFakeUrl = getURI(jarRealFiles[i]).toString();
- jarFakeUrl = "jar:" + jarFakeUrl + "!/" + path;
- entry.source = new URL(jarFakeUrl);
- entry.lastModified = jarRealFiles[i].lastModified();
- } catch (MalformedURLException e) {
- return null;
- }
- contentLength = (int) jarEntry.getSize();
- try {
- entry.manifest = jarFiles[i].getManifest();
- binaryStream = jarFiles[i].getInputStream(jarEntry);
- } catch (IOException e) {
- return null;
- }
-
- // Extract resources contained in JAR to the workdir
- if (antiJARLocking && !(path.endsWith(".class"))) {
- byte[] buf = new byte[1024];
- File resourceFile = new File
- (loaderDir, jarEntry.getName());
- if (!resourceFile.exists()) {
- Enumeration entries = jarFiles[i].entries();
- while (entries.hasMoreElements()) {
- JarEntry jarEntry2 =
- (JarEntry) entries.nextElement();
- if (!(jarEntry2.isDirectory())
- && (!jarEntry2.getName().endsWith
- (".class"))) {
- resourceFile = new File
- (loaderDir, jarEntry2.getName());
- resourceFile.getParentFile().mkdirs();
- FileOutputStream os = null;
- InputStream is = null;
- try {
- is = jarFiles[i].getInputStream
- (jarEntry2);
- os = new FileOutputStream
- (resourceFile);
- while (true) {
- int n = is.read(buf);
- if (n <= 0) {
- break;
- }
- os.write(buf, 0, n);
- }
- } catch (IOException e) {
- // Ignore
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- } catch (IOException e) {
- }
- try {
- if (os != null) {
- os.close();
- }
- } catch (IOException e) {
- }
- }
- }
- }
- }
- }
-
- }
-
- }
-
- if (entry == null) {
- synchronized (notFoundResources) {
- notFoundResources.put(name, name);
- }
- return null;
- }
-
- if (binaryStream != null) {
-
- byte[] binaryContent = new byte[contentLength];
-
- int pos = 0;
- try {
-
- while (true) {
- int n = binaryStream.read(binaryContent, pos,
- binaryContent.length - pos);
- if (n <= 0)
- break;
- pos += n;
- }
- } catch (IOException e) {
- log.error(sm.getString("webappClassLoader.readError", name), e);
- return null;
- } finally {
- try {
- binaryStream.close();
- } catch (IOException e) {}
- }
-
- if (fileNeedConvert) {
- String str = new String(binaryContent,0,pos);
- try {
- binaryContent = str.getBytes("UTF-8");
- } catch (Exception e) {
- return null;
- }
- }
- entry.binaryContent = binaryContent;
-
- // The certificates are only available after the JarEntry
- // associated input stream has been fully read
- if (jarEntry != null) {
- entry.certificates = jarEntry.getCertificates();
- }
-
- }
-
- }
-
- // Add the entry in the local resource repository
- synchronized (resourceEntries) {
- // Ensures that all the threads which may be in a race to load
- // a particular class all end up with the same ResourceEntry
- // instance
- ResourceEntry entry2 = (ResourceEntry) resourceEntries.get(name);
- if (entry2 == null) {
- resourceEntries.put(name, entry);
- } else {
- entry = entry2;
- }
- }
-
- return entry;
-
- }
-
-
- /**
- * Returns true if the specified package name is sealed according to the
- * given manifest.
- */
- protected boolean isPackageSealed(String name, Manifest man) {
-
- String path = name.replace('.', '/') + '/';
- Attributes attr = man.getAttributes(path);
- String sealed = null;
- if (attr != null) {
- sealed = attr.getValue(Name.SEALED);
- }
- if (sealed == null) {
- if ((attr = man.getMainAttributes()) != null) {
- sealed = attr.getValue(Name.SEALED);
- }
- }
- return "true".equalsIgnoreCase(sealed);
-
- }
-
-
- /**
- * Finds the resource with the given name if it has previously been
- * loaded and cached by this class loader, and return an input stream
- * to the resource data. If this resource has not been cached, return
- * <code>null</code>.
- *
- * @param name Name of the resource to return
- */
- protected InputStream findLoadedResource(String name) {
-
- ResourceEntry entry = (ResourceEntry) resourceEntries.get(name);
- if (entry != null) {
- if (entry.binaryContent != null)
- return new ByteArrayInputStream(entry.binaryContent);
- }
- return (null);
-
- }
-
-
- /**
- * Finds the class with the given name if it has previously been
- * loaded and cached by this class loader, and return the Class object.
- * If this class has not been cached, return <code>null</code>.
- *
- * @param name Name of the resource to return
- */
- protected Class findLoadedClass0(String name) {
-
- ResourceEntry entry = (ResourceEntry) resourceEntries.get(name);
- if (entry != null) {
- return entry.loadedClass;
- }
- return (null); // FIXME - findLoadedResource()
-
- }
-
-
- /**
- * Refresh the system policy file, to pick up eventual changes.
- */
- protected void refreshPolicy() {
-
- try {
- // The policy file may have been modified to adjust
- // permissions, so we're reloading it when loading or
- // reloading a Context
- Policy policy = Policy.getPolicy();
- policy.refresh();
- } catch (AccessControlException e) {
- // Some policy files may restrict this, even for the core,
- // so this exception is ignored
- }
-
- }
-
-
- /**
- * Filter classes.
- *
- * @param name class name
- * @return true if the class should be filtered
- */
- protected boolean filter(String name) {
-
- if (name == null)
- return false;
-
- // Looking up the package
- String packageName = null;
- int pos = name.lastIndexOf('.');
- if (pos != -1)
- packageName = name.substring(0, pos);
- else
- return false;
-
- for (int i = 0; i < packageTriggers.length; i++) {
- if (packageName.startsWith(packageTriggers[i]))
- return true;
- }
-
- return false;
-
- }
-
-
- /**
- * Validate a classname. As per SRV.9.7.2, we must restict loading of
- * classes from J2SE (java.*) and classes of the servlet API
- * (javax.servlet.*). That should enhance robustness and prevent a number
- * of user error (where an older version of servlet.jar would be present
- * in /WEB-INF/lib).
- *
- * @param name class name
- * @return true if the name is valid
- */
- protected boolean validate(String name) {
-
- if (name == null)
- return false;
- if (name.startsWith("java."))
- return false;
-
- return true;
-
- }
-
-
- /**
- * Check the specified JAR file, and return <code>true</code> if it does
- * not contain any of the trigger classes.
- *
- * @param jarfile The JAR file to be checked
- *
- * @exception IOException if an input/output error occurs
- */
- protected boolean validateJarFile(File jarfile)
- throws IOException {
-
- if (triggers == null)
- return (true);
- JarFile jarFile = new JarFile(jarfile);
- for (int i = 0; i < triggers.length; i++) {
- Class clazz = null;
- try {
- if (parent != null) {
- clazz = parent.loadClass(triggers[i]);
- } else {
- clazz = Class.forName(triggers[i]);
- }
- } catch (Throwable t) {
- clazz = null;
- }
- if (clazz == null)
- continue;
- String name = triggers[i].replace('.', '/') + ".class";
- if (log.isDebugEnabled())
- log.debug(" Checking for " + name);
- JarEntry jarEntry = jarFile.getJarEntry(name);
- if (jarEntry != null) {
- log.info("validateJarFile(" + jarfile +
- ") - jar not loaded. See Servlet Spec 2.3, "
- + "section 9.7.2. Offending class: " + name);
- jarFile.close();
- return (false);
- }
- }
- jarFile.close();
- return (true);
-
- }
-
-
- /**
- * Get URL.
- */
- protected URL getURL(File file, boolean encoded)
- throws MalformedURLException {
-
- File realFile = file;
- try {
- realFile = realFile.getCanonicalFile();
- } catch (IOException e) {
- // Ignore
- }
- if(encoded) {
- return getURI(realFile);
- } else {
- return realFile.toURL();
- }
-
- }
-
-
- /**
- * Get URL.
- */
- protected URL getURI(File file)
- throws MalformedURLException {
-
-
- File realFile = file;
- try {
- realFile = realFile.getCanonicalFile();
- } catch (IOException e) {
- // Ignore
- }
- return realFile.toURI().toURL();
-
- }
-
-
- /**
- * Delete the specified directory, including all of its contents and
- * subdirectories recursively.
- *
- * @param dir File object representing the directory to be deleted
- */
- protected static void deleteDir(File dir) {
-
- String files[] = dir.list();
- if (files == null) {
- files = new String[0];
- }
- for (int i = 0; i < files.length; i++) {
- File file = new File(dir, files[i]);
- if (file.isDirectory()) {
- deleteDir(file);
- } else {
- file.delete();
- }
- }
- dir.delete();
-
- }
-
-
-}
-
Deleted: trunk/java/org/apache/catalina/loader/LegacyWebappLoader.java
===================================================================
--- trunk/java/org/apache/catalina/loader/LegacyWebappLoader.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/LegacyWebappLoader.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,1234 +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.loader;
-
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FilePermission;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLStreamHandlerFactory;
-import java.util.ArrayList;
-import java.util.jar.JarFile;
-
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-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.Container;
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Globals;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.Loader;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.util.LifecycleSupport;
-import org.apache.catalina.util.StringManager;
-import org.apache.naming.resources.DirContextURLStreamHandler;
-import org.apache.naming.resources.DirContextURLStreamHandlerFactory;
-import org.apache.naming.resources.Resource;
-import org.apache.tomcat.util.modeler.Registry;
-
-
-/**
- * Classloader implementation which is specialized for handling web
- * applications in the most efficient way, while being Catalina aware (all
- * accesses to resources are made through the DirContext interface).
- * This class loader supports detection of modified
- * Java classes, which can be used to implement auto-reload support.
- * <p>
- * This class loader is configured by adding the pathnames of directories,
- * JAR files, and ZIP files with the <code>addRepository()</code> method,
- * prior to calling <code>start()</code>. When a new class is required,
- * these repositories will be consulted first to locate the class. If it
- * is not present, the system class loader will be used instead.
- *
- * @author Craig R. McClanahan
- * @author Remy Maucherat
- * @version $Revision: 914 $ $Date: 2009-01-29 17:56:25 +0100 (Thu, 29 Jan 2009) $
- */
-
-public class LegacyWebappLoader
- implements Lifecycle, Loader, PropertyChangeListener, MBeanRegistration {
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a new WebappLoader with no defined parent class loader
- * (so that the actual parent will be the system class loader).
- */
- public LegacyWebappLoader() {
-
- this(null);
-
- }
-
-
- /**
- * Construct a new WebappLoader with the specified class loader
- * to be defined as the parent of the ClassLoader we ultimately create.
- *
- * @param parent The parent class loader
- */
- public LegacyWebappLoader(ClassLoader parent) {
- super();
- this.parentClassLoader = parent;
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * First load of the class.
- */
- private static boolean first = true;
-
-
- /**
- * The class loader being managed by this Loader component.
- */
- private LegacyWebappClassLoader classLoader = null;
-
-
- /**
- * The Container with which this Loader has been associated.
- */
- private Container container = null;
-
-
- /**
- * The "follow standard delegation model" flag that will be used to
- * configure our ClassLoader.
- */
- private boolean delegate = false;
-
-
- /**
- * The descriptive information about this Loader implementation.
- */
- private static final String info =
- "org.apache.catalina.loader.LegacyWebappLoader/1.0";
-
-
- /**
- * The lifecycle event support for this component.
- */
- protected LifecycleSupport lifecycle = new LifecycleSupport(this);
-
-
- /**
- * The Java class name of the ClassLoader implementation to be used.
- * This class should extend LegacyWebappClassLoader, otherwise, a different
- * loader implementation must be used.
- */
- private String loaderClass =
- "org.apache.catalina.loader.LegacyWebappClassLoader";
-
-
- /**
- * The parent class loader of the class loader we will create.
- */
- private ClassLoader parentClassLoader = null;
-
-
- /**
- * The reloadable flag for this Loader.
- */
- private boolean reloadable = false;
-
-
- /**
- * The set of repositories associated with this class loader.
- */
- private String repositories[] = new String[0];
-
-
- /**
- * The string manager for this package.
- */
- protected static final StringManager sm =
- StringManager.getManager(Constants.Package);
-
-
- /**
- * Has this component been started?
- */
- private boolean started = false;
-
-
- /**
- * The property change support for this component.
- */
- protected PropertyChangeSupport support = new PropertyChangeSupport(this);
-
-
- /**
- * Classpath set in the loader.
- */
- private String classpath = null;
-
-
- /**
- * Repositories that are set in the loader, for JMX.
- */
- private ArrayList loaderRepositories = null;
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return the Java class loader to be used by this Container.
- */
- public ClassLoader getClassLoader() {
-
- return ((ClassLoader) classLoader);
-
- }
-
-
- /**
- * Return the Container with which this Logger has been associated.
- */
- public Container getContainer() {
-
- return (container);
-
- }
-
-
- /**
- * Set the Container with which this Logger has been associated.
- *
- * @param container The associated Container
- */
- public void setContainer(Container container) {
-
- // Deregister from the old Container (if any)
- if ((this.container != null) && (this.container instanceof Context))
- ((Context) this.container).removePropertyChangeListener(this);
-
- // Process this property change
- Container oldContainer = this.container;
- this.container = container;
- support.firePropertyChange("container", oldContainer, this.container);
-
- // Register with the new Container (if any)
- if ((this.container != null) && (this.container instanceof Context)) {
- setReloadable( ((Context) this.container).getReloadable() );
- ((Context) this.container).addPropertyChangeListener(this);
- }
-
- }
-
-
- /**
- * Return the "follow standard delegation model" flag used to configure
- * our ClassLoader.
- */
- public boolean getDelegate() {
-
- return (this.delegate);
-
- }
-
-
- /**
- * Set the "follow standard delegation model" flag used to configure
- * our ClassLoader.
- *
- * @param delegate The new flag
- */
- public void setDelegate(boolean delegate) {
-
- boolean oldDelegate = this.delegate;
- this.delegate = delegate;
- support.firePropertyChange("delegate", new Boolean(oldDelegate),
- new Boolean(this.delegate));
-
- }
-
-
- /**
- * Return descriptive information about this Loader implementation and
- * the corresponding version number, in the format
- * <code><description>/<version></code>.
- */
- public String getInfo() {
-
- return (info);
-
- }
-
-
- /**
- * Return the ClassLoader class name.
- */
- public String getLoaderClass() {
-
- return (this.loaderClass);
-
- }
-
-
- /**
- * Set the ClassLoader class name.
- *
- * @param loaderClass The new ClassLoader class name
- */
- public void setLoaderClass(String loaderClass) {
-
- this.loaderClass = loaderClass;
-
- }
-
-
- /**
- * Return the reloadable flag for this Loader.
- */
- public boolean getReloadable() {
-
- return (this.reloadable);
-
- }
-
-
- /**
- * Set the reloadable flag for this Loader.
- *
- * @param reloadable The new reloadable flag
- */
- public void setReloadable(boolean reloadable) {
-
- // Process this property change
- boolean oldReloadable = this.reloadable;
- this.reloadable = reloadable;
- support.firePropertyChange("reloadable",
- new Boolean(oldReloadable),
- new Boolean(this.reloadable));
-
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Add a property change listener to this component.
- *
- * @param listener The listener to add
- */
- public void addPropertyChangeListener(PropertyChangeListener listener) {
-
- support.addPropertyChangeListener(listener);
-
- }
-
-
- /**
- * Add a new repository to the set of repositories for this class loader.
- *
- * @param repository Repository to be added
- */
- public void addRepository(String repository) {
-
- if (log.isDebugEnabled())
- log.debug(sm.getString("webappLoader.addRepository", repository));
-
- for (int i = 0; i < repositories.length; i++) {
- if (repository.equals(repositories[i]))
- return;
- }
- String results[] = new String[repositories.length + 1];
- for (int i = 0; i < repositories.length; i++)
- results[i] = repositories[i];
- results[repositories.length] = repository;
- repositories = results;
-
- if (started && (classLoader != null)) {
- classLoader.addRepository(repository);
- if( loaderRepositories != null ) loaderRepositories.add(repository);
- setClassPath();
- }
-
- }
-
-
- /**
- * 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() {
- if (reloadable && modified()) {
- try {
- Thread.currentThread().setContextClassLoader
- (LegacyWebappLoader.class.getClassLoader());
- if (container instanceof StandardContext) {
- ((StandardContext) container).reload();
- }
- } finally {
- if (container.getLoader() != null) {
- Thread.currentThread().setContextClassLoader
- (container.getLoader().getClassLoader());
- }
- }
- } else {
- closeJARs(false);
- }
- }
-
-
- /**
- * Return the set of repositories defined for this class loader.
- * If none are defined, a zero-length array is returned.
- * For security reason, returns a clone of the Array (since
- * String are immutable).
- */
- public String[] findRepositories() {
-
- return ((String[])repositories.clone());
-
- }
-
- public String[] getRepositories() {
- return ((String[])repositories.clone());
- }
-
- /** Extra repositories for this loader
- */
- public String getRepositoriesString() {
- StringBuffer sb=new StringBuffer();
- for( int i=0; i<repositories.length ; i++ ) {
- sb.append( repositories[i]).append(":");
- }
- return sb.toString();
- }
-
- public String[] findLoaderRepositories() {
- return getLoaderRepositories();
- }
-
- public String[] getLoaderRepositories() {
- if( loaderRepositories==null ) return null;
- String res[]=new String[ loaderRepositories.size()];
- loaderRepositories.toArray(res);
- return res;
- }
-
- public String getLoaderRepositoriesString() {
- String repositories[]=getLoaderRepositories();
- StringBuffer sb=new StringBuffer();
- for( int i=0; i<repositories.length ; i++ ) {
- sb.append( repositories[i]).append(":");
- }
- return sb.toString();
- }
-
-
- /**
- * Classpath, as set in org.apache.catalina.jsp_classpath context
- * property
- *
- * @return The classpath
- */
- public String getClasspath() {
- return classpath;
- }
-
-
- /**
- * Has the internal repository associated with this Loader been modified,
- * such that the loaded classes should be reloaded?
- */
- public boolean modified() {
-
- return (classLoader.modified());
-
- }
-
-
- /**
- * Used to periodically signal to the classloader to release JAR resources.
- */
- public void closeJARs(boolean force) {
- if (classLoader !=null){
- classLoader.closeJARs(force);
- }
- }
-
-
- /**
- * Remove a property change listener from this component.
- *
- * @param listener The listener to remove
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
-
- support.removePropertyChangeListener(listener);
-
- }
-
-
- /**
- * Return a String representation of this component.
- */
- public String toString() {
-
- StringBuffer sb = new StringBuffer("WebappLoader[");
- if (container != null)
- sb.append(container.getName());
- sb.append("]");
- return (sb.toString());
-
- }
-
-
- // ------------------------------------------------------ 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);
-
- }
-
- private boolean initialized=false;
-
- public void init() {
- initialized=true;
-
- if( oname==null ) {
- // not registered yet - standalone or API
- if( container instanceof StandardContext) {
- // Register ourself. The container must be a webapp
- try {
- StandardContext ctx=(StandardContext)container;
- Engine eng=(Engine)ctx.getParent().getParent();
- String path = ctx.getPath();
- if (path.equals("")) {
- path = "/";
- }
- oname=new ObjectName(ctx.getEngineName() + ":type=Loader,path=" +
- path + ",host=" + ctx.getParent().getName());
- Registry.getRegistry(null, null).registerComponent(this, oname, null);
- controller=oname;
- } catch (Exception e) {
- log.error("Error registering loader", e );
- }
- }
- }
-
- if( container == null ) {
- // JMX created the loader
- // TODO
-
- }
- }
-
- public void destroy() {
- if( controller==oname ) {
- // Self-registration, undo it
- Registry.getRegistry(null, null).unregisterComponent(oname);
- oname = null;
- }
- initialized = false;
-
- }
-
- /**
- * Start this component, initializing our associated class loader.
- *
- * @exception LifecycleException if a lifecycle error occurs
- */
- public void start() throws LifecycleException {
- // Validate and update our current component state
- if( ! initialized ) init();
- if (started)
- throw new LifecycleException
- (sm.getString("webappLoader.alreadyStarted"));
- if (log.isDebugEnabled())
- log.debug(sm.getString("webappLoader.starting"));
- lifecycle.fireLifecycleEvent(START_EVENT, null);
- started = true;
-
- if (container.getResources() == null) {
- log.info("No resources for " + container);
- return;
- }
- // Register a stream handler factory for the JNDI protocol
- URLStreamHandlerFactory streamHandlerFactory =
- new DirContextURLStreamHandlerFactory();
- if (first) {
- first = false;
- try {
- URL.setURLStreamHandlerFactory(streamHandlerFactory);
- } catch (Exception e) {
- // Log and continue anyway, this is not critical
- log.error("Error registering jndi stream handler", e);
- } catch (Throwable t) {
- // This is likely a dual registration, ignore
- }
- }
-
- // Construct a class loader based on our current repositories list
- try {
-
- classLoader = createClassLoader();
- classLoader.setResources(container.getResources());
- classLoader.setDelegate(this.delegate);
- if (container instanceof StandardContext)
- classLoader.setAntiJARLocking(((StandardContext) container).getAntiJARLocking());
-
- for (int i = 0; i < repositories.length; i++) {
- classLoader.addRepository(repositories[i]);
- }
-
- // Configure our repositories
- setRepositories();
- setClassPath();
-
- setPermissions();
-
- if (classLoader instanceof Lifecycle)
- ((Lifecycle) classLoader).start();
-
- // Binding the Webapp class loader to the directory context
- DirContextURLStreamHandler.bind
- ((ClassLoader) classLoader, this.container.getResources());
-
- StandardContext ctx=(StandardContext)container;
- Engine eng=(Engine)ctx.getParent().getParent();
- String path = ctx.getPath();
- if (path.equals("")) {
- path = "/";
- }
- ObjectName cloname = new ObjectName
- (ctx.getEngineName() + ":type=LegacyWebappClassLoader,path="
- + path + ",host=" + ctx.getParent().getName());
- Registry.getRegistry(null, null)
- .registerComponent(classLoader, cloname, null);
-
- } catch (Throwable t) {
- log.error( "LifecycleException ", t );
- throw new LifecycleException("start: ", t);
- }
-
- }
-
-
- /**
- * Stop this component, finalizing our associated class loader.
- *
- * @exception LifecycleException if a lifecycle error occurs
- */
- public void stop() throws LifecycleException {
-
- // Validate and update our current component state
- if (!started)
- throw new LifecycleException
- (sm.getString("webappLoader.notStarted"));
- if (log.isDebugEnabled())
- log.debug(sm.getString("webappLoader.stopping"));
- lifecycle.fireLifecycleEvent(STOP_EVENT, null);
- started = false;
-
- // Remove context attributes as appropriate
- if (container instanceof Context) {
- ServletContext servletContext =
- ((Context) container).getServletContext();
- servletContext.removeAttribute(Globals.CLASS_PATH_ATTR);
- }
-
- // Throw away our current class loader
- if (classLoader instanceof Lifecycle)
- ((Lifecycle) classLoader).stop();
- DirContextURLStreamHandler.unbind((ClassLoader) classLoader);
-
- try {
- StandardContext ctx=(StandardContext)container;
- Engine eng=(Engine)ctx.getParent().getParent();
- String path = ctx.getPath();
- if (path.equals("")) {
- path = "/";
- }
- ObjectName cloname = new ObjectName
- (ctx.getEngineName() + ":type=LegacyWebappClassLoader,path="
- + path + ",host=" + ctx.getParent().getName());
- Registry.getRegistry(null, null).unregisterComponent(cloname);
- } catch (Throwable t) {
- log.error( "LifecycleException ", t );
- }
-
- classLoader = null;
-
- destroy();
-
- }
-
-
- // ----------------------------------------- PropertyChangeListener Methods
-
-
- /**
- * Process property change events from our associated Context.
- *
- * @param event The property change event that has occurred
- */
- public void propertyChange(PropertyChangeEvent event) {
-
- // Validate the source of this event
- if (!(event.getSource() instanceof Context))
- return;
- Context context = (Context) event.getSource();
-
- // Process a relevant property change
- if (event.getPropertyName().equals("reloadable")) {
- try {
- setReloadable
- ( ((Boolean) event.getNewValue()).booleanValue() );
- } catch (NumberFormatException e) {
- log.error(sm.getString("webappLoader.reloadable",
- event.getNewValue().toString()));
- }
- }
-
- }
-
-
- // ------------------------------------------------------- Private Methods
-
-
- /**
- * Create associated classLoader.
- */
- private LegacyWebappClassLoader createClassLoader()
- throws Exception {
-
- Class clazz = Class.forName(loaderClass);
- LegacyWebappClassLoader classLoader = null;
-
- if (parentClassLoader == null) {
- parentClassLoader = container.getParentClassLoader();
- }
- Class[] argTypes = { ClassLoader.class };
- Object[] args = { parentClassLoader };
- Constructor constr = clazz.getConstructor(argTypes);
- classLoader = (LegacyWebappClassLoader) constr.newInstance(args);
-
- return classLoader;
-
- }
-
-
- /**
- * Configure associated class loader permissions.
- */
- private void setPermissions() {
-
- if (!Globals.IS_SECURITY_ENABLED)
- return;
- if (!(container instanceof Context))
- return;
-
- // Tell the class loader the root of the context
- ServletContext servletContext =
- ((Context) container).getServletContext();
-
- // Assigning permissions for the work directory
- File workDir =
- (File) servletContext.getAttribute(ServletContext.TEMPDIR);
- if (workDir != null) {
- try {
- String workDirPath = workDir.getCanonicalPath();
- classLoader.addPermission
- (new FilePermission(workDirPath, "read,write"));
- classLoader.addPermission
- (new FilePermission(workDirPath + File.separator + "-",
- "read,write,delete"));
- } catch (IOException e) {
- // Ignore
- }
- }
-
- try {
-
- URL rootURL = servletContext.getResource("/");
- classLoader.addPermission(rootURL);
-
- String contextRoot = servletContext.getRealPath("/");
- if (contextRoot != null) {
- try {
- contextRoot = (new File(contextRoot)).getCanonicalPath();
- classLoader.addPermission(contextRoot);
- } catch (IOException e) {
- // Ignore
- }
- }
-
- URL classesURL = servletContext.getResource("/WEB-INF/classes/");
- classLoader.addPermission(classesURL);
- URL libURL = servletContext.getResource("/WEB-INF/lib/");
- classLoader.addPermission(libURL);
-
- if (contextRoot != null) {
-
- if (libURL != null) {
- File rootDir = new File(contextRoot);
- File libDir = new File(rootDir, "WEB-INF/lib/");
- try {
- String path = libDir.getCanonicalPath();
- classLoader.addPermission(path);
- } catch (IOException e) {
- }
- }
-
- } else {
-
- if (workDir != null) {
- if (libURL != null) {
- File libDir = new File(workDir, "WEB-INF/lib/");
- try {
- String path = libDir.getCanonicalPath();
- classLoader.addPermission(path);
- } catch (IOException e) {
- }
- }
- if (classesURL != null) {
- File classesDir = new File(workDir, "WEB-INF/classes/");
- try {
- String path = classesDir.getCanonicalPath();
- classLoader.addPermission(path);
- } catch (IOException e) {
- }
- }
- }
-
- }
-
- } catch (MalformedURLException e) {
- }
-
- }
-
-
- /**
- * Configure the repositories for our class loader, based on the
- * associated Context.
- */
- private void setRepositories() {
-
- if (!(container instanceof Context))
- return;
- ServletContext servletContext =
- ((Context) container).getServletContext();
- if (servletContext == null)
- return;
-
- loaderRepositories=new ArrayList();
- // Loading the work directory
- File workDir =
- (File) servletContext.getAttribute(ServletContext.TEMPDIR);
- if (workDir == null) {
- log.info("No work dir for " + servletContext);
- }
-
- if( log.isDebugEnabled())
- log.debug(sm.getString("webappLoader.deploy", workDir.getAbsolutePath()));
-
- classLoader.setWorkDir(workDir);
-
- DirContext resources = container.getResources();
-
- // Setting up the class repository (/WEB-INF/classes), if it exists
-
- String classesPath = "/WEB-INF/classes";
- DirContext classes = null;
-
- try {
- Object object = resources.lookup(classesPath);
- if (object instanceof DirContext) {
- classes = (DirContext) object;
- }
- } catch(NamingException e) {
- // Silent catch: it's valid that no /WEB-INF/classes collection
- // exists
- }
-
- if (classes != null) {
-
- File classRepository = null;
-
- String absoluteClassesPath =
- servletContext.getRealPath(classesPath);
-
- if (absoluteClassesPath != null) {
-
- classRepository = new File(absoluteClassesPath);
-
- } else {
-
- classRepository = new File(workDir, classesPath);
- classRepository.mkdirs();
- copyDir(classes, classRepository);
-
- }
-
- if(log.isDebugEnabled())
- log.debug(sm.getString("webappLoader.classDeploy", classesPath,
- classRepository.getAbsolutePath()));
-
-
- // Adding the repository to the class loader
- classLoader.addRepository(classesPath + "/", classRepository);
- loaderRepositories.add(classRepository.getAbsolutePath());
-
- }
-
- // Setting up the JAR repository (/WEB-INF/lib), if it exists
-
- String libPath = "/WEB-INF/lib";
-
- classLoader.setJarPath(libPath);
-
- DirContext libDir = null;
- // Looking up directory /WEB-INF/lib in the context
- try {
- Object object = resources.lookup(libPath);
- if (object instanceof DirContext)
- libDir = (DirContext) object;
- } catch(NamingException e) {
- // Silent catch: it's valid that no /WEB-INF/lib collection
- // exists
- }
-
- if (libDir != null) {
-
- boolean copyJars = false;
- String absoluteLibPath = servletContext.getRealPath(libPath);
-
- File destDir = null;
-
- if (absoluteLibPath != null) {
- destDir = new File(absoluteLibPath);
- } else {
- copyJars = true;
- destDir = new File(workDir, libPath);
- destDir.mkdirs();
- }
-
- // Looking up directory /WEB-INF/lib in the context
- try {
- NamingEnumeration enumeration = resources.listBindings(libPath);
- while (enumeration.hasMoreElements()) {
-
- Binding binding = (Binding) enumeration.nextElement();
- String filename = libPath + "/" + binding.getName();
- if (!filename.endsWith(".jar"))
- continue;
-
- // Copy JAR in the work directory, always (the JAR file
- // would get locked otherwise, which would make it
- // impossible to update it or remove it at runtime)
- File destFile = new File(destDir, binding.getName());
-
- if( log.isDebugEnabled())
- log.debug(sm.getString("webappLoader.jarDeploy", filename,
- destFile.getAbsolutePath()));
-
- Object obj = binding.getObject();
- if (!(obj instanceof Resource))
- continue;
-
- Resource jarResource = (Resource) obj;
- if (copyJars) {
- if (!copy(jarResource.streamContent(),
- new FileOutputStream(destFile)))
- continue;
- }
-
- try {
- JarFile jarFile = new JarFile(destFile);
- classLoader.addJar(filename, jarFile, destFile);
- } catch (Exception ex) {
- // Catch the exception if there is an empty jar file
- // Should ignore and continute loading other jar files
- // in the dir
- }
-
- loaderRepositories.add(destFile.getAbsolutePath());
-
- }
- } catch (NamingException e) {
- // Silent catch: it's valid that no /WEB-INF/lib directory
- // exists
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- }
-
- }
-
-
- /**
- * Set the appropriate context attribute for our class path. This
- * is required only because Jasper depends on it.
- */
- private void setClassPath() {
-
- // Validate our current state information
- if (!(container instanceof Context))
- return;
- ServletContext servletContext =
- ((Context) container).getServletContext();
- if (servletContext == null)
- return;
-
- if (container instanceof StandardContext) {
- String baseClasspath =
- ((StandardContext) container).getCompilerClasspath();
- if (baseClasspath != null) {
- servletContext.setAttribute(Globals.CLASS_PATH_ATTR,
- baseClasspath);
- return;
- }
- }
-
- StringBuffer classpath = new StringBuffer();
-
- // Assemble the class path information from our class loader chain
- ClassLoader loader = getClassLoader();
- int layers = 0;
- int n = 0;
- while (loader != null) {
- if (!(loader instanceof URLClassLoader)) {
- String cp=getClasspath( loader );
- if( cp==null ) {
- log.info( "Unknown loader " + loader + " " + loader.getClass());
- break;
- } else {
- if (n > 0)
- classpath.append(File.pathSeparator);
- classpath.append(cp);
- n++;
- }
- break;
- //continue;
- }
- URL repositories[] =
- ((URLClassLoader) loader).getURLs();
- for (int i = 0; i < repositories.length; i++) {
- String repository = repositories[i].toString();
- if (repository.startsWith("file://"))
- repository = repository.substring(7);
- else if (repository.startsWith("file:"))
- repository = repository.substring(5);
- else if (repository.startsWith("jndi:"))
- repository =
- servletContext.getRealPath(repository.substring(5));
- else
- continue;
- if (repository == null)
- continue;
- if (n > 0)
- classpath.append(File.pathSeparator);
- classpath.append(repository);
- n++;
- }
- loader = loader.getParent();
- layers++;
- }
-
- this.classpath=classpath.toString();
-
- // Store the assembled class path as a servlet context attribute
- servletContext.setAttribute(Globals.CLASS_PATH_ATTR,
- classpath.toString());
-
- }
-
- // try to extract the classpath from a loader that is not URLClassLoader
- private String getClasspath( ClassLoader loader ) {
- try {
- Method m=loader.getClass().getMethod("getClasspath", new Class[] {});
- if( log.isTraceEnabled())
- log.trace("getClasspath " + m );
- if( m==null ) return null;
- Object o=m.invoke( loader, new Object[] {} );
- if( log.isDebugEnabled() )
- log.debug("gotClasspath " + o);
- if( o instanceof String )
- return (String)o;
- return null;
- } catch( Exception ex ) {
- if (log.isDebugEnabled())
- log.debug("getClasspath ", ex);
- }
- return null;
- }
-
- /**
- * Copy directory.
- */
- private boolean copyDir(DirContext srcDir, File destDir) {
-
- try {
-
- NamingEnumeration enumeration = srcDir.list("");
- while (enumeration.hasMoreElements()) {
- NameClassPair ncPair =
- (NameClassPair) enumeration.nextElement();
- String name = ncPair.getName();
- Object object = srcDir.lookup(name);
- File currentFile = new File(destDir, name);
- if (object instanceof Resource) {
- InputStream is = ((Resource) object).streamContent();
- OutputStream os = new FileOutputStream(currentFile);
- if (!copy(is, os))
- return false;
- } else if (object instanceof InputStream) {
- OutputStream os = new FileOutputStream(currentFile);
- if (!copy((InputStream) object, os))
- return false;
- } else if (object instanceof DirContext) {
- currentFile.mkdir();
- copyDir((DirContext) object, currentFile);
- }
- }
-
- } catch (NamingException e) {
- return false;
- } catch (IOException e) {
- return false;
- }
-
- return true;
-
- }
-
-
- /**
- * Copy a file to the specified temp directory. This is required only
- * because Jasper depends on it.
- */
- private boolean copy(InputStream is, OutputStream os) {
-
- try {
- byte[] buf = new byte[4096];
- while (true) {
- int len = is.read(buf);
- if (len < 0)
- break;
- os.write(buf, 0, len);
- }
- is.close();
- os.close();
- } catch (IOException e) {
- return false;
- }
-
- return true;
-
- }
-
-
- private static org.jboss.logging.Logger log=
- org.jboss.logging.Logger.getLogger( LegacyWebappLoader.class );
-
- private ObjectName oname;
- private MBeanServer mserver;
- private String domain;
- private ObjectName controller;
-
- public ObjectName preRegister(MBeanServer server,
- ObjectName name) throws Exception {
- oname=name;
- mserver=server;
- domain=name.getDomain();
-
- return name;
- }
-
- public void postRegister(Boolean registrationDone) {
- }
-
- public void preDeregister() throws Exception {
- }
-
- public void postDeregister() {
- }
-
- public ObjectName getController() {
- return controller;
- }
-
- public void setController(ObjectName controller) {
- this.controller = controller;
- }
-
-}
Deleted: trunk/java/org/apache/catalina/loader/LocaStrings_fr.properties
===================================================================
--- trunk/java/org/apache/catalina/loader/LocaStrings_fr.properties 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/LocaStrings_fr.properties 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,30 +0,0 @@
-fileClassLoader.canRead=Le r�ceptacle (repository) {0} ne peut �tre lu
-fileClassLoader.exists=Le r�ceptacle (repository) {0} n''existe pas
-fileClassLoader.jarFile=Impossible de lire le fichier JAR {0}
-fileClassLoader.restricted=Impossible de charger la classe restreinte (restricted class) {0}
-standardLoader.addRepository=Ajout du r�ceptacle (repository) {0}
-standardLoader.alreadyStarted=Le chargeur (loader) a d�j� �t� d�marr�
-standardLoader.checkInterval=Impossible de r�gler l''interval de v�rification de rechargement � {0} secondes
-standardLoader.notContext=Impossible d''auto-recharger sans que le conteneur ne soit un contexte
-standardLoader.notReloadabe=Propri�t� de rechargement (reloadable property) mise � faux
-standardLoader.notStarted=Le chargeur (loader) n''a pas encore �t� d�marr�
-standardLoader.reloadable=Impossible de mettre la propri�t� de rechargement (reloadable property) � {0}
-standardLoader.reloading=Les v�rifications de rechargement sont activ�es pour ce contexte
-standardLoader.removeRepository=Retrait du r�ceptacle (repository) {0}
-standardLoader.starting=D�marrage de ce chargeur (loader)
-standardLoader.stopping=Arr�t de ce chargeur (loader)
-webappLoader.addRepository=Ajout du r�ceptacle (repository) {0}
-webappLoader.deploy=D�ploiement des classes des r�ceptacles (class repositories) vers le dossier de travail (work directory) {0}
-webappLoader.jarDeploy=D�ploiement du JAR {0} vers {1}
-webappLoader.classDeploy=D�ploiement des fichiers classes {0} vers {1}
-webappLoader.alreadyStarted=Le chargeur (loader) a d�j� �t� d�marr�
-webappLoader.checkInterval=Impossible de r�gler l''interval de v�rification de rechargement � {0} secondes
-webappLoader.notContext=Impossible d''auto-recharger sans que le conteneur ne soit un contexte
-webappLoader.notReloadabe=Propri�t� de rechargement (reloadable property) mise � faux
-webappLoader.notStarted=Le chargeur (loader) n''a pas encore �t� d�marr�
-webappLoader.reloadable=Impossible de mettre la propri�t� de rechargement (reloadable property) � {0}
-webappLoader.reloading=Les v�rifications de rechargement sont activ�es pour ce contexte
-webappLoader.removeRepository=Retrait du r�ceptacle (repository) {0}
-webappLoader.starting=D�marrage de ce chargeur (loader)
-webappLoader.stopping=Arr�t de ce chargeur (loader)
-webappLoader.failModifiedCheck=Erreur dans le suivi des modifications
Deleted: trunk/java/org/apache/catalina/loader/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/loader/LocalStrings.properties 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/LocalStrings.properties 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,33 +0,0 @@
-fileClassLoader.canRead=Repository {0} cannot be read
-fileClassLoader.exists=Repository {0} does not exist
-fileClassLoader.jarFile=Cannot read JAR file {0}
-fileClassLoader.restricted=Cannot load restricted class {0}
-standardLoader.addRepository=Adding repository {0}
-standardLoader.alreadyStarted=Loader has already been started
-standardLoader.checkInterval=Cannot set reload check interval to {0} seconds
-standardLoader.notContext=Cannot auto-reload unless our Container is a Context
-standardLoader.notReloadabe=Reloadable property is set to false
-standardLoader.notStarted=Loader has not yet been started
-standardLoader.reloadable=Cannot set reloadable property to {0}
-standardLoader.reloading=Reloading checks are enabled for this Context
-standardLoader.removeRepository=Removing repository {0}
-standardLoader.starting=Starting this Loader
-standardLoader.stopping=Stopping this Loader
-webappClassLoader.illegalJarPath=Illegal JAR entry detected with name {0}
-webappClassLoader.stopped=Illegal access: this web application instance has been stopped already. Could not load {0}. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
-webappClassLoader.validationErrorJarPath=Unable to validate JAR entry with name {0}
-webappLoader.addRepository=Adding repository {0}
-webappLoader.deploy=Deploying class repositories to work directory {0}
-webappLoader.jarDeploy=Deploy JAR {0} to {1}
-webappLoader.classDeploy=Deploy class files {0} to {1}
-webappLoader.alreadyStarted=Loader has already been started
-webappLoader.checkInterval=Cannot set reload check interval to {0} seconds
-webappLoader.notContext=Cannot auto-reload unless our Container is a Context
-webappLoader.notReloadabe=Reloadable property is set to false
-webappLoader.notStarted=Loader has not yet been started
-webappLoader.reloadable=Cannot set reloadable property to {0}
-webappLoader.reloading=Reloading checks are enabled for this Context
-webappLoader.removeRepository=Removing repository {0}
-webappLoader.starting=Starting this Loader
-webappLoader.stopping=Stopping this Loader
-webappLoader.failModifiedCheck=Error tracking modifications
Deleted: trunk/java/org/apache/catalina/loader/LocalStrings_es.properties
===================================================================
--- trunk/java/org/apache/catalina/loader/LocalStrings_es.properties 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/LocalStrings_es.properties 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,46 +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.
-fileClassLoader.canRead = No se puede leer el Repositorio {0}
-fileClassLoader.exists = No existe el Repositorio {0}
-fileClassLoader.jarFile = No puedo leer archivo JAR {0}
-fileClassLoader.restricted = No puedo cargar clase restringida {0}
-standardLoader.addRepository = A\u00F1adiendo repositorio {0}
-standardLoader.alreadyStarted = Ya ha sido arrancado el Cargador
-standardLoader.checkInterval = No puedo poner el intervalo de revisi\u00F3n de recarga a {0} segundos
-standardLoader.notContext = No puedo auto-recargar a menos que nuestro Contenedor sea un Contexto
-standardLoader.notReloadabe = La propiedad Recargable est\u00E1 puesta a falsa
-standardLoader.notStarted = A\u00FAn no se ha arrancado el Cargador
-standardLoader.reloadable = No puedo poner la propiedad recargable a {0}
-standardLoader.reloading = Se han activado las revisiones de Recarga para este Contexto
-standardLoader.removeRepository = Quitando repositorio {0}
-standardLoader.starting = Arrancando este Cargador
-standardLoader.stopping = Parando este Cargador
-webappClassLoader.stopped = Acceso ilegal\: esta instancia de aplicaci\u00F3n web ya ha sido parada. Could not load {0}. La eventual traza de pila que sigue ha sido motivada por un error lanzado con motivos de depuraci\u00F3n as\u00ED como para intentar terminar el hilo que motiv\u00F3 el acceso ilegal y no tiene impacto funcional.
-webappClassLoader.wrongVersion = (no puedo cargar clase {0})
-webappLoader.addRepository = A\u00F1adiendo repositorio {0}
-webappLoader.deploy = Desplegando repositorios de clase en directorio de trabajo {0}
-webappLoader.jarDeploy = Despliegue del JAR {0} en {1}
-webappLoader.classDeploy = Despliegue de archivos de clase {0} en {1}
-webappLoader.alreadyStarted = Ya se ha arrancado el Cargador
-webappLoader.checkInterval = No puedo poner el intervalo de revisi\u00F3n de recarga a {0} segundos
-webappLoader.notContext = No puedo auto-recargar a menos que nuestro Contenedor sea un Contexto
-webappLoader.notReloadabe = Se ha puesto la propiedad Recargable a falsa
-webappLoader.notStarted = A\u00FAn no se ha arrancado el Cargador
-webappLoader.reloadable = No puedo poner la propiedad recargable a {0}
-webappLoader.reloading = Se han activado los chequeos de Recarga para este Contexto
-webappLoader.removeRepository = Quitando repositorio {0}
-webappLoader.starting = Arrancando este Cargador
-webappLoader.stopping = Parando este Cargador
-webappLoader.failModifiedCheck = Modificaciones de pista de error
Deleted: trunk/java/org/apache/catalina/loader/LocalStrings_ja.properties
===================================================================
--- trunk/java/org/apache/catalina/loader/LocalStrings_ja.properties 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/LocalStrings_ja.properties 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,31 +0,0 @@
-fileClassLoader.canRead=\u30ea\u30dd\u30b8\u30c8\u30ea {0} \u304c\u8aad\u3081\u307e\u305b\u3093
-fileClassLoader.exists=\u30ea\u30dd\u30b8\u30c8\u30ea {0} \u304c\u5b58\u5728\u3057\u307e\u305b\u3093
-fileClassLoader.jarFile=JAR\u30d5\u30a1\u30a4\u30eb {0} \u304c\u8aad\u3081\u307e\u305b\u3093
-fileClassLoader.restricted=\u5236\u9650\u3055\u308c\u305f\u30af\u30e9\u30b9 {0} \u3092\u30ed\u30fc\u30c9\u3067\u304d\u307e\u305b\u3093
-standardLoader.addRepository=\u30ea\u30dd\u30b8\u30c8\u30ea {0} \u3092\u8ffd\u52a0\u3057\u307e\u3059
-standardLoader.alreadyStarted=\u30ed\u30fc\u30c0\u306f\u65e2\u306b\u8d77\u52d5\u3055\u308c\u3066\u3044\u307e\u3059
-standardLoader.checkInterval=\u518d\u30ed\u30fc\u30c9\u30c1\u30a7\u30c3\u30af\u9593\u9694\u3092{0}\u79d2\u306b\u8a2d\u5b9a\u3067\u304d\u307e\u305b\u3093
-standardLoader.notContext=\u3053\u306e\u30b3\u30f3\u30c6\u30ca\u304c\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3067\u306a\u3051\u308c\u3070\u3001\u81ea\u52d5\u518d\u30ed\u30fc\u30c9\u306f\u3067\u304d\u307e\u305b\u3093
-standardLoader.notReloadabe=reloadable\u30d7\u30ed\u30d1\u30c6\u30a3\u304cfalse\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059
-standardLoader.notStarted=\u30ed\u30fc\u30c0\u306f\u307e\u3060\u8d77\u52d5\u3055\u308c\u3066\u3044\u307e\u305b\u3093
-standardLoader.reloadable=reloadable\u30d7\u30ed\u30d1\u30c6\u30a3\u3092 {0} \u306b\u8a2d\u5b9a\u3067\u304d\u307e\u305b\u3093
-standardLoader.reloading=\u3053\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306e\u518d\u30ed\u30fc\u30c9\u30c1\u30a7\u30c3\u30af\u306f\u6709\u52b9\u3067\u3059
-standardLoader.removeRepository=\u30ea\u30dd\u30b8\u30c8\u30ea {0} \u3092\u524a\u9664\u3057\u307e\u3059
-standardLoader.starting=\u3053\u306e\u30ed\u30fc\u30c0\u3092\u8d77\u52d5\u3057\u307e\u3059
-standardLoader.stopping=\u3053\u306e\u30ed\u30fc\u30c0\u3092\u505c\u6b62\u3057\u307e\u3059
-webappClassLoader.stopped=\u4e0d\u6b63\u306a\u30a2\u30af\u30bb\u30b9: \u3053\u306eWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306f\u65e2\u306b\u505c\u6b62\u3055\u308c\u3066\u3044\u307e\u3059 Could not load {0}. \u4e0d\u6b63\u306a\u30a2\u30af\u30bb\u30b9\u3092\u5f15\u304d\u8d77\u3053\u3057\u305f\u30b9\u30ec\u30c3\u30c9\u3092\u7d42\u4e86\u3055\u305b\u3001\u6295\u3052\u3089\u308c\u305f\u30a8\u30e9\u30fc\u306b\u3088\u308a\u30c7\u30d0\u30c3\u30b0\u7528\u306b\u6b21\u306e\u30b9\u30bf\u30c3\u30af\u30c8\u30ec\u30fc\u30b9\u304c\u751f\u6210\u3055\u308c\u307e\u3057\u305f\u304c\uff0c\u6a5f\u80fd\u306b\u5f71\u97ff\u306f\u3042\u308a\u307e\u305b\u3093
-webappLoader.addRepository=\u30ea\u30dd\u30b8\u30c8\u30ea {0} \u3092\u8ffd\u52a0\u3057\u307e\u3059
-webappLoader.deploy=\u30af\u30e9\u30b9\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea {0} \u306b\u914d\u5099\u3057\u307e\u3059
-webappLoader.jarDeploy=JAR {0} \u3092 {1} \u306b\u914d\u5099\u3057\u307e\u3059
-webappLoader.classDeploy=\u30af\u30e9\u30b9\u30d5\u30a1\u30a4\u30eb {0} \u3092 {1} \u306b\u914d\u5099\u3057\u307e\u3059
-webappLoader.alreadyStarted=\u30ed\u30fc\u30c0\u306f\u65e2\u306b\u8d77\u52d5\u3055\u308c\u3066\u3044\u307e\u3059
-webappLoader.checkInterval=\u518d\u30ed\u30fc\u30c9\u30c1\u30a7\u30c3\u30af\u9593\u9694\u3092{0}\u79d2\u306b\u8a2d\u5b9a\u3067\u304d\u307e\u305b\u3093
-webappLoader.notContext=\u3053\u306e\u30b3\u30f3\u30c6\u30ca\u304c\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u3067\u306a\u3051\u308c\u3070\u3001\u81ea\u52d5\u518d\u30ed\u30fc\u30c9\u306f\u3067\u304d\u307e\u305b\u3093
-webappLoader.notReloadabe=reloadable\u30d7\u30ed\u30d1\u30c6\u30a3\u304cfalse\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u3059
-webappLoader.notStarted=\u30ed\u30fc\u30c0\u306f\u307e\u3060\u8d77\u52d5\u3055\u308c\u3066\u3044\u307e\u305b\u3093
-webappLoader.reloadable=reloadable\u30d7\u30ed\u30d1\u30c6\u30a3\u3092 {0} \u306b\u8a2d\u5b9a\u3067\u304d\u307e\u305b\u3093
-webappLoader.reloading=\u3053\u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u306e\u518d\u30ed\u30fc\u30c9\u30c1\u30a7\u30c3\u30af\u306f\u6709\u52b9\u3067\u3059
-webappLoader.removeRepository=\u30ea\u30dd\u30b8\u30c8\u30ea {0} \u3092\u524a\u9664\u3057\u307e\u3059
-webappLoader.starting=\u3053\u306e\u30ed\u30fc\u30c0\u3092\u8d77\u52d5\u3057\u307e\u3059
-webappLoader.stopping=\u3053\u306e\u30ed\u30fc\u30c0\u3092\u505c\u6b62\u3057\u307e\u3059
-webappLoader.failModifiedCheck=\u5909\u66f4\u8ffd\u8de1\u30a8\u30e9\u30fc\u3067\u3059
Deleted: trunk/java/org/apache/catalina/loader/Reloader.java
===================================================================
--- trunk/java/org/apache/catalina/loader/Reloader.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/Reloader.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,62 +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.loader;
-
-
-/**
- * Internal interface that <code>ClassLoader</code> implementations may
- * optionally implement to support the auto-reload functionality of
- * the classloader associated with the context.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public interface Reloader {
-
-
- /**
- * Add a new repository to the set of places this ClassLoader can look for
- * classes to be loaded.
- *
- * @param repository Name of a source of classes to be loaded, such as a
- * directory pathname, a JAR file pathname, or a ZIP file pathname
- *
- * @exception IllegalArgumentException if the specified repository is
- * invalid or does not exist
- */
- public void addRepository(String repository);
-
-
- /**
- * Return a String array of the current repositories for this class
- * loader. If there are no repositories, a zero-length array is
- * returned.
- */
- public String[] findRepositories();
-
-
- /**
- * Have one or more classes or resources been modified so that a reload
- * is appropriate?
- */
- public boolean modified();
-
-
-}
Deleted: trunk/java/org/apache/catalina/loader/ResourceEntry.java
===================================================================
--- trunk/java/org/apache/catalina/loader/ResourceEntry.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/ResourceEntry.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,78 +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.loader;
-
-import java.net.URL;
-import java.security.cert.Certificate;
-import java.util.jar.Manifest;
-
-/**
- * Resource entry.
- *
- * @author Remy Maucherat
- * @version $Revision$ $Date$
- */
-public class ResourceEntry {
-
-
- /**
- * The "last modified" time of the origin file at the time this class
- * was loaded, in milliseconds since the epoch.
- */
- public long lastModified = -1;
-
-
- /**
- * Binary content of the resource.
- */
- public byte[] binaryContent = null;
-
-
- /**
- * Loaded class.
- */
- public Class loadedClass = null;
-
-
- /**
- * URL source from where the object was loaded.
- */
- public URL source = null;
-
-
- /**
- * URL of the codebase from where the object was loaded.
- */
- public URL codeBase = null;
-
-
- /**
- * Manifest (if the resource was loaded from a JAR).
- */
- public Manifest manifest = null;
-
-
- /**
- * Certificates (if the resource was loaded from a JAR).
- */
- public Certificate[] certificates = null;
-
-
-}
-
Deleted: trunk/java/org/apache/catalina/loader/StandardClassLoader.java
===================================================================
--- trunk/java/org/apache/catalina/loader/StandardClassLoader.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/StandardClassLoader.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,46 +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.loader;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-
-/**
- * Subclass implementation of <b>java.net.URLClassLoader</b>. There are no
- * functional differences between this class and <b>java.net.URLClassLoader</b>.
- *
- * @author Craig R. McClanahan
- * @author Remy Maucherat
- * @version $Revision$ $Date$
- */
-
-public class StandardClassLoader
- extends URLClassLoader
- implements StandardClassLoaderMBean {
-
- public StandardClassLoader(URL repositories[]) {
- super(repositories);
- }
-
- public StandardClassLoader(URL repositories[], ClassLoader parent) {
- super(repositories, parent);
- }
-
-}
-
Deleted: trunk/java/org/apache/catalina/loader/StandardClassLoaderMBean.java
===================================================================
--- trunk/java/org/apache/catalina/loader/StandardClassLoaderMBean.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/StandardClassLoaderMBean.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,29 +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.loader;
-
-/**
- * MBean interface for StandardClassLoader, to allow JMX remote management.
- *
- * @author Remy Maucherat
- * @version $Revision$ $Date$
- */
-public interface StandardClassLoaderMBean {
-}
-
Deleted: trunk/java/org/apache/catalina/loader/WebappClassLoader.java
===================================================================
--- trunk/java/org/apache/catalina/loader/WebappClassLoader.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/WebappClassLoader.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,1883 +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.
- *
- *
- * 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.loader;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FilePermission;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.security.AccessControlException;
-import java.security.AccessController;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Policy;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-import java.util.jar.Attributes.Name;
-
-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.StringManager;
-import org.apache.naming.JndiPermission;
-import org.apache.tomcat.util.IntrospectionUtils;
-
-/**
- * Specialized web application class loader.
- * <p>
- * This class loader is a full reimplementation of the
- * <code>URLClassLoader</code> from the JDK. It is desinged to be fully
- * compatible with a normal <code>URLClassLoader</code>, although its internal
- * behavior may be completely different.
- * <p>
- * <strong>IMPLEMENTATION NOTE</strong> - This class loader faithfully follows
- * the delegation model recommended in the specification. The system class
- * loader will be queried first, then the local repositories, and only then
- * delegation to the parent class loader will occur. This allows the web
- * application to override any shared class except the classes from J2SE.
- * Special handling is provided from the JAXP XML parser interfaces, the JNDI
- * interfaces, and the classes from the servlet API, which are never loaded
- * from the webapp repository.
- * <p>
- * <strong>IMPLEMENTATION NOTE</strong> - Due to limitations in Jasper
- * compilation technology, any repository which contains classes from
- * the servlet API will be ignored by the class loader.
- * <p>
- * <strong>IMPLEMENTATION NOTE</strong> - The class loader generates source
- * URLs which include the full JAR URL when a class is loaded from a JAR file,
- * which allows setting security permission at the class level, even when a
- * class is contained inside a JAR.
- * <p>
- * <strong>IMPLEMENTATION NOTE</strong> - Local repositories are searched in
- * the order they are specified in the JarRepository.
- * <p>
- * <strong>IMPLEMENTATION NOTE</strong> - No check for sealing violations or
- * security is made unless a security manager is present.
- *
- * @author Remy Maucherat
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-public class WebappClassLoader
- extends URLClassLoader
- implements Lifecycle
- {
-
- protected static org.jboss.logging.Logger log=
- org.jboss.logging.Logger.getLogger( WebappClassLoader.class );
-
- public static final boolean ENABLE_CLEAR_REFERENCES =
- Boolean.valueOf(System.getProperty("org.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES", "true")).booleanValue();
-
- public static final boolean SYSTEM_CL_DELEGATION =
- Boolean.valueOf(System.getProperty("org.apache.catalina.loader.WebappClassLoader.SYSTEM_CL_DELEGATION", "true")).booleanValue();
-
- protected class PrivilegedFindResource
- implements PrivilegedAction {
-
- protected File file;
- protected String path;
-
- PrivilegedFindResource(File file, String path) {
- this.file = file;
- this.path = path;
- }
-
- public Object run() {
- return findResourceInternal(file, path);
- }
-
- }
-
-
- // ------------------------------------------------------- Static Variables
-
-
- /**
- * The set of trigger classes that will cause a proposed repository not
- * to be added if this class is visible to the class loader that loaded
- * this factory class. Typically, trigger classes will be listed for
- * components that have been integrated into the JDK for later versions,
- * but where the corresponding JAR files are required to run on
- * earlier versions.
- */
- protected static final String[] triggers = {
- "javax.servlet.Servlet" // Servlet API
- };
-
-
- /**
- * Set of package names which are not allowed to be loaded from a webapp
- * class loader without delegating first.
- */
- protected static final String[] packageTriggers = {
- "javax.servlet."
- };
-
-
- /**
- * The string manager for this package.
- */
- protected static final StringManager sm =
- StringManager.getManager(Constants.Package);
-
-
- /**
- * Use anti JAR locking code, which does URL rerouting when accessing
- * resources.
- */
- boolean antiJARLocking = false;
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a new ClassLoader with no defined repositories and no
- * parent ClassLoader.
- */
- public WebappClassLoader() {
-
- super(new URL[0]);
- this.parent = getParent();
- system = getSystemClassLoader();
- securityManager = System.getSecurityManager();
-
- if (securityManager != null) {
- refreshPolicy();
- }
-
- }
-
-
- /**
- * Construct a new ClassLoader with no defined repositories and no
- * parent ClassLoader.
- */
- public WebappClassLoader(ClassLoader parent) {
-
- super(new URL[0], parent);
-
- this.parent = getParent();
-
- system = getSystemClassLoader();
- securityManager = System.getSecurityManager();
-
- if (securityManager != null) {
- refreshPolicy();
- }
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * Associated Jar repository.
- */
- protected JarRepository repository = null;
-
-
- /**
- * The cache of ResourceEntry for classes and resources we have loaded,
- * keyed by resource name.
- */
- protected Map<String, ResourceEntry> resourceEntries = new ConcurrentHashMap<String, ResourceEntry>();
-
-
- /**
- * The list of not found resources.
- */
- protected Map<String, Object> notFoundResources = new ConcurrentHashMap<String, Object>();
- protected static final Object VALUE = new Object();
-
-
- /**
- * Should this class loader delegate to the parent class loader
- * <strong>before</strong> searching its own repositories (i.e. the
- * usual Java2 delegation model)? If set to <code>false</code>,
- * this class loader will search its own repositories first, and
- * delegate to the parent only if the class or resource is not
- * found locally.
- */
- protected boolean delegate = false;
-
-
- /**
- * Repositories URLs, used to cache the result of getURLs.
- */
- protected URL[] repositoryURLs = null;
-
-
- /**
- * A list of read File and Jndi Permission's required if this loader
- * is for a web application context.
- */
- protected ArrayList permissionList = new ArrayList();
-
-
- /**
- * Path where resources loaded from JARs will be extracted.
- */
- protected File loaderDir = null;
- protected String canonicalLoaderDir = null;
-
- /**
- * The PermissionCollection for each CodeSource for a web
- * application context.
- */
- protected HashMap loaderPC = new HashMap();
-
-
- /**
- * Instance of the SecurityManager installed.
- */
- protected SecurityManager securityManager = null;
-
-
- /**
- * The parent class loader.
- */
- protected ClassLoader parent = null;
-
-
- /**
- * The system class loader.
- */
- protected ClassLoader system = null;
-
-
- /**
- * Has this component been started?
- */
- protected boolean started = false;
-
-
- /**
- * need conversion for properties files
- */
- protected boolean needConvert = false;
-
-
- /**
- * All permission.
- */
- protected Permission allPermission = new java.security.AllPermission();
-
-
- // ------------------------------------------------------------- Properties
-
-
- public JarRepository getRepository() {
- return repository;
- }
-
-
- public void setRepository(JarRepository repository) {
- this.repository = repository;
- }
-
-
- /**
- * Return the "delegate first" flag for this class loader.
- */
- public boolean getDelegate() {
-
- return (this.delegate);
-
- }
-
-
- /**
- * Set the "delegate first" flag for this class loader.
- *
- * @param delegate The new "delegate first" flag
- */
- public void setDelegate(boolean delegate) {
-
- this.delegate = delegate;
-
- }
-
-
- /**
- * @return Returns the antiJARLocking.
- */
- public boolean getAntiJARLocking() {
- return antiJARLocking;
- }
-
-
- /**
- * @param antiJARLocking The antiJARLocking to set.
- */
- public void setAntiJARLocking(boolean antiJARLocking) {
- this.antiJARLocking = antiJARLocking;
- }
-
-
- /**
- * If there is a Java SecurityManager create a read FilePermission
- * or JndiPermission for the file directory path.
- *
- * @param path file directory path
- */
- public void addPermission(String path) {
- if (path == null) {
- return;
- }
-
- if (securityManager != null) {
- Permission permission = null;
- if( path.startsWith("jndi:") || path.startsWith("jar:jndi:") ) {
- if (!path.endsWith("/")) {
- path = path + "/";
- }
- permission = new JndiPermission(path + "*");
- addPermission(permission);
- } else {
- if (!path.endsWith(File.separator)) {
- permission = new FilePermission(path, "read");
- addPermission(permission);
- path = path + File.separator;
- }
- permission = new FilePermission(path + "-", "read");
- addPermission(permission);
- }
- }
- }
-
-
- /**
- * If there is a Java SecurityManager create a read FilePermission
- * or JndiPermission for URL.
- *
- * @param url URL for a file or directory on local system
- */
- public void addPermission(URL url) {
- if (url != null) {
- addPermission(url.toString());
- }
- }
-
-
- /**
- * If there is a Java SecurityManager create a Permission.
- *
- * @param permission The permission
- */
- public void addPermission(Permission permission) {
- if ((securityManager != null) && (permission != null)) {
- permissionList.add(permission);
- }
- }
-
-
- /**
- * Change the work directory.
- */
- public void setWorkDir(File workDir) {
- this.loaderDir = new File(workDir, "loader");
- if (loaderDir == null) {
- canonicalLoaderDir = null;
- } else {
- try {
- canonicalLoaderDir = loaderDir.getCanonicalPath();
- if (!canonicalLoaderDir.endsWith(File.separator)) {
- canonicalLoaderDir += File.separator;
- }
- } catch (IOException ioe) {
- canonicalLoaderDir = null;
- }
- }
- }
-
- /**
- * Utility method for use in subclasses.
- * Must be called before Lifecycle methods to have any effect.
- */
- protected void setParentClassLoader(ClassLoader pcl) {
- parent = pcl;
- }
-
-
- /**
- * Render a String representation of this object.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("WebappClassLoader\r\n");
- sb.append(" delegate: ");
- sb.append(delegate);
- sb.append("\r\n");
- if (this.parent != null) {
- sb.append("----------> Parent Classloader:\r\n");
- sb.append(this.parent.toString());
- sb.append("\r\n");
- }
- return (sb.toString());
-
- }
-
-
- // ---------------------------------------------------- ClassLoader Methods
-
-
- /**
- * Find the specified class in our local repositories, if possible. If
- * not found, throw <code>ClassNotFoundException</code>.
- *
- * @param name Name of the class to be loaded
- *
- * @exception ClassNotFoundException if the class was not found
- */
- public Class findClass(String name) throws ClassNotFoundException {
-
- if (log.isDebugEnabled())
- log.debug(" findClass(" + name + ")");
-
- // Cannot load anything from local repositories if class loader is stopped
- if (!started) {
- throw new ClassNotFoundException(name);
- }
-
- // (1) Permission to define this class when using a SecurityManager
- if (securityManager != null) {
- int i = name.lastIndexOf('.');
- if (i >= 0) {
- try {
- if (log.isTraceEnabled())
- log.trace(" securityManager.checkPackageDefinition");
- securityManager.checkPackageDefinition(name.substring(0,i));
- } catch (Exception se) {
- if (log.isTraceEnabled())
- log.trace(" -->Exception-->ClassNotFoundException", se);
- throw new ClassNotFoundException(name, se);
- }
- }
- }
-
- // Ask our superclass to locate this class, if possible
- // (throws ClassNotFoundException if it is not found)
- Class clazz = null;
- if (log.isTraceEnabled())
- log.trace(" findClassInternal(" + name + ")");
- try {
- clazz = findClassInternal(name);
- } catch(ClassNotFoundException cnfe) {
- throw cnfe;
- } catch(AccessControlException ace) {
- throw new ClassNotFoundException(name, ace);
- } catch (RuntimeException e) {
- if (log.isTraceEnabled())
- log.trace(" -->RuntimeException Rethrown", e);
- throw e;
- }
-
- // Return the class we have located
- if (log.isTraceEnabled())
- log.debug(" Returning class " + clazz);
- if ((log.isTraceEnabled()) && (clazz != null))
- log.debug(" Loaded by " + clazz.getClassLoader());
- return (clazz);
-
- }
-
-
- /**
- * Find the specified resource in our local repository, and return a
- * <code>URL</code> refering to it, or <code>null</code> if this resource
- * cannot be found.
- *
- * @param name Name of the resource to be found
- */
- public URL findResource(final String name) {
-
- if (log.isDebugEnabled())
- log.debug(" findResource(" + name + ")");
-
- URL url = null;
-
- ResourceEntry entry = (ResourceEntry) resourceEntries.get(name);
- if (entry == null) {
- entry = findResourceInternal(name, name);
- }
- if (entry != null) {
- url = entry.source;
- }
-
- if (log.isDebugEnabled()) {
- if (url != null)
- log.debug(" --> Returning '" + url.toString() + "'");
- else
- log.debug(" --> Resource not found, returning null");
- }
- return (url);
-
- }
-
-
- /**
- * Return an enumeration of <code>URLs</code> representing all of the
- * resources with the given name. If no resources with this name are
- * found, return an empty enumeration.
- *
- * @param name Name of the resources to be found
- *
- * @exception IOException if an input/output error occurs
- */
- public Enumeration findResources(String name) throws IOException {
-
- if (log.isDebugEnabled())
- log.debug(" findResources(" + name + ")");
-
- Vector result = new Vector();
-
- File[] repositories = repository.findExplodedJars();
- JarFile[] jarFiles = repository.findJars();
-
- // Looking at the repositories
- for (int i = 0; i < repositories.length; i++) {
- File resource = new File(repositories[i], name);
- if (resource.exists()) {
- result.addElement(getURI(resource));
- }
- }
-
- // Looking at the JAR files
- for (int i = 0; i < jarFiles.length; i++) {
- JarEntry jarEntry = jarFiles[i].getJarEntry(name);
- if (jarEntry != null) {
- File jarFile = new File(jarFiles[i].getName());
- try {
- String jarFakeUrl = getURI(jarFile).toString();
- jarFakeUrl = "jar:" + jarFakeUrl + "!/" + name;
- result.addElement(new URL(jarFakeUrl));
- } catch (MalformedURLException e) {
- // Ignore
- }
- }
- }
-
- return result.elements();
-
- }
-
-
- /**
- * Find the resource with the given name. A resource is some data
- * (images, audio, text, etc.) that can be accessed by class code in a
- * way that is independent of the location of the code. The name of a
- * resource is a "/"-separated path name that identifies the resource.
- * If the resource cannot be found, return <code>null</code>.
- * <p>
- * This method searches according to the following algorithm, returning
- * as soon as it finds the appropriate URL. If the resource cannot be
- * found, returns <code>null</code>.
- * <ul>
- * <li>If the <code>delegate</code> property is set to <code>true</code>,
- * call the <code>getResource()</code> method of the parent class
- * loader, if any.</li>
- * <li>Call <code>findResource()</code> to find this resource in our
- * locally defined repositories.</li>
- * <li>Call the <code>getResource()</code> method of the parent class
- * loader, if any.</li>
- * </ul>
- *
- * @param name Name of the resource to return a URL for
- */
- public URL getResource(String name) {
-
- if (log.isDebugEnabled())
- log.debug("getResource(" + name + ")");
- URL url = null;
-
- // (1) Delegate to parent if requested
- if (delegate) {
- if (log.isDebugEnabled())
- log.debug(" Delegating to parent classloader " + parent);
- ClassLoader loader = parent;
- if (loader == null)
- loader = system;
- url = loader.getResource(name);
- if (url != null) {
- if (log.isDebugEnabled())
- log.debug(" --> Returning '" + url.toString() + "'");
- return (url);
- }
- }
-
- // (2) Search local repositories
- url = findResource(name);
- if (url != null) {
- // Locating the repository for special handling in the case
- // of a JAR
- if (antiJARLocking) {
- ResourceEntry entry = (ResourceEntry) resourceEntries.get(name);
- try {
- String repository = entry.codeBase.toString();
- if ((repository.endsWith(".jar"))
- && (!(name.endsWith(".class")))) {
- // Copy binary content to the work directory if not present
- File resourceFile = new File(loaderDir, name);
- url = getURI(resourceFile);
- }
- } catch (Exception e) {
- // Ignore
- }
- }
- if (log.isDebugEnabled())
- log.debug(" --> Returning '" + url.toString() + "'");
- return (url);
- }
-
- // (3) Delegate to parent unconditionally if not already attempted
- if( !delegate ) {
- ClassLoader loader = parent;
- if (loader == null)
- loader = system;
- url = loader.getResource(name);
- if (url != null) {
- if (log.isDebugEnabled())
- log.debug(" --> Returning '" + url.toString() + "'");
- return (url);
- }
- }
-
- // (4) Resource was not found
- if (log.isDebugEnabled())
- log.debug(" --> Resource not found, returning null");
- return (null);
-
- }
-
-
- /**
- * Find the resource with the given name, and return an input stream
- * that can be used for reading it. The search order is as described
- * for <code>getResource()</code>, after checking to see if the resource
- * data has been previously cached. If the resource cannot be found,
- * return <code>null</code>.
- *
- * @param name Name of the resource to return an input stream for
- */
- public InputStream getResourceAsStream(String name) {
-
- if (log.isDebugEnabled())
- log.debug("getResourceAsStream(" + name + ")");
- InputStream stream = null;
-
- // (0) Check for a cached copy of this resource
- stream = findLoadedResource(name);
- if (stream != null) {
- if (log.isDebugEnabled())
- log.debug(" --> Returning stream from cache");
- return (stream);
- }
-
- // (1) Delegate to parent if requested
- if (delegate) {
- if (log.isDebugEnabled())
- log.debug(" Delegating to parent classloader " + parent);
- ClassLoader loader = parent;
- if (loader == null)
- loader = system;
- stream = loader.getResourceAsStream(name);
- if (stream != null) {
- // FIXME - cache???
- if (log.isDebugEnabled())
- log.debug(" --> Returning stream from parent");
- return (stream);
- }
- }
-
- // (2) Search local repositories
- if (log.isDebugEnabled())
- log.debug(" Searching local repositories");
- URL url = findResource(name);
- if (url != null) {
- // FIXME - cache???
- if (log.isDebugEnabled())
- log.debug(" --> Returning stream from local");
- stream = findLoadedResource(name);
- if (stream != null)
- return (stream);
- }
-
- // (3) Delegate to parent unconditionally
- if (!delegate) {
- if (log.isDebugEnabled())
- log.debug(" Delegating to parent classloader unconditionally " + parent);
- ClassLoader loader = parent;
- if (loader == null)
- loader = system;
- stream = loader.getResourceAsStream(name);
- if (stream != null) {
- // FIXME - cache???
- if (log.isDebugEnabled())
- log.debug(" --> Returning stream from parent");
- return (stream);
- }
- }
-
- // (4) Resource was not found
- if (log.isDebugEnabled())
- log.debug(" --> Resource not found, returning null");
- return (null);
-
- }
-
-
- /**
- * Load the class with the specified name, searching using the following
- * algorithm until it finds and returns the class. If the class cannot
- * be found, returns <code>ClassNotFoundException</code>.
- * <ul>
- * <li>Call <code>findLoadedClass(String)</code> to check if the
- * class has already been loaded. If it has, the same
- * <code>Class</code> object is returned.</li>
- * <li>If the <code>delegate</code> property is set to <code>true</code>,
- * call the <code>loadClass()</code> method of the parent class
- * loader, if any.</li>
- * <li>Call <code>findClass()</code> to find this class in our locally
- * defined repositories.</li>
- * <li>Call the <code>loadClass()</code> method of our parent
- * class loader, if any.</li>
- * </ul>
- * If the class was found using the above steps, and the
- * <code>resolve</code> flag is <code>true</code>, this method will then
- * call <code>resolveClass(Class)</code> on the resulting Class object.
- *
- * @param name Name of the class to be loaded
- * @param resolve If <code>true</code> then resolve the class
- *
- * @exception ClassNotFoundException if the class was not found
- */
- public Class<?> loadClass(String name, boolean resolve)
- throws ClassNotFoundException {
-
- if (log.isDebugEnabled())
- log.debug("loadClass(" + name + ", " + resolve + ")");
- Class clazz = null;
-
- // Log access to stopped classloader
- if (!started) {
- try {
- throw new IllegalStateException();
- } catch (IllegalStateException e) {
- log.info(sm.getString("webappClassLoader.stopped", name), e);
- }
- }
-
- // (0) Check our previously loaded local class cache
- clazz = findLoadedClass0(name);
- if (clazz != null) {
- if (log.isDebugEnabled())
- log.debug(" Returning class from cache");
- if (resolve)
- resolveClass(clazz);
- return (clazz);
- }
-
- // (0.1) Check our previously loaded class cache
- clazz = findLoadedClass(name);
- if (clazz != null) {
- if (log.isDebugEnabled())
- log.debug(" Returning class from cache");
- if (resolve)
- resolveClass(clazz);
- return (clazz);
- }
-
- // (0.2) Try loading the class with the system class loader, to prevent
- // the webapp from overriding J2SE classes
- if (SYSTEM_CL_DELEGATION) {
- try {
- clazz = Class.forName(name, false, system);
- if (clazz != null) {
- if (resolve)
- resolveClass(clazz);
- return (clazz);
- }
- } catch (ClassNotFoundException e) {
- // Ignore
- }
- }
-
- // (0.5) Permission to access this class when using a SecurityManager
- if (securityManager != null) {
- int i = name.lastIndexOf('.');
- if (i >= 0) {
- try {
- securityManager.checkPackageAccess(name.substring(0,i));
- } catch (SecurityException se) {
- String error = "Security Violation, attempt to use " +
- "Restricted Class: " + name;
- log.info(error, se);
- throw new ClassNotFoundException(error, se);
- }
- }
- }
-
- boolean delegateLoad = delegate || filter(name);
-
- // (1) Delegate to our parent if requested
- if (delegateLoad) {
- if (log.isDebugEnabled())
- log.debug(" Delegating to parent classloader1 " + parent);
- ClassLoader loader = parent;
- if (loader == null)
- loader = system;
- try {
- clazz = Class.forName(name, false, loader);
- if (clazz != null) {
- if (log.isDebugEnabled())
- log.debug(" Loading class from parent");
- if (resolve)
- resolveClass(clazz);
- return (clazz);
- }
- } catch (ClassNotFoundException e) {
- ;
- }
- }
-
- // (2) Search local repositories
- if (log.isDebugEnabled())
- log.debug(" Searching local repositories");
- try {
- clazz = findClass(name);
- if (clazz != null) {
- if (log.isDebugEnabled())
- log.debug(" Loading class from local repository");
- if (resolve)
- resolveClass(clazz);
- return (clazz);
- }
- } catch (ClassNotFoundException e) {
- ;
- }
-
- // (3) Delegate to parent unconditionally
- if (!delegateLoad) {
- if (log.isDebugEnabled())
- log.debug(" Delegating to parent classloader at end: " + parent);
- ClassLoader loader = parent;
- if (loader == null)
- loader = system;
- try {
- clazz = Class.forName(name, false, loader);
- if (clazz != null) {
- if (log.isDebugEnabled())
- log.debug(" Loading class from parent");
- if (resolve)
- resolveClass(clazz);
- return (clazz);
- }
- } catch (ClassNotFoundException e) {
- ;
- }
- }
-
- throw new ClassNotFoundException(name);
- }
-
-
- /**
- * Get the Permissions for a CodeSource. If this instance
- * of WebappClassLoader is for a web application context,
- * add read FilePermission or JndiPermissions for the base
- * directory (if unpacked),
- * the context URL, and jar file resources.
- *
- * @param codeSource where the code was loaded from
- * @return PermissionCollection for CodeSource
- */
- protected PermissionCollection getPermissions(CodeSource codeSource) {
-
- String codeUrl = codeSource.getLocation().toString();
- PermissionCollection pc;
- if ((pc = (PermissionCollection)loaderPC.get(codeUrl)) == null) {
- pc = super.getPermissions(codeSource);
- if (pc != null) {
- Iterator perms = permissionList.iterator();
- while (perms.hasNext()) {
- Permission p = (Permission)perms.next();
- pc.add(p);
- }
- loaderPC.put(codeUrl,pc);
- }
- }
- return (pc);
-
- }
-
-
- /**
- * Returns the search path of URLs for loading classes and resources.
- * This includes the original list of URLs specified to the constructor,
- * along with any URLs subsequently appended by the addURL() method.
- * @return the search path of URLs for loading classes and resources.
- */
- public URL[] getURLs() {
-
- if (repositoryURLs != null) {
- return repositoryURLs;
- }
-
- URL[] external = super.getURLs();
-
- File[] repositories = repository.findExplodedJars();
- JarFile[] jarFiles = repository.findJars();
-
- int length = repositories.length + jarFiles.length;
-
- try {
-
- URL[] urls = new URL[length];
- for (int i = 0; i < length; i++) {
- if (i < repositories.length) {
- urls[i] = getURL(repositories[i], true);
- } else {
- urls[i] = getURL(new File(jarFiles[i - repositories.length].getName()), true);
- }
- }
-
- repositoryURLs = urls;
-
- } catch (MalformedURLException e) {
- repositoryURLs = new URL[0];
- }
-
- return repositoryURLs;
-
- }
-
-
- // ------------------------------------------------------ Lifecycle Methods
-
-
- /**
- * Add a lifecycle event listener to this component.
- *
- * @param listener The listener to add
- */
- public void addLifecycleListener(LifecycleListener 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 new LifecycleListener[0];
- }
-
-
- /**
- * Remove a lifecycle event listener from this component.
- *
- * @param listener The listener to remove
- */
- public void removeLifecycleListener(LifecycleListener listener) {
- }
-
-
- /**
- * Start the class loader.
- *
- * @exception LifecycleException if a lifecycle error occurs
- */
- public void start() throws LifecycleException {
-
- started = true;
- String encoding = null;
- try {
- encoding = System.getProperty("file.encoding");
- } catch (Exception e) {
- return;
- }
- if (encoding.indexOf("EBCDIC")!=-1) {
- needConvert = true;
- }
-
- }
-
-
- /**
- * Stop the class loader.
- *
- * @exception LifecycleException if a lifecycle error occurs
- */
- public void stop() throws LifecycleException {
-
- // Clearing references should be done before setting started to
- // false, due to possible side effects
- clearReferences();
-
- started = false;
-
- notFoundResources.clear();
- resourceEntries.clear();
- repositoryURLs = null;
- parent = null;
- repository = null;
-
- permissionList.clear();
- loaderPC.clear();
-
- if (loaderDir != null) {
- deleteDir(loaderDir);
- }
-
- }
-
-
- // ------------------------------------------------------ Protected Methods
-
-
- /**
- * Clear references.
- */
- protected void clearReferences() {
-
- /*
- * Deregister any JDBC drivers registered by the webapp that the webapp
- * forgot. This is made unnecessary complex because a) DriverManager
- * checks the class loader of the calling class (it would be much easier
- * if it checked the context class loader) b) using reflection would
- * create a dependency on the DriverManager implementation which can,
- * and has, changed.
- *
- * We can't just create an instance of JdbcLeakPrevention as it will be
- * loaded by the common class loader (since it's .class file is in the
- * $CATALINA_HOME/lib directory). This would fail DriverManager's check
- * on the class loader of the calling class. So, we load the bytes via
- * our parent class loader but define the class with this class loader
- * so the JdbcLeakPrevention looks like a webapp class to the
- * DriverManager.
- *
- * If only apps cleaned up after themselves...
- */
- InputStream is = getResourceAsStream(
- "org/apache/catalina/loader/JdbcLeakPrevention.class");
- // Cheat - we know roughly how big the class will be (~1K) but allow
- // plenty room to grow
- byte[] classBytes = new byte[4096];
- int offset = 0;
- try {
- int read = is.read(classBytes, offset, 4096-offset);
- while (read > -1) {
- offset += read;
- read = is.read(classBytes, offset, 4096-offset);
- }
- Class<?> lpClass =
- defineClass("org.apache.catalina.loader.JdbcLeakPrevention",
- classBytes, 0, offset);
- Object obj = lpClass.newInstance();
- obj.getClass().getMethod(
- "clearJdbcDriverRegistrations").invoke(obj);
- } catch (Exception e) {
- // So many things to go wrong above...
- log.warn(sm.getString("webappClassLoader.jdbcRemoveFailed"), e);
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException ioe) {
- log.warn(sm.getString(
- "webappClassLoader.jdbcRemoveStreamError"), ioe);
- }
- }
- }
-
- // Null out any static or final fields from loaded classes,
- // as a workaround for apparent garbage collection bugs
- if (ENABLE_CLEAR_REFERENCES) {
- java.util.Collection<ResourceEntry> values = resourceEntries.values();
- Iterator<ResourceEntry> loadedClasses = values.iterator();
- //
- // walk through all loaded class to trigger initialization for
- // any uninitialized classes, otherwise initialization of
- // one class may call a previously cleared class.
- while(loadedClasses.hasNext()) {
- ResourceEntry entry = loadedClasses.next();
- if (entry.loadedClass != null) {
- Class<?> clazz = entry.loadedClass;
- try {
- Field[] fields = clazz.getDeclaredFields();
- for (int i = 0; i < fields.length; i++) {
- if(Modifier.isStatic(fields[i].getModifiers())) {
- fields[i].get(null);
- break;
- }
- }
- } catch(Throwable t) {
- // Ignore
- }
- }
- }
- loadedClasses = values.iterator();
- while (loadedClasses.hasNext()) {
- ResourceEntry entry = (ResourceEntry) loadedClasses.next();
- if (entry.loadedClass != null) {
- Class clazz = entry.loadedClass;
- try {
- Field[] fields = clazz.getDeclaredFields();
- for (int i = 0; i < fields.length; i++) {
- Field field = fields[i];
- int mods = field.getModifiers();
- if (field.getType().isPrimitive()
- || (field.getName().indexOf("$") != -1)) {
- continue;
- }
- if (Modifier.isStatic(mods)) {
- try {
- field.setAccessible(true);
- if (Modifier.isFinal(mods)) {
- if (!((field.getType().getName().startsWith("java."))
- || (field.getType().getName().startsWith("javax.")))) {
- nullInstance(field.get(null));
- }
- } else {
- field.set(null, null);
- if (log.isDebugEnabled()) {
- log.debug("Set field " + field.getName()
- + " to null in class " + clazz.getName());
- }
- }
- } catch (Throwable t) {
- if (log.isDebugEnabled()) {
- log.debug("Could not set field " + field.getName()
- + " to null in class " + clazz.getName(), t);
- }
- }
- }
- }
- } catch (Throwable t) {
- if (log.isDebugEnabled()) {
- log.debug("Could not clean fields for class " + clazz.getName(), t);
- }
- }
- }
- }
- }
-
- // Clear the IntrospectionUtils cache.
- IntrospectionUtils.clear();
-
- // Clear the classloader reference in the VM's bean introspector
- java.beans.Introspector.flushCaches();
-
- }
-
-
- protected void nullInstance(Object instance) {
- if (instance == null) {
- return;
- }
- Field[] fields = instance.getClass().getDeclaredFields();
- for (int i = 0; i < fields.length; i++) {
- Field field = fields[i];
- int mods = field.getModifiers();
- if (field.getType().isPrimitive()
- || (field.getName().indexOf("$") != -1)) {
- continue;
- }
- try {
- field.setAccessible(true);
- if (Modifier.isStatic(mods) && Modifier.isFinal(mods)) {
- // Doing something recursively is too risky
- continue;
- } else {
- Object value = field.get(instance);
- if (null != value) {
- Class valueClass = value.getClass();
- if (!loadedByThisOrChild(valueClass)) {
- if (log.isDebugEnabled()) {
- log.debug("Not setting field " + field.getName() +
- " to null in object of class " +
- instance.getClass().getName() +
- " because the referenced object was of type " +
- valueClass.getName() +
- " which was not loaded by this WebappClassLoader.");
- }
- } else {
- field.set(instance, null);
- if (log.isDebugEnabled()) {
- log.debug("Set field " + field.getName()
- + " to null in class " + instance.getClass().getName());
- }
- }
- }
- }
- } catch (Throwable t) {
- if (log.isDebugEnabled()) {
- log.debug("Could not set field " + field.getName()
- + " to null in object instance of class "
- + instance.getClass().getName(), t);
- }
- }
- }
- }
-
-
- /**
- * Determine whether a class was loaded by this class loader or one of
- * its child class loaders.
- */
- protected boolean loadedByThisOrChild(Class clazz)
- {
- boolean result = false;
- for (ClassLoader classLoader = clazz.getClassLoader();
- null != classLoader; classLoader = classLoader.getParent()) {
- if (classLoader.equals(this)) {
- result = true;
- break;
- }
- }
- return result;
- }
-
-
- /**
- * Find specified class in local repositories.
- *
- * @return the loaded class, or null if the class isn't found
- */
- protected Class findClassInternal(String name)
- throws ClassNotFoundException {
-
- if (!validate(name))
- throw new ClassNotFoundException(name);
-
- String tempPath = name.replace('.', '/');
- String classPath = tempPath + ".class";
-
- ResourceEntry entry = null;
-
- entry = findResourceInternal(name, classPath);
-
- if (entry == null)
- throw new ClassNotFoundException(name);
-
- Class clazz = entry.loadedClass;
- if (clazz != null)
- return clazz;
-
- synchronized (this) {
- clazz = entry.loadedClass;
- if (clazz != null)
- return clazz;
-
- if (entry.binaryContent == null)
- throw new ClassNotFoundException(name);
-
- // Looking up the package
- String packageName = null;
- int pos = name.lastIndexOf('.');
- if (pos != -1)
- packageName = name.substring(0, pos);
-
- Package pkg = null;
-
- if (packageName != null) {
- pkg = getPackage(packageName);
- // Define the package (if null)
- if (pkg == null) {
- try {
- if (entry.manifest == null) {
- definePackage(packageName, null, null, null, null,
- null, null, null);
- } else {
- definePackage(packageName, entry.manifest,
- entry.codeBase);
- }
- } catch (IllegalArgumentException e) {
- // Ignore: normal error due to dual definition of package
- }
- pkg = getPackage(packageName);
- }
- }
-
- if (securityManager != null) {
-
- // Checking sealing
- if (pkg != null) {
- boolean sealCheck = true;
- if (pkg.isSealed()) {
- sealCheck = pkg.isSealed(entry.codeBase);
- } else {
- sealCheck = (entry.manifest == null)
- || !isPackageSealed(packageName, entry.manifest);
- }
- if (!sealCheck)
- throw new SecurityException
- ("Sealing violation loading " + name + " : Package "
- + packageName + " is sealed.");
- }
-
- }
-
- clazz = defineClass(name, entry.binaryContent, 0,
- entry.binaryContent.length,
- new CodeSource(entry.codeBase, entry.certificates));
- entry.loadedClass = clazz;
- entry.binaryContent = null;
- entry.source = null;
- entry.codeBase = null;
- entry.manifest = null;
- entry.certificates = null;
- }
-
- return clazz;
-
- }
-
- /**
- * Find specified resource in local repositories. This block
- * will execute under an AccessControl.doPrivilege block.
- *
- * @return the loaded resource, or null if the resource isn't found
- */
- protected ResourceEntry findResourceInternal(File file, String path){
- ResourceEntry entry = new ResourceEntry();
- try {
- entry.source = getURI(new File(file, path));
- entry.codeBase = getURL(new File(file, path), false);
- } catch (MalformedURLException e) {
- return null;
- }
- return entry;
- }
-
-
- /**
- * Find specified resource in local repositories.
- *
- * @return the loaded resource, or null if the resource isn't found
- */
- protected ResourceEntry findResourceInternal(String name, String path) {
-
- if (!started) {
- log.info(sm.getString("webappClassLoader.stopped", name));
- return null;
- }
-
- if ((name == null) || (path == null))
- return null;
-
- ResourceEntry entry = (ResourceEntry) resourceEntries.get(name);
- if (entry != null)
- return entry;
-
- int contentLength = -1;
- InputStream binaryStream = null;
-
- File[] repositories = repository.findExplodedJars();
- JarFile[] jarFiles = repository.findJars();
-
- int i;
-
- //Resource resource = null;
-
- boolean fileNeedConvert = false;
-
- for (i = 0; (entry == null) && (i < repositories.length); i++) {
-
- File resource = new File(repositories[i], path);
- if (!resource.exists()) {
- continue;
- }
-
- // Note : Not getting an exception here means the resource was
- // found
- if (securityManager != null) {
- PrivilegedAction dp =
- new PrivilegedFindResource(repositories[i], path);
- entry = (ResourceEntry)AccessController.doPrivileged(dp);
- } else {
- entry = findResourceInternal(repositories[i], path);
- }
-
- contentLength = (int) resource.length();
- entry.lastModified = resource.lastModified();
-
- try {
- binaryStream = new FileInputStream(resource);
- } catch (IOException e) {
- return null;
- }
-
- if (needConvert) {
- if (path.endsWith(".properties")) {
- fileNeedConvert = true;
- }
- }
-
- }
-
- if ((entry == null) && (notFoundResources.containsKey(name)))
- return null;
-
- JarEntry jarEntry = null;
-
- for (i = 0; (entry == null) && (i < jarFiles.length); i++) {
-
- jarEntry = jarFiles[i].getJarEntry(path);
-
- if (jarEntry != null) {
-
- entry = new ResourceEntry();
- try {
- File jarFile = new File(jarFiles[i].getName());
- entry.codeBase = getURL(jarFile, false);
- String jarFakeUrl = getURI(jarFile).toString();
- jarFakeUrl = "jar:" + jarFakeUrl + "!/" + path;
- entry.source = new URL(jarFakeUrl);
- entry.lastModified = jarFile.lastModified();
- } catch (MalformedURLException e) {
- return null;
- }
- contentLength = (int) jarEntry.getSize();
- try {
- entry.manifest = jarFiles[i].getManifest();
- binaryStream = jarFiles[i].getInputStream(jarEntry);
- } catch (IOException e) {
- return null;
- }
-
- // Extract resources contained in JAR to the workdir
- if (antiJARLocking && !(path.endsWith(".class"))) {
- byte[] buf = new byte[1024];
- File resourceFile = new File
- (loaderDir, jarEntry.getName());
- if (!resourceFile.exists()) {
- Enumeration entries = jarFiles[i].entries();
- while (entries.hasMoreElements()) {
- JarEntry jarEntry2 =
- (JarEntry) entries.nextElement();
- if (!(jarEntry2.isDirectory())
- && (!jarEntry2.getName().endsWith(".class"))) {
- resourceFile = new File
- (loaderDir, jarEntry2.getName());
- try {
- if (!resourceFile.getCanonicalPath().startsWith(
- canonicalLoaderDir)) {
- throw new IllegalArgumentException(
- sm.getString("webappClassLoader.illegalJarPath",
- jarEntry2.getName()));
- }
- } catch (IOException ioe) {
- throw new IllegalArgumentException(
- sm.getString("webappClassLoader.validationErrorJarPath",
- jarEntry2.getName()), ioe);
- }
- resourceFile.getParentFile().mkdirs();
- FileOutputStream os = null;
- InputStream is = null;
- try {
- is = jarFiles[i].getInputStream(jarEntry2);
- os = new FileOutputStream(resourceFile);
- while (true) {
- int n = is.read(buf);
- if (n <= 0) {
- break;
- }
- os.write(buf, 0, n);
- }
- } catch (IOException e) {
- // Ignore
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- } catch (IOException e) {
- }
- try {
- if (os != null) {
- os.close();
- }
- } catch (IOException e) {
- }
- }
- }
- }
- }
- }
-
- }
-
- }
-
- if (entry == null) {
- notFoundResources.put(name, VALUE);
- return null;
- }
-
- if (binaryStream != null) {
-
- byte[] binaryContent = new byte[contentLength];
-
- int pos = 0;
- try {
-
- while (true) {
- int n = binaryStream.read(binaryContent, pos,
- binaryContent.length - pos);
- if (n <= 0)
- break;
- pos += n;
- }
- } catch (IOException e) {
- log.error(sm.getString("webappClassLoader.readError", name), e);
- return null;
- } finally {
- try {
- binaryStream.close();
- } catch (IOException e) {}
- }
-
- if (fileNeedConvert) {
- String str = new String(binaryContent,0,pos);
- try {
- binaryContent = str.getBytes("UTF-8");
- } catch (Exception e) {
- return null;
- }
- }
- entry.binaryContent = binaryContent;
-
- // The certificates are only available after the JarEntry
- // associated input stream has been fully read
- if (jarEntry != null) {
- entry.certificates = jarEntry.getCertificates();
- }
-
- }
-
- // Add the entry in the local resource repository
- synchronized (resourceEntries) {
- // Ensures that all the threads which may be in a race to load
- // a particular class all end up with the same ResourceEntry
- // instance
- ResourceEntry entry2 = (ResourceEntry) resourceEntries.get(name);
- if (entry2 == null) {
- resourceEntries.put(name, entry);
- } else {
- entry = entry2;
- }
- }
-
- return entry;
-
- }
-
-
- /**
- * Returns true if the specified package name is sealed according to the
- * given manifest.
- */
- protected boolean isPackageSealed(String name, Manifest man) {
-
- String path = name.replace('.', '/') + '/';
- Attributes attr = man.getAttributes(path);
- String sealed = null;
- if (attr != null) {
- sealed = attr.getValue(Name.SEALED);
- }
- if (sealed == null) {
- if ((attr = man.getMainAttributes()) != null) {
- sealed = attr.getValue(Name.SEALED);
- }
- }
- return "true".equalsIgnoreCase(sealed);
-
- }
-
-
- /**
- * Finds the resource with the given name if it has previously been
- * loaded and cached by this class loader, and return an input stream
- * to the resource data. If this resource has not been cached, return
- * <code>null</code>.
- *
- * @param name Name of the resource to return
- */
- protected InputStream findLoadedResource(String name) {
-
- ResourceEntry entry = (ResourceEntry) resourceEntries.get(name);
- if (entry != null) {
- if (entry.binaryContent != null)
- return new ByteArrayInputStream(entry.binaryContent);
- }
- return (null);
-
- }
-
-
- /**
- * Finds the class with the given name if it has previously been
- * loaded and cached by this class loader, and return the Class object.
- * If this class has not been cached, return <code>null</code>.
- *
- * @param name Name of the resource to return
- */
- protected Class findLoadedClass0(String name) {
-
- ResourceEntry entry = (ResourceEntry) resourceEntries.get(name);
- if (entry != null) {
- return entry.loadedClass;
- }
- return (null); // FIXME - findLoadedResource()
-
- }
-
-
- /**
- * Refresh the system policy file, to pick up eventual changes.
- */
- protected void refreshPolicy() {
-
- try {
- // The policy file may have been modified to adjust
- // permissions, so we're reloading it when loading or
- // reloading a Context
- Policy policy = Policy.getPolicy();
- policy.refresh();
- } catch (AccessControlException e) {
- // Some policy files may restrict this, even for the core,
- // so this exception is ignored
- }
-
- }
-
-
- /**
- * Filter classes.
- *
- * @param name class name
- * @return true if the class should be filtered
- */
- protected boolean filter(String name) {
-
- if (name == null)
- return false;
-
- // Looking up the package
- String packageName = null;
- int pos = name.lastIndexOf('.');
- if (pos != -1)
- packageName = name.substring(0, pos);
- else
- return false;
-
- for (int i = 0; i < packageTriggers.length; i++) {
- if (packageName.startsWith(packageTriggers[i]))
- return true;
- }
-
- return false;
-
- }
-
-
- /**
- * Validate a classname. As per SRV.9.7.2, we must restict loading of
- * classes from J2SE (java.*) and classes of the servlet API
- * (javax.servlet.*). That should enhance robustness and prevent a number
- * of user error (where an older version of servlet.jar would be present
- * in /WEB-INF/lib).
- *
- * @param name class name
- * @return true if the name is valid
- */
- protected boolean validate(String name) {
-
- if (name == null)
- return false;
- if (name.startsWith("java."))
- return false;
-
- return true;
-
- }
-
-
- /**
- * Check the specified JAR file, and return <code>true</code> if it does
- * not contain any of the trigger classes.
- *
- * @param jarfile The JAR file to be checked
- *
- * @exception IOException if an input/output error occurs
- */
- protected boolean validateJarFile(File jarfile)
- throws IOException {
-
- if (triggers == null)
- return (true);
- JarFile jarFile = new JarFile(jarfile);
- for (int i = 0; i < triggers.length; i++) {
- Class clazz = null;
- try {
- if (parent != null) {
- clazz = parent.loadClass(triggers[i]);
- } else {
- clazz = Class.forName(triggers[i]);
- }
- } catch (Throwable t) {
- clazz = null;
- }
- if (clazz == null)
- continue;
- String name = triggers[i].replace('.', '/') + ".class";
- if (log.isDebugEnabled())
- log.debug(" Checking for " + name);
- JarEntry jarEntry = jarFile.getJarEntry(name);
- if (jarEntry != null) {
- log.info("validateJarFile(" + jarfile +
- ") - jar not loaded. See Servlet Spec 2.3, "
- + "section 9.7.2. Offending class: " + name);
- jarFile.close();
- return (false);
- }
- }
- jarFile.close();
- return (true);
-
- }
-
-
- /**
- * Get URL.
- */
- protected URL getURL(File file, boolean encoded)
- throws MalformedURLException {
-
- File realFile = file;
- try {
- realFile = realFile.getCanonicalFile();
- } catch (IOException e) {
- // Ignore
- }
- if(encoded) {
- return getURI(realFile);
- } else {
- return realFile.toURL();
- }
-
- }
-
-
- /**
- * Get URL.
- */
- protected URL getURI(File file)
- throws MalformedURLException {
-
-
- File realFile = file;
- try {
- realFile = realFile.getCanonicalFile();
- } catch (IOException e) {
- // Ignore
- }
- return realFile.toURI().toURL();
-
- }
-
-
- /**
- * Delete the specified directory, including all of its contents and
- * subdirectories recursively.
- *
- * @param dir File object representing the directory to be deleted
- */
- protected static void deleteDir(File dir) {
-
- String files[] = dir.list();
- if (files == null) {
- files = new String[0];
- }
- for (int i = 0; i < files.length; i++) {
- File file = new File(dir, files[i]);
- if (file.isDirectory()) {
- deleteDir(file);
- } else {
- file.delete();
- }
- }
- dir.delete();
-
- }
-
-
-}
-
Deleted: trunk/java/org/apache/catalina/loader/WebappLoader.java
===================================================================
--- trunk/java/org/apache/catalina/loader/WebappLoader.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/WebappLoader.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,846 +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.
- *
- *
- * 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.loader;
-
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.io.File;
-import java.io.FilePermission;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLStreamHandlerFactory;
-
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.servlet.ServletContext;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Globals;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.Loader;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.util.LifecycleSupport;
-import org.apache.catalina.util.StringManager;
-import org.apache.naming.resources.DirContextURLStreamHandler;
-import org.apache.naming.resources.DirContextURLStreamHandlerFactory;
-import org.apache.tomcat.util.modeler.Registry;
-
-
-/**
- * Classloader implementation which is specialized for handling web
- * applications in the most efficient way, while being Catalina aware (all
- * accesses to resources are made through the DirContext interface).
- * This class loader supports detection of modified
- * Java classes, which can be used to implement auto-reload support.
- * <p>
- * This class loader is configured by adding the pathnames of directories,
- * JAR files, and ZIP files with the <code>addRepository()</code> method,
- * prior to calling <code>start()</code>. When a new class is required,
- * these repositories will be consulted first to locate the class. If it
- * is not present, the system class loader will be used instead.
- *
- * @author Craig R. McClanahan
- * @author Remy Maucherat
- * @version $Revision$ $Date$
- */
-
-public class WebappLoader
- implements Lifecycle, Loader, PropertyChangeListener, MBeanRegistration {
-
- /**
- * The string manager for this package.
- */
- protected static final StringManager sm =
- StringManager.getManager(Constants.Package);
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a new WebappLoader with no defined parent class loader
- * (so that the actual parent will be the system class loader).
- */
- public WebappLoader() {
-
- this(null);
-
- }
-
-
- /**
- * Construct a new WebappLoader with the specified class loader
- * to be defined as the parent of the ClassLoader we ultimately create.
- *
- * @param parent The parent class loader
- */
- public WebappLoader(ClassLoader parent) {
- super();
- this.parentClassLoader = parent;
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * First load of the class.
- */
- private static boolean first = true;
-
-
- /**
- * The class loader being managed by this Loader component.
- */
- private WebappClassLoader classLoader = null;
-
-
- /**
- * The Container with which this Loader has been associated.
- */
- private Container container = null;
-
-
- /**
- * The "follow standard delegation model" flag that will be used to
- * configure our ClassLoader.
- */
- private boolean delegate = false;
-
-
- /**
- * The descriptive information about this Loader implementation.
- */
- private static final String info =
- "org.apache.catalina.loader.WebappLoader/1.0";
-
-
- /**
- * The lifecycle event support for this component.
- */
- protected LifecycleSupport lifecycle = new LifecycleSupport(this);
-
-
- /**
- * The Java class name of the ClassLoader implementation to be used.
- * This class should extend WebappClassLoader, otherwise, a different
- * loader implementation must be used.
- */
- private String loaderClass =
- "org.apache.catalina.loader.WebappClassLoader";
-
-
- /**
- * The parent class loader of the class loader we will create.
- */
- private ClassLoader parentClassLoader = null;
-
-
- /**
- * The reloadable flag for this Loader.
- */
- private boolean reloadable = false;
-
-
- /**
- * Has this component been started?
- */
- private boolean started = false;
-
-
- /**
- * The property change support for this component.
- */
- protected PropertyChangeSupport support = new PropertyChangeSupport(this);
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Return the Java class loader to be used by this Container.
- */
- public ClassLoader getClassLoader() {
-
- return ((ClassLoader) classLoader);
-
- }
-
-
- /**
- * Return the Container with which this Logger has been associated.
- */
- public Container getContainer() {
-
- return (container);
-
- }
-
-
- /**
- * Set the Container with which this Logger has been associated.
- *
- * @param container The associated Container
- */
- public void setContainer(Container container) {
-
- // Deregister from the old Container (if any)
- if ((this.container != null) && (this.container instanceof Context))
- ((Context) this.container).removePropertyChangeListener(this);
-
- // Process this property change
- Container oldContainer = this.container;
- this.container = container;
- support.firePropertyChange("container", oldContainer, this.container);
-
- // Register with the new Container (if any)
- if ((this.container != null) && (this.container instanceof Context)) {
- setReloadable( ((Context) this.container).getReloadable() );
- ((Context) this.container).addPropertyChangeListener(this);
- }
-
- }
-
-
- /**
- * Return the "follow standard delegation model" flag used to configure
- * our ClassLoader.
- */
- public boolean getDelegate() {
-
- return (this.delegate);
-
- }
-
-
- /**
- * Set the "follow standard delegation model" flag used to configure
- * our ClassLoader.
- *
- * @param delegate The new flag
- */
- public void setDelegate(boolean delegate) {
-
- boolean oldDelegate = this.delegate;
- this.delegate = delegate;
- support.firePropertyChange("delegate", new Boolean(oldDelegate),
- new Boolean(this.delegate));
-
- }
-
-
- /**
- * Return descriptive information about this Loader implementation and
- * the corresponding version number, in the format
- * <code><description>/<version></code>.
- */
- public String getInfo() {
-
- return (info);
-
- }
-
-
- /**
- * Return the ClassLoader class name.
- */
- public String getLoaderClass() {
-
- return (this.loaderClass);
-
- }
-
-
- /**
- * Set the ClassLoader class name.
- *
- * @param loaderClass The new ClassLoader class name
- */
- public void setLoaderClass(String loaderClass) {
-
- this.loaderClass = loaderClass;
-
- }
-
-
- /**
- * Return the reloadable flag for this Loader.
- */
- public boolean getReloadable() {
-
- return (this.reloadable);
-
- }
-
-
- /**
- * Set the reloadable flag for this Loader.
- *
- * @param reloadable The new reloadable flag
- */
- public void setReloadable(boolean reloadable) {
-
- // Process this property change
- boolean oldReloadable = this.reloadable;
- this.reloadable = reloadable;
- support.firePropertyChange("reloadable",
- new Boolean(oldReloadable),
- new Boolean(this.reloadable));
-
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Add a property change listener to this component.
- *
- * @param listener The listener to add
- */
- public void addPropertyChangeListener(PropertyChangeListener listener) {
-
- support.addPropertyChangeListener(listener);
-
- }
-
-
- /**
- * Add a new repository to the set of repositories for this class loader.
- *
- * @param repository Repository to be added
- */
- public void addRepository(String repository) {
-
- if (log.isDebugEnabled())
- log.debug(sm.getString("webappLoader.addRepository", repository));
-
- }
-
-
- /**
- * 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() {
- if (reloadable && modified()) {
- try {
- Thread.currentThread().setContextClassLoader
- (WebappLoader.class.getClassLoader());
- if (container instanceof StandardContext) {
- ((StandardContext) container).reload();
- }
- } finally {
- if (container.getLoader() != null) {
- Thread.currentThread().setContextClassLoader
- (container.getLoader().getClassLoader());
- }
- }
- }
- }
-
-
- /**
- * Return the set of repositories defined for this class loader.
- * If none are defined, a zero-length array is returned.
- * For security reason, returns a clone of the Array (since
- * String are immutable).
- */
- public String[] findRepositories() {
- return null;
- }
-
-
- public String[] findLoaderRepositories() {
- return null;
- }
-
-
- /**
- * Has the internal repository associated with this Loader been modified,
- * such that the loaded classes should be reloaded?
- */
- public boolean modified() {
- return false;
- }
-
-
- /**
- * Remove a property change listener from this component.
- *
- * @param listener The listener to remove
- */
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- support.removePropertyChangeListener(listener);
- }
-
-
- /**
- * Return a String representation of this component.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("WebappLoader[");
- if (container != null)
- sb.append(container.getName());
- sb.append("]");
- return (sb.toString());
-
- }
-
-
- // ------------------------------------------------------ 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);
-
- }
-
- private boolean initialized=false;
-
- public void init() {
- initialized=true;
-
- if( oname==null ) {
- // not registered yet - standalone or API
- if( container instanceof StandardContext) {
- // Register ourself. The container must be a webapp
- try {
- StandardContext ctx=(StandardContext)container;
- Engine eng=(Engine)ctx.getParent().getParent();
- String path = ctx.getPath();
- if (path.equals("")) {
- path = "/";
- }
- oname=new ObjectName(ctx.getEngineName() + ":type=Loader,path=" +
- path + ",host=" + ctx.getParent().getName());
- Registry.getRegistry(null, null).registerComponent(this, oname, null);
- controller=oname;
- } catch (Exception e) {
- log.error("Error registering loader", e );
- }
- }
- }
-
- if( container == null ) {
- // JMX created the loader
- // TODO
-
- }
- }
-
- public void destroy() {
- if( controller==oname ) {
- // Self-registration, undo it
- Registry.getRegistry(null, null).unregisterComponent(oname);
- oname = null;
- }
- initialized = false;
-
- }
-
- /**
- * Start this component, initializing our associated class loader.
- *
- * @exception LifecycleException if a lifecycle error occurs
- */
- public void start() throws LifecycleException {
- // Validate and update our current component state
- if( ! initialized ) init();
- if (started)
- throw new LifecycleException
- (sm.getString("webappLoader.alreadyStarted"));
- if (log.isDebugEnabled())
- log.debug(sm.getString("webappLoader.starting"));
- lifecycle.fireLifecycleEvent(START_EVENT, null);
- started = true;
-
- if (container.getResources() == null) {
- log.info("No resources for " + container);
- return;
- }
- // Register a stream handler factory for the JNDI protocol
- URLStreamHandlerFactory streamHandlerFactory =
- new DirContextURLStreamHandlerFactory();
- if (first) {
- first = false;
- try {
- URL.setURLStreamHandlerFactory(streamHandlerFactory);
- } catch (Exception e) {
- // Log and continue anyway, this is not critical
- log.error("Error registering jndi stream handler", e);
- } catch (Throwable t) {
- // This is likely a dual registration, ignore
- }
- }
-
- // Construct a class loader based on our current repositories list
- try {
-
- classLoader = createClassLoader();
- classLoader.setDelegate(this.delegate);
- if (container instanceof StandardContext)
- classLoader.setAntiJARLocking(((StandardContext) container).getAntiJARLocking());
-
- // Configure our repositories
- if (!(container instanceof Context))
- throw new IllegalStateException("This loader only supports a Context");
- ServletContext servletContext = ((Context) container).getServletContext();
- if (servletContext == null)
- throw new IllegalStateException("No servlet context available");
-
- File workDir =
- (File) servletContext.getAttribute(ServletContext.TEMPDIR);
- if (workDir == null) {
- log.info("No work dir for " + servletContext);
- }
-
- if( log.isDebugEnabled())
- log.debug(sm.getString("webappLoader.deploy", workDir.getAbsolutePath()));
-
- classLoader.setWorkDir(workDir);
- classLoader.setRepository(container.getJarRepository());
-
- setPermissions();
-
- if (classLoader instanceof Lifecycle)
- ((Lifecycle) classLoader).start();
-
- // Binding the Webapp class loader to the directory context
- DirContextURLStreamHandler.bind
- ((ClassLoader) classLoader, this.container.getResources());
-
- StandardContext ctx=(StandardContext)container;
- Engine eng=(Engine)ctx.getParent().getParent();
- String path = ctx.getPath();
- if (path.equals("")) {
- path = "/";
- }
- ObjectName cloname = new ObjectName
- (ctx.getEngineName() + ":type=WebappClassLoader,path="
- + path + ",host=" + ctx.getParent().getName());
- Registry.getRegistry(null, null)
- .registerComponent(classLoader, cloname, null);
-
- } catch (Throwable t) {
- log.error( "LifecycleException ", t );
- throw new LifecycleException("start: ", t);
- }
-
- }
-
-
- /**
- * Stop this component, finalizing our associated class loader.
- *
- * @exception LifecycleException if a lifecycle error occurs
- */
- public void stop() throws LifecycleException {
-
- // Validate and update our current component state
- if (!started)
- throw new LifecycleException
- (sm.getString("webappLoader.notStarted"));
- if (log.isDebugEnabled())
- log.debug(sm.getString("webappLoader.stopping"));
- lifecycle.fireLifecycleEvent(STOP_EVENT, null);
- started = false;
-
- // Remove context attributes as appropriate
- if (container instanceof Context) {
- ServletContext servletContext =
- ((Context) container).getServletContext();
- servletContext.removeAttribute(Globals.CLASS_PATH_ATTR);
- }
-
- // Throw away our current class loader
- if (classLoader instanceof Lifecycle)
- ((Lifecycle) classLoader).stop();
- DirContextURLStreamHandler.unbind((ClassLoader) classLoader);
-
- try {
- StandardContext ctx=(StandardContext)container;
- Engine eng=(Engine)ctx.getParent().getParent();
- String path = ctx.getPath();
- if (path.equals("")) {
- path = "/";
- }
- ObjectName cloname = new ObjectName
- (ctx.getEngineName() + ":type=WebappClassLoader,path="
- + path + ",host=" + ctx.getParent().getName());
- Registry.getRegistry(null, null).unregisterComponent(cloname);
- } catch (Throwable t) {
- log.error( "LifecycleException ", t );
- }
-
- classLoader = null;
-
- destroy();
-
- }
-
-
- // ----------------------------------------- PropertyChangeListener Methods
-
-
- /**
- * Process property change events from our associated Context.
- *
- * @param event The property change event that has occurred
- */
- public void propertyChange(PropertyChangeEvent event) {
-
- // Validate the source of this event
- if (!(event.getSource() instanceof Context))
- return;
- Context context = (Context) event.getSource();
-
- // Process a relevant property change
- if (event.getPropertyName().equals("reloadable")) {
- try {
- setReloadable
- ( ((Boolean) event.getNewValue()).booleanValue() );
- } catch (NumberFormatException e) {
- log.error(sm.getString("webappLoader.reloadable",
- event.getNewValue().toString()));
- }
- }
-
- }
-
-
- // ------------------------------------------------------- Private Methods
-
-
- /**
- * Create associated classLoader.
- */
- private WebappClassLoader createClassLoader()
- throws Exception {
-
- Class clazz = Class.forName(loaderClass);
- WebappClassLoader classLoader = null;
-
- if (parentClassLoader == null) {
- parentClassLoader = container.getParentClassLoader();
- }
- Class[] argTypes = { ClassLoader.class };
- Object[] args = { parentClassLoader };
- Constructor constr = clazz.getConstructor(argTypes);
- classLoader = (WebappClassLoader) constr.newInstance(args);
-
- return classLoader;
-
- }
-
-
- /**
- * Configure associated class loader permissions.
- */
- private void setPermissions() {
-
- if (!Globals.IS_SECURITY_ENABLED)
- return;
- if (!(container instanceof Context))
- return;
-
- // Tell the class loader the root of the context
- ServletContext servletContext =
- ((Context) container).getServletContext();
-
- // Assigning permissions for the work directory
- File workDir =
- (File) servletContext.getAttribute(ServletContext.TEMPDIR);
- if (workDir != null) {
- try {
- String workDirPath = workDir.getCanonicalPath();
- classLoader.addPermission
- (new FilePermission(workDirPath, "read,write"));
- classLoader.addPermission
- (new FilePermission(workDirPath + File.separator + "-",
- "read,write,delete"));
- } catch (IOException e) {
- // Ignore
- }
- }
-
- try {
-
- URL rootURL = servletContext.getResource("/");
- classLoader.addPermission(rootURL);
-
- String contextRoot = servletContext.getRealPath("/");
- if (contextRoot != null) {
- try {
- contextRoot = (new File(contextRoot)).getCanonicalPath();
- classLoader.addPermission(contextRoot);
- } catch (IOException e) {
- // Ignore
- }
- }
-
- URL classesURL = servletContext.getResource("/WEB-INF/classes/");
- classLoader.addPermission(classesURL);
- URL libURL = servletContext.getResource("/WEB-INF/lib/");
- classLoader.addPermission(libURL);
-
- if (contextRoot != null) {
-
- if (libURL != null) {
- File rootDir = new File(contextRoot);
- File libDir = new File(rootDir, "WEB-INF/lib/");
- try {
- String path = libDir.getCanonicalPath();
- classLoader.addPermission(path);
- } catch (IOException e) {
- }
- }
-
- } else {
-
- if (workDir != null) {
- if (libURL != null) {
- File libDir = new File(workDir, "WEB-INF/lib/");
- try {
- String path = libDir.getCanonicalPath();
- classLoader.addPermission(path);
- } catch (IOException e) {
- }
- }
- if (classesURL != null) {
- File classesDir = new File(workDir, "WEB-INF/classes/");
- try {
- String path = classesDir.getCanonicalPath();
- classLoader.addPermission(path);
- } catch (IOException e) {
- }
- }
- }
-
- }
-
- } catch (MalformedURLException e) {
- }
-
- }
-
-
- private static org.jboss.logging.Logger log=
- org.jboss.logging.Logger.getLogger( WebappLoader.class );
-
- private ObjectName oname;
- private MBeanServer mserver;
- private String domain;
- private ObjectName controller;
-
- public ObjectName preRegister(MBeanServer server,
- ObjectName name) throws Exception {
- oname=name;
- mserver=server;
- domain=name.getDomain();
-
- return name;
- }
-
- public void postRegister(Boolean registrationDone) {
- }
-
- public void preDeregister() throws Exception {
- }
-
- public void postDeregister() {
- }
-
- public ObjectName getController() {
- return controller;
- }
-
- public void setController(ObjectName controller) {
- this.controller = controller;
- }
-
-}
Deleted: trunk/java/org/apache/catalina/loader/mbeans-descriptors.xml
===================================================================
--- trunk/java/org/apache/catalina/loader/mbeans-descriptors.xml 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/loader/mbeans-descriptors.xml 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,59 +0,0 @@
-<?xml version="1.0"?>
-<mbeans-descriptors>
-
- <mbean name="WebappLoader"
- description="Classloader implementation which is specialized for
- handling web applications"
- domain="Catalina"
- group="Loader"
- type="org.apache.catalina.loader.WebappLoader">
-
- <attribute name="className"
- description="Fully qualified class name of the managed object"
- type="java.lang.String"
- writeable="false"/>
-
- <attribute name="delegate"
- description="The 'follow standard delegation model' flag that will be
- used to configure our ClassLoader"
- type="boolean"/>
-
- <attribute name="reloadable"
- description="The reloadable flag for this Loader"
- type="boolean"/>
-
- <attribute name="repositories"
- description="Extra repositories managed by this loader"
- type="[Ljava.lang.String;"/>
-
- <attribute name="repositoriesString"
- description="Extra repositories managed by this loader"
- writeable="false"
- type="java.lang.String"/>
-
- <attribute name="loaderRepositories"
- description="Repositories set in the real loader"
- type="[Ljava.lang.String;"
- writeable="false" />
-
- <attribute name="loaderRepositoriesString"
- description="Repositories set in the real loader"
- type="java.lang.String"
- writeable="false" />
-
- <operation name="toString"
- description="Info about the loader"
- impact="INFO"
- returnType="String">
- </operation>
- </mbean>
-
-
- <mbean name="WebappClassLoader"
- description="Classloader implementation which is specialized for
- handling web applications"
- domain="Catalina"
- group="Loader"
- type="org.apache.catalina.loader.WebappClassLoader" />
-
-</mbeans-descriptors>
Deleted: trunk/java/org/apache/catalina/manager/HTMLManagerServlet.java
===================================================================
--- trunk/java/org/apache/catalina/manager/HTMLManagerServlet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/manager/HTMLManagerServlet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,1118 +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.manager;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.Part;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.Context;
-import org.apache.catalina.Session;
-import org.apache.catalina.manager.util.BaseSessionComparator;
-import org.apache.catalina.manager.util.ReverseComparator;
-import org.apache.catalina.manager.util.SessionUtils;
-import org.apache.catalina.util.RequestUtil;
-import org.apache.catalina.util.ServerInfo;
-import org.apache.catalina.util.URLEncoder;
-import org.apache.tomcat.util.http.fileupload.ParameterParser;
-
-/**
-* Servlet that enables remote management of the web applications deployed
-* within the same virtual host as this web application is. Normally, this
-* functionality will be protected by a security constraint in the web
-* application deployment descriptor. However, this requirement can be
-* relaxed during testing.
-* <p>
-* The difference between the <code>ManagerServlet</code> and this
-* Servlet is that this Servlet prints out a HTML interface which
-* makes it easier to administrate.
-* <p>
-* However if you use a software that parses the output of
-* <code>ManagerServlet</code> you won't be able to upgrade
-* to this Servlet since the output are not in the
-* same format ar from <code>ManagerServlet</code>
-*
-* @author Bip Thelin
-* @author Malcolm Edgar
-* @author Glenn L. Nielsen
-* @version $Revision$, $Date$
-* @see ManagerServlet
-*/
-
-public final class HTMLManagerServlet extends ManagerServlet {
-
- protected static final URLEncoder URL_ENCODER;
- protected static final String APPLICATION_MESSAGE = "message";
- protected static final String APPLICATION_ERROR = "error";
- protected String sessionsListJspPath = "/sessionsList.jsp";
- protected String sessionDetailJspPath = "/sessionDetail.jsp";
- static {
- URL_ENCODER = new URLEncoder();
- // '/' should not be encoded in context paths
- URL_ENCODER.addSafeCharacter('/');
- }
-
- // --------------------------------------------------------- Public Methods
-
- /**
- * Process a GET request for the specified resource.
- *
- * @param request The servlet request we are processing
- * @param response The servlet response we are creating
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet-specified error occurs
- */
- public void doGet(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
-
- // Identify the request parameters that we need
- String command = request.getPathInfo();
-
- String path = request.getParameter("path");
- String deployPath = request.getParameter("deployPath");
- String deployConfig = request.getParameter("deployConfig");
- String deployWar = request.getParameter("deployWar");
-
- // Prepare our output writer to generate the response message
- response.setContentType("text/html; charset=" + Constants.CHARSET);
-
- String message = "";
- // Process the requested command
- if (command == null || command.equals("/")) {
- } else if (command.equals("/deploy")) {
- message = deployInternal(deployConfig, deployPath, deployWar);
- } else if (command.equals("/list")) {
- } else if (command.equals("/reload")) {
- message = reload(path);
- } else if (command.equals("/undeploy")) {
- message = undeploy(path);
- } else if (command.equals("/expire")) {
- message = expireSessions(path, request);
- } else if (command.equals("/sessions")) {
- try {
- doSessions(path, request, response);
- return;
- } catch (Exception e) {
- log("HTMLManagerServlet.sessions[" + path + "]", e);
- message = sm.getString("managerServlet.exception",
- e.toString());
- }
- } else if (command.equals("/start")) {
- message = start(path);
- } else if (command.equals("/stop")) {
- message = stop(path);
- } else {
- message =
- sm.getString("managerServlet.unknownCommand",
- RequestUtil.filter(command));
- }
-
- list(request, response, message);
- }
-
- /**
- * Process a POST request for the specified resource.
- *
- * @param request The servlet request we are processing
- * @param response The servlet response we are creating
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet-specified error occurs
- */
- public void doPost(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
-
- // Identify the request parameters that we need
- String command = request.getPathInfo();
-
- if (command == null || !command.equals("/upload")) {
- doGet(request,response);
- return;
- }
-
- // Prepare our output writer to generate the response message
- response.setContentType("text/html; charset=" + Constants.CHARSET);
-
- String message = "";
-
- Part warPart = null;
- String filename = null;
- String basename = null;
-
- Collection<Part> parts = request.getParts();
- Iterator<Part> iter = parts.iterator();
-
- try {
- while (iter.hasNext()) {
- Part part = iter.next();
- if (part.getName().equals("deployWar") && warPart == null) {
- warPart = part;
- } else {
- part.delete();
- }
- }
-
- while (true) {
- if (warPart == null) {
- message =
- sm.getString("htmlManagerServlet.deployUploadNoFile");
- break;
- }
- filename =
- extractFilename(warPart.getHeader("Content-Disposition"));
- if (!filename.toLowerCase().endsWith(".war")) {
- message = sm.getString(
- "htmlManagerServlet.deployUploadNotWar", filename);
- break;
- }
- // Get the filename if uploaded name includes a path
- if (filename.lastIndexOf('\\') >= 0) {
- filename =
- filename.substring(filename.lastIndexOf('\\') + 1);
- }
- if (filename.lastIndexOf('/') >= 0) {
- filename =
- filename.substring(filename.lastIndexOf('/') + 1);
- }
- // Identify the appBase of the owning Host of this Context
- // (if any)
- basename = filename.substring(0,
- filename.toLowerCase().indexOf(".war"));
- File file = new File(getAppBase(), filename);
- if (file.exists()) {
- message = sm.getString(
- "htmlManagerServlet.deployUploadWarExists",
- filename);
- break;
- }
- String path = null;
- if (basename.equals("ROOT")) {
- path = "";
- } else {
- path = "/" + basename.replace('#', '/');
- }
-
- if ((host.findChild(path) != null) && !isDeployed(path)) {
- message = sm.getString(
- "htmlManagerServlet.deployUploadInServerXml",
- filename);
- break;
- }
-
- if (!isServiced(path)) {
- addServiced(path);
- try {
- warPart.write(file.getAbsolutePath());
- // Perform new deployment
- check(path);
- } finally {
- removeServiced(path);
- }
- }
- break;
- }
- } catch(Exception e) {
- message = sm.getString
- ("htmlManagerServlet.deployUploadFail", e.getMessage());
- log(message, e);
- } finally {
- if (warPart != null) {
- warPart.delete();
- }
- warPart = null;
- }
-
- list(request, response, message);
- }
-
- private String extractFilename(String cd) {
- String fileName = null;
- if (cd != null) {
- String cdl = cd.toLowerCase();
- if (cdl.startsWith("form-data") || cdl.startsWith("attachment")) {
- ParameterParser parser = new ParameterParser();
- parser.setLowerCaseNames(true);
- // Parameter parser can handle null input
- Map<String,String> params =
- parser.parse(cd, ';');
- if (params.containsKey("filename")) {
- fileName = params.get("filename");
- if (fileName != null) {
- fileName = fileName.trim();
- } else {
- // Even if there is no value, the parameter is present,
- // so we return an empty file name rather than no file
- // name.
- fileName = "";
- }
- }
- }
- }
- return fileName;
- }
-
- /**
- * Deploy an application for the specified path from the specified
- * web application archive.
- *
- * @param config URL of the context configuration file to be deployed
- * @param path Context path of the application to be deployed
- * @param war URL of the web application archive to be deployed
- * @return message String
- */
- protected String deployInternal(String config, String path, String war) {
-
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
-
- super.deploy(printWriter, config, path, war, false);
-
- return stringWriter.toString();
- }
-
- /**
- * Render a HTML list of the currently active Contexts in our virtual host,
- * and memory and server status information.
- *
- * @param request The request
- * @param response The response
- * @param message a message to display
- */
- public void list(HttpServletRequest request,
- HttpServletResponse response,
- String message) throws IOException {
-
- if (debug >= 1)
- log("list: Listing contexts for virtual host '" +
- host.getName() + "'");
-
- PrintWriter writer = response.getWriter();
-
- // HTML Header Section
- Object[] args = new Object[1];
- args[0] = request.getContextPath();
- writer.print(MessageFormat.format(Constants.HTML_HEADER_SECTION, args));
-
- // Body Header Section
- args = new Object[2];
- args[0] = request.getContextPath();
- args[1] = sm.getString("htmlManagerServlet.title");
- writer.print(MessageFormat.format(Constants.BODY_HEADER_SECTION, args));
-
- // Manager Section
- args = new Object[9];
- args[0] = sm.getString("htmlManagerServlet.manager");
- args[1] = response.encodeURL(request.getContextPath() + "/html/list");
- args[2] = sm.getString("htmlManagerServlet.list");
- args[3] = response.encodeURL
- (request.getContextPath() + "/" +
- sm.getString("htmlManagerServlet.helpHtmlManagerFile"));
- args[4] = sm.getString("htmlManagerServlet.helpHtmlManager");
- args[5] = response.encodeURL
- (request.getContextPath() + "/" +
- sm.getString("htmlManagerServlet.helpManagerFile"));
- args[6] = sm.getString("htmlManagerServlet.helpManager");
- args[7] = response.encodeURL
- (request.getContextPath() + "/status");
- args[8] = sm.getString("statusServlet.title");
- writer.print(MessageFormat.format(Constants.MANAGER_SECTION, args));
-
- // Message Section
- args = new Object[3];
- args[0] = sm.getString("htmlManagerServlet.messageLabel");
- if (message == null || message.length() == 0) {
- args[1] = "OK";
- } else {
- args[1] = RequestUtil.filter(message);
- }
- writer.print(MessageFormat.format(Constants.MESSAGE_SECTION, args));
-
- // Apps Header Section
- args = new Object[6];
- args[0] = sm.getString("htmlManagerServlet.appsTitle");
- args[1] = sm.getString("htmlManagerServlet.appsPath");
- args[2] = sm.getString("htmlManagerServlet.appsName");
- args[3] = sm.getString("htmlManagerServlet.appsAvailable");
- args[4] = sm.getString("htmlManagerServlet.appsSessions");
- args[5] = sm.getString("htmlManagerServlet.appsTasks");
- writer.print(MessageFormat.format(APPS_HEADER_SECTION, args));
-
- // Apps Row Section
- // Create sorted map of deployed applications context paths.
- Container children[] = host.findChildren();
- String contextPaths[] = new String[children.length];
- for (int i = 0; i < children.length; i++)
- contextPaths[i] = children[i].getName();
-
- TreeMap sortedContextPathsMap = new TreeMap();
-
- for (int i = 0; i < contextPaths.length; i++) {
- String displayPath = contextPaths[i];
- sortedContextPathsMap.put(displayPath, contextPaths[i]);
- }
-
- String appsStart = sm.getString("htmlManagerServlet.appsStart");
- String appsStop = sm.getString("htmlManagerServlet.appsStop");
- String appsReload = sm.getString("htmlManagerServlet.appsReload");
- String appsUndeploy = sm.getString("htmlManagerServlet.appsUndeploy");
- String appsExpire = sm.getString("htmlManagerServlet.appsExpire");
-
- Iterator iterator = sortedContextPathsMap.entrySet().iterator();
- boolean isDeployed = true;
- boolean isHighlighted = false;
- String highlightStyle = null;
-
- while (iterator.hasNext()) {
- // Bugzilla 34818, alternating row colors
- isHighlighted = !isHighlighted;
- if(isHighlighted) {
- highlightStyle = "oddRow";
- } else {
- highlightStyle = "evenRow";
- }
-
- Map.Entry entry = (Map.Entry) iterator.next();
- String displayPath = (String) entry.getKey();
- String contextPath = (String) entry.getValue();
- Context context = (Context) host.findChild(contextPath);
- if (displayPath.equals("")) {
- displayPath = "/";
- }
-
- if (context != null ) {
- try {
- isDeployed = isDeployed(contextPath);
- } catch (Exception e) {
- // Assume false on failure for safety
- isDeployed = false;
- }
-
- args = new Object[7];
- args[0] = URL_ENCODER.encode(displayPath);
- args[1] = displayPath;
- args[2] = context.getDisplayName();
- if (args[2] == null) {
- args[2] = " ";
- }
- args[3] = new Boolean(context.getAvailable());
- args[4] = response.encodeURL
- (request.getContextPath() +
- "/html/sessions?path=" + URL_ENCODER.encode(displayPath));
- if (context.getManager() != null) {
- args[5] = new Integer
- (context.getManager().getActiveSessions());
- } else {
- args[5] = new Integer(0);
- }
-
- args[6] = highlightStyle;
-
- writer.print
- (MessageFormat.format(APPS_ROW_DETAILS_SECTION, args));
-
- args = new Object[14];
- args[0] = response.encodeURL
- (request.getContextPath() +
- "/html/start?path=" + displayPath);
- args[1] = appsStart;
- args[2] = response.encodeURL
- (request.getContextPath() +
- "/html/stop?path=" + displayPath);
- args[3] = appsStop;
- args[4] = response.encodeURL
- (request.getContextPath() +
- "/html/reload?path=" + displayPath);
- args[5] = appsReload;
- args[6] = response.encodeURL
- (request.getContextPath() +
- "/html/undeploy?path=" + displayPath);
- args[7] = appsUndeploy;
-
- args[8] = response.encodeURL
- (request.getContextPath() +
- "/html/expire?path=" + displayPath);
- args[9] = appsExpire;
- args[10] = sm.getString("htmlManagerServlet.expire.explain");
- if (context.getManager() == null) {
- args[11] = sm.getString("htmlManagerServlet.noManager");
- } else {
- args[11] = new Integer(
- context.getManager().getMaxInactiveInterval()/60);
- }
- args[12] = sm.getString("htmlManagerServlet.expire.unit");
-
- args[13] = highlightStyle;
-
- if (context.getPath().equals(this.context.getPath())) {
- writer.print(MessageFormat.format(
- MANAGER_APP_ROW_BUTTON_SECTION, args));
- } else if (context.getAvailable() && isDeployed) {
- writer.print(MessageFormat.format(
- STARTED_DEPLOYED_APPS_ROW_BUTTON_SECTION, args));
- } else if (context.getAvailable() && !isDeployed) {
- writer.print(MessageFormat.format(
- STARTED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION, args));
- } else if (!context.getAvailable() && isDeployed) {
- writer.print(MessageFormat.format(
- STOPPED_DEPLOYED_APPS_ROW_BUTTON_SECTION, args));
- } else {
- writer.print(MessageFormat.format(
- STOPPED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION, args));
- }
-
- }
- }
-
- // Deploy Section
- args = new Object[7];
- args[0] = sm.getString("htmlManagerServlet.deployTitle");
- args[1] = sm.getString("htmlManagerServlet.deployServer");
- args[2] = response.encodeURL(request.getContextPath() + "/html/deploy");
- args[3] = sm.getString("htmlManagerServlet.deployPath");
- args[4] = sm.getString("htmlManagerServlet.deployConfig");
- args[5] = sm.getString("htmlManagerServlet.deployWar");
- args[6] = sm.getString("htmlManagerServlet.deployButton");
- writer.print(MessageFormat.format(DEPLOY_SECTION, args));
-
- args = new Object[4];
- args[0] = sm.getString("htmlManagerServlet.deployUpload");
- args[1] = response.encodeURL(request.getContextPath() + "/html/upload");
- args[2] = sm.getString("htmlManagerServlet.deployUploadFile");
- args[3] = sm.getString("htmlManagerServlet.deployButton");
- writer.print(MessageFormat.format(UPLOAD_SECTION, args));
-
- // Server Header Section
- args = new Object[7];
- args[0] = sm.getString("htmlManagerServlet.serverTitle");
- args[1] = sm.getString("htmlManagerServlet.serverVersion");
- args[2] = sm.getString("htmlManagerServlet.serverJVMVersion");
- args[3] = sm.getString("htmlManagerServlet.serverJVMVendor");
- args[4] = sm.getString("htmlManagerServlet.serverOSName");
- args[5] = sm.getString("htmlManagerServlet.serverOSVersion");
- args[6] = sm.getString("htmlManagerServlet.serverOSArch");
- writer.print(MessageFormat.format
- (Constants.SERVER_HEADER_SECTION, args));
-
- // Server Row Section
- args = new Object[6];
- args[0] = ServerInfo.getServerInfo();
- args[1] = System.getProperty("java.runtime.version");
- args[2] = System.getProperty("java.vm.vendor");
- args[3] = System.getProperty("os.name");
- args[4] = System.getProperty("os.version");
- args[5] = System.getProperty("os.arch");
- writer.print(MessageFormat.format(Constants.SERVER_ROW_SECTION, args));
-
- // HTML Tail Section
- writer.print(Constants.HTML_TAIL_SECTION);
-
- // Finish up the response
- writer.flush();
- writer.close();
- }
-
- /**
- * Reload the web application at the specified context path.
- *
- * @see ManagerServlet#reload(PrintWriter, String)
- *
- * @param path Context path of the application to be restarted
- * @return message String
- */
- protected String reload(String path) {
-
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
-
- super.reload(printWriter, path);
-
- return stringWriter.toString();
- }
-
- /**
- * Undeploy the web application at the specified context path.
- *
- * @see ManagerServlet#undeploy(PrintWriter, String)
- *
- * @param path Context path of the application to be undeployd
- * @return message String
- */
- protected String undeploy(String path) {
-
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
-
- super.undeploy(printWriter, path);
-
- return stringWriter.toString();
- }
-
- /**
- * Display session information and invoke list.
- *
- * @see ManagerServlet#sessions(PrintWriter, String, int)
- *
- * @param path Context path of the application to list session information
- * @param idle Expire all sessions with idle time ≥ idle for this context
- * @return message String
- */
- public String sessions(String path, int idle) {
-
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
-
- super.sessions(printWriter, path, idle);
-
- return stringWriter.toString();
- }
-
- /**
- * Display session information and invoke list.
- *
- * @see ManagerServlet#sessions(PrintWriter, String)
- *
- * @param path Context path of the application to list session information
- * @return message String
- */
- public String sessions(String path) {
-
- return sessions(path, -1);
- }
-
- /**
- * Start the web application at the specified context path.
- *
- * @see ManagerServlet#start(PrintWriter, String)
- *
- * @param path Context path of the application to be started
- * @return message String
- */
- public String start(String path) {
-
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
-
- super.start(printWriter, path);
-
- return stringWriter.toString();
- }
-
- /**
- * Stop the web application at the specified context path.
- *
- * @see ManagerServlet#stop(PrintWriter, String)
- *
- * @param path Context path of the application to be stopped
- * @return message String
- */
- protected String stop(String path) {
-
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
-
- super.stop(printWriter, path);
-
- return stringWriter.toString();
- }
-
- /**
- * @see javax.servlet.Servlet#getServletInfo()
- */
- public String getServletInfo() {
- return "HTMLManagerServlet, Copyright (c) The Apache Software Foundation";
- }
-
- /**
- * @see javax.servlet.GenericServlet#init()
- */
- public void init() throws ServletException {
- super.init();
- }
-
- // ------------------------------------------------ Sessions administration
-
- /**
- *
- * Extract the expiration request parameter
- *
- * @param path
- * @param req
- */
- protected String expireSessions(String path, HttpServletRequest req) {
- int idle = -1;
- String idleParam = req.getParameter("idle");
- if (idleParam != null) {
- try {
- idle = Integer.parseInt(idleParam);
- } catch (NumberFormatException e) {
- log("Could not parse idle parameter to an int: " + idleParam);
- }
- }
- return sessions(path, idle);
- }
-
- /**
- *
- * @param req
- * @param resp
- * @throws ServletException
- * @throws IOException
- */
- protected void doSessions(String path, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- req.setAttribute("path", path);
- String action = req.getParameter("action");
- if (debug >= 1) {
- log("sessions: Session action '" + action + "' for web application at '" + path + "'");
- }
- if ("sessionDetail".equals(action)) {
- String sessionId = req.getParameter("sessionId");
- displaySessionDetailPage(req, resp, path, sessionId);
- return;
- } else if ("invalidateSessions".equals(action)) {
- String[] sessionIds = req.getParameterValues("sessionIds");
- int i = invalidateSessions(path, sessionIds);
- req.setAttribute(APPLICATION_MESSAGE, "" + i + " sessions invalidated.");
- } else if ("removeSessionAttribute".equals(action)) {
- String sessionId = req.getParameter("sessionId");
- String name = req.getParameter("attributeName");
- boolean removed = removeSessionAttribute(path, sessionId, name);
- String outMessage = removed ? "Session attribute '" + name + "' removed." : "Session did not contain any attribute named '" + name + "'";
- req.setAttribute(APPLICATION_MESSAGE, outMessage);
- resp.sendRedirect(resp.encodeRedirectURL(req.getRequestURL().append("?path=").append(path).append("&action=sessionDetail&sessionId=").append(sessionId).toString()));
- return;
- } // else
- displaySessionsListPage(path, req, resp);
- }
-
- protected Session[] getSessionsForPath(String path) {
- if ((path == null) || (!path.startsWith("/") && path.equals(""))) {
- throw new IllegalArgumentException(sm.getString("managerServlet.invalidPath",
- RequestUtil.filter(path)));
- }
- String displayPath = path;
- if( path.equals("/") )
- path = "";
- Context context = (Context) host.findChild(path);
- if (null == context) {
- throw new IllegalArgumentException(sm.getString("managerServlet.noContext",
- RequestUtil.filter(displayPath)));
- }
- Session[] sessions = context.getManager().findSessions();
- return sessions;
- }
- protected Session getSessionForPathAndId(String path, String id) throws IOException {
- if ((path == null) || (!path.startsWith("/") && path.equals(""))) {
- throw new IllegalArgumentException(sm.getString("managerServlet.invalidPath",
- RequestUtil.filter(path)));
- }
- String displayPath = path;
- if( path.equals("/") )
- path = "";
- Context context = (Context) host.findChild(path);
- if (null == context) {
- throw new IllegalArgumentException(sm.getString("managerServlet.noContext",
- RequestUtil.filter(displayPath)));
- }
- Session session = context.getManager().findSession(id);
- return session;
- }
-
- /**
- *
- * @param req
- * @param resp
- * @throws ServletException
- * @throws IOException
- */
- protected void displaySessionsListPage(String path, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- List/*<Session>*/ activeSessions = Arrays.asList(getSessionsForPath(path));
- String sortBy = req.getParameter("sort");
- String orderBy = null;
- if (null != sortBy && !"".equals(sortBy.trim())) {
- Comparator comparator = getComparator(sortBy);
- if (comparator != null) {
- orderBy = req.getParameter("order");
- if ("DESC".equalsIgnoreCase(orderBy)) {
- comparator = new ReverseComparator(comparator);
- // orderBy = "ASC";
- } else {
- //orderBy = "DESC";
- }
- try {
- Collections.sort(activeSessions, comparator);
- } catch (IllegalStateException ise) {
- // at least 1 of the sessions is invalidated
- req.setAttribute(APPLICATION_ERROR, "Can't sort session list: one session is invalidated");
- }
- } else {
- log("WARNING: unknown sort order: " + sortBy);
- }
- }
- // keep sort order
- req.setAttribute("sort", sortBy);
- req.setAttribute("order", orderBy);
- req.setAttribute("activeSessions", activeSessions);
- //strong>NOTE</strong> - This header will be overridden
- // automatically if a <code>RequestDispatcher.forward()</code> call is
- // ultimately invoked.
- resp.setHeader("Pragma", "No-cache"); // HTTP 1.0
- resp.setHeader("Cache-Control", "no-cache,no-store,max-age=0"); // HTTP 1.1
- resp.setDateHeader("Expires", 0); // 0 means now
- getServletContext().getRequestDispatcher(sessionsListJspPath).include(req, resp);
- }
-
- /**
- *
- * @param req
- * @param resp
- * @throws ServletException
- * @throws IOException
- */
- protected void displaySessionDetailPage(HttpServletRequest req, HttpServletResponse resp, String path, String sessionId) throws ServletException, IOException {
- Session session = getSessionForPathAndId(path, sessionId);
- //strong>NOTE</strong> - This header will be overridden
- // automatically if a <code>RequestDispatcher.forward()</code> call is
- // ultimately invoked.
- resp.setHeader("Pragma", "No-cache"); // HTTP 1.0
- resp.setHeader("Cache-Control", "no-cache,no-store,max-age=0"); // HTTP 1.1
- resp.setDateHeader("Expires", 0); // 0 means now
- req.setAttribute("currentSession", session);
- getServletContext().getRequestDispatcher(sessionDetailJspPath).include(req, resp);
- }
-
- /**
- * Invalidate HttpSessions
- * @param sessionIds
- * @return number of invalidated sessions
- * @throws IOException
- */
- public int invalidateSessions(String path, String[] sessionIds) throws IOException {
- if (null == sessionIds) {
- return 0;
- }
- int nbAffectedSessions = 0;
- for (int i = 0; i < sessionIds.length; ++i) {
- String sessionId = sessionIds[i];
- HttpSession session = getSessionForPathAndId(path, sessionId).getSession();
- if (null == session) {
- // Shouldn't happen, but let's play nice...
- if (debug >= 1) {
- log("WARNING: can't invalidate null session " + sessionId);
- }
- continue;
- }
- try {
- session.invalidate();
- ++nbAffectedSessions;
- if (debug >= 1) {
- log("Invalidating session id " + sessionId);
- }
- } catch (IllegalStateException ise) {
- if (debug >= 1) {
- log("Can't invalidate already invalidated session id " + sessionId);
- }
- }
- }
- return nbAffectedSessions;
- }
-
- /**
- * Removes an attribute from an HttpSession
- * @param sessionId
- * @param attributeName
- * @return true if there was an attribute removed, false otherwise
- * @throws IOException
- */
- public boolean removeSessionAttribute(String path, String sessionId, String attributeName) throws IOException {
- HttpSession session = getSessionForPathAndId(path, sessionId).getSession();
- if (null == session) {
- // Shouldn't happen, but let's play nice...
- if (debug >= 1) {
- log("WARNING: can't remove attribute '" + attributeName + "' for null session " + sessionId);
- }
- return false;
- }
- boolean wasPresent = (null != session.getAttribute(attributeName));
- try {
- session.removeAttribute(attributeName);
- } catch (IllegalStateException ise) {
- if (debug >= 1) {
- log("Can't remote attribute '" + attributeName + "' for invalidated session id " + sessionId);
- }
- }
- return wasPresent;
- }
-
- /**
- * Sets the maximum inactive interval (session timeout) an HttpSession
- * @param sessionId
- * @param maxInactiveInterval in seconds
- * @return old value for maxInactiveInterval
- * @throws IOException
- */
- public int setSessionMaxInactiveInterval(String path, String sessionId, int maxInactiveInterval) throws IOException {
- HttpSession session = getSessionForPathAndId(path, sessionId).getSession();
- if (null == session) {
- // Shouldn't happen, but let's play nice...
- if (debug >= 1) {
- log("WARNING: can't set timout for null session " + sessionId);
- }
- return 0;
- }
- try {
- int oldMaxInactiveInterval = session.getMaxInactiveInterval();
- session.setMaxInactiveInterval(maxInactiveInterval);
- return oldMaxInactiveInterval;
- } catch (IllegalStateException ise) {
- if (debug >= 1) {
- log("Can't set MaxInactiveInterval '" + maxInactiveInterval + "' for invalidated session id " + sessionId);
- }
- return 0;
- }
- }
-
- protected Comparator getComparator(String sortBy) {
- Comparator comparator = null;
- if ("CreationTime".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
- return new Date(session.getCreationTime());
- }
- };
- } else if ("id".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
- return session.getId();
- }
- };
- } else if ("LastAccessedTime".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
- return new Date(session.getLastAccessedTime());
- }
- };
- } else if ("MaxInactiveInterval".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
- return new Date(session.getMaxInactiveInterval());
- }
- };
- } else if ("new".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
- return Boolean.valueOf(session.getSession().isNew());
- }
- };
- } else if ("locale".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
- return JspHelper.guessDisplayLocaleFromSession(session);
- }
- };
- } else if ("user".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
- return JspHelper.guessDisplayUserFromSession(session);
- }
- };
- } else if ("UsedTime".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
- return new Date(SessionUtils.getUsedTimeForSession(session));
- }
- };
- } else if ("InactiveTime".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
- return new Date(SessionUtils.getInactiveTimeForSession(session));
- }
- };
- } else if ("TTL".equalsIgnoreCase(sortBy)) {
- comparator = new BaseSessionComparator() {
- public Comparable getComparableObject(Session session) {
- return new Date(SessionUtils.getTTLForSession(session));
- }
- };
- }
- //TODO: complete this to TTL, etc.
- return comparator;
- }
-
- // ------------------------------------------------------ Private Constants
-
- // These HTML sections are broken in relatively small sections, because of
- // limited number of subsitutions MessageFormat can process
- // (maximium of 10).
-
- private static final String APPS_HEADER_SECTION =
- "<table width=\"100%\" cellspacing=\"0\" class=\"tableStyle\" >\n" +
- "<tr>\n" +
- " <th colspan=\"5\">{0}</th>\n" +
- "</tr>\n" +
- "<tbody>\n" +
- " <tr class=\"UnsortableTableHeader\">\n" +
- " <td>{1}</td>\n" +
- " <td>{2}</td>\n" +
- " <td>{3}</td>\n" +
- " <td>{4}</td>\n" +
- " <td>{5}</td>\n" +
- " </tr>\n";
-
- private static final String APPS_ROW_DETAILS_SECTION =
- "<tr class=\"{6}\">\n" +
- " <td class=\"first\" rowspan=\"2\"><a href=\"{0}\">{1}</a></td>\n" +
- " <td rowspan=\"2\">{2}</td>\n" +
- " <td rowspan=\"2\">{3}</td>\n" +
- " <td rowspan=\"2\"><a href=\"{4}\" target=\"_new\">{5}</a></td>\n";
-
- private static final String MANAGER_APP_ROW_BUTTON_SECTION =
- " <td>\n" +
- " {1} \n" +
- " {3} \n" +
- " {5} \n" +
- " {7} \n" +
- " </td>\n" +
- "</tr><tr class=\"{13}\">\n" +
- " <td>\n" +
- " <form method=\"POST\" action=\"{8}\">\n" +
- " <input type=\"submit\" value=\"{9}\" class=\"buttonmed\"> {10} <input type=\"text\" name=\"idle\" size=\"5\" value=\"{11}\"> {12} \n" +
- " </form>\n" +
- " </td>\n" +
- "</tr>\n";
-
- private static final String STARTED_DEPLOYED_APPS_ROW_BUTTON_SECTION =
- " <td>\n" +
- " {1} \n" +
- " <a href=\"{2}\" onclick=\"return(confirm('''Are you sure?'''))\">{3}</a> \n" +
- " <a href=\"{4}\" onclick=\"return(confirm('''Are you sure?'''))\">{5}</a> \n" +
- " <a href=\"{6}\" onclick=\"return(confirm('''Are you sure?'''))\">{7}</a> \n" +
- " </td>\n" +
- " </tr><tr class=\"{13}\">\n" +
- " <td>\n" +
- " <form method=\"POST\" action=\"{8}\">\n" +
- " <input type=\"submit\" value=\"{9}\" class=\"buttonmed\"> {10} <input type=\"text\" name=\"idle\" size=\"5\" value=\"{11}\"> {12} \n" +
- " </form>\n" +
- " </td>\n" +
- "</tr>\n";
-
- private static final String STOPPED_DEPLOYED_APPS_ROW_BUTTON_SECTION =
- " <td rowspan=\"2\">\n" +
- " <a href=\"{0}\" onclick=\"return(confirm('''Are you sure?'''))\">{1}</a> \n" +
- " {3} \n" +
- " {5} \n" +
- " <a href=\"{6}\" onclick=\"return(confirm('''Are you sure? This will delete the application.'''))\">{7}</a> \n" +
- " </td>\n" +
- "</tr>\n<tr class=\"{13}\"></tr>\n";
-
- private static final String STARTED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION =
- " <td rowspan=\"2\">\n" +
- " {1} \n" +
- " <a href=\"{2}\" onclick=\"return(confirm('''Are you sure?'''))\">{3}</a> \n" +
- " <a href=\"{4}\" onclick=\"return(confirm('''Are you sure?'''))\">{5}</a> \n" +
- " {7} \n" +
- " </td>\n" +
- "</tr>\n<tr class=\"{13}\"></tr>\n";
-
- private static final String STOPPED_NONDEPLOYED_APPS_ROW_BUTTON_SECTION =
- " <td rowspan=\"2\">\n" +
- " <a href=\"{0}\" onclick=\"return(confirm('''Are you sure?'''))\">{1}</a> \n" +
- " {3} \n" +
- " {5} \n" +
- " {7} \n" +
- " </td>\n" +
- "</tr>\n<tr class=\"{13}\"></tr>\n";
-
- private static final String DEPLOY_SECTION =
- "</tbody></table>\n" +
- "<table width=\"100%\" cellspacing=\"0\" class=\"tableStyle\">\n" +
- "<tr>\n" +
- " <th colspan=\"2\">{0}</th>\n" +
- "</tr>\n" +
- "<tbody><tr class=\"UnsortableTableHeader\">\n" +
- " <td colspan=\"2\">{1}</td>\n" +
- "</tr>\n" +
- "<tr class=\"oddRow\">\n" +
- " <td colspan=\"2\" class=\"first\">\n" +
- "<form method=\"get\" action=\"{2}\">\n" +
- "<table cellspacing=\"0\" cellpadding=\"3\" style=\"border:0px;\"><tbody>\n" +
- "<tr>\n" +
- " <td style=\"border:0px;\">{3}</td>\n" +
- " <td style=\"border:0px;\"><input type=\"text\" name=\"deployPath\" size=\"20\"></td>\n" +
- "</tr>\n" +
- "<tr>\n" +
- " <td style=\"border:0px;\">{4}</td>\n" +
- " <td style=\"border:0px;\"><input type=\"text\" name=\"deployConfig\" size=\"20\"></td>\n" +
- "</tr>\n" +
- "<tr>\n" +
- " <td style=\"border:0px;\">{5}</td>\n" +
- " <td style=\"border:0px;\"><input type=\"text\" name=\"deployWar\" size=\"40\"></td>\n" +
- "</tr>\n" +
- "<tr>\n" +
- " <td style=\"border:0px;\"> </td>\n" +
- " <td style=\"border:0px;\"><input type=\"submit\" value=\"{6}\" class=\"buttonmed\"></td>\n" +
- "</tr>\n" +
- "</tbody></table>\n" +
- "</form>\n" +
- "</td>\n" +
- "</tr>\n";
-
- private static final String UPLOAD_SECTION =
- "<tr class=\"UnsortableTableHeader\">\n" +
- " <th colspan=\"2\">{0}</th>\n" +
- "</tr>\n" +
- "<tr class=\"evenRow\">\n" +
- " <td colspan=\"2\" class=\"first\">\n" +
- "<form action=\"{1}\" method=\"post\" " +
- "enctype=\"multipart/form-data\">\n" +
- "<table cellspacing=\"0\" cellpadding=\"3\"><tbody>\n" +
- "<tr>\n" +
- " <td style=\"border:0px;\">{2}</td>\n" +
- " <td style=\"border:0px;\"><input type=\"file\" name=\"deployWar\" size=\"40\"></td>\n" +
- "</tr>\n" +
- "<tr>\n" +
- " <td style=\"border:0px;\"> </td>\n" +
- " <td style=\"border:0px;\"><input type=\"submit\" value=\"{3}\" class=\"buttonmed\"></td>\n" +
- "</tr>\n" +
- "</tbody></table>\n" +
- "</form>\n" +
- "</td></tr></tbody></table>\n" +
- "\n";
-
-}
Deleted: trunk/java/org/apache/catalina/manager/JMXProxyServlet.java
===================================================================
--- trunk/java/org/apache/catalina/manager/JMXProxyServlet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/manager/JMXProxyServlet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,233 +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.manager;
-
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.Set;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.MBeanInfo;
-import javax.management.MBeanAttributeInfo;
-import javax.management.Attribute;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.tomcat.util.modeler.Registry;
-
-/**
- * This servlet will dump JMX attributes in a simple format
- * and implement proxy services for modeler.
- *
- * @author Costin Manolache
- */
-public class JMXProxyServlet extends HttpServlet {
- // ----------------------------------------------------- Instance Variables
-
- /**
- * MBean server.
- */
- protected MBeanServer mBeanServer = null;
- protected Registry registry;
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Initialize this servlet.
- */
- public void init() throws ServletException {
- // Retrieve the MBean server
- registry = Registry.getRegistry(null, null);
- mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
- }
-
-
- /**
- * Process a GET request for the specified resource.
- *
- * @param request The servlet request we are processing
- * @param response The servlet response we are creating
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet-specified error occurs
- */
- public void doGet(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException
- {
-
- response.setContentType("text/plain");
-
- PrintWriter writer = response.getWriter();
-
- if( mBeanServer==null ) {
- writer.println("Error - No mbean server");
- return;
- }
-
- String qry=request.getParameter("set");
- if( qry!= null ) {
- String name=request.getParameter("att");
- String val=request.getParameter("val");
-
- setAttribute( writer, qry, name, val );
- return;
- }
- qry=request.getParameter("get");
- if( qry!= null ) {
- String name=request.getParameter("att");
- getAttribute( writer, qry, name );
- return;
- }
- qry=request.getParameter("qry");
- if( qry == null ) {
- qry = "*:*";
- }
-
- listBeans( writer, qry );
-
- }
-
- public void getAttribute(PrintWriter writer, String onameStr, String att) {
- try {
- ObjectName oname = new ObjectName(onameStr);
- Object value = mBeanServer.getAttribute(oname, att);
- writer.println("OK - Attribute get '" + onameStr + "' - " + att
- + "= " + escape(value.toString()));
- } catch (Exception ex) {
- writer.println("Error - " + ex.toString());
- }
- }
-
- public void setAttribute( PrintWriter writer,
- String onameStr, String att, String val )
- {
- try {
- ObjectName oname=new ObjectName( onameStr );
- String type=registry.getType(oname, att);
- Object valueObj=registry.convertValue(type, val );
- mBeanServer.setAttribute( oname, new Attribute(att, valueObj));
- writer.println("OK - Attribute set");
- } catch( Exception ex ) {
- writer.println("Error - " + ex.toString());
- }
- }
-
- public void listBeans( PrintWriter writer, String qry )
- {
-
- Set names = null;
- try {
- names=mBeanServer.queryNames(new ObjectName(qry), null);
- writer.println("OK - Number of results: " + names.size());
- writer.println();
- } catch (Exception e) {
- writer.println("Error - " + e.toString());
- return;
- }
-
- Iterator it=names.iterator();
- while( it.hasNext()) {
- ObjectName oname=(ObjectName)it.next();
- writer.println( "Name: " + oname.toString());
-
- try {
- MBeanInfo minfo=mBeanServer.getMBeanInfo(oname);
- // can't be null - I thinl
- String code=minfo.getClassName();
- if ("org.apache.commons.modeler.BaseModelMBean".equals(code)) {
- code=(String)mBeanServer.getAttribute(oname, "modelerType");
- }
- writer.println("modelerType: " + code);
-
- MBeanAttributeInfo attrs[]=minfo.getAttributes();
- Object value=null;
-
- for( int i=0; i< attrs.length; i++ ) {
- if( ! attrs[i].isReadable() ) continue;
- if( ! isSupported( attrs[i].getType() )) continue;
- String attName=attrs[i].getName();
- if( attName.indexOf( "=") >=0 ||
- attName.indexOf( ":") >=0 ||
- attName.indexOf( " ") >=0 ) {
- continue;
- }
-
- try {
- value=mBeanServer.getAttribute(oname, attName);
- } catch( Throwable t) {
- log("Error getting attribute " + oname +
- " " + attName + " " + t.toString());
- continue;
- }
- if( value==null ) continue;
- if( "modelerType".equals( attName)) continue;
- String valueString=value.toString();
- writer.println( attName + ": " + escape(valueString));
- }
- } catch (Exception e) {
- // Ignore
- }
- writer.println();
- }
-
- }
-
- public String escape(String value) {
- // The only invalid char is \n
- // We also need to keep the string short and split it with \nSPACE
- // XXX TODO
- int idx=value.indexOf( "\n" );
- if( idx < 0 ) return value;
-
- int prev=0;
- StringBuilder sb=new StringBuilder();
- while( idx >= 0 ) {
- appendHead(sb, value, prev, idx);
-
- sb.append( "\\n\n ");
- prev=idx+1;
- if( idx==value.length() -1 ) break;
- idx=value.indexOf('\n', idx+1);
- }
- if( prev < value.length() )
- appendHead( sb, value, prev, value.length());
- return sb.toString();
- }
-
- private void appendHead( StringBuilder sb, String value, int start, int end) {
- if (end < 1) return;
-
- int pos=start;
- while( end-pos > 78 ) {
- sb.append( value.substring(pos, pos+78));
- sb.append( "\n ");
- pos=pos+78;
- }
- sb.append( value.substring(pos,end));
- }
-
- public boolean isSupported( String type ) {
- return true;
- }
-}
Deleted: trunk/java/org/apache/catalina/manager/JspHelper.java
===================================================================
--- trunk/java/org/apache/catalina/manager/JspHelper.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/manager/JspHelper.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,246 +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.manager;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.text.DateFormat;
-import java.text.NumberFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-import org.apache.catalina.Session;
-import org.apache.catalina.manager.util.SessionUtils;
-
-
-/**
- * Helper JavaBean for JSPs, because JSTL 1.1/EL 2.0 is too dumb to
- * to what I need (call methods with parameters), or I am too dumb to use it correctly. :)
- * @author Cédrik LIME
- */
-public class JspHelper {
-
- private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
- private static final String DATE_FORMAT = "yyyy-MM-dd";
- private static final String TIME_FORMAT = "HH:mm:ss";
-
- /**
- * Public constructor, so that this class can be considered a JavaBean
- */
- private JspHelper() {
- super();
- }
-
- /**
- * Try to get user locale from the session, if possible.
- * IMPLEMENTATION NOTE: this method has explicit support for Tapestry 3 and Struts 1.x
- * @param in_session
- * @return String
- */
- public static String guessDisplayLocaleFromSession(Session in_session) {
- return localeToString(SessionUtils.guessLocaleFromSession(in_session));
- }
- private static String localeToString(Locale locale) {
- if (locale != null) {
- return locale.toString();//locale.getDisplayName();
- } else {
- return "";
- }
- }
-
- /**
- * Try to get user name from the session, if possible.
- * @param in_session
- * @return String
- */
- public static String guessDisplayUserFromSession(Session in_session) {
- Object user = SessionUtils.guessUserFromSession(in_session);
- return escapeXml(user);
- }
-
-
- public static String getDisplayCreationTimeForSession(Session in_session) {
- try {
- DateFormat formatter = new SimpleDateFormat(DATE_TIME_FORMAT);
- return formatter.format(new Date(in_session.getCreationTime()));
- } catch (IllegalStateException ise) {
- //ignore: invalidated session
- return "";
- }
- }
-
- public static String getDisplayLastAccessedTimeForSession(Session in_session) {
- try {
- DateFormat formatter = new SimpleDateFormat(DATE_TIME_FORMAT);
- return formatter.format(new Date(in_session.getLastAccessedTime()));
- } catch (IllegalStateException ise) {
- //ignore: invalidated session
- return "";
- }
- }
-
- public static String getDisplayUsedTimeForSession(Session in_session) {
- return secondsToTimeString(SessionUtils.getUsedTimeForSession(in_session)/1000);
- }
-
- public static String getDisplayTTLForSession(Session in_session) {
- return secondsToTimeString(SessionUtils.getTTLForSession(in_session)/1000);
- }
-
- public static String getDisplayInactiveTimeForSession(Session in_session) {
- return secondsToTimeString(SessionUtils.getInactiveTimeForSession(in_session)/1000);
- }
-
- public static String secondsToTimeString(long in_seconds) {
- StringBuilder buff = new StringBuilder(9);
- long rest = in_seconds;
- long hour = rest / 3600;
- rest = rest % 3600;
- long minute = rest / 60;
- rest = rest % 60;
- long second = rest;
- if (hour < 10) {
- buff.append('0');
- }
- buff.append(hour);
- buff.append(':');
- if (minute < 10) {
- buff.append('0');
- }
- buff.append(minute);
- buff.append(':');
- if (second < 10) {
- buff.append('0');
- }
- buff.append(second);
- return buff.toString();
- }
-
-
- /**
- * Following copied from org.apache.taglibs.standard.tag.common.core.OutSupport v1.1.2
- *
- * Optimized to create no extra objects and write directly
- * to the JspWriter using blocks of escaped and unescaped characters
- *
- */
- private static void writeEscapedXml(char[] buffer, int length, Writer w) throws IOException {
- int start = 0;
-
- for (int i = 0; i < length; i++) {
- char c = buffer[i];
- if (c <= HIGHEST_SPECIAL) {
- char[] escaped = specialCharactersRepresentation[c];
- if (escaped != null) {
- // add unescaped portion
- if (start < i) {
- w.write(buffer,start,i-start);
- }
- // add escaped xml
- w.write(escaped);
- start = i + 1;
- }
- }
- }
- // add rest of unescaped portion
- if (start < length) {
- w.write(buffer,start,length-start);
- }
- }
-
-
- /*
- * Following copied from org.apache.taglibs.standard.tag.common.core.Util v1.1.2
- */
-
- private static final int HIGHEST_SPECIAL = '>';
- private static char[][] specialCharactersRepresentation = new char[HIGHEST_SPECIAL + 1][];
- static {
- specialCharactersRepresentation['&'] = "&".toCharArray();
- specialCharactersRepresentation['<'] = "<".toCharArray();
- specialCharactersRepresentation['>'] = ">".toCharArray();
- specialCharactersRepresentation['"'] = """.toCharArray();
- specialCharactersRepresentation['\''] = "'".toCharArray();
- }
-
- public static String escapeXml(Object obj) {
- String value = null;
- try {
- value = (obj == null) ? null : String.valueOf(obj);
- } catch (Exception e) {
- // Ignore
- }
- return escapeXml(value);
- }
-
- /**
- * Performs the following substring replacements
- * (to facilitate output to XML/HTML pages):
- *
- * & -> &
- * < -> <
- * > -> >
- * " -> "
- * ' -> '
- *
- * See also OutSupport.writeEscapedXml().
- */
- public static String escapeXml(String buffer) {
- if (buffer == null) {
- return "";
- }
- int start = 0;
- int length = buffer.length();
- char[] arrayBuffer = buffer.toCharArray();
- StringBuilder escapedBuffer = null;
-
- for (int i = 0; i < length; i++) {
- char c = arrayBuffer[i];
- if (c <= HIGHEST_SPECIAL) {
- char[] escaped = specialCharactersRepresentation[c];
- if (escaped != null) {
- // create StringBuilder to hold escaped xml string
- if (start == 0) {
- escapedBuffer = new StringBuilder(length + 5);
- }
- // add unescaped portion
- if (start < i) {
- escapedBuffer.append(arrayBuffer,start,i-start);
- }
- start = i + 1;
- // add escaped xml
- escapedBuffer.append(escaped);
- }
- }
- }
- // no xml escaping was necessary
- if (start == 0) {
- return buffer;
- }
- // add rest of unescaped portion
- if (start < length) {
- escapedBuffer.append(arrayBuffer,start,length-start);
- }
- return escapedBuffer.toString();
- }
-
- public static String formatNumber(long number) {
- return NumberFormat.getNumberInstance().format(number);
- }
-}
Deleted: trunk/java/org/apache/catalina/manager/ManagerServlet.java
===================================================================
--- trunk/java/org/apache/catalina/manager/ManagerServlet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/manager/ManagerServlet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,1621 +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.manager;
-
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.naming.Binding;
-import javax.naming.NamingEnumeration;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletInputStream;
-import javax.servlet.UnavailableException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.ContainerServlet;
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Globals;
-import org.apache.catalina.Host;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.Manager;
-import org.apache.catalina.Server;
-import org.apache.catalina.Session;
-import org.apache.catalina.Wrapper;
-import org.apache.catalina.core.StandardServer;
-import org.apache.catalina.util.RequestUtil;
-import org.apache.catalina.util.ServerInfo;
-import org.apache.catalina.util.StringManager;
-import org.apache.tomcat.util.modeler.Registry;
-
-
-/**
- * Servlet that enables remote management of the web applications installed
- * within the same virtual host as this web application is. Normally, this
- * functionality will be protected by a security constraint in the web
- * application deployment descriptor. However, this requirement can be
- * relaxed during testing.
- * <p>
- * This servlet examines the value returned by <code>getPathInfo()</code>
- * and related query parameters to determine what action is being requested.
- * The following actions and parameters (starting after the servlet path)
- * are supported:
- * <ul>
- * <li><b>/deploy?config={config-url}</b> - Install and start a new
- * web application, based on the contents of the context configuration
- * file found at the specified URL. The <code>docBase</code> attribute
- * of the context configuration file is used to locate the actual
- * WAR or directory containing the application.</li>
- * <li><b>/deploy?config={config-url}&war={war-url}/</b> - Install and start
- * a new web application, based on the contents of the context
- * configuration file found at <code>{config-url}</code>, overriding the
- * <code>docBase</code> attribute with the contents of the web
- * application archive found at <code>{war-url}</code>.</li>
- * <li><b>/deploy?path=/xxx&war={war-url}</b> - Install and start a new
- * web application attached to context path <code>/xxx</code>, based
- * on the contents of the web application archive found at the
- * specified URL.</li>
- * <li><b>/list</b> - List the context paths of all currently installed web
- * applications for this virtual host. Each context will be listed with
- * the following format <code>path:status:sessions</code>.
- * Where path is the context path. Status is either running or stopped.
- * Sessions is the number of active Sessions.</li>
- * <li><b>/reload?path=/xxx</b> - Reload the Java classes and resources for
- * the application at the specified path.</li>
- * <li><b>/resources?type=xxxx</b> - Enumerate the available global JNDI
- * resources, optionally limited to those of the specified type
- * (fully qualified Java class name), if available.</li>
- * <li><b>/roles</b> - Enumerate the available security role names and
- * descriptions from the user database connected to the <code>users</code>
- * resource reference.
- * <li><b>/serverinfo</b> - Display system OS and JVM properties.
- * <li><b>/expire?path=/xxx</b> - List session idle timeinformation about the
- * web application attached to context path <code>/xxx</code> for this
- * virtual host.</li>
- * <li><b>/expire?path=/xxx&idle=mm</b> - Expire sessions
- * for the context path <code>/xxx</code> which were idle for at
- * least mm minutes.</li>
- * <li><b>/start?path=/xxx</b> - Start the web application attached to
- * context path <code>/xxx</code> for this virtual host.</li>
- * <li><b>/stop?path=/xxx</b> - Stop the web application attached to
- * context path <code>/xxx</code> for this virtual host.</li>
- * <li><b>/undeploy?path=/xxx</b> - Shutdown and remove the web application
- * attached to context path <code>/xxx</code> for this virtual host,
- * and remove the underlying WAR file or document base directory.
- * (<em>NOTE</em> - This is only allowed if the WAR file or document
- * base is stored in the <code>appBase</code> directory of this host,
- * typically as a result of being placed there via the <code>/deploy</code>
- * command.</li>
- * </ul>
- * <p>Use <code>path=/</code> for the ROOT context.</p>
- * <p>The syntax of the URL for a web application archive must conform to one
- * of the following patterns to be successfully deployed:</p>
- * <ul>
- * <li><b>file:/absolute/path/to/a/directory</b> - You can specify the absolute
- * path of a directory that contains the unpacked version of a web
- * application. This directory will be attached to the context path you
- * specify without any changes.</li>
- * <li><b>jar:file:/absolute/path/to/a/warfile.war!/</b> - You can specify a
- * URL to a local web application archive file. The syntax must conform to
- * the rules specified by the <code>JarURLConnection</code> class for a
- * reference to an entire JAR file.</li>
- * <li><b>jar:http://hostname:port/path/to/a/warfile.war!/</b> - You can specify
- * a URL to a remote (HTTP-accessible) web application archive file. The
- * syntax must conform to the rules specified by the
- * <code>JarURLConnection</code> class for a reference to an entire
- * JAR file.</li>
- * </ul>
- * <p>
- * <b>NOTE</b> - Attempting to reload or remove the application containing
- * this servlet itself will not succeed. Therefore, this servlet should
- * generally be deployed as a separate web application within the virtual host
- * to be managed.
- * <p>
- * <b>NOTE</b> - For security reasons, this application will not operate
- * when accessed via the invoker servlet. You must explicitly map this servlet
- * with a servlet mapping, and you will always want to protect it with
- * appropriate security constraints as well.
- * <p>
- * The following servlet initialization parameters are recognized:
- * <ul>
- * <li><b>debug</b> - The debugging detail level that controls the amount
- * of information that is logged by this servlet. Default is zero.
- * </ul>
- *
- * @author Craig R. McClanahan
- * @author Remy Maucherat
- * @version $Revision$ $Date$
- */
-
-public class ManagerServlet
- extends HttpServlet implements ContainerServlet {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * Path where context descriptors should be deployed.
- */
- protected File configBase = null;
-
-
- /**
- * The Context container associated with our web application.
- */
- protected Context context = null;
-
-
- /**
- * The debugging detail level for this servlet.
- */
- protected int debug = 1;
-
-
- /**
- * File object representing the directory into which the deploy() command
- * will store the WAR and context configuration files that have been
- * uploaded.
- */
- protected File deployed = null;
-
-
- /**
- * Path used to store revisions of webapps.
- */
- protected File versioned = null;
-
-
- /**
- * Path used to store context descriptors.
- */
- protected File contextDescriptors = null;
-
-
- /**
- * The associated host.
- */
- protected Host host = null;
-
-
- /**
- * The host appBase.
- */
- protected File appBase = null;
-
-
- /**
- * MBean server.
- */
- protected MBeanServer mBeanServer = null;
-
-
- /**
- * The associated deployer ObjectName.
- */
- protected ObjectName oname = null;
-
-
- /**
- * The global JNDI <code>NamingContext</code> for this server,
- * if available.
- */
- protected javax.naming.Context global = null;
-
-
- /**
- * The string manager for this package.
- */
- protected static StringManager sm =
- StringManager.getManager(Constants.Package);
-
-
- /**
- * The Wrapper container associated with this servlet.
- */
- protected Wrapper wrapper = null;
-
-
- // ----------------------------------------------- ContainerServlet Methods
-
-
- /**
- * Return the Wrapper with which we are associated.
- */
- public Wrapper getWrapper() {
-
- return (this.wrapper);
-
- }
-
-
- /**
- * Set the Wrapper with which we are associated.
- *
- * @param wrapper The new wrapper
- */
- public void setWrapper(Wrapper wrapper) {
-
- this.wrapper = wrapper;
- if (wrapper == null) {
- context = null;
- host = null;
- oname = null;
- } else {
- context = (Context) wrapper.getParent();
- host = (Host) context.getParent();
- Engine engine = (Engine) host.getParent();
- try {
- oname = new ObjectName(engine.getName()
- + ":type=Deployer,host=" + host.getName());
- } catch (Exception e) {
- // ?
- }
- }
-
- // Retrieve the MBean server
- mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
-
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Finalize this servlet.
- */
- public void destroy() {
-
- ; // No actions necessary
-
- }
-
-
- /**
- * Process a GET request for the specified resource.
- *
- * @param request The servlet request we are processing
- * @param response The servlet response we are creating
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet-specified error occurs
- */
- public void doGet(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
-
- // Verify that we were not accessed using the invoker servlet
- if (request.getAttribute(Globals.INVOKED_ATTR) != null)
- throw new UnavailableException
- (sm.getString("managerServlet.cannotInvoke"));
-
- // Identify the request parameters that we need
- String command = request.getPathInfo();
- if (command == null)
- command = request.getServletPath();
- String config = request.getParameter("config");
- String path = request.getParameter("path");
- String type = request.getParameter("type");
- String war = request.getParameter("war");
- String tag = request.getParameter("tag");
- boolean update = false;
- if ((request.getParameter("update") != null)
- && (request.getParameter("update").equals("true"))) {
- update = true;
- }
-
- // Prepare our output writer to generate the response message
- response.setContentType("text/plain; charset=" + Constants.CHARSET);
- PrintWriter writer = response.getWriter();
-
- // Process the requested command (note - "/deploy" is not listed here)
- if (command == null) {
- writer.println(sm.getString("managerServlet.noCommand"));
- } else if (command.equals("/deploy")) {
- if (war != null || config != null) {
- deploy(writer, config, path, war, update);
- } else {
- deploy(writer, path, tag);
- }
- } else if (command.equals("/install")) {
- // Deprecated
- deploy(writer, config, path, war, false);
- } else if (command.equals("/list")) {
- list(writer);
- } else if (command.equals("/reload")) {
- reload(writer, path);
- } else if (command.equals("/remove")) {
- // Deprecated
- undeploy(writer, path);
- } else if (command.equals("/resources")) {
- resources(writer, type);
- } else if (command.equals("/save")) {
- save(writer, path);
- } else if (command.equals("/serverinfo")) {
- serverinfo(writer);
- } else if (command.equals("/expire")) {
- expireSessions(writer, path, request);
- } else if (command.equals("/sessions")) {
- expireSessions(writer, path, request);
- } else if (command.equals("/start")) {
- start(writer, path);
- } else if (command.equals("/stop")) {
- stop(writer, path);
- } else if (command.equals("/undeploy")) {
- undeploy(writer, path);
- } else {
- writer.println(sm.getString("managerServlet.unknownCommand",
- command));
- }
-
- // Finish up the response
- writer.flush();
- writer.close();
-
- }
-
-
- /**
- * Process a PUT request for the specified resource.
- *
- * @param request The servlet request we are processing
- * @param response The servlet response we are creating
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet-specified error occurs
- */
- public void doPut(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
-
- // Verify that we were not accessed using the invoker servlet
- if (request.getAttribute(Globals.INVOKED_ATTR) != null)
- throw new UnavailableException
- (sm.getString("managerServlet.cannotInvoke"));
-
- // Identify the request parameters that we need
- String command = request.getPathInfo();
- if (command == null)
- command = request.getServletPath();
- String path = request.getParameter("path");
- String tag = request.getParameter("tag");
- boolean update = false;
- if ((request.getParameter("update") != null)
- && (request.getParameter("update").equals("true"))) {
- update = true;
- }
-
- // Prepare our output writer to generate the response message
- response.setContentType("text/plain;charset="+Constants.CHARSET);
- PrintWriter writer = response.getWriter();
-
- // Process the requested command
- if (command == null) {
- writer.println(sm.getString("managerServlet.noCommand"));
- } else if (command.equals("/deploy")) {
- deploy(writer, path, tag, update, request);
- } else {
- writer.println(sm.getString("managerServlet.unknownCommand",
- command));
- }
-
- // Finish up the response
- writer.flush();
- writer.close();
-
- }
-
-
- /**
- * Initialize this servlet.
- */
- public void init() throws ServletException {
-
- // Ensure that our ContainerServlet properties have been set
- if ((wrapper == null) || (context == null))
- throw new UnavailableException
- (sm.getString("managerServlet.noWrapper"));
-
- // Verify that we were not accessed using the invoker servlet
- String servletName = getServletConfig().getServletName();
- if (servletName == null)
- servletName = "";
- if (servletName.startsWith("org.apache.catalina.INVOKER."))
- throw new UnavailableException
- (sm.getString("managerServlet.cannotInvoke"));
-
- // Set our properties from the initialization parameters
- String value = null;
- try {
- value = getServletConfig().getInitParameter("debug");
- debug = Integer.parseInt(value);
- } catch (Throwable t) {
- ;
- }
-
- // Acquire global JNDI resources if available
- Server server = ((Engine) host.getParent()).getService().getServer();
- if ((server != null) && (server instanceof StandardServer)) {
- global = ((StandardServer) server).getGlobalNamingContext();
- }
-
- // Calculate the directory into which we will be deploying applications
- versioned = (File) getServletContext().getAttribute(ServletContext.TEMPDIR);
-
- // Identify the appBase of the owning Host of this Context
- // (if any)
- String appBase = ((Host) context.getParent()).getAppBase();
- deployed = new File(appBase);
- if (!deployed.isAbsolute()) {
- deployed = new File(System.getProperty("catalina.base"),
- appBase);
- }
- configBase = new File(System.getProperty("catalina.base"), "conf");
- Container container = context;
- Container host = null;
- Container engine = null;
- while (container != null) {
- if (container instanceof Host)
- host = container;
- if (container instanceof Engine)
- engine = container;
- container = container.getParent();
- }
- if (engine != null) {
- configBase = new File(configBase, engine.getName());
- }
- if (host != null) {
- configBase = new File(configBase, host.getName());
- }
- // Note: The directory must exist for this to work.
-
- // Log debugging messages as necessary
- if (debug >= 1) {
- log("init: Associated with Deployer '" +
- oname + "'");
- if (global != null) {
- log("init: Global resources are available");
- }
- }
-
- }
-
-
-
- // -------------------------------------------------------- Private Methods
-
-
- /**
- * Store server configuration.
- *
- * @param path Optional context path to save
- */
- protected synchronized void save(PrintWriter writer, String path) {
-
- Server server = ((Engine) host.getParent()).getService().getServer();
-
- if (!(server instanceof StandardServer)) {
- writer.println(sm.getString("managerServlet.saveFail", server));
- return;
- }
-
- if ((path == null) || path.length() == 0 || !path.startsWith("/")) {
- try {
- ((StandardServer) server).storeConfig();
- writer.println(sm.getString("managerServlet.saved"));
- } catch (Exception e) {
- log("managerServlet.storeConfig", e);
- writer.println(sm.getString("managerServlet.exception",
- e.toString()));
- return;
- }
- } else {
- String contextPath = path;
- if (path.equals("/")) {
- contextPath = "";
- }
- Context context = (Context) host.findChild(contextPath);
- if (context == null) {
- writer.println(sm.getString("managerServlet.noContext", path));
- return;
- }
- try {
- ((StandardServer) server).storeContext(context);
- writer.println(sm.getString("managerServlet.savedContext",
- path));
- } catch (Exception e) {
- log("managerServlet.save[" + path + "]", e);
- writer.println(sm.getString("managerServlet.exception",
- e.toString()));
- return;
- }
- }
-
- }
-
-
- /**
- * Deploy a web application archive (included in the current request)
- * at the specified context path.
- *
- * @param writer Writer to render results to
- * @param path Context path of the application to be installed
- * @param tag Tag to be associated with the webapp
- * @param request Servlet request we are processing
- */
- protected synchronized void deploy
- (PrintWriter writer, String path,
- String tag, boolean update, HttpServletRequest request) {
-
- if (debug >= 1) {
- log("deploy: Deploying web application at '" + path + "'");
- }
-
- // Validate the requested context path
- if ((path == null) || path.length() == 0 || !path.startsWith("/")) {
- writer.println(sm.getString("managerServlet.invalidPath", path));
- return;
- }
- String displayPath = path;
- if( path.equals("/") )
- path = "";
- String basename = getDocBase(path);
-
- // Check if app already exists, or undeploy it if updating
- Context context = (Context) host.findChild(path);
- if (update) {
- if (context != null) {
- undeploy(writer, displayPath);
- }
- context = (Context) host.findChild(path);
- }
- if (context != null) {
- writer.println
- (sm.getString("managerServlet.alreadyContext",
- displayPath));
- return;
- }
-
- // Calculate the base path
- File deployedPath = deployed;
- if (tag != null) {
- deployedPath = new File(versioned, tag);
- deployedPath.mkdirs();
- }
-
- // Upload the web application archive to a local WAR file
- File localWar = new File(deployedPath, basename + ".war");
- if (debug >= 2) {
- log("Uploading WAR file to " + localWar);
- }
-
- // Copy WAR to appBase
- try {
- if (!isServiced(path)) {
- addServiced(path);
- try {
- // Upload WAR
- uploadWar(request, localWar);
- // Copy WAR and XML to the host app base if needed
- if (tag != null) {
- deployedPath = deployed;
- File localWarCopy = new File(deployedPath, basename + ".war");
- copy(localWar, localWarCopy);
- localWar = localWarCopy;
- copy(localWar, new File(getAppBase(), basename + ".war"));
- }
- // Perform new deployment
- check(path);
- } finally {
- removeServiced(path);
- }
- }
- } catch (Exception e) {
- log("managerServlet.check[" + displayPath + "]", e);
- writer.println(sm.getString("managerServlet.exception",
- e.toString()));
- return;
- }
-
- context = (Context) host.findChild(path);
- if (context != null && context.getConfigured()) {
- writer.println(sm.getString("managerServlet.deployed", displayPath));
- } else {
- // Something failed
- writer.println(sm.getString("managerServlet.deployFailed", displayPath));
- }
-
- }
-
-
- /**
- * Install an application for the specified path from the specified
- * web application archive.
- *
- * @param writer Writer to render results to
- * @param tag Revision tag to deploy from
- * @param path Context path of the application to be installed
- */
- protected void deploy(PrintWriter writer, String path, String tag) {
-
- // Validate the requested context path
- if ((path == null) || path.length() == 0 || !path.startsWith("/")) {
- writer.println(sm.getString("managerServlet.invalidPath", path));
- return;
- }
- String displayPath = path;
- if( path.equals("/") )
- path = "";
-
- // Calculate the base path
- File deployedPath = versioned;
- if (tag != null) {
- deployedPath = new File(deployedPath, tag);
- }
-
- // Find the local WAR file
- File localWar = new File(deployedPath, getDocBase(path) + ".war");
- // Find the local context deployment file (if any)
- File localXml = new File(configBase, getConfigFile(path) + ".xml");
-
- // Check if app already exists, or undeploy it if updating
- Context context = (Context) host.findChild(path);
- if (context != null) {
- undeploy(writer, displayPath);
- }
-
- // Copy WAR to appBase
- try {
- if (!isServiced(path)) {
- addServiced(path);
- try {
- copy(localWar, new File(getAppBase(), getDocBase(path) + ".war"));
- // Perform new deployment
- check(path);
- } finally {
- removeServiced(path);
- }
- }
- } catch (Exception e) {
- log("managerServlet.check[" + displayPath + "]", e);
- writer.println(sm.getString("managerServlet.exception",
- e.toString()));
- return;
- }
-
- context = (Context) host.findChild(path);
- if (context != null && context.getConfigured()) {
- writer.println(sm.getString("managerServlet.deployed", displayPath));
- } else {
- // Something failed
- writer.println(sm.getString("managerServlet.deployFailed", displayPath));
- }
-
- }
-
-
- /**
- * Install an application for the specified path from the specified
- * web application archive.
- *
- * @param writer Writer to render results to
- * @param config URL of the context configuration file to be installed
- * @param path Context path of the application to be installed
- * @param war URL of the web application archive to be installed
- * @param update true to override any existing webapp on the path
- */
- protected void deploy(PrintWriter writer, String config,
- String path, String war, boolean update) {
-
- if (config != null && config.length() == 0) {
- config = null;
- }
- if (war != null && war.length() == 0) {
- war = null;
- }
-
- if (debug >= 1) {
- if (config != null && config.length() > 0) {
- if (war != null) {
- log("install: Installing context configuration at '" +
- config + "' from '" + war + "'");
- } else {
- log("install: Installing context configuration at '" +
- config + "'");
- }
- } else {
- if (path != null && path.length() > 0) {
- log("install: Installing web application at '" + path +
- "' from '" + war + "'");
- } else {
- log("install: Installing web application from '" + war + "'");
- }
- }
- }
-
- if (path == null || path.length() == 0 || !path.startsWith("/")) {
- writer.println(sm.getString("managerServlet.invalidPath",
- RequestUtil.filter(path)));
- return;
- }
- String displayPath = path;
- if("/".equals(path)) {
- path = "";
- }
-
- // Check if app already exists, or undeploy it if updating
- Context context = (Context) host.findChild(path);
- if (update) {
- if (context != null) {
- undeploy(writer, displayPath);
- }
- context = (Context) host.findChild(path);
- }
- if (context != null) {
- writer.println
- (sm.getString("managerServlet.alreadyContext",
- displayPath));
- return;
- }
-
- if (config != null && (config.startsWith("file:"))) {
- config = config.substring("file:".length());
- }
- if (war != null && (war.startsWith("file:"))) {
- war = war.substring("file:".length());
- }
-
- try {
- if (!isServiced(path)) {
- addServiced(path);
- try {
- if (config != null) {
- configBase.mkdirs();
- copy(new File(config),
- new File(configBase, getConfigFile(path) + ".xml"));
- }
- if (war != null) {
- if (war.endsWith(".war")) {
- copy(new File(war),
- new File(getAppBase(), getDocBase(path) + ".war"));
- } else {
- copy(new File(war),
- new File(getAppBase(), getDocBase(path)));
- }
- }
- // Perform new deployment
- check(path);
- } finally {
- removeServiced(path);
- }
- }
- context = (Context) host.findChild(path);
- if (context != null && context.getConfigured() && context.getAvailable()) {
- writer.println(sm.getString("managerServlet.deployed", displayPath));
- } else if (context!=null && !context.getAvailable()) {
- writer.println(sm.getString("managerServlet.deployedButNotStarted", displayPath));
- } else {
- // Something failed
- writer.println(sm.getString("managerServlet.deployFailed", displayPath));
- }
- } catch (Throwable t) {
- log("ManagerServlet.install[" + displayPath + "]", t);
- writer.println(sm.getString("managerServlet.exception",
- t.toString()));
- }
-
- }
-
-
- /**
- * Render a list of the currently active Contexts in our virtual host.
- *
- * @param writer Writer to render to
- */
- protected void list(PrintWriter writer) {
-
- if (debug >= 1)
- log("list: Listing contexts for virtual host '" +
- host.getName() + "'");
-
- writer.println(sm.getString("managerServlet.listed",
- host.getName()));
- Container[] contexts = host.findChildren();
- for (int i = 0; i < contexts.length; i++) {
- Context context = (Context) contexts[i];
- if (context != null ) {
- String displayPath = context.getPath();
- if( displayPath.equals("") )
- displayPath = "/";
- if (context.getAvailable()) {
- writer.println(sm.getString("managerServlet.listitem",
- displayPath,
- "running",
- "" + context.getManager().findSessions().length,
- context.getDocBase()));
- } else {
- writer.println(sm.getString("managerServlet.listitem",
- displayPath,
- "stopped",
- "0",
- context.getDocBase()));
- }
- }
- }
- }
-
-
- /**
- * Reload the web application at the specified context path.
- *
- * @param writer Writer to render to
- * @param path Context path of the application to be restarted
- */
- protected void reload(PrintWriter writer, String path) {
-
- if (debug >= 1)
- log("restart: Reloading web application at '" + path + "'");
-
- if ((path == null) || (!path.startsWith("/") && path.equals(""))) {
- writer.println(sm.getString("managerServlet.invalidPath",
- RequestUtil.filter(path)));
- return;
- }
- String displayPath = path;
- if( path.equals("/") )
- path = "";
-
- try {
- Context context = (Context) host.findChild(path);
- if (context == null) {
- writer.println(sm.getString
- ("managerServlet.noContext",
- RequestUtil.filter(displayPath)));
- return;
- }
- // It isn't possible for the manager to reload itself
- if (context.getPath().equals(this.context.getPath())) {
- writer.println(sm.getString("managerServlet.noSelf"));
- return;
- }
- context.reload();
- writer.println
- (sm.getString("managerServlet.reloaded", displayPath));
- } catch (Throwable t) {
- log("ManagerServlet.reload[" + displayPath + "]", t);
- writer.println(sm.getString("managerServlet.exception",
- t.toString()));
- }
-
- }
-
-
- /**
- * Render a list of available global JNDI resources.
- *
- * @param type Fully qualified class name of the resource type of interest,
- * or <code>null</code> to list resources of all types
- */
- protected void resources(PrintWriter writer, String type) {
-
- if (debug >= 1) {
- if (type != null) {
- log("resources: Listing resources of type " + type);
- } else {
- log("resources: Listing resources of all types");
- }
- }
-
- // Is the global JNDI resources context available?
- if (global == null) {
- writer.println(sm.getString("managerServlet.noGlobal"));
- return;
- }
-
- // Enumerate the global JNDI resources of the requested type
- if (type != null) {
- writer.println(sm.getString("managerServlet.resourcesType",
- type));
- } else {
- writer.println(sm.getString("managerServlet.resourcesAll"));
- }
-
- Class clazz = null;
- try {
- if (type != null) {
- clazz = Class.forName(type);
- }
- } catch (Throwable t) {
- log("ManagerServlet.resources[" + type + "]", t);
- writer.println(sm.getString("managerServlet.exception",
- t.toString()));
- return;
- }
-
- printResources(writer, "", global, type, clazz);
-
- }
-
-
- /**
- * List the resources of the given context.
- */
- protected void printResources(PrintWriter writer, String prefix,
- javax.naming.Context namingContext,
- String type, Class clazz) {
-
- try {
- NamingEnumeration items = namingContext.listBindings("");
- while (items.hasMore()) {
- Binding item = (Binding) items.next();
- if (item.getObject() instanceof javax.naming.Context) {
- printResources
- (writer, prefix + item.getName() + "/",
- (javax.naming.Context) item.getObject(), type, clazz);
- } else {
- if ((clazz != null) &&
- (!(clazz.isInstance(item.getObject())))) {
- continue;
- }
- writer.print(prefix + item.getName());
- writer.print(':');
- writer.print(item.getClassName());
- // Do we want a description if available?
- writer.println();
- }
- }
- } catch (Throwable t) {
- log("ManagerServlet.resources[" + type + "]", t);
- writer.println(sm.getString("managerServlet.exception",
- t.toString()));
- }
-
- }
-
-
- /**
- * Writes System OS and JVM properties.
- * @param writer Writer to render to
- */
- protected void serverinfo(PrintWriter writer) {
- if (debug >= 1)
- log("serverinfo");
- try {
- StringBuilder props = new StringBuilder();
- props.append("OK - Server info");
- props.append("\nTomcat Version: ");
- props.append(ServerInfo.getServerInfo());
- props.append("\nOS Name: ");
- props.append(System.getProperty("os.name"));
- props.append("\nOS Version: ");
- props.append(System.getProperty("os.version"));
- props.append("\nOS Architecture: ");
- props.append(System.getProperty("os.arch"));
- props.append("\nJVM Version: ");
- props.append(System.getProperty("java.runtime.version"));
- props.append("\nJVM Vendor: ");
- props.append(System.getProperty("java.vm.vendor"));
- writer.println(props.toString());
- } catch (Throwable t) {
- getServletContext().log("ManagerServlet.serverinfo",t);
- writer.println(sm.getString("managerServlet.exception",
- t.toString()));
- }
- }
-
- /**
- * Session information for the web application at the specified context path.
- * Displays a profile of session lastAccessedTime listing number
- * of sessions for each 10 minute interval up to 10 hours.
- *
- * @param writer Writer to render to
- * @param path Context path of the application to list session information for
- * @param idle Expire all sessions with idle time ≥ idle for this context
- */
- protected void sessions(PrintWriter writer, String path, int idle) {
-
- if (debug >= 1) {
- log("sessions: Session information for web application at '" + path + "'");
- if (idle >= 0)
- log("sessions: Session expiration for " + idle + " minutes '" + path + "'");
- }
-
- if ((path == null) || (!path.startsWith("/") && path.equals(""))) {
- writer.println(sm.getString("managerServlet.invalidPath",
- RequestUtil.filter(path)));
- return;
- }
- String displayPath = path;
- if( path.equals("/") )
- path = "";
- try {
- Context context = (Context) host.findChild(path);
- if (context == null) {
- writer.println(sm.getString("managerServlet.noContext",
- RequestUtil.filter(displayPath)));
- return;
- }
- Manager manager = context.getManager() ;
- if (manager == null) {
- writer.println(sm.getString("managerServlet.noManager",
- RequestUtil.filter(displayPath)));
- return;
- }
- int maxCount = 60;
- int maxInactiveInterval = manager.getMaxInactiveInterval()/60;
- int histoInterval = maxInactiveInterval / maxCount;
- if ( histoInterval * maxCount < maxInactiveInterval )
- histoInterval++;
- if (histoInterval == 0)
- histoInterval = 1;
- maxCount = maxInactiveInterval / histoInterval;
- if ( histoInterval * maxCount < maxInactiveInterval )
- maxCount++;
-
- writer.println(sm.getString("managerServlet.sessions", displayPath));
- writer.println(sm.getString("managerServlet.sessiondefaultmax",
- "" + maxInactiveInterval));
- Session [] sessions = manager.findSessions();
- int [] timeout = new int[maxCount];
- int notimeout = 0;
- int expired = 0;
- long now = System.currentTimeMillis();
- for (int i = 0; i < sessions.length; i++) {
- int time = (int)((now-sessions[i].getLastAccessedTimeInternal())/1000);
- if (idle >= 0 && time >= idle*60) {
- sessions[i].expire();
- idle++;
- }
- time=time/60/histoInterval;
- if (time < 0)
- notimeout++;
- else if (time >= maxCount)
- timeout[maxCount-1]++;
- else
- timeout[time]++;
- }
- if (timeout[0] > 0)
- writer.println(sm.getString("managerServlet.sessiontimeout",
- "<" + histoInterval, "" + timeout[0]));
- for (int i = 1; i < maxCount-1; i++) {
- if (timeout[i] > 0)
- writer.println(sm.getString("managerServlet.sessiontimeout",
- "" + (i)*histoInterval + " - <" + (i+1)*histoInterval,
- "" + timeout[i]));
- }
- if (timeout[maxCount-1] > 0)
- writer.println(sm.getString("managerServlet.sessiontimeout",
- ">=" + maxCount*histoInterval,
- "" + timeout[maxCount-1]));
- if (notimeout > 0)
- writer.println(sm.getString("managerServlet.sessiontimeout",
- "unlimited","" + notimeout));
- if (idle >= 0)
- writer.println(sm.getString("managerServlet.sessiontimeout",
- "" + idle,"expired " + expired));
- } catch (Throwable t) {
- log("ManagerServlet.sessions[" + displayPath + "]", t);
- writer.println(sm.getString("managerServlet.exception",
- t.toString()));
- }
-
- }
-
-
- /**
- * Session information for the web application at the specified context path.
- * Displays a profile of session lastAccessedTime listing number
- * of sessions for each 10 minute interval up to 10 hours.
- *
- * @param writer Writer to render to
- * @param path Context path of the application to list session information for
- */
- protected void sessions(PrintWriter writer, String path) {
- sessions(writer, path, -1);
- }
-
-
- /**
- *
- * Extract the expiration request parameter
- *
- * @param path
- * @param req
- */
- protected void expireSessions(PrintWriter writer, String path, HttpServletRequest req) {
- int idle = -1;
- String idleParam = req.getParameter("idle");
- if (idleParam != null) {
- try {
- idle = Integer.parseInt(idleParam);
- } catch (NumberFormatException e) {
- log("Could not parse idle parameter to an int: " + idleParam);
- }
- }
- sessions(writer, path, idle);
- }
-
- /**
- * Start the web application at the specified context path.
- *
- * @param writer Writer to render to
- * @param path Context path of the application to be started
- */
- protected void start(PrintWriter writer, String path) {
-
- if (debug >= 1)
- log("start: Starting web application at '" + path + "'");
-
- if ((path == null) || (!path.startsWith("/") && path.equals(""))) {
- writer.println(sm.getString("managerServlet.invalidPath",
- RequestUtil.filter(path)));
- return;
- }
- String displayPath = path;
- if( path.equals("/") )
- path = "";
-
- try {
- Context context = (Context) host.findChild(path);
- if (context == null) {
- writer.println(sm.getString("managerServlet.noContext",
- RequestUtil.filter(displayPath)));
- return;
- }
- ((Lifecycle) context).start();
- if (context.getAvailable())
- writer.println
- (sm.getString("managerServlet.started", displayPath));
- else
- writer.println
- (sm.getString("managerServlet.startFailed", displayPath));
- } catch (Throwable t) {
- getServletContext().log
- (sm.getString("managerServlet.startFailed", displayPath), t);
- writer.println
- (sm.getString("managerServlet.startFailed", displayPath));
- writer.println(sm.getString("managerServlet.exception",
- t.toString()));
- }
-
- }
-
-
- /**
- * Stop the web application at the specified context path.
- *
- * @param writer Writer to render to
- * @param path Context path of the application to be stopped
- */
- protected void stop(PrintWriter writer, String path) {
-
- if (debug >= 1)
- log("stop: Stopping web application at '" + path + "'");
-
- if ((path == null) || (!path.startsWith("/") && path.equals(""))) {
- writer.println(sm.getString("managerServlet.invalidPath",
- RequestUtil.filter(path)));
- return;
- }
- String displayPath = path;
- if( path.equals("/") )
- path = "";
-
- try {
- Context context = (Context) host.findChild(path);
- if (context == null) {
- writer.println(sm.getString("managerServlet.noContext",
- RequestUtil.filter(displayPath)));
- return;
- }
- // It isn't possible for the manager to stop itself
- if (context.getPath().equals(this.context.getPath())) {
- writer.println(sm.getString("managerServlet.noSelf"));
- return;
- }
- ((Lifecycle) context).stop();
- writer.println(sm.getString("managerServlet.stopped", displayPath));
- } catch (Throwable t) {
- log("ManagerServlet.stop[" + displayPath + "]", t);
- writer.println(sm.getString("managerServlet.exception",
- t.toString()));
- }
-
- }
-
-
- /**
- * Undeploy the web application at the specified context path.
- *
- * @param writer Writer to render to
- * @param path Context path of the application to be removed
- */
- protected void undeploy(PrintWriter writer, String path) {
-
- if (debug >= 1)
- log("undeploy: Undeploying web application at '" + path + "'");
-
- if ((path == null) || (!path.startsWith("/") && path.equals(""))) {
- writer.println(sm.getString("managerServlet.invalidPath",
- RequestUtil.filter(path)));
- return;
- }
- String displayPath = path;
- if( path.equals("/") )
- path = "";
-
- try {
-
- // Validate the Context of the specified application
- Context context = (Context) host.findChild(path);
- if (context == null) {
- writer.println(sm.getString("managerServlet.noContext",
- RequestUtil.filter(displayPath)));
- return;
- }
-
- // Identify the appBase of the owning Host of this Context (if any)
- String appBase = null;
- File appBaseDir = null;
- if (context.getParent() instanceof Host) {
- appBase = ((Host) context.getParent()).getAppBase();
- appBaseDir = new File(appBase);
- if (!appBaseDir.isAbsolute()) {
- appBaseDir = new File(System.getProperty("catalina.base"),
- appBase);
- }
- }
-
- if (!isDeployed(path)) {
- writer.println(sm.getString("managerServlet.notDeployed",
- RequestUtil.filter(displayPath)));
- return;
- }
-
- if (!isServiced(path)) {
- addServiced(path);
- try {
- // Try to stop the context first to be nicer
- ((Lifecycle) context).stop();
- } catch (Throwable t) {
- // Ignore
- }
- try {
- if (path.lastIndexOf('/') > 0) {
- path = "/" + path.substring(1).replace('/','#');
- }
- File war = new File(getAppBase(), getDocBase(path) + ".war");
- File dir = new File(getAppBase(), getDocBase(path));
- File xml = new File(configBase, getConfigFile(path) + ".xml");
- if (war.exists()) {
- war.delete();
- } else if (dir.exists()) {
- undeployDir(dir);
- } else {
- xml.delete();
- }
- // Perform new deployment
- check(path.replace('#','/'));
- } finally {
- removeServiced(path.replace('#','/'));
- }
- }
- writer.println(sm.getString("managerServlet.undeployed",
- displayPath));
- } catch (Throwable t) {
- log("ManagerServlet.undeploy[" + displayPath + "]", t);
- writer.println(sm.getString("managerServlet.exception",
- t.toString()));
- }
-
- }
-
-
- // -------------------------------------------------------- Support Methods
-
-
- /**
- * Given a context path, get the config file name.
- */
- protected String getConfigFile(String path) {
- String basename = null;
- if (path.equals("")) {
- basename = "ROOT";
- } else {
- basename = path.substring(1).replace('/', '#');
- }
- return (basename);
- }
-
-
- /**
- * Given a context path, get the doc abse.
- */
- protected String getDocBase(String path) {
- String basename = null;
- if (path.equals("")) {
- basename = "ROOT";
- } else {
- basename = path.substring(1).replace('/', '#');
- }
- return (basename);
- }
-
-
- /**
- * Return a File object representing the "application root" directory
- * for our associated Host.
- */
- protected File getAppBase() {
-
- if (appBase != null) {
- return appBase;
- }
-
- File file = new File(host.getAppBase());
- if (!file.isAbsolute())
- file = new File(System.getProperty("catalina.base"),
- host.getAppBase());
- try {
- appBase = file.getCanonicalFile();
- } catch (IOException e) {
- appBase = file;
- }
- return (appBase);
-
- }
-
-
- /**
- * Invoke the isDeployed method on the deployer.
- */
- protected boolean isDeployed(String name)
- throws Exception {
- String[] params = { name };
- String[] signature = { "java.lang.String" };
- Boolean result =
- (Boolean) mBeanServer.invoke(oname, "isDeployed", params, signature);
- return result.booleanValue();
- }
-
-
- /**
- * Invoke the check method on the deployer.
- */
- protected void check(String name)
- throws Exception {
- String[] params = { name };
- String[] signature = { "java.lang.String" };
- mBeanServer.invoke(oname, "check", params, signature);
- }
-
-
- /**
- * Invoke the isServiced method on the deployer.
- */
- protected boolean isServiced(String name)
- throws Exception {
- String[] params = { name };
- String[] signature = { "java.lang.String" };
- Boolean result =
- (Boolean) mBeanServer.invoke(oname, "isServiced", params, signature);
- return result.booleanValue();
- }
-
-
- /**
- * Invoke the addServiced method on the deployer.
- */
- protected void addServiced(String name)
- throws Exception {
- String[] params = { name };
- String[] signature = { "java.lang.String" };
- mBeanServer.invoke(oname, "addServiced", params, signature);
- }
-
-
- /**
- * Invoke the removeServiced method on the deployer.
- */
- protected void removeServiced(String name)
- throws Exception {
- String[] params = { name };
- String[] signature = { "java.lang.String" };
- mBeanServer.invoke(oname, "removeServiced", params, signature);
- }
-
-
- /**
- * Delete the specified directory, including all of its contents and
- * subdirectories recursively.
- *
- * @param dir File object representing the directory to be deleted
- */
- protected void undeployDir(File dir) {
-
- String files[] = dir.list();
- if (files == null) {
- files = new String[0];
- }
- for (int i = 0; i < files.length; i++) {
- File file = new File(dir, files[i]);
- if (file.isDirectory()) {
- undeployDir(file);
- } else {
- file.delete();
- }
- }
- dir.delete();
-
- }
-
-
- /**
- * Upload the WAR file included in this request, and store it at the
- * specified file location.
- *
- * @param request The servlet request we are processing
- * @param war The file into which we should store the uploaded WAR
- *
- * @exception IOException if an I/O error occurs during processing
- */
- protected void uploadWar(HttpServletRequest request, File war)
- throws IOException {
-
- war.delete();
- ServletInputStream istream = null;
- BufferedOutputStream ostream = null;
- try {
- istream = request.getInputStream();
- ostream =
- new BufferedOutputStream(new FileOutputStream(war), 1024);
- byte buffer[] = new byte[1024];
- while (true) {
- int n = istream.read(buffer);
- if (n < 0) {
- break;
- }
- ostream.write(buffer, 0, n);
- }
- ostream.flush();
- ostream.close();
- ostream = null;
- istream.close();
- istream = null;
- } catch (IOException e) {
- war.delete();
- throw e;
- } finally {
- if (ostream != null) {
- try {
- ostream.close();
- } catch (Throwable t) {
- ;
- }
- ostream = null;
- }
- if (istream != null) {
- try {
- istream.close();
- } catch (Throwable t) {
- ;
- }
- istream = null;
- }
- }
-
- }
-
-
- /**
- * Copy the specified file or directory to the destination.
- *
- * @param src File object representing the source
- * @param dest File object representing the destination
- */
- public static boolean copy(File src, File dest) {
- boolean result = false;
- try {
- if( src != null &&
- !src.getCanonicalPath().equals(dest.getCanonicalPath()) ) {
- result = copyInternal(src, dest, new byte[4096]);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return result;
- }
-
-
- /**
- * Copy the specified file or directory to the destination.
- *
- * @param src File object representing the source
- * @param dest File object representing the destination
- */
- public static boolean copyInternal(File src, File dest, byte[] buf) {
-
- boolean result = true;
-
- String files[] = null;
- if (src.isDirectory()) {
- files = src.list();
- result = dest.mkdir();
- } else {
- files = new String[1];
- files[0] = "";
- }
- if (files == null) {
- files = new String[0];
- }
- for (int i = 0; (i < files.length) && result; i++) {
- File fileSrc = new File(src, files[i]);
- File fileDest = new File(dest, files[i]);
- if (fileSrc.isDirectory()) {
- result = copyInternal(fileSrc, fileDest, buf);
- } else {
- FileInputStream is = null;
- FileOutputStream os = null;
- try {
- is = new FileInputStream(fileSrc);
- os = new FileOutputStream(fileDest);
- int len = 0;
- while (true) {
- len = is.read(buf);
- if (len == -1)
- break;
- os.write(buf, 0, len);
- }
- } catch (IOException e) {
- e.printStackTrace();
- result = false;
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- }
- }
- if (os != null) {
- try {
- os.close();
- } catch (IOException e) {
- }
- }
- }
- }
- }
- return result;
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/manager/host/Constants.java
===================================================================
--- trunk/java/org/apache/catalina/manager/host/Constants.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/manager/host/Constants.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,102 +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.manager.host;
-
-
-public class Constants {
-
- public static final String Package = "org.apache.catalina.manager.host";
-
- public static final String HTML_HEADER_SECTION =
- "<html>\n" +
- "<head>\n" +
- "<link href=\"{0}/jbossweb.css\" rel=\"stylesheet\" type=\"text/css\" />\n";
-
- public static final String BODY_HEADER_SECTION =
- "<title>{1}</title>\n" +
- "</head>\n" +
- "\n" +
- "<body>\n" +
- "\n" +
- "<div class=\"wrapper\">\n" +
- " <div class=\"header\">\n" +
- " <div class=\"floatleft\"><a href=\"list\"><img src=\"{0}/images/hdr_hdrtitle.gif\" border=\"0\"></a></div>\n" +
- " <div class=\"floatright\"><a href=\"http://www.jboss.com/\"><img src=\"{0}/images/hdr_jbosslogo.gif\" alt=\"JBoss, a division of Red Hat\" border=\"0\"></a><a href=\"http://www.jboss.org\"><img src=\"{0}/images/hdr_jbossorglogo.gif\" alt=\"JBoss.org - Community driven.\" border=\"0\" /></a></div>\n" +
- " </div>\n" +
- " <div class=\"container\">\n" +
- "\n";
-
- public static final String MESSAGE_SECTION =
- "<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n" +
- " <tr>\n" +
- " <td class=\"row-left\" width=\"10%\">" +
- "<small><strong>{0}</strong></small> </td>\n" +
- " <td class=\"row-left\"><pre>{1}</pre></td>\n" +
- " </tr>\n" +
- "</table>\n" +
- "<br>\n" +
- "\n";
-
- public static final String MANAGER_SECTION =
- "<div class=\"leftcol\"><dl>\n" +
- " <dt>Manager</dt>" +
- " <dd><a href=\"{1}\">{2}</a></dd>" +
- " <dd><a href=\"{3}\">{4}</a></dd>" +
- " <dd><a href=\"{5}\">{6}</a></dd>" +
- " <dd><a href=\"{7}\">{8}</a></dd>" +
- "</dl></div>\n" +
- "<div class=\"maincol\">\n";
-
- public static final String SERVER_HEADER_SECTION =
- "<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n" +
- "<tr>\n" +
- " <td colspan=\"6\" class=\"title\">{0}</td>\n" +
- "</tr>\n" +
- "<tr>\n" +
- " <td class=\"header-center\"><small>{1}</small></td>\n" +
- " <td class=\"header-center\"><small>{2}</small></td>\n" +
- " <td class=\"header-center\"><small>{3}</small></td>\n" +
- " <td class=\"header-center\"><small>{4}</small></td>\n" +
- " <td class=\"header-center\"><small>{5}</small></td>\n" +
- " <td class=\"header-center\"><small>{6}</small></td>\n" +
- "</tr>\n";
-
- public static final String SERVER_ROW_SECTION =
- "<tr>\n" +
- " <td class=\"row-center\"><small>{0}</small></td>\n" +
- " <td class=\"row-center\"><small>{1}</small></td>\n" +
- " <td class=\"row-center\"><small>{2}</small></td>\n" +
- " <td class=\"row-center\"><small>{3}</small></td>\n" +
- " <td class=\"row-center\"><small>{4}</small></td>\n" +
- " <td class=\"row-center\"><small>{5}</small></td>\n" +
- "</tr>\n" +
- "</table>\n" +
- "<br>\n" +
- "\n";
-
- public static final String HTML_TAIL_SECTION =
- " </div>\n" +
- " </div>\n" +
- " <div class=\"footer\">© 2008 Red Hat Middleware, LLC. All Rights Reserved. </div>\n" +
- "</div></body></html>";
-
- public static final String CHARSET="utf-8";
-
-}
-
Deleted: trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java
===================================================================
--- trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/manager/host/HTMLHostManagerServlet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,473 +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.manager.host;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URLEncoder;
-import java.text.MessageFormat;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.Host;
-import org.apache.catalina.manager.Constants;
-import org.apache.catalina.util.RequestUtil;
-import org.apache.catalina.util.ServerInfo;
-
-/**
-* Servlet that enables remote management of the virtual hosts deployed
-* on the server. Normally, this functionality will be protected by a security
-* constraint in the web application deployment descriptor. However,
-* this requirement can be relaxed during testing.
-* <p>
-* The difference between the <code>HostManagerServlet</code> and this
-* Servlet is that this Servlet prints out a HTML interface which
-* makes it easier to administrate.
-* <p>
-* However if you use a software that parses the output of
-* <code>HostManagerServlet</code> you won't be able to upgrade
-* to this Servlet since the output are not in the
-* same format as from <code>HostManagerServlet</code>
-*
-* @author Bip Thelin
-* @author Malcolm Edgar
-* @author Glenn L. Nielsen
-* @author Peter Rossbach
-* @version $Revision$, $Date$
-* @see ManagerServlet
-*/
-
-public final class HTMLHostManagerServlet extends HostManagerServlet {
-
- // --------------------------------------------------------- Public Methods
-
- /**
- * Process a GET request for the specified resource.
- *
- * @param request The servlet request we are processing
- * @param response The servlet response we are creating
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet-specified error occurs
- */
- public void doGet(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
-
- // Identify the request parameters that we need
- String command = request.getPathInfo();
-
- String name = request.getParameter("name");
-
- // Prepare our output writer to generate the response message
- response.setContentType("text/html; charset=" + Constants.CHARSET);
-
- String message = "";
- // Process the requested command
- if (command == null) {
- } else if (command.equals("/add")) {
- message = add(request, name);
- } else if (command.equals("/remove")) {
- message = remove(name);
- } else if (command.equals("/list")) {
- } else if (command.equals("/start")) {
- message = start(name);
- } else if (command.equals("/stop")) {
- message = stop(name);
- } else {
- message =
- sm.getString("hostManagerServlet.unknownCommand", command);
- }
-
- list(request, response, message);
- }
-
-
- /**
- * Add a host using the specified parameters.
- *
- * @param name host name
- */
- protected String add(HttpServletRequest request,String name) {
-
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
-
- super.add(request,printWriter,name,true);
-
- return stringWriter.toString();
- }
-
-
- /**
- * Remove the specified host.
- *
- * @param writer Writer to render results to
- * @param name host name
- */
- protected String remove(String name) {
-
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
-
- super.remove(printWriter, name);
-
- return stringWriter.toString();
- }
-
-
- /**
- * Start the host with the specified name.
- *
- * @param name Host name
- */
- protected String start(String name) {
-
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
-
- super.start(printWriter, name);
-
- return stringWriter.toString();
- }
-
-
- /**
- * Stop the host with the specified name.
- *
- * @param name Host name
- */
- protected String stop(String name) {
-
- StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
-
- super.stop(printWriter, name);
-
- return stringWriter.toString();
- }
-
-
- /**
- * Render a HTML list of the currently active Contexts in our virtual host,
- * and memory and server status information.
- *
- * @param request The request
- * @param response The response
- * @param message a message to display
- */
- public void list(HttpServletRequest request,
- HttpServletResponse response,
- String message) throws IOException {
-
- PrintWriter writer = response.getWriter();
-
- // HTML Header Section
- Object[] args = new Object[1];
- args[0] = request.getContextPath();
- writer.print(MessageFormat.format(Constants.HTML_HEADER_SECTION, args));
-
- // Body Header Section
- args = new Object[2];
- args[0] = request.getContextPath();
- args[1] = sm.getString("htmlHostManagerServlet.title");
- writer.print(MessageFormat.format(Constants.BODY_HEADER_SECTION, args));
-
- // Manager Section
- args = new Object[9];
- args[0] = sm.getString("htmlHostManagerServlet.manager");
- args[1] = response.encodeURL(request.getContextPath() + "/html/list");
- args[2] = sm.getString("htmlHostManagerServlet.list");
- args[3] = response.encodeURL
- (request.getContextPath() + "/" +
- sm.getString("htmlHostManagerServlet.helpHtmlManagerFile"));
- args[4] = sm.getString("htmlHostManagerServlet.helpHtmlManager");
- args[5] = response.encodeURL
- (request.getContextPath() + "/" +
- sm.getString("htmlHostManagerServlet.helpManagerFile"));
- args[6] = sm.getString("htmlHostManagerServlet.helpManager");
- args[7] = response.encodeURL("/manager/status");
- args[8] = sm.getString("statusServlet.title");
- writer.print(MessageFormat.format(Constants.MANAGER_SECTION, args));
-
- // Message Section
- args = new Object[3];
- args[0] = sm.getString("htmlHostManagerServlet.messageLabel");
- if (message == null || message.length() == 0) {
- args[1] = "OK";
- } else {
- args[1] = RequestUtil.filter(message);
- }
- writer.print(MessageFormat.format(Constants.MESSAGE_SECTION, args));
-
- // Hosts Header Section
- args = new Object[3];
- args[0] = sm.getString("htmlHostManagerServlet.hostName");
- args[1] = sm.getString("htmlHostManagerServlet.hostAliases");
- args[2] = sm.getString("htmlHostManagerServlet.hostTasks");
- writer.print(MessageFormat.format(HOSTS_HEADER_SECTION, args));
-
- // Hosts Row Section
- // Create sorted map of host names.
- Container[] children = engine.findChildren();
- String hostNames[] = new String[children.length];
- for (int i = 0; i < children.length; i++)
- hostNames[i] = children[i].getName();
-
- TreeMap<String,String> sortedHostNamesMap =
- new TreeMap<String,String>();
-
- for (int i = 0; i < hostNames.length; i++) {
- String displayPath = hostNames[i];
- sortedHostNamesMap.put(displayPath, hostNames[i]);
- }
-
- String hostsStart = sm.getString("htmlHostManagerServlet.hostsStart");
- String hostsStop = sm.getString("htmlHostManagerServlet.hostsStop");
- String hostsRemove = sm.getString("htmlHostManagerServlet.hostsRemove");
-
- Iterator<Map.Entry<String,String>> iterator =
- sortedHostNamesMap.entrySet().iterator();
- boolean isHighlighted = false;
- String highlightStyle = null;
- while (iterator.hasNext()) {
- Map.Entry<String,String> entry = iterator.next();
- String hostName = (String) entry.getKey();
- Host host = (Host) engine.findChild(hostName);
-
- if (host != null ) {
-
- isHighlighted = !isHighlighted;
- if(isHighlighted) {
- highlightStyle = "oddRow";
- } else {
- highlightStyle = "evenRow";
- }
-
- args = new Object[3];
- args[0] = RequestUtil.filter(hostName);
- String[] aliases = host.findAliases();
- StringBuilder buf = new StringBuilder();
- if (aliases.length > 0) {
- buf.append(aliases[0]);
- for (int j = 1; j < aliases.length; j++) {
- buf.append(", ").append(aliases[j]);
- }
- }
-
- if (buf.length() == 0) {
- buf.append(" ");
- args[1] = buf.toString();
- } else {
- args[1] = RequestUtil.filter(buf.toString());
- }
-
- args[2] = highlightStyle;
-
- writer.print
- (MessageFormat.format(HOSTS_ROW_DETAILS_SECTION, args));
-
- args = new Object[7];
- args[0] = response.encodeURL
- (request.getContextPath() +
- "/html/start?name=" + URLEncoder.encode(hostName, "UTF-8"));
- args[1] = hostsStart;
- args[2] = response.encodeURL
- (request.getContextPath() +
- "/html/stop?name=" + URLEncoder.encode(hostName, "UTF-8"));
- args[3] = hostsStop;
- args[4] = response.encodeURL
- (request.getContextPath() +
- "/html/remove?name=" + URLEncoder.encode(hostName, "UTF-8"));
- args[5] = hostsRemove;
- args[6] = RequestUtil.filter(hostName);
- if (host == this.host) {
- writer.print(MessageFormat.format(
- MANAGER_HOST_ROW_BUTTON_SECTION, args));
- } else {
- writer.print(MessageFormat.format(
- HOSTS_ROW_BUTTON_SECTION, args));
- }
-
- }
- }
-
- // Add Section
- args = new Object[6];
- args[0] = sm.getString("htmlHostManagerServlet.addTitle");
- args[1] = sm.getString("htmlHostManagerServlet.addHost");
- args[2] = response.encodeURL(request.getContextPath() + "/html/add");
- args[3] = sm.getString("htmlHostManagerServlet.addName");
- args[4] = sm.getString("htmlHostManagerServlet.addAliases");
- args[5] = sm.getString("htmlHostManagerServlet.addAppBase");
- writer.print(MessageFormat.format(ADD_SECTION_START, args));
-
- args = new Object[3];
- args[0] = sm.getString("htmlHostManagerServlet.addAutoDeploy");
- args[1] = "autoDeploy";
- args[2] = "checked";
- writer.print(MessageFormat.format(ADD_SECTION_BOOLEAN, args));
- args[0] = sm.getString("htmlHostManagerServlet.addDeployOnStartup");
- args[1] = "deployOnStartup";
- args[2] = "checked";
- writer.print(MessageFormat.format(ADD_SECTION_BOOLEAN, args));
- args[0] = sm.getString("htmlHostManagerServlet.addDeployXML");
- args[1] = "deployXML";
- args[2] = "checked";
- writer.print(MessageFormat.format(ADD_SECTION_BOOLEAN, args));
- args[0] = sm.getString("htmlHostManagerServlet.addUnpackWARs");
- args[1] = "unpackWARs";
- args[2] = "checked";
- writer.print(MessageFormat.format(ADD_SECTION_BOOLEAN, args));
- args[0] = sm.getString("htmlHostManagerServlet.addXmlNamespaceAware");
- args[1] = "xmlNamespaceAware";
- args[2] = "";
- writer.print(MessageFormat.format(ADD_SECTION_BOOLEAN, args));
- args[0] = sm.getString("htmlHostManagerServlet.addXmlValidation");
- args[1] = "xmlValidation";
- args[2] = "";
- writer.print(MessageFormat.format(ADD_SECTION_BOOLEAN, args));
-
- args[0] = sm.getString("htmlHostManagerServlet.addManager");
- args[1] = "manager";
- args[2] = "checked";
- writer.print(MessageFormat.format(ADD_SECTION_BOOLEAN, args));
-
- args = new Object[1];
- args[0] = sm.getString("htmlHostManagerServlet.addButton");
- writer.print(MessageFormat.format(ADD_SECTION_END, args));
-
- // Server Header Section
- args = new Object[7];
- args[0] = sm.getString("htmlHostManagerServlet.serverTitle");
- args[1] = sm.getString("htmlHostManagerServlet.serverVersion");
- args[2] = sm.getString("htmlHostManagerServlet.serverJVMVersion");
- args[3] = sm.getString("htmlHostManagerServlet.serverJVMVendor");
- args[4] = sm.getString("htmlHostManagerServlet.serverOSName");
- args[5] = sm.getString("htmlHostManagerServlet.serverOSVersion");
- args[6] = sm.getString("htmlHostManagerServlet.serverOSArch");
- writer.print(MessageFormat.format
- (Constants.SERVER_HEADER_SECTION, args));
-
- // Server Row Section
- args = new Object[6];
- args[0] = ServerInfo.getServerInfo();
- args[1] = System.getProperty("java.runtime.version");
- args[2] = System.getProperty("java.vm.vendor");
- args[3] = System.getProperty("os.name");
- args[4] = System.getProperty("os.version");
- args[5] = System.getProperty("os.arch");
- writer.print(MessageFormat.format(Constants.SERVER_ROW_SECTION, args));
-
- // HTML Tail Section
- writer.print(Constants.HTML_TAIL_SECTION);
-
- // Finish up the response
- writer.flush();
- writer.close();
- }
-
-
- // ------------------------------------------------------ Private Constants
-
- // These HTML sections are broken in relatively small sections, because of
- // limited number of subsitutions MessageFormat can process
- // (maximium of 10).
-
- private static final String HOSTS_HEADER_SECTION =
- "<table width=\"100%\" cellspacing=\"0\" class=\"tableStyle\" >\n" +
- "<thead><th colspan=\"5\">{0}</th></thead>\n" +
- "<tr class=\"UnsortableTableHeader\">\n" +
- " <td>{0}</td>\n" +
- " <td>{1}</td>\n" +
- " <td>{2}</td>\n" +
- "</tr>\n";
-
- private static final String HOSTS_ROW_DETAILS_SECTION =
- "<tr class=\"{2}\">\n" +
- " <td class=\"first\"><a href=\"http://{0}\">{0}</a></td>\n" +
- " <td>{1}</td>\n";
-
- private static final String MANAGER_HOST_ROW_BUTTON_SECTION =
- " <td>\n" +
- " {1} \n" +
- " {3} \n" +
- " {5} \n" +
- " </td>\n" +
- "</tr>\n";
-
- private static final String HOSTS_ROW_BUTTON_SECTION =
- " <td NOWRAP>\n" +
- " <a href=\"{0}\" onclick=\"return(confirm(''{1} {6}\\n\\nAre you sure?''))\">{1}</a> \n" +
- " <a href=\"{2}\" onclick=\"return(confirm(''{3} {6}\\n\\nAre you sure?''))\">{3}</a> \n" +
- " <a href=\"{4}\" onclick=\"return(confirm(''{5} {6}\\n\\nAre you sure?''))\">{5}</a> \n" +
- " </td>\n" +
- "</tr>\n";
-
- private static final String ADD_SECTION_START =
- "</table>\n" +
- "<table width=\"100%\" cellspacing=\"0\" class=\"tableStyle\">\n" +
- "<tr>\n" +
- " <th colspan=\"2\">{0}</th>\n" +
- "</tr>\n" +
- "<tbody>\n" +
- " <tr class=\"UnsortableTableHeader\"><td>{1}</td></tr>\n" +
- "<tr class=\"oddRow\">\n" +
- " <td colspan=\"2\" class=\"first\">\n" +
- "<form method=\"get\" action=\"{2}\">\n" +
- "<table cellpadding=\"3\" cellspacing=\"0\" style=\"border:0px;\"><tbody>\n" +
- "<tr>\n" +
- " <td style=\"border:0px;\">{3}</td>\n" +
- " <td style=\"border:0px;\"><input type=\"text\" name=\"name\" size=\"20\"></td>\n" +
- "</tr>\n" +
- "<tr>\n" +
- " <td style=\"border:0px;\">{4}</td>\n" +
- " <td style=\"border:0px;\"><input type=\"text\" name=\"aliases\" size=\"64\"></td>\n" +
- "</tr>\n" +
- "<tr>\n" +
- " <td style=\"border:0px;\">{5}</td>\n" +
- " <td style=\"border:0px;\"><input type=\"text\" name=\"appBase\" size=\"64\"></td>\n" +
- "</tr>\n" ;
-
- private static final String ADD_SECTION_BOOLEAN =
- "<tr>\n" +
- " <td style=\"border:0px;\">{0}</small></td>\n" +
- " <td style=\"border:0px;\"><input type=\"checkbox\" name=\"{1}\" {2}></td>\n" +
- "</tr>\n" ;
-
- private static final String ADD_SECTION_END =
- "<tr>\n" +
- " <td style=\"border:0px;\"> </td>\n" +
- " <td style=\"border:0px;\"><input type=\"submit\" value=\"{0}\" class=\"buttonmed\"></td>\n" +
- "</tr>\n" +
- "</tbody></table>\n" +
- "</form>\n" +
- "</td>\n" +
- "</tr>\n" +
- "</table>\n" +
- "\n";
-
-}
Deleted: trunk/java/org/apache/catalina/manager/host/HostManagerServlet.java
===================================================================
--- trunk/java/org/apache/catalina/manager/host/HostManagerServlet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/manager/host/HostManagerServlet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,686 +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.manager.host;
-
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.StringTokenizer;
-
-import javax.management.MBeanServer;
-import javax.servlet.ServletException;
-import javax.servlet.UnavailableException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.ContainerServlet;
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Globals;
-import org.apache.catalina.Host;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.Wrapper;
-import org.apache.catalina.core.StandardHost;
-import org.apache.catalina.startup.HostConfig;
-import org.apache.catalina.util.StringManager;
-import org.apache.tomcat.util.modeler.Registry;
-import org.apache.catalina.core.ContainerBase;
-
-
-/**
- * Servlet that enables remote management of the virtual hosts installed
- * on the server. Normally, this functionality will be protected by
- * a security constraint in the web application deployment descriptor.
- * However, this requirement can be relaxed during testing.
- * <p>
- * This servlet examines the value returned by <code>getPathInfo()</code>
- * and related query parameters to determine what action is being requested.
- * The following actions and parameters (starting after the servlet path)
- * are supported:
- * <ul>
- * <li><b>/add?name={host-name}&aliases={host-aliases}&manager={manager}</b> -
- * Create and add a new virtual host. The <code>host-name</code> attribute
- * indicates the name of the new host. The <code>host-aliases</code>
- * attribute is a comma separated list of the host alias names.
- * The <code>manager</code> attribute is a boolean value indicating if the
- * webapp manager will be installed in the newly created host (optional,
- * false by default).</li>
- * <li><b>/remove?name={host-name}</b> - Remove a virtual host.
- * The <code>host-name</code> attribute indicates the name of the host.
- * </li>
- * <li><b>/list</b> - List the virtual hosts installed on the server.
- * Each host will be listed with the following format
- * <code>host-name#host-aliases</code>.</li>
- * <li><b>/start?name={host-name}</b> - Start the virtual host.</li>
- * <li><b>/stop?name={host-name}</b> - Stop the virtual host.</li>
- * </ul>
- * <p>
- * <b>NOTE</b> - Attempting to stop or remove the host containing
- * this servlet itself will not succeed. Therefore, this servlet should
- * generally be deployed in a separate virtual host.
- * <p>
- * <b>NOTE</b> - For security reasons, this application will not operate
- * when accessed via the invoker servlet. You must explicitly map this servlet
- * with a servlet mapping, and you will always want to protect it with
- * appropriate security constraints as well.
- * <p>
- * The following servlet initialization parameters are recognized:
- * <ul>
- * <li><b>debug</b> - The debugging detail level that controls the amount
- * of information that is logged by this servlet. Default is zero.
- * </ul>
- *
- * @author Craig R. McClanahan
- * @author Remy Maucherat
- * @version $Revision$ $Date$
- */
-
-public class HostManagerServlet
- extends HttpServlet implements ContainerServlet {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * Path where context descriptors should be deployed.
- */
- protected File configBase = null;
-
-
- /**
- * The Context container associated with our web application.
- */
- protected Context context = null;
-
-
- /**
- * The debugging detail level for this servlet.
- */
- protected int debug = 1;
-
-
- /**
- * The associated host.
- */
- protected Host host = null;
-
-
- /**
- * The associated engine.
- */
- protected Engine engine = null;
-
-
- /**
- * MBean server.
- */
- protected MBeanServer mBeanServer = null;
-
-
- /**
- * The string manager for this package.
- */
- protected static StringManager sm =
- StringManager.getManager(Constants.Package);
-
-
- /**
- * The Wrapper container associated with this servlet.
- */
- protected Wrapper wrapper = null;
-
-
- // ----------------------------------------------- ContainerServlet Methods
-
-
- /**
- * Return the Wrapper with which we are associated.
- */
- public Wrapper getWrapper() {
-
- return (this.wrapper);
-
- }
-
-
- /**
- * Set the Wrapper with which we are associated.
- *
- * @param wrapper The new wrapper
- */
- public void setWrapper(Wrapper wrapper) {
-
- this.wrapper = wrapper;
- if (wrapper == null) {
- context = null;
- host = null;
- engine = null;
- } else {
- context = (Context) wrapper.getParent();
- host = (Host) context.getParent();
- engine = (Engine) host.getParent();
- }
-
- // Retrieve the MBean server
- mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
-
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Finalize this servlet.
- */
- public void destroy() {
-
- ; // No actions necessary
-
- }
-
-
- /**
- * Process a GET request for the specified resource.
- *
- * @param request The servlet request we are processing
- * @param response The servlet response we are creating
- *
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet-specified error occurs
- */
- public void doGet(HttpServletRequest request,
- HttpServletResponse response)
- throws IOException, ServletException {
-
- // Verify that we were not accessed using the invoker servlet
- if (request.getAttribute(Globals.INVOKED_ATTR) != null)
- throw new UnavailableException
- (sm.getString("hostManagerServlet.cannotInvoke"));
-
- // Identify the request parameters that we need
- String command = request.getPathInfo();
- if (command == null)
- command = request.getServletPath();
- String name = request.getParameter("name");
-
- // Prepare our output writer to generate the response message
- response.setContentType("text/plain; charset=" + Constants.CHARSET);
- PrintWriter writer = response.getWriter();
-
- // Process the requested command
- if (command == null) {
- writer.println(sm.getString("hostManagerServlet.noCommand"));
- } else if (command.equals("/add")) {
- add(request, writer, name, false);
- } else if (command.equals("/remove")) {
- remove(writer, name);
- } else if (command.equals("/list")) {
- list(writer);
- } else if (command.equals("/start")) {
- start(writer, name);
- } else if (command.equals("/stop")) {
- stop(writer, name);
- } else {
- writer.println(sm.getString("hostManagerServlet.unknownCommand",
- command));
- }
-
- // Finish up the response
- writer.flush();
- writer.close();
-
- }
-
-
- /**
- * Add host with the given parameters.
- *
- * @param request The request
- * @param writer The output writer
- * @param name The host name
- * @param htmlMode Flag value
- */
- protected void add(HttpServletRequest request, PrintWriter writer, String name, boolean htmlMode ) {
- String aliases = request.getParameter("aliases");
- String appBase = request.getParameter("appBase");
- boolean manager = booleanParameter(request, "manager", false, htmlMode);
- boolean autoDeploy = booleanParameter(request, "autoDeploy", true, htmlMode);
- boolean deployOnStartup = booleanParameter(request, "deployOnStartup", true, htmlMode);
- boolean deployXML = booleanParameter(request, "deployXML", true, htmlMode);
- boolean unpackWARs = booleanParameter(request, "unpackWARs", true, htmlMode);
- boolean xmlNamespaceAware = booleanParameter(request, "xmlNamespaceAware", false, htmlMode);
- boolean xmlValidation = booleanParameter(request, "xmlValidation", false, htmlMode);
- add(writer, name, aliases, appBase, manager,
- autoDeploy,
- deployOnStartup,
- deployXML,
- unpackWARs,
- xmlNamespaceAware,
- xmlValidation);
- }
-
-
- /**
- * extract boolean value from checkbox with default
- * @param request
- * @param parameter
- * @param theDefault
- * @param htmlMode
- * @return
- */
- protected boolean booleanParameter(HttpServletRequest request,
- String parameter, boolean theDefault, boolean htmlMode) {
- String value = request.getParameter(parameter);
- boolean booleanValue = theDefault;
- if (value != null) {
- if (htmlMode) {
- if (value.equals("on")) {
- booleanValue = true;
- }
- } else if (theDefault) {
- if (value.equals("false")) {
- booleanValue = false;
- }
- } else if (value.equals("true")) {
- booleanValue = true;
- }
- } else if (htmlMode)
- booleanValue = false;
- return booleanValue;
- }
-
-
- /**
- * Initialize this servlet.
- */
- public void init() throws ServletException {
-
- // Ensure that our ContainerServlet properties have been set
- if ((wrapper == null) || (context == null))
- throw new UnavailableException
- (sm.getString("hostManagerServlet.noWrapper"));
-
- // Verify that we were not accessed using the invoker servlet
- String servletName = getServletConfig().getServletName();
- if (servletName == null)
- servletName = "";
- if (servletName.startsWith("org.apache.catalina.INVOKER."))
- throw new UnavailableException
- (sm.getString("hostManagerServlet.cannotInvoke"));
-
- // Set our properties from the initialization parameters
- String value = null;
- try {
- value = getServletConfig().getInitParameter("debug");
- debug = Integer.parseInt(value);
- } catch (Throwable t) {
- ;
- }
-
- }
-
-
-
- // -------------------------------------------------------- Private Methods
-
-
- /**
- * Add a host using the specified parameters.
- *
- * @param writer Writer to render results to
- * @param name host name
- * @param aliases comma separated alias list
- * @param appBase application base for the host
- * @param manager should the manager webapp be deployed to the new host ?
- */
- protected synchronized void add
- (PrintWriter writer, String name, String aliases, String appBase,
- boolean manager,
- boolean autoDeploy,
- boolean deployOnStartup,
- boolean deployXML,
- boolean unpackWARs,
- boolean xmlNamespaceAware,
- boolean xmlValidation) {
- if (debug >= 1) {
- log("add: Adding host '" + name + "'");
- }
-
- // Validate the requested host name
- if ((name == null) || name.length() == 0) {
- writer.println(sm.getString("hostManagerServlet.invalidHostName", name));
- return;
- }
-
- // Check if host already exists
- if (engine.findChild(name) != null) {
- writer.println
- (sm.getString("hostManagerServlet.alreadyHost", name));
- return;
- }
-
- // Validate and create appBase
- File appBaseFile = null;
- if (appBase == null || appBase.length() == 0) {
- appBase = name;
- }
- File file = new File(appBase);
- if (!file.isAbsolute())
- file = new File(System.getProperty("catalina.base"), appBase);
- try {
- appBaseFile = file.getCanonicalFile();
- } catch (IOException e) {
- appBaseFile = file;
- }
- if (!appBaseFile.exists()) {
- appBaseFile.mkdirs();
- }
-
- // Create base for config files
- File configBaseFile = getConfigBase(name);
-
- // Copy manager.xml if requested
- if (manager) {
- InputStream is = null;
- OutputStream os = null;
- try {
- is = getServletContext().getResourceAsStream("/manager.xml");
- os = new FileOutputStream(new File(configBaseFile, "manager.xml"));
- byte buffer[] = new byte[512];
- int len = buffer.length;
- while (true) {
- len = is.read(buffer);
- if (len == -1)
- break;
- os.write(buffer, 0, len);
- }
- } catch (IOException e) {
- writer.println
- (sm.getString("hostManagerServlet.managerXml"));
- return;
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- }
- }
- if (os != null) {
- try {
- os.close();
- } catch (IOException e) {
- }
- }
- }
- }
-
- StandardHost host = new StandardHost();
- host.setAppBase(appBase);
- host.setName(name);
-
- host.addLifecycleListener(new HostConfig());
-
- // Add host aliases
- if ((aliases != null) && !("".equals(aliases))) {
- StringTokenizer tok = new StringTokenizer(aliases, ", ");
- while (tok.hasMoreTokens()) {
- host.addAlias(tok.nextToken());
- }
- }
- host.setAutoDeploy(autoDeploy);
- host.setDeployOnStartup(deployOnStartup);
- host.setDeployXML(deployXML);
- host.setUnpackWARs(unpackWARs);
-
- // Add new host
- try {
- engine.addChild(host);
- } catch (Exception e) {
- writer.println(sm.getString("hostManagerServlet.exception",
- e.toString()));
- return;
- }
-
- host = (StandardHost) engine.findChild(name);
- if (host != null) {
- writer.println(sm.getString("hostManagerServlet.add", name));
- } else {
- // Something failed
- writer.println(sm.getString("hostManagerServlet.addFailed", name));
- }
-
- }
-
-
- /**
- * Remove the specified host.
- *
- * @param writer Writer to render results to
- * @param name host name
- */
- protected synchronized void remove(PrintWriter writer, String name) {
-
- if (debug >= 1) {
- log("remove: Removing host '" + name + "'");
- }
-
- // Validate the requested host name
- if ((name == null) || name.length() == 0) {
- writer.println(sm.getString("hostManagerServlet.invalidHostName", name));
- return;
- }
-
- // Check if host exists
- if (engine.findChild(name) == null) {
- writer.println
- (sm.getString("hostManagerServlet.noHost", name));
- return;
- }
-
- // Prevent removing our own host
- if (engine.findChild(name) == host) {
- writer.println
- (sm.getString("hostManagerServlet.cannotRemoveOwnHost", name));
- return;
- }
-
- // Remove host
- // Note that the host will not get physically removed
- try {
- Container child = engine.findChild(name);
- engine.removeChild(child);
- if ( child instanceof ContainerBase ) ((ContainerBase)child).destroy();
- } catch (Exception e) {
- writer.println(sm.getString("hostManagerServlet.exception",
- e.toString()));
- return;
- }
-
- Host host = (StandardHost) engine.findChild(name);
- if (host == null) {
- writer.println(sm.getString("hostManagerServlet.remove", name));
- } else {
- // Something failed
- writer.println(sm.getString("hostManagerServlet.removeFailed", name));
- }
-
- }
-
-
- /**
- * Render a list of the currently active Contexts in our virtual host.
- *
- * @param writer Writer to render to
- */
- protected void list(PrintWriter writer) {
-
- if (debug >= 1)
- log("list: Listing hosts for engine '"
- + engine.getName() + "'");
-
- writer.println(sm.getString("hostManagerServlet.listed",
- engine.getName()));
- Container[] hosts = engine.findChildren();
- for (int i = 0; i < hosts.length; i++) {
- Host host = (Host) hosts[i];
- String name = host.getName();
- String[] aliases = host.findAliases();
- StringBuilder buf = new StringBuilder();
- if (aliases.length > 0) {
- buf.append(aliases[0]);
- for (int j = 1; j < aliases.length; j++) {
- buf.append(',').append(aliases[j]);
- }
- }
- writer.println(sm.getString("hostManagerServlet.listitem",
- name, buf.toString()));
- }
- }
-
-
- /**
- * Start the host with the specified name.
- *
- * @param writer Writer to render to
- * @param name Host name
- */
- protected void start(PrintWriter writer, String name) {
-
- if (debug >= 1)
- log("start: Starting host with name '" + name + "'");
-
- // Validate the requested host name
- if ((name == null) || name.length() == 0) {
- writer.println(sm.getString("hostManagerServlet.invalidHostName", name));
- return;
- }
-
- // Check if host exists
- if (engine.findChild(name) == null) {
- writer.println
- (sm.getString("hostManagerServlet.noHost", name));
- return;
- }
-
- // Prevent starting our own host
- if (engine.findChild(name) == host) {
- writer.println
- (sm.getString("hostManagerServlet.cannotStartOwnHost", name));
- return;
- }
-
- // Start host
- try {
- ((Lifecycle) engine.findChild(name)).start();
- writer.println
- (sm.getString("hostManagerServlet.started", name));
- } catch (Throwable t) {
- getServletContext().log
- (sm.getString("hostManagerServlet.startFailed", name), t);
- writer.println
- (sm.getString("hostManagerServlet.startFailed", name));
- writer.println(sm.getString("hostManagerServlet.exception",
- t.toString()));
- return;
- }
-
- }
-
-
- /**
- * Start the host with the specified name.
- *
- * @param writer Writer to render to
- * @param name Host name
- */
- protected void stop(PrintWriter writer, String name) {
-
- if (debug >= 1)
- log("stop: Stopping host with name '" + name + "'");
-
- // Validate the requested host name
- if ((name == null) || name.length() == 0) {
- writer.println(sm.getString("hostManagerServlet.invalidHostName", name));
- return;
- }
-
- // Check if host exists
- if (engine.findChild(name) == null) {
- writer.println
- (sm.getString("hostManagerServlet.noHost", name));
- return;
- }
-
- // Prevent starting our own host
- if (engine.findChild(name) == host) {
- writer.println
- (sm.getString("hostManagerServlet.cannotStopOwnHost", name));
- return;
- }
-
- // Start host
- try {
- ((Lifecycle) engine.findChild(name)).stop();
- writer.println
- (sm.getString("hostManagerServlet.stopped", name));
- } catch (Throwable t) {
- getServletContext().log
- (sm.getString("hostManagerServlet.stopFailed", name), t);
- writer.println
- (sm.getString("hostManagerServlet.stopFailed", name));
- writer.println(sm.getString("hostManagerServlet.exception",
- t.toString()));
- return;
- }
-
- }
-
-
- // -------------------------------------------------------- Support Methods
-
-
- /**
- * Get config base.
- */
- protected File getConfigBase(String hostName) {
- File configBase =
- new File(System.getProperty("catalina.base"), "conf");
- if (!configBase.exists()) {
- return null;
- }
- if (engine != null) {
- configBase = new File(configBase, engine.getName());
- }
- if (host != null) {
- configBase = new File(configBase, hostName);
- }
- configBase.mkdirs();
- return configBase;
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/manager/host/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/catalina/manager/host/LocalStrings.properties 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/manager/host/LocalStrings.properties 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,59 +0,0 @@
-hostManagerServlet.cannotInvoke=Cannot invoke host manager servlet through invoker
-hostManagerServlet.noCommand=FAIL - No command was specified
-hostManagerServlet.unknownCommand=FAIL - Unknown command {0}
-hostManagerServlet.noWrapper=Container has not called setWrapper() for this servlet
-hostManagerServlet.invalidHostName=FAIL - Invalid host name {0} was specified
-hostManagerServlet.alreadyHost=FAIL - Host already exists with host name {0}
-hostManagerServlet.managerXml=FAIL - Couldn't install manager.xml
-hostManagerServlet.exception=FAIL - Encountered exception {0}
-hostManagerServlet.add=OK - Host {0} added
-hostManagerServlet.addFailed=FAIL - Failed to add host {0}
-hostManagerServlet.cannotRemoveOwnHost=FAIL - Cannot remove own host {0}
-hostManagerServlet.remove=OK - Removed host {0}
-hostManagerServlet.removeFailed=FAIL - Failed to remove host {0}
-hostManagerServlet.listed=OK - Listed hosts
-hostManagerServlet.listitem={0}:{1}
-hostManagerServlet.cannotStartOwnHost=FAIL - Cannot start own host {0}
-hostManagerServlet.started=OK - Host {0} started
-hostManagerServlet.startFailed=FAIL - Failed to start host {0}
-hostManagerServlet.cannotStopOwnHost=FAIL - Cannot stop own host {0}
-hostManagerServlet.stopped=OK - Host {0} stopped
-hostManagerServlet.stopFailed=FAIL - Failed to stop host {0}
-
-htmlHostManagerServlet.title=Tomcat Virtual Host Manager
-htmlHostManagerServlet.messageLabel=Message:
-htmlHostManagerServlet.manager=Host Manager
-htmlHostManagerServlet.list=List Virtual Hosts
-htmlHostManagerServlet.helpHtmlManagerFile=html-host-manager-howto.html
-htmlHostManagerServlet.helpHtmlManager=HTML Host Manager Help (Coming Soon!)
-htmlHostManagerServlet.helpManagerFile=../docs/host-manager-howto.html
-htmlHostManagerServlet.helpManager=Host Manager Help
-htmlHostManagerServlet.hostName=Host name
-htmlHostManagerServlet.hostAliases=Host aliases
-htmlHostManagerServlet.hostTasks=Commands
-htmlHostManagerServlet.hostsStart=Start
-htmlHostManagerServlet.hostsStop=Stop
-htmlHostManagerServlet.hostsRemove=Remove
-htmlHostManagerServlet.addTitle=Add Virtual Host
-htmlHostManagerServlet.addHost=Host
-htmlHostManagerServlet.addName=Name:
-htmlHostManagerServlet.addAliases=Aliases:
-htmlHostManagerServlet.addAppBase=App base:
-htmlHostManagerServlet.addManager=Manager App
-htmlHostManagerServlet.addAutoDeploy=AutoDeploy
-htmlHostManagerServlet.addDeployOnStartup=DeployOnStartup
-htmlHostManagerServlet.addDeployXML=DeployXML
-htmlHostManagerServlet.addUnpackWARs=UnpackWARs
-htmlHostManagerServlet.addXmlNamespaceAware=XmlNamespaceAware
-htmlHostManagerServlet.addXmlValidation=XmlValidation
-htmlHostManagerServlet.addButton=Add
-htmlHostManagerServlet.serverTitle=Server Information
-htmlHostManagerServlet.serverVersion=Tomcat Version
-htmlHostManagerServlet.serverJVMVersion=JVM Version
-htmlHostManagerServlet.serverJVMVendor=JVM Vendor
-htmlHostManagerServlet.serverOSName=OS Name
-htmlHostManagerServlet.serverOSVersion=OS Version
-htmlHostManagerServlet.serverOSArch=OS Architecture
-
-statusServlet.title=Server Status
-statusServlet.complete=Complete Server Status
Deleted: trunk/java/org/apache/catalina/manager/host/LocalStrings_es.properties
===================================================================
--- trunk/java/org/apache/catalina/manager/host/LocalStrings_es.properties 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/manager/host/LocalStrings_es.properties 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,57 +0,0 @@
-hostManagerServlet.cannotInvoke = No puedo invocar servlet de gestor de m\u00E1quina a trav\u00E9s del invocador
-hostManagerServlet.noCommand = FALLO - No se ha especificado comando
-hostManagerServlet.unknownCommand = FALLO - Comando desconocido {0}
-hostManagerServlet.noWrapper = El contenedor no ha llamado a setWrapper() para este servlet
-hostManagerServlet.invalidHostName = FALLO - Se ha especificado un nombre inv\u00E1lido de m\u00E1quina {0}
-hostManagerServlet.alreadyHost = FALLO - Ya existe m\u00E1quina con nombre de m\u00E1quina {0}
-hostManagerServlet.managerXml = FALLO - no pude instalar manager.xml
-hostManagerServlet.exception = FALLO - Encontrada excepci\u00F3n {0}
-hostManagerServlet.add = OK - A\u00F1adida m\u00E1quina {0}
-hostManagerServlet.addFailed = FALLO - No pude a\u00F1adir m\u00E1quina {0}
-hostManagerServlet.cannotRemoveOwnHost = FALLO - No puedo quitar m\u00E1quina propia {0}
-hostManagerServlet.remove = OK - Quitada m\u00E1quina {0}
-hostManagerServlet.removeFailed = FALLO - No pude quitar m\u00E1quina {0}
-hostManagerServlet.listed = OK - M\u00E1quinas listadas
-hostManagerServlet.listitem = {0}\:{1}
-hostManagerServlet.cannotStartOwnHost = FALLO - No puedo empezar m\u00E1quina propia {0}
-hostManagerServlet.started = OK - M\u00E1quina {0} arrancada
-hostManagerServlet.startFailed = FALLO - No pude arrancar m\u00E1quina {0}
-hostManagerServlet.cannotStopOwnHost = FALLO - No puedo para m\u00E1quina propia {0}
-hostManagerServlet.stopped = OK - M\u00E1quina {0} parada
-hostManagerServlet.stopFailed = FALLO - No pude parar m\u00E1quina {0}
-htmlHostManagerServlet.title = Gestor de M\u00E1quina Virtual de Tomcat
-htmlHostManagerServlet.messageLabel = Mensaje\:
-htmlHostManagerServlet.manager = Gestor de M\u00E1quina
-htmlHostManagerServlet.list = Lista de M\u00E1quinas Virtuales
-htmlHostManagerServlet.helpHtmlManagerFile = html-host-manager-howto.html
-htmlHostManagerServlet.helpHtmlManager = Ayuda de Gestor de M\u00E1quina HTML (\u00A1En breve\!)
-htmlHostManagerServlet.helpManagerFile = ../docs/host-manager-howto.html
-htmlHostManagerServlet.helpManager = Ayuda de Gestor de M\u00E1quina
-htmlHostManagerServlet.hostName = Nombre de M\u00E1quina
-htmlHostManagerServlet.hostAliases = Aliases de M\u00E1quina
-htmlHostManagerServlet.hostTasks = Comandos
-htmlHostManagerServlet.hostsStart = Iniciar
-htmlHostManagerServlet.hostsStop = Parar
-htmlHostManagerServlet.hostsRemove = Quitar
-htmlHostManagerServlet.addTitle = A\u00F1adir M\u00E1quina Virtual
-htmlHostManagerServlet.addHost = M\u00E1quina
-htmlHostManagerServlet.addName = Nombre\:
-htmlHostManagerServlet.addAliases = Aliases\:
-htmlHostManagerServlet.addAppBase = App base\:
-htmlHostManagerServlet.addManager = App de Gestor
-htmlHostManagerServlet.addAutoDeploy = AutoDeploy
-htmlHostManagerServlet.addDeployOnStartup = DeployOnStartup
-htmlHostManagerServlet.addDeployXML = DeployXML
-htmlHostManagerServlet.addUnpackWARs = UnpackWARs
-htmlHostManagerServlet.addXmlNamespaceAware = XmlNamespaceAware
-htmlHostManagerServlet.addXmlValidation = XmlValidation
-htmlHostManagerServlet.addButton = A\u00F1adir
-htmlHostManagerServlet.serverTitle = Informaci\u00F3n de Servidor
-htmlHostManagerServlet.serverVersion = Versi\u00F3n de Tomcat
-htmlHostManagerServlet.serverJVMVersion = Versi\u00F3n de JVM
-htmlHostManagerServlet.serverJVMVendor = Vendedor JVM
-htmlHostManagerServlet.serverOSName = Nombre de SO
-htmlHostManagerServlet.serverOSVersion = Versi\u00F3n de SO
-htmlHostManagerServlet.serverOSArch = Arquitectura de SO
-statusServlet.title = Estado de Servidor
-statusServlet.complete = Completar Estado de Servidor
Deleted: trunk/java/org/apache/catalina/mbeans/ClassNameMBean.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/ClassNameMBean.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/mbeans/ClassNameMBean.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,77 +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.mbeans;
-
-
-import javax.management.MBeanException;
-import javax.management.RuntimeOperationsException;
-
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-
-
-/**
- * <p>A convenience base class for <strong>ModelMBean</strong> implementations
- * where the underlying base class (and therefore the set of supported
- * properties) is different for varying implementations of a standard
- * interface. For Catalina, that includes at least the following:
- * Connector, Logger, Realm, and Valve. This class creates an artificial
- * MBean attribute named <code>className</code>, which reports the fully
- * qualified class name of the managed object as its value.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public class ClassNameMBean extends BaseModelMBean {
-
-
- // ---------------------------------------------------------- Constructors
-
-
- /**
- * Construct a <code>ModelMBean</code> with default
- * <code>ModelMBeanInfo</code> information.
- *
- * @exception MBeanException if the initialize of an object
- * throws an exception
- * @exception RuntimeOperationsException if an IllegalArgumentException
- * occurs
- */
- public ClassNameMBean()
- throws MBeanException, RuntimeOperationsException {
-
- super();
-
- }
-
-
- // ------------------------------------------------------------ Properties
-
-
- /**
- * Return the fully qualified Java class name of the managed object
- * for this MBean.
- */
- public String getClassName() {
-
- return (this.resource.getClass().getName());
-
- }
-
-
- }
Deleted: trunk/java/org/apache/catalina/mbeans/ConnectorMBean.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/ConnectorMBean.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/mbeans/ConnectorMBean.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,141 +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.mbeans;
-
-import javax.management.Attribute;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.ReflectionException;
-import javax.management.RuntimeOperationsException;
-import javax.management.modelmbean.InvalidTargetObjectTypeException;
-
-import org.apache.catalina.connector.Connector;
-import org.apache.tomcat.util.IntrospectionUtils;
-
-
-/**
- * <p>A <strong>ModelMBean</strong> implementation for the
- * <code>org.apache.coyote.tomcat5.CoyoteConnector</code> component.</p>
- *
- * @author Amy Roh
- * @version $Revision$ $Date$
- */
-
-public class ConnectorMBean extends ClassNameMBean {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a <code>ModelMBean</code> with default
- * <code>ModelMBeanInfo</code> information.
- *
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception RuntimeOperationsException if an IllegalArgumentException
- * occurs
- */
- public ConnectorMBean()
- throws MBeanException, RuntimeOperationsException {
-
- super();
-
- }
-
-
- // ------------------------------------------------------------- Attributes
-
-
- /**
- * Obtain and return the value of a specific attribute of this MBean.
- *
- * @param name Name of the requested attribute
- *
- * @exception AttributeNotFoundException if this attribute is not
- * supported by this MBean
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception ReflectionException if a Java reflection exception
- * occurs when invoking the getter
- */
- public Object getAttribute(String name) throws AttributeNotFoundException,
- MBeanException, ReflectionException {
-
- Object attribute = null;
- // Validate the input parameters
- if (name == null)
- throw new RuntimeOperationsException(new IllegalArgumentException(
- "Attribute name is null"), "Attribute name is null");
-
- Object result = null;
- try {
- Connector connector = (Connector) getManagedResource();
- result = IntrospectionUtils.getProperty(connector, name);
- } catch (InstanceNotFoundException e) {
- throw new MBeanException(e);
- } catch (InvalidTargetObjectTypeException e) {
- throw new MBeanException(e);
- }
-
- return result;
-
- }
-
-
- /**
- * Set the value of a specific attribute of this MBean.
- *
- * @param attribute The identification of the attribute to be set
- * and the new value
- *
- * @exception AttributeNotFoundException if this attribute is not
- * supported by this MBean
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception ReflectionException if a Java reflection exception
- * occurs when invoking the getter
- */
- public void setAttribute(Attribute attribute)
- throws AttributeNotFoundException, MBeanException,
- ReflectionException {
-
- // Validate the input parameters
- if (attribute == null)
- throw new RuntimeOperationsException(new IllegalArgumentException(
- "Attribute is null"), "Attribute is null");
- String name = attribute.getName();
- Object value = attribute.getValue();
- if (name == null)
- throw new RuntimeOperationsException(new IllegalArgumentException(
- "Attribute name is null"), "Attribute name is null");
-
- try {
- Connector connector = (Connector) getManagedResource();
- IntrospectionUtils.setProperty(connector, name, String.valueOf(value));
- } catch (InstanceNotFoundException e) {
- throw new MBeanException(e);
- } catch (InvalidTargetObjectTypeException e) {
- throw new MBeanException(e);
- }
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/mbeans/ContextEnvironmentMBean.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,106 +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.mbeans;
-
-
-import javax.management.Attribute;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.ReflectionException;
-import javax.management.RuntimeOperationsException;
-import javax.management.modelmbean.InvalidTargetObjectTypeException;
-
-import org.apache.catalina.deploy.ContextEnvironment;
-import org.apache.catalina.deploy.NamingResources;
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-
-
-/**
- * <p>A <strong>ModelMBean</strong> implementation for the
- * <code>org.apache.catalina.deploy.ContextEnvironment</code> component.</p>
- *
- * @author Amy Roh
- * @version $Revision$ $Date$
- */
-
-public class ContextEnvironmentMBean extends BaseModelMBean {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a <code>ModelMBean</code> with default
- * <code>ModelMBeanInfo</code> information.
- *
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception RuntimeOperationsException if an IllegalArgumentException
- * occurs
- */
- public ContextEnvironmentMBean()
- throws MBeanException, RuntimeOperationsException {
-
- super();
-
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- // ------------------------------------------------------------- Attributes
-
-
- /**
- * Set the value of a specific attribute of this MBean.
- *
- * @param attribute The identification of the attribute to be set
- * and the new value
- *
- * @exception AttributeNotFoundException if this attribute is not
- * supported by this MBean
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception ReflectionException if a Java reflection exception
- * occurs when invoking the getter
- */
- public void setAttribute(Attribute attribute)
- throws AttributeNotFoundException, MBeanException,
- ReflectionException {
-
- super.setAttribute(attribute);
-
- ContextEnvironment ce = null;
- try {
- ce = (ContextEnvironment) getManagedResource();
- } catch (InstanceNotFoundException e) {
- throw new MBeanException(e);
- } catch (InvalidTargetObjectTypeException e) {
- throw new MBeanException(e);
- }
-
- // cannot use side-efects. It's removed and added back each time
- // there is a modification in a resource.
- NamingResources nr = ce.getNamingResources();
- nr.removeEnvironment(ce.getName());
- nr.addEnvironment(ce);
- }
-
-}
Deleted: trunk/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/mbeans/ContextResourceLinkMBean.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,106 +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.mbeans;
-
-
-import javax.management.Attribute;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.ReflectionException;
-import javax.management.RuntimeOperationsException;
-import javax.management.modelmbean.InvalidTargetObjectTypeException;
-
-import org.apache.catalina.deploy.ContextResourceLink;
-import org.apache.catalina.deploy.NamingResources;
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-
-
-/**
- * <p>A <strong>ModelMBean</strong> implementation for the
- * <code>org.apache.catalina.deploy.ContextResourceLink</code> component.</p>
- *
- * @author Amy Roh
- * @version $Revision$ $Date$
- */
-
-public class ContextResourceLinkMBean extends BaseModelMBean {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a <code>ModelMBean</code> with default
- * <code>ModelMBeanInfo</code> information.
- *
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception RuntimeOperationsException if an IllegalArgumentException
- * occurs
- */
- public ContextResourceLinkMBean()
- throws MBeanException, RuntimeOperationsException {
-
- super();
-
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- // ------------------------------------------------------------- Attributes
-
-
- /**
- * Set the value of a specific attribute of this MBean.
- *
- * @param attribute The identification of the attribute to be set
- * and the new value
- *
- * @exception AttributeNotFoundException if this attribute is not
- * supported by this MBean
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception ReflectionException if a Java reflection exception
- * occurs when invoking the getter
- */
- public void setAttribute(Attribute attribute)
- throws AttributeNotFoundException, MBeanException,
- ReflectionException {
-
- super.setAttribute(attribute);
-
- ContextResourceLink crl = null;
- try {
- crl = (ContextResourceLink) getManagedResource();
- } catch (InstanceNotFoundException e) {
- throw new MBeanException(e);
- } catch (InvalidTargetObjectTypeException e) {
- throw new MBeanException(e);
- }
-
- // cannot use side-efects. It's removed and added back each time
- // there is a modification in a resource.
- NamingResources nr = crl.getNamingResources();
- nr.removeResourceLink(crl.getName());
- nr.addResourceLink(crl);
- }
-
-}
Deleted: trunk/java/org/apache/catalina/mbeans/ContextResourceMBean.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/ContextResourceMBean.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/mbeans/ContextResourceMBean.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,185 +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.mbeans;
-
-
-import javax.management.Attribute;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.ReflectionException;
-import javax.management.RuntimeOperationsException;
-import javax.management.modelmbean.InvalidTargetObjectTypeException;
-
-import org.apache.catalina.deploy.ContextResource;
-import org.apache.catalina.deploy.NamingResources;
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-
-
-/**
- * <p>A <strong>ModelMBean</strong> implementation for the
- * <code>org.apache.catalina.deploy.ContextResource</code> component.</p>
- *
- * @author Amy Roh
- * @version $Revision$ $Date$
- */
-
-public class ContextResourceMBean extends BaseModelMBean {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a <code>ModelMBean</code> with default
- * <code>ModelMBeanInfo</code> information.
- *
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception RuntimeOperationsException if an IllegalArgumentException
- * occurs
- */
- public ContextResourceMBean()
- throws MBeanException, RuntimeOperationsException {
-
- super();
-
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- // ------------------------------------------------------------- Attributes
-
-
- /**
- * Obtain and return the value of a specific attribute of this MBean.
- *
- * @param name Name of the requested attribute
- *
- * @exception AttributeNotFoundException if this attribute is not
- * supported by this MBean
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception ReflectionException if a Java reflection exception
- * occurs when invoking the getter
- */
- public Object getAttribute(String name)
- throws AttributeNotFoundException, MBeanException,
- ReflectionException {
-
- // Validate the input parameters
- if (name == null)
- throw new RuntimeOperationsException
- (new IllegalArgumentException("Attribute name is null"),
- "Attribute name is null");
-
- ContextResource cr = null;
- try {
- cr = (ContextResource) getManagedResource();
- } catch (InstanceNotFoundException e) {
- throw new MBeanException(e);
- } catch (InvalidTargetObjectTypeException e) {
- throw new MBeanException(e);
- }
-
- String value = null;
- if ("auth".equals(name)) {
- return (cr.getAuth());
- } else if ("description".equals(name)) {
- return (cr.getDescription());
- } else if ("name".equals(name)) {
- return (cr.getName());
- } else if ("scope".equals(name)) {
- return (cr.getScope());
- } else if ("type".equals(name)) {
- return (cr.getType());
- } else {
- value = (String) cr.getProperty(name);
- if (value == null) {
- throw new AttributeNotFoundException
- ("Cannot find attribute "+name);
- }
- }
-
- return value;
-
- }
-
-
- /**
- * Set the value of a specific attribute of this MBean.
- *
- * @param attribute The identification of the attribute to be set
- * and the new value
- *
- * @exception AttributeNotFoundException if this attribute is not
- * supported by this MBean
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception ReflectionException if a Java reflection exception
- * occurs when invoking the getter
- */
- public void setAttribute(Attribute attribute)
- throws AttributeNotFoundException, MBeanException,
- ReflectionException {
-
- // Validate the input parameters
- if (attribute == null)
- throw new RuntimeOperationsException
- (new IllegalArgumentException("Attribute is null"),
- "Attribute is null");
- String name = attribute.getName();
- Object value = attribute.getValue();
- if (name == null)
- throw new RuntimeOperationsException
- (new IllegalArgumentException("Attribute name is null"),
- "Attribute name is null");
-
- ContextResource cr = null;
- try {
- cr = (ContextResource) getManagedResource();
- } catch (InstanceNotFoundException e) {
- throw new MBeanException(e);
- } catch (InvalidTargetObjectTypeException e) {
- throw new MBeanException(e);
- }
-
- if ("auth".equals(name)) {
- cr.setAuth((String)value);
- } else if ("description".equals(name)) {
- cr.setDescription((String)value);
- } else if ("name".equals(name)) {
- cr.setName((String)value);
- } else if ("scope".equals(name)) {
- cr.setScope((String)value);
- } else if ("type".equals(name)) {
- cr.setType((String)value);
- } else {
- cr.setProperty(name, ""+value);
- }
-
- // cannot use side-efects. It's removed and added back each time
- // there is a modification in a resource.
- NamingResources nr = cr.getNamingResources();
- nr.removeResource(cr.getName());
- nr.addResource(cr);
- }
-
-}
Deleted: trunk/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/mbeans/GlobalResourcesLifecycleListener.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,163 +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.mbeans;
-
-
-import javax.naming.Binding;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.OperationNotSupportedException;
-
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.LifecycleListener;
-import org.apache.tomcat.util.modeler.Registry;
-import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
-
-
-/**
- * Implementation of <code>LifecycleListener</code> that instantiates the
- * set of MBeans associated with global JNDI resources that are subject to
- * management.
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * @since 4.1
- */
-
-public class GlobalResourcesLifecycleListener
- implements LifecycleListener {
- private static Logger log = Logger.getLogger(GlobalResourcesLifecycleListener.class);
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The owning Catalina component that we are attached to.
- */
- protected Lifecycle component = null;
-
-
- /**
- * The configuration information registry for our managed beans.
- */
- protected static Registry registry = MBeanUtils.createRegistry();
-
-
- // ---------------------------------------------- LifecycleListener Methods
-
-
- /**
- * Primary entry point for startup and shutdown events.
- *
- * @param event The event that has occurred
- */
- public void lifecycleEvent(LifecycleEvent event) {
-
- if (Lifecycle.START_EVENT.equals(event.getType())) {
- component = event.getLifecycle();
- createMBeans();
- } else if (Lifecycle.STOP_EVENT.equals(event.getType())) {
- destroyMBeans();
- component = null;
- }
-
- }
-
-
- // ------------------------------------------------------ Protected Methods
-
-
- /**
- * Create the MBeans for the interesting global JNDI resources.
- */
- protected void createMBeans() {
-
- // Look up our global naming context
- Context context = null;
- try {
- context = (Context) (new InitialContext()).lookup("java:/");
- } catch (NamingException e) {
- log.error("No global naming context defined for server");
- return;
- }
-
- // Recurse through the defined global JNDI resources context
- try {
- createMBeans("", context);
- } catch (NamingException e) {
- log.error("Exception processing Global JNDI Resources", e);
- }
-
- }
-
-
- /**
- * Create the MBeans for the interesting global JNDI resources in
- * the specified naming context.
- *
- * @param prefix Prefix for complete object name paths
- * @param context Context to be scanned
- *
- * @exception NamingException if a JNDI exception occurs
- */
- protected void createMBeans(String prefix, Context context)
- throws NamingException {
-
- if (log.isDebugEnabled()) {
- log.debug("Creating MBeans for Global JNDI Resources in Context '" +
- prefix + "'");
- }
-
- try {
- NamingEnumeration bindings = context.listBindings("");
- while (bindings.hasMore()) {
- Binding binding = (Binding) bindings.next();
- String name = prefix + binding.getName();
- Object value = context.lookup(binding.getName());
- if (log.isDebugEnabled()) {
- log.debug("Checking resource " + name);
- }
- if (value instanceof Context) {
- createMBeans(name + "/", (Context) value);
- }
- }
- } catch( RuntimeException ex) {
- log.error("RuntimeException " + ex);
- } catch( OperationNotSupportedException ex) {
- log.error("Operation not supported " + ex);
- }
-
- }
-
-
- /**
- * Destroy the MBeans for the interesting global JNDI resources.
- */
- protected void destroyMBeans() {
-
- if (log.isDebugEnabled()) {
- log.debug("Destroying MBeans for Global JNDI Resources");
- }
-
- }
-
-}
Deleted: trunk/java/org/apache/catalina/mbeans/MBeanFactory.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/MBeanFactory.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/mbeans/MBeanFactory.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,960 +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.mbeans;
-
-import java.io.File;
-
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.RuntimeOperationsException;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Host;
-import org.apache.catalina.Server;
-import org.apache.catalina.Service;
-import org.apache.catalina.Valve;
-import org.apache.catalina.authenticator.SingleSignOn;
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.core.ContainerBase;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.core.StandardEngine;
-import org.apache.catalina.core.StandardHost;
-import org.apache.catalina.core.StandardService;
-import org.apache.catalina.loader.WebappLoader;
-import org.apache.catalina.realm.DataSourceRealm;
-import org.apache.catalina.realm.JDBCRealm;
-import org.apache.catalina.realm.JNDIRealm;
-import org.apache.catalina.realm.MemoryRealm;
-import org.apache.catalina.session.StandardManager;
-import org.apache.catalina.startup.ContextConfig;
-import org.apache.catalina.startup.HostConfig;
-import org.apache.catalina.valves.AccessLogValve;
-import org.apache.catalina.valves.RemoteAddrValve;
-import org.apache.catalina.valves.RemoteHostValve;
-import org.apache.catalina.valves.RequestDumperValve;
-import org.apache.catalina.valves.ValveBase;
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-import org.apache.tomcat.util.modeler.Registry;
-
-
-/**
- * <p>A <strong>ModelMBean</strong> implementation for the
- * <code>org.apache.catalina.core.StandardServer</code> component.</p>
- *
- * @author Amy Roh
- * @version $Revision$ $Date$
- */
-
-public class MBeanFactory extends BaseModelMBean {
-
- private static org.jboss.logging.Logger log =
- org.jboss.logging.Logger.getLogger(MBeanFactory.class);
-
- /**
- * The <code>MBeanServer</code> for this application.
- */
- private static MBeanServer mserver = MBeanUtils.createServer();
-
- /**
- * The configuration information registry for our managed beans.
- */
- private static Registry registry = MBeanUtils.createRegistry();
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a <code>ModelMBean</code> with default
- * <code>ModelMBeanInfo</code> information.
- *
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception RuntimeOperationsException if an IllegalArgumentException
- * occurs
- */
- public MBeanFactory()
- throws MBeanException, RuntimeOperationsException {
-
- super();
-
- }
-
-
- // ------------------------------------------------------------- Attributes
-
- /**
- * The container (Server/Service) for which this factory was created.
- */
- private Object container;
-
-
- // ------------------------------------------------------------- Operations
-
- /**
- * Set the container that this factory was created for.
- */
- public void setContainer(Object container) {
- this.container = container;
- }
-
-
- /**
- * Return the managed bean definition for the specified bean type
- *
- * @param type MBean type
- */
- public String findObjectName(String type) {
-
- if (type.equals("org.apache.catalina.core.StandardContext")) {
- return "StandardContext";
- } else if (type.equals("org.apache.catalina.core.StandardEngine")) {
- return "Engine";
- } else if (type.equals("org.apache.catalina.core.StandardHost")) {
- return "Host";
- } else {
- return null;
- }
-
- }
-
-
- /**
- * Little convenience method to remove redundant code
- * when retrieving the path string
- *
- * @param t path string
- * @return empty string if t==null || t.equals("/")
- */
- private final String getPathStr(String t) {
- if (t == null || t.equals("/")) {
- return "";
- }
- return t;
- }
-
- /**
- * Get Parent ContainerBase to add its child component
- * from parent's ObjectName
- */
- private ContainerBase getParentContainerFromParent(ObjectName pname)
- throws Exception {
-
- String type = pname.getKeyProperty("type");
- String j2eeType = pname.getKeyProperty("j2eeType");
- Service service = getService(pname);
- StandardEngine engine = (StandardEngine) service.getContainer();
- if ((j2eeType!=null) && (j2eeType.equals("WebModule"))) {
- String name = pname.getKeyProperty("name");
- name = name.substring(2);
- int i = name.indexOf("/");
- String hostName = name.substring(0,i);
- String path = name.substring(i);
- Host host = (Host) engine.findChild(hostName);
- String pathStr = getPathStr(path);
- StandardContext context = (StandardContext)host.findChild(pathStr);
- return context;
- } else if (type != null) {
- if (type.equals("Engine")) {
- return engine;
- } else if (type.equals("Host")) {
- String hostName = pname.getKeyProperty("host");
- StandardHost host = (StandardHost) engine.findChild(hostName);
- return host;
- }
- }
- return null;
-
- }
-
-
- /**
- * Get Parent ContainerBase to add its child component
- * from child component's ObjectName as a String
- */
- private ContainerBase getParentContainerFromChild(ObjectName oname)
- throws Exception {
-
- String hostName = oname.getKeyProperty("host");
- String path = oname.getKeyProperty("path");
- Service service = getService(oname);
- StandardEngine engine = (StandardEngine) service.getContainer();
- if (hostName == null) {
- // child's container is Engine
- return engine;
- } else if (path == null) {
- // child's container is Host
- StandardHost host = (StandardHost) engine.findChild(hostName);
- return host;
- } else {
- // child's container is Context
- StandardHost host = (StandardHost) engine.findChild(hostName);
- path = getPathStr(path);
- StandardContext context = (StandardContext) host.findChild(path);
- return context;
- }
- }
-
-
- private Service getService(ObjectName oname) throws Exception {
-
- if (container instanceof Service) {
- // Don't bother checking the domain - this is the only option
- return (Service) container;
- }
-
- StandardService service = null;
- String domain = oname.getDomain();
- if (container instanceof Server) {
- Service[] services = ((Server)container).findServices();
- for (int i = 0; i < services.length; i++) {
- service = (StandardService) services[i];
- if (domain.equals(service.getObjectName().getDomain())) {
- break;
- }
- }
- }
- if (service == null ||
- !service.getObjectName().getDomain().equals(domain)) {
- throw new Exception("Service with the domain is not found");
- }
- return service;
-
- }
-
-
- /**
- * Create a new AccessLoggerValve.
- *
- * @param parent MBean Name of the associated parent component
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createAccessLoggerValve(String parent)
- throws Exception {
-
- ObjectName pname = new ObjectName(parent);
- // Create a new AccessLogValve instance
- AccessLogValve accessLogger = new AccessLogValve();
- ContainerBase containerBase = getParentContainerFromParent(pname);
- // Add the new instance to its parent component
- containerBase.addValve(accessLogger);
- ObjectName oname = accessLogger.getObjectName();
- return (oname.toString());
-
- }
-
-
- /**
- * Create a new AjpConnector
- *
- * @param parent MBean Name of the associated parent component
- * @param address The IP address on which to bind
- * @param port TCP port number to listen on
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createAjpConnector(String parent, String address, int port)
- throws Exception {
-
- return createConnector(parent, address, port, true, false);
- }
-
- /**
- * Create a new DataSource Realm.
- *
- * @param parent MBean Name of the associated parent component
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createDataSourceRealm(String parent, String dataSourceName,
- String roleNameCol, String userCredCol, String userNameCol,
- String userRoleTable, String userTable) throws Exception {
-
- // Create a new DataSourceRealm instance
- DataSourceRealm realm = new DataSourceRealm();
- realm.setDataSourceName(dataSourceName);
- realm.setRoleNameCol(roleNameCol);
- realm.setUserCredCol(userCredCol);
- realm.setUserNameCol(userNameCol);
- realm.setUserRoleTable(userRoleTable);
- realm.setUserTable(userTable);
-
- // Add the new instance to its parent component
- ObjectName pname = new ObjectName(parent);
- ContainerBase containerBase = getParentContainerFromParent(pname);
- // Add the new instance to its parent component
- containerBase.setRealm(realm);
- // Return the corresponding MBean name
- ObjectName oname = realm.getObjectName();
- if (oname != null) {
- return (oname.toString());
- } else {
- return null;
- }
-
- }
-
- /**
- * Create a new HttpConnector
- *
- * @param parent MBean Name of the associated parent component
- * @param address The IP address on which to bind
- * @param port TCP port number to listen on
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createHttpConnector(String parent, String address, int port)
- throws Exception {
- return createConnector(parent, address, port, false, false);
- }
-
- /**
- * Create a new Connector
- *
- * @param parent MBean Name of the associated parent component
- * @param address The IP address on which to bind
- * @param port TCP port number to listen on
- * @param isAjp Create a AJP/1.3 Connector
- * @param isSSL Create a secure Connector
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- private String createConnector(String parent, String address, int port, boolean isAjp, boolean isSSL)
- throws Exception {
- Connector retobj = new Connector();
- if ((address!=null) && (address.length()>0)) {
- retobj.setProperty("address", address);
- }
- // Set port number
- retobj.setPort(port);
- // Set the protocol
- retobj.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
- // Set SSL
- retobj.setSecure(isSSL);
- retobj.setScheme(isSSL ? "https" : "http");
- // Add the new instance to its parent component
- // FIX ME - addConnector will fail
- ObjectName pname = new ObjectName(parent);
- Service service = getService(pname);
- service.addConnector(retobj);
-
- // Return the corresponding MBean name
- ObjectName coname = retobj.getObjectName();
-
- return (coname.toString());
- }
-
-
- /**
- * Create a new HttpsConnector
- *
- * @param parent MBean Name of the associated parent component
- * @param address The IP address on which to bind
- * @param port TCP port number to listen on
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createHttpsConnector(String parent, String address, int port)
- throws Exception {
- return createConnector(parent, address, port, false, true);
- }
-
- /**
- * Create a new JDBC Realm.
- *
- * @param parent MBean Name of the associated parent component
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createJDBCRealm(String parent, String driverName,
- String connectionName, String connectionPassword, String connectionURL)
- throws Exception {
-
- // Create a new JDBCRealm instance
- JDBCRealm realm = new JDBCRealm();
- realm.setDriverName(driverName);
- realm.setConnectionName(connectionName);
- realm.setConnectionPassword(connectionPassword);
- realm.setConnectionURL(connectionURL);
-
- // Add the new instance to its parent component
- ObjectName pname = new ObjectName(parent);
- ContainerBase containerBase = getParentContainerFromParent(pname);
- // Add the new instance to its parent component
- containerBase.setRealm(realm);
- // Return the corresponding MBean name
- ObjectName oname = realm.getObjectName();
-
- if (oname != null) {
- return (oname.toString());
- } else {
- return null;
- }
-
- }
-
-
- /**
- * Create a new JNDI Realm.
- *
- * @param parent MBean Name of the associated parent component
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createJNDIRealm(String parent)
- throws Exception {
-
- // Create a new JNDIRealm instance
- JNDIRealm realm = new JNDIRealm();
-
- // Add the new instance to its parent component
- ObjectName pname = new ObjectName(parent);
- ContainerBase containerBase = getParentContainerFromParent(pname);
- // Add the new instance to its parent component
- containerBase.setRealm(realm);
- // Return the corresponding MBean name
- ObjectName oname = realm.getObjectName();
-
- if (oname != null) {
- return (oname.toString());
- } else {
- return null;
- }
-
-
- }
-
-
- /**
- * Create a new Memory Realm.
- *
- * @param parent MBean Name of the associated parent component
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createMemoryRealm(String parent)
- throws Exception {
-
- // Create a new MemoryRealm instance
- MemoryRealm realm = new MemoryRealm();
-
- // Add the new instance to its parent component
- ObjectName pname = new ObjectName(parent);
- ContainerBase containerBase = getParentContainerFromParent(pname);
- // Add the new instance to its parent component
- containerBase.setRealm(realm);
- // Return the corresponding MBean name
- ObjectName oname = realm.getObjectName();
- if (oname != null) {
- return (oname.toString());
- } else {
- return null;
- }
-
- }
-
-
- /**
- * Create a new Remote Address Filter Valve.
- *
- * @param parent MBean Name of the associated parent component
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createRemoteAddrValve(String parent)
- throws Exception {
-
- // Create a new RemoteAddrValve instance
- RemoteAddrValve valve = new RemoteAddrValve();
-
- // Add the new instance to its parent component
- ObjectName pname = new ObjectName(parent);
- ContainerBase containerBase = getParentContainerFromParent(pname);
- containerBase.addValve(valve);
- ObjectName oname = valve.getObjectName();
- return (oname.toString());
-
- }
-
-
- /**
- * Create a new Remote Host Filter Valve.
- *
- * @param parent MBean Name of the associated parent component
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createRemoteHostValve(String parent)
- throws Exception {
-
- // Create a new RemoteHostValve instance
- RemoteHostValve valve = new RemoteHostValve();
-
- // Add the new instance to its parent component
- ObjectName pname = new ObjectName(parent);
- ContainerBase containerBase = getParentContainerFromParent(pname);
- containerBase.addValve(valve);
- ObjectName oname = valve.getObjectName();
- return (oname.toString());
-
- }
-
-
- /**
- * Create a new Request Dumper Valve.
- *
- * @param parent MBean Name of the associated parent component
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createRequestDumperValve(String parent)
- throws Exception {
-
- // Create a new RequestDumperValve instance
- RequestDumperValve valve = new RequestDumperValve();
-
- // Add the new instance to its parent component
- ObjectName pname = new ObjectName(parent);
- ContainerBase containerBase = getParentContainerFromParent(pname);
- containerBase.addValve(valve);
- ObjectName oname = valve.getObjectName();
- return (oname.toString());
-
- }
-
-
- /**
- * Create a new Single Sign On Valve.
- *
- * @param parent MBean Name of the associated parent component
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createSingleSignOn(String parent)
- throws Exception {
-
- // Create a new SingleSignOn instance
- SingleSignOn valve = new SingleSignOn();
-
- // Add the new instance to its parent component
- ObjectName pname = new ObjectName(parent);
- ContainerBase containerBase = getParentContainerFromParent(pname);
- containerBase.addValve(valve);
- ObjectName oname = valve.getObjectName();
- return (oname.toString());
-
- }
-
-
- /**
- * Create a new StandardContext.
- *
- * @param parent MBean Name of the associated parent component
- * @param path The context path for this Context
- * @param docBase Document base directory (or WAR) for this Context
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createStandardContext(String parent,
- String path,
- String docBase)
- throws Exception {
-
- // XXX for backward compatibility. Remove it once supported by the admin
- return
- createStandardContext(parent,path,docBase,false,false,false,false);
- }
-
- /**
- * Given a context path, get the config file name.
- */
- private String getConfigFile(String path) {
- String basename = null;
- if (path.equals("")) {
- basename = "ROOT";
- } else {
- basename = path.substring(1).replace('/', '#');
- }
- return (basename);
- }
-
- /**
- * Create a new StandardContext.
- *
- * @param parent MBean Name of the associated parent component
- * @param path The context path for this Context
- * @param docBase Document base directory (or WAR) for this Context
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createStandardContext(String parent,
- String path,
- String docBase,
- boolean xmlValidation,
- boolean xmlNamespaceAware,
- boolean tldValidation,
- boolean tldNamespaceAware)
- throws Exception {
-
- // Create a new StandardContext instance
- StandardContext context = new StandardContext();
- path = getPathStr(path);
- context.setPath(path);
- context.setDocBase(docBase);
-
- ContextConfig contextConfig = new ContextConfig();
- context.addLifecycleListener(contextConfig);
-
- // Add the new instance to its parent component
- ObjectName pname = new ObjectName(parent);
- ObjectName deployer = new ObjectName(pname.getDomain()+
- ":type=Deployer,host="+
- pname.getKeyProperty("host"));
- if(mserver.isRegistered(deployer)) {
- String contextPath = context.getPath();
- mserver.invoke(deployer, "addServiced",
- new Object [] {contextPath},
- new String [] {"java.lang.String"});
- String configPath = (String)mserver.getAttribute(deployer,
- "configBaseName");
- String baseName = getConfigFile(contextPath);
- File configFile = new File(new File(configPath), baseName+".xml");
- context.setConfigFile(configFile.getAbsolutePath());
- mserver.invoke(deployer, "manageApp",
- new Object[] {context},
- new String[] {"org.apache.catalina.Context"});
- mserver.invoke(deployer, "removeServiced",
- new Object [] {contextPath},
- new String [] {"java.lang.String"});
- } else {
- log.warn("Deployer not found for "+pname.getKeyProperty("host"));
- Service service = getService(pname);
- Engine engine = (Engine) service.getContainer();
- Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
- host.addChild(context);
- }
-
- // Return the corresponding MBean name
- ObjectName oname = context.getJmxName();
-
- return (oname.toString());
-
- }
-
-
- /**
- * Create a new StandardHost.
- *
- * @param parent MBean Name of the associated parent component
- * @param name Unique name of this Host
- * @param appBase Application base directory name
- * @param autoDeploy Should we auto deploy?
- * @param deployOnStartup Deploy on server startup?
- * @param deployXML Should we deploy Context XML config files property?
- * @param unpackWARs Should we unpack WARs when auto deploying?
- * @param xmlNamespaceAware Should we turn on/off XML namespace awareness?
- * @param xmlValidation Should we turn on/off XML validation?
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createStandardHost(String parent, String name,
- String appBase,
- boolean autoDeploy,
- boolean deployOnStartup,
- boolean deployXML,
- boolean unpackWARs,
- boolean xmlNamespaceAware,
- boolean xmlValidation)
- throws Exception {
-
- // Create a new StandardHost instance
- StandardHost host = new StandardHost();
- host.setName(name);
- host.setAppBase(appBase);
- host.setAutoDeploy(autoDeploy);
- host.setDeployOnStartup(deployOnStartup);
- host.setDeployXML(deployXML);
- host.setUnpackWARs(unpackWARs);
-
- // add HostConfig for active reloading
- HostConfig hostConfig = new HostConfig();
- host.addLifecycleListener(hostConfig);
-
- // Add the new instance to its parent component
- ObjectName pname = new ObjectName(parent);
- Service service = getService(pname);
- Engine engine = (Engine) service.getContainer();
- engine.addChild(host);
-
- // Return the corresponding MBean name
- return (host.getObjectName().toString());
-
- }
-
-
- /**
- * Create a new StandardManager.
- *
- * @param parent MBean Name of the associated parent component
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createStandardManager(String parent)
- throws Exception {
-
- // Create a new StandardManager instance
- StandardManager manager = new StandardManager();
-
- // Add the new instance to its parent component
- ObjectName pname = new ObjectName(parent);
- ContainerBase containerBase = getParentContainerFromParent(pname);
- if (containerBase != null) {
- containerBase.setManager(manager);
- }
- ObjectName oname = manager.getObjectName();
- if (oname != null) {
- return (oname.toString());
- } else {
- return null;
- }
-
- }
-
-
- /**
- * Create a new Web Application Loader.
- *
- * @param parent MBean Name of the associated parent component
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- public String createWebappLoader(String parent)
- throws Exception {
-
- // Create a new WebappLoader instance
- WebappLoader loader = new WebappLoader();
-
- // Add the new instance to its parent component
- ObjectName pname = new ObjectName(parent);
- ContainerBase containerBase = getParentContainerFromParent(pname);
- if (containerBase != null) {
- containerBase.setLoader(loader);
- }
- // FIXME add Loader.getObjectName
- //ObjectName oname = loader.getObjectName();
- ObjectName oname =
- MBeanUtils.createObjectName(pname.getDomain(), loader);
- return (oname.toString());
-
- }
-
-
- /**
- * Remove an existing Connector.
- *
- * @param name MBean Name of the component to remove
- *
- * @exception Exception if a component cannot be removed
- */
- public void removeConnector(String name) throws Exception {
-
- // Acquire a reference to the component to be removed
- ObjectName oname = new ObjectName(name);
- Service service = getService(oname);
- String port = oname.getKeyProperty("port");
- //String address = oname.getKeyProperty("address");
-
- Connector conns[] = (Connector[]) service.findConnectors();
-
- for (int i = 0; i < conns.length; i++) {
- String connAddress = String.valueOf(conns[i].getProperty("address"));
- String connPort = ""+conns[i].getPort();
-
- // if (((address.equals("null")) &&
- if ((connAddress==null) && port.equals(connPort)) {
- service.removeConnector(conns[i]);
- conns[i].destroy();
- break;
- }
- // } else if (address.equals(connAddress))
- if (port.equals(connPort)) {
- // Remove this component from its parent component
- service.removeConnector(conns[i]);
- conns[i].destroy();
- break;
- }
- }
-
- }
-
-
- /**
- * Remove an existing Context.
- *
- * @param contextName MBean Name of the comonent to remove
- *
- * @exception Exception if a component cannot be removed
- */
- public void removeContext(String contextName) throws Exception {
-
- // Acquire a reference to the component to be removed
- ObjectName oname = new ObjectName(contextName);
- String domain = oname.getDomain();
- StandardService service = (StandardService) getService(oname);
-
- Engine engine = (Engine) service.getContainer();
- String name = oname.getKeyProperty("name");
- name = name.substring(2);
- int i = name.indexOf("/");
- String hostName = name.substring(0,i);
- String path = name.substring(i);
- ObjectName deployer = new ObjectName(domain+":type=Deployer,host="+
- hostName);
- String pathStr = getPathStr(path);
- if(mserver.isRegistered(deployer)) {
- mserver.invoke(deployer,"addServiced",
- new Object[]{pathStr},
- new String[] {"java.lang.String"});
- mserver.invoke(deployer,"unmanageApp",
- new Object[] {pathStr},
- new String[] {"java.lang.String"});
- mserver.invoke(deployer,"removeServiced",
- new Object[] {pathStr},
- new String[] {"java.lang.String"});
- } else {
- log.warn("Deployer not found for "+hostName);
- Host host = (Host) engine.findChild(hostName);
- Context context = (Context) host.findChild(pathStr);
- // Remove this component from its parent component
- host.removeChild(context);
- if(context instanceof StandardContext)
- try {
- ((StandardContext)context).destroy();
- } catch (Exception e) {
- log.warn("Error during context [" + context.getName() + "] destroy ", e);
- }
-
- }
-
- }
-
-
- /**
- * Remove an existing Host.
- *
- * @param name MBean Name of the comonent to remove
- *
- * @exception Exception if a component cannot be removed
- */
- public void removeHost(String name) throws Exception {
-
- // Acquire a reference to the component to be removed
- ObjectName oname = new ObjectName(name);
- String hostName = oname.getKeyProperty("host");
- Service service = getService(oname);
- Engine engine = (Engine) service.getContainer();
- Host host = (Host) engine.findChild(hostName);
-
- // Remove this component from its parent component
- if(host!=null) {
- if(host instanceof StandardHost)
- ((StandardHost)host).destroy();
- else
- engine.removeChild(host);
- }
-
- }
-
-
- /**
- * Remove an existing Loader.
- *
- * @param name MBean Name of the comonent to remove
- *
- * @exception Exception if a component cannot be removed
- */
- public void removeLoader(String name) throws Exception {
-
- ObjectName oname = new ObjectName(name);
- // Acquire a reference to the component to be removed
- ContainerBase container = getParentContainerFromChild(oname);
- container.setLoader(null);
-
- }
-
-
- /**
- * Remove an existing Manager.
- *
- * @param name MBean Name of the comonent to remove
- *
- * @exception Exception if a component cannot be removed
- */
- public void removeManager(String name) throws Exception {
-
- ObjectName oname = new ObjectName(name);
- // Acquire a reference to the component to be removed
- ContainerBase container = getParentContainerFromChild(oname);
- container.setManager(null);
-
- }
-
-
- /**
- * Remove an existing Realm.
- *
- * @param name MBean Name of the comonent to remove
- *
- * @exception Exception if a component cannot be removed
- */
- public void removeRealm(String name) throws Exception {
-
- ObjectName oname = new ObjectName(name);
- // Acquire a reference to the component to be removed
- ContainerBase container = getParentContainerFromChild(oname);
- container.setRealm(null);
- }
-
-
- /**
- * Remove an existing Valve.
- *
- * @param name MBean Name of the comonent to remove
- *
- * @exception Exception if a component cannot be removed
- */
- public void removeValve(String name) throws Exception {
-
- // Acquire a reference to the component to be removed
- ObjectName oname = new ObjectName(name);
- ContainerBase container = getParentContainerFromChild(oname);
- String sequence = oname.getKeyProperty("seq");
- Valve[] valves = (Valve[])container.getValves();
- for (int i = 0; i < valves.length; i++) {
- ObjectName voname = ((ValveBase) valves[i]).getObjectName();
- if (voname.equals(oname)) {
- container.removeValve(valves[i]);
- }
- }
- }
-
-}
-
Deleted: trunk/java/org/apache/catalina/mbeans/MBeanUtils.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/MBeanUtils.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/mbeans/MBeanUtils.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,1582 +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.mbeans;
-
-
-import java.util.Hashtable;
-import java.util.Set;
-
-import javax.management.DynamicMBean;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.catalina.Contained;
-import org.apache.catalina.Container;
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Host;
-import org.apache.catalina.Loader;
-import org.apache.catalina.Manager;
-import org.apache.catalina.Realm;
-import org.apache.catalina.Server;
-import org.apache.catalina.Service;
-import org.apache.catalina.Valve;
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.deploy.ContextEnvironment;
-import org.apache.catalina.deploy.ContextResource;
-import org.apache.catalina.deploy.ContextResourceLink;
-import org.apache.catalina.deploy.NamingResources;
-import org.apache.catalina.valves.ValveBase;
-import org.apache.coyote.ProtocolHandler;
-import org.apache.coyote.ajp.AjpAprProtocol;
-import org.apache.coyote.ajp.AjpProtocol;
-import org.apache.coyote.http11.Http11AprProtocol;
-import org.apache.coyote.http11.Http11Protocol;
-import org.apache.tomcat.util.IntrospectionUtils;
-import org.apache.tomcat.util.modeler.ManagedBean;
-import org.apache.tomcat.util.modeler.Registry;
-import org.jboss.logging.Logger;
-
-
-/**
- * Public utility methods in support of the server side MBeans implementation.
- *
- * @author Craig R. McClanahan
- * @author Amy Roh
- * @version $Revision$ $Date$
- */
-
-public class MBeanUtils {
- private static Logger log = Logger.getLogger(MBeanUtils.class);
-
- // ------------------------------------------------------- Static Variables
-
-
- /**
- * The set of exceptions to the normal rules used by
- * <code>createManagedBean()</code>. The first element of each pair
- * is a class name, and the second element is the managed bean name.
- */
- private static String exceptions[][] = {
- { "org.apache.ajp.tomcat4.Ajp13Connector",
- "Ajp13Connector" },
- { "org.apache.coyote.tomcat4.Ajp13Connector",
- "CoyoteConnector" },
- { "org.apache.catalina.users.JDBCGroup",
- "Group" },
- { "org.apache.catalina.users.JDBCRole",
- "Role" },
- { "org.apache.catalina.users.JDBCUser",
- "User" },
- { "org.apache.catalina.users.MemoryGroup",
- "Group" },
- { "org.apache.catalina.users.MemoryRole",
- "Role" },
- { "org.apache.catalina.users.MemoryUser",
- "User" },
- };
-
-
- /**
- * The configuration information registry for our managed beans.
- */
- private static Registry registry = createRegistry();
-
-
- /**
- * The <code>MBeanServer</code> for this application.
- */
- private static MBeanServer mserver = createServer();
-
-
- // --------------------------------------------------------- Static Methods
-
- /**
- * Create and return the name of the <code>ManagedBean</code> that
- * corresponds to this Catalina component.
- *
- * @param component The component for which to create a name
- */
- static String createManagedName(Object component) {
-
- // Deal with exceptions to the standard rule
- String className = component.getClass().getName();
- for (int i = 0; i < exceptions.length; i++) {
- if (className.equals(exceptions[i][0])) {
- return (exceptions[i][1]);
- }
- }
-
- // Perform the standard transformation
- int period = className.lastIndexOf('.');
- if (period >= 0)
- className = className.substring(period + 1);
- return (className);
-
- }
-
-
- /**
- * Create, register, and return an MBean for this
- * <code>Connector</code> object.
- *
- * @param connector The Connector to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(Connector connector)
- throws Exception {
-
- String mname = createManagedName(connector);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(connector);
- ObjectName oname = createObjectName(domain, connector);
- if( mserver.isRegistered( oname )) {
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
-
- /**
- * Create, register, and return an MBean for this
- * <code>Context</code> object.
- *
- * @param context The Context to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(Context context)
- throws Exception {
-
- String mname = createManagedName(context);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(context);
- ObjectName oname = createObjectName(domain, context);
- if( mserver.isRegistered(oname)) {
- log.debug("Already registered " + oname);
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
-
- /**
- * Create, register, and return an MBean for this
- * <code>ContextEnvironment</code> object.
- *
- * @param environment The ContextEnvironment to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(ContextEnvironment environment)
- throws Exception {
-
- String mname = createManagedName(environment);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(environment);
- ObjectName oname = createObjectName(domain, environment);
- if( mserver.isRegistered( oname )) {
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
-
- /**
- * Create, register, and return an MBean for this
- * <code>ContextResource</code> object.
- *
- * @param resource The ContextResource to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(ContextResource resource)
- throws Exception {
-
- String mname = createManagedName(resource);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(resource);
- ObjectName oname = createObjectName(domain, resource);
- if( mserver.isRegistered( oname )) {
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
-
- /**
- * Create, register, and return an MBean for this
- * <code>ContextResourceLink</code> object.
- *
- * @param resourceLink The ContextResourceLink to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(ContextResourceLink resourceLink)
- throws Exception {
-
- String mname = createManagedName(resourceLink);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(resourceLink);
- ObjectName oname = createObjectName(domain, resourceLink);
- if( mserver.isRegistered( oname )) {
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
- /**
- * Create, register, and return an MBean for this
- * <code>Engine</code> object.
- *
- * @param engine The Engine to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(Engine engine)
- throws Exception {
-
- String mname = createManagedName(engine);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(engine);
- ObjectName oname = createObjectName(domain, engine);
- if( mserver.isRegistered( oname )) {
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
-
- /**
- * Create, register, and return an MBean for this
- * <code>Host</code> object.
- *
- * @param host The Host to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(Host host)
- throws Exception {
-
- String mname = createManagedName(host);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(host);
- ObjectName oname = createObjectName(domain, host);
- if( mserver.isRegistered( oname )) {
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
-
- /**
- * Create, register, and return an MBean for this
- * <code>Loader</code> object.
- *
- * @param loader The Loader to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(Loader loader)
- throws Exception {
-
- String mname = createManagedName(loader);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(loader);
- ObjectName oname = createObjectName(domain, loader);
- if( mserver.isRegistered( oname )) {
- // side effect: stop it
- mserver.unregisterMBean( oname );
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
- /**
- * Create, register, and return an MBean for this
- * <code>Manager</code> object.
- *
- * @param manager The Manager to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(Manager manager)
- throws Exception {
-
- String mname = createManagedName(manager);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(manager);
- ObjectName oname = createObjectName(domain, manager);
- if( mserver.isRegistered( oname )) {
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
-
- /**
- * Create, register, and return an MBean for this
- * <code>MBeanFactory</code> object.
- *
- * @param factory The MBeanFactory to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(MBeanFactory factory)
- throws Exception {
-
- String mname = createManagedName(factory);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(factory);
- ObjectName oname = createObjectName(domain, factory);
- if( mserver.isRegistered(oname )) {
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
-
- /**
- * Create, register, and return an MBean for this
- * <code>NamingResources</code> object.
- *
- * @param resource The NamingResources to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(NamingResources resource)
- throws Exception {
-
- String mname = createManagedName(resource);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(resource);
- ObjectName oname = createObjectName(domain, resource);
- if( mserver.isRegistered( oname )) {
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
-
- /**
- * Create, register, and return an MBean for this
- * <code>Realm</code> object.
- *
- * @param realm The Realm to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(Realm realm)
- throws Exception {
-
- String mname = createManagedName(realm);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(realm);
- ObjectName oname = createObjectName(domain, realm);
- if( mserver.isRegistered( oname )) {
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
-
- /**
- * Create, register, and return an MBean for this
- * <code>Server</code> object.
- *
- * @param server The Server to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(Server server)
- throws Exception {
-
- String mname = createManagedName(server);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(server);
- ObjectName oname = createObjectName(domain, server);
- if( mserver.isRegistered( oname )) {
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
-
- /**
- * Create, register, and return an MBean for this
- * <code>Service</code> object.
- *
- * @param service The Service to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(Service service)
- throws Exception {
-
- String mname = createManagedName(service);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(service);
- ObjectName oname = createObjectName(domain, service);
- if( mserver.isRegistered( oname )) {
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
-
- /**
- * Create, register, and return an MBean for this
- * <code>Valve</code> object.
- *
- * @param valve The Valve to be managed
- *
- * @exception Exception if an MBean cannot be created or registered
- */
- static DynamicMBean createMBean(Valve valve)
- throws Exception {
-
- String mname = createManagedName(valve);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- Exception e = new Exception("ManagedBean is not found with "+mname);
- throw new MBeanException(e);
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- DynamicMBean mbean = managed.createMBean(valve);
- ObjectName oname = createObjectName(domain, valve);
- if( mserver.isRegistered( oname )) {
- mserver.unregisterMBean(oname);
- }
- mserver.registerMBean(mbean, oname);
- return (mbean);
-
- }
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>Connector</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param connector The Connector to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- static ObjectName createObjectName(String domain,
- Connector connector)
- throws MalformedObjectNameException {
-
- ObjectName name = null;
- try {
- String address = (String)
- IntrospectionUtils.getProperty(connector, "address");
- Integer port = (Integer)
- IntrospectionUtils.getProperty(connector, "port");
- Service service = connector.getService();
- String serviceName = null;
- if (service != null)
- serviceName = service.getName();
- StringBuilder sb = new StringBuilder(domain);
- sb.append(":type=Connector");
- sb.append(",port=" + port);
- if ((address != null) && (address.length()>0)) {
- sb.append(",address=" + address);
- }
- name = new ObjectName(sb.toString());
- return (name);
- } catch (Exception e) {
- throw new MalformedObjectNameException
- ("Cannot create object name for " + connector+e);
- }
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>Context</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param context The Context to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- static ObjectName createObjectName(String domain,
- Context context)
- throws MalformedObjectNameException {
-
- ObjectName name = null;
- Host host = (Host)context.getParent();
- Service service = ((Engine)host.getParent()).getService();
- String path = context.getPath();
- if (path.length() < 1)
- path = "/";
- // FIXME
- name = new ObjectName(domain + ":j2eeType=WebModule,name=//" +
- host.getName()+ path +
- ",J2EEApplication=none,J2EEServer=none");
-
- return (name);
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>Service</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param environment The ContextEnvironment to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- public static ObjectName createObjectName(String domain,
- ContextEnvironment environment)
- throws MalformedObjectNameException {
-
- ObjectName name = null;
- Object container =
- environment.getNamingResources().getContainer();
- if (container instanceof Server) {
- name = new ObjectName(domain + ":type=Environment" +
- ",resourcetype=Global,name=" + environment.getName());
- } else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1)
- path = "/";
- Host host = (Host) ((Context)container).getParent();
- Engine engine = (Engine) host.getParent();
- Service service = engine.getService();
- name = new ObjectName(domain + ":type=Environment" +
- ",resourcetype=Context,path=" + path +
- ",host=" + host.getName() +
- ",name=" + environment.getName());
- }
- return (name);
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>ContextResource</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param resource The ContextResource to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- public static ObjectName createObjectName(String domain,
- ContextResource resource)
- throws MalformedObjectNameException {
-
- ObjectName name = null;
- String quotedResourceName = ObjectName.quote(resource.getName());
- Object container =
- resource.getNamingResources().getContainer();
- if (container instanceof Server) {
- name = new ObjectName(domain + ":type=Resource" +
- ",resourcetype=Global,class=" + resource.getType() +
- ",name=" + quotedResourceName);
- } else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1)
- path = "/";
- Host host = (Host) ((Context)container).getParent();
- Engine engine = (Engine) host.getParent();
- Service service = engine.getService();
- name = new ObjectName(domain + ":type=Resource" +
- ",resourcetype=Context,path=" + path +
- ",host=" + host.getName() +
- ",class=" + resource.getType() +
- ",name=" + quotedResourceName);
- }
-
- return (name);
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>ContextResourceLink</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param resourceLink The ContextResourceLink to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- public static ObjectName createObjectName(String domain,
- ContextResourceLink resourceLink)
- throws MalformedObjectNameException {
-
- ObjectName name = null;
- String quotedResourceLinkName
- = ObjectName.quote(resourceLink.getName());
- Object container =
- resourceLink.getNamingResources().getContainer();
- if (container instanceof Server) {
- name = new ObjectName(domain + ":type=ResourceLink" +
- ",resourcetype=Global" +
- ",name=" + quotedResourceLinkName);
- } else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1)
- path = "/";
- Host host = (Host) ((Context)container).getParent();
- Engine engine = (Engine) host.getParent();
- Service service = engine.getService();
- name = new ObjectName(domain + ":type=ResourceLink" +
- ",resourcetype=Context,path=" + path +
- ",host=" + host.getName() +
- ",name=" + quotedResourceLinkName);
- }
-
- return (name);
-
- }
-
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>Engine</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param engine The Engine to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- static ObjectName createObjectName(String domain,
- Engine engine)
- throws MalformedObjectNameException {
-
- ObjectName name = null;
- name = new ObjectName(domain + ":type=Engine");
- return (name);
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>Host</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param host The Host to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- static ObjectName createObjectName(String domain,
- Host host)
- throws MalformedObjectNameException {
-
- ObjectName name = null;
- Engine engine = (Engine)host.getParent();
- Service service = engine.getService();
- name = new ObjectName(domain + ":type=Host,host=" +
- host.getName());
- return (name);
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>Loader</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param loader The Loader to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- static ObjectName createObjectName(String domain,
- Loader loader)
- throws MalformedObjectNameException {
-
- ObjectName name = null;
- Container container = loader.getContainer();
-
- if (container instanceof Engine) {
- Service service = ((Engine)container).getService();
- name = new ObjectName(domain + ":type=Loader");
- } else if (container instanceof Host) {
- Engine engine = (Engine) container.getParent();
- Service service = engine.getService();
- name = new ObjectName(domain + ":type=Loader,host=" +
- container.getName());
- } else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1) {
- path = "/";
- }
- Host host = (Host) container.getParent();
- Engine engine = (Engine) host.getParent();
- Service service = engine.getService();
- name = new ObjectName(domain + ":type=Loader,path=" + path +
- ",host=" + host.getName());
- }
-
- return (name);
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>Manager</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param manager The Manager to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- static ObjectName createObjectName(String domain,
- Manager manager)
- throws MalformedObjectNameException {
-
- ObjectName name = null;
- Container container = manager.getContainer();
-
- if (container instanceof Engine) {
- Service service = ((Engine)container).getService();
- name = new ObjectName(domain + ":type=Manager");
- } else if (container instanceof Host) {
- Engine engine = (Engine) container.getParent();
- Service service = engine.getService();
- name = new ObjectName(domain + ":type=Manager,host=" +
- container.getName());
- } else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1) {
- path = "/";
- }
- Host host = (Host) container.getParent();
- Engine engine = (Engine) host.getParent();
- Service service = engine.getService();
- name = new ObjectName(domain + ":type=Manager,path=" + path +
- ",host=" + host.getName());
- }
-
- return (name);
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>Server</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param resources The NamingResources to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- static ObjectName createObjectName(String domain,
- NamingResources resources)
- throws MalformedObjectNameException {
-
- ObjectName name = null;
- Object container = resources.getContainer();
- if (container instanceof Server) {
- name = new ObjectName(domain + ":type=NamingResources" +
- ",resourcetype=Global");
- } else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1)
- path = "/";
- Host host = (Host) ((Context)container).getParent();
- Engine engine = (Engine) host.getParent();
- Service service = engine.getService();
- name = new ObjectName(domain + ":type=NamingResources" +
- ",resourcetype=Context,path=" + path +
- ",host=" + host.getName());
- }
-
- return (name);
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>MBeanFactory</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param factory The MBeanFactory to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- static ObjectName createObjectName(String domain,
- MBeanFactory factory)
- throws MalformedObjectNameException {
-
- ObjectName name = new ObjectName(domain + ":type=MBeanFactory");
-
- return (name);
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>Realm</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param realm The Realm to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- static ObjectName createObjectName(String domain,
- Realm realm)
- throws MalformedObjectNameException {
-
- ObjectName name = null;
- Container container = realm.getContainer();
-
- if (container instanceof Engine) {
- Service service = ((Engine)container).getService();
- name = new ObjectName(domain + ":type=Realm");
- } else if (container instanceof Host) {
- Engine engine = (Engine) container.getParent();
- Service service = engine.getService();
- name = new ObjectName(domain + ":type=Realm,host=" +
- container.getName());
- } else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1) {
- path = "/";
- }
- Host host = (Host) container.getParent();
- Engine engine = (Engine) host.getParent();
- Service service = engine.getService();
- name = new ObjectName(domain + ":type=Realm,path=" + path +
- ",host=" + host.getName());
- }
-
- return (name);
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>Server</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param server The Server to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- static ObjectName createObjectName(String domain,
- Server server)
- throws MalformedObjectNameException {
-
- ObjectName name = null;
- name = new ObjectName(domain + ":type=Server");
- return (name);
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>Service</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param service The Service to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- static ObjectName createObjectName(String domain,
- Service service)
- throws MalformedObjectNameException {
-
- ObjectName name = null;
- name = new ObjectName(domain + ":type=Service,serviceName=" +
- service.getName());
- return (name);
-
- }
-
-
- /**
- * Create an <code>ObjectName</code> for this
- * <code>Valve</code> object.
- *
- * @param domain Domain in which this name is to be created
- * @param valve The Valve to be named
- *
- * @exception MalformedObjectNameException if a name cannot be created
- */
- static ObjectName createObjectName(String domain,
- Valve valve)
- throws MalformedObjectNameException {
- if( valve instanceof ValveBase ) {
- ObjectName name=((ValveBase)valve).getObjectName();
- if( name != null )
- return name;
- }
-
- ObjectName name = null;
- Container container = null;
- String className=valve.getClass().getName();
- int period = className.lastIndexOf('.');
- if (period >= 0)
- className = className.substring(period + 1);
- if( valve instanceof Contained ) {
- container = ((Contained)valve).getContainer();
- }
- if( container == null ) {
- throw new MalformedObjectNameException(
- "Cannot create mbean for non-contained valve " +
- valve);
- }
- if (container instanceof Engine) {
- Service service = ((Engine)container).getService();
- String local="";
- int seq = getSeq(local);
- String ext="";
- if( seq > 0 ) {
- ext=",seq=" + seq;
- }
- name = new ObjectName(domain + ":type=Valve,name=" + className +
- ext + local );
- } else if (container instanceof Host) {
- Service service = ((Engine)container.getParent()).getService();
- String local=",host=" +container.getName();
- int seq = getSeq(local);
- String ext="";
- if( seq > 0 ) {
- ext=",seq=" + seq;
- }
- name = new ObjectName(domain + ":type=Valve,name=" + className +
- ext + local );
- } else if (container instanceof Context) {
- String path = ((Context)container).getPath();
- if (path.length() < 1) {
- path = "/";
- }
- Host host = (Host) container.getParent();
- Service service = ((Engine) host.getParent()).getService();
- String local=",path=" + path + ",host=" +
- host.getName();
- int seq = getSeq(local);
- String ext="";
- if( seq > 0 ) {
- ext=",seq=" + seq;
- }
- name = new ObjectName(domain + ":type=Valve,name=" + className +
- ext + local );
- }
-
- return (name);
-
- }
-
- static Hashtable seq=new Hashtable();
- static int getSeq( String key ) {
- int i[]=(int [])seq.get( key );
- if (i == null ) {
- i=new int[1];
- i[0]=0;
- seq.put( key, i);
- } else {
- i[0]++;
- }
- return i[0];
- }
-
- /**
- * Create and configure (if necessary) and return the registry of
- * managed object descriptions.
- */
- public synchronized static Registry createRegistry() {
-
- if (registry == null) {
- registry = Registry.getRegistry(null, null);
- ClassLoader cl=ServerLifecycleListener.class.getClassLoader();
-
- registry.loadDescriptors("org.apache.catalina.mbeans", cl);
- registry.loadDescriptors("org.apache.catalina.authenticator", cl);
- registry.loadDescriptors("org.apache.catalina.core", cl);
- registry.loadDescriptors("org.apache.catalina", cl);
- registry.loadDescriptors("org.apache.catalina.deploy", cl);
- registry.loadDescriptors("org.apache.catalina.loader", cl);
- registry.loadDescriptors("org.apache.catalina.realm", cl);
- registry.loadDescriptors("org.apache.catalina.session", cl);
- registry.loadDescriptors("org.apache.catalina.startup", cl);
- registry.loadDescriptors("org.apache.catalina.users", cl);
- registry.loadDescriptors("org.apache.catalina.ha", cl);
- registry.loadDescriptors("org.apache.catalina.connector", cl);
- registry.loadDescriptors("org.apache.catalina.valves", cl);
- }
- return (registry);
-
- }
-
-
- /**
- * Create and configure (if necessary) and return the
- * <code>MBeanServer</code> with which we will be
- * registering our <code>DynamicMBean</code> implementations.
- */
- public synchronized static MBeanServer createServer() {
-
- if (mserver == null) {
- try {
- mserver = Registry.getRegistry(null, null).getMBeanServer();
- } catch (Throwable t) {
- t.printStackTrace(System.out);
- System.exit(1);
- }
- }
- return (mserver);
-
- }
-
-
- /**
- * Deregister the MBean for this
- * <code>Connector</code> object.
- *
- * @param connector The Connector to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(Connector connector, Service service)
- throws Exception {
-
- connector.setService(service);
- String mname = createManagedName(connector);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, connector);
- connector.setService(null);
- if( mserver.isRegistered( oname )) {
- mserver.unregisterMBean(oname);
- }
- // Unregister associated request processor
- String worker = null;
- ProtocolHandler handler = connector.getProtocolHandler();
- if (handler instanceof Http11Protocol) {
- worker = ((Http11Protocol)handler).getName();
- } else if (handler instanceof Http11AprProtocol) {
- worker = ((Http11AprProtocol)handler).getName();
- } else if (handler instanceof AjpProtocol) {
- worker = ((AjpProtocol)handler).getName();
- } else if (handler instanceof AjpAprProtocol) {
- worker = ((AjpAprProtocol)handler).getName();
- }
- ObjectName query = new ObjectName(
- domain + ":type=RequestProcessor,worker=" + worker + ",*");
- Set<ObjectName> results = mserver.queryNames(query, null);
- for(ObjectName result : results) {
- mserver.unregisterMBean(result);
- }
- }
-
-
- /**
- * Deregister the MBean for this
- * <code>Context</code> object.
- *
- * @param context The Context to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(Context context)
- throws Exception {
-
- String mname = createManagedName(context);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, context);
- if( mserver.isRegistered(oname) )
- mserver.unregisterMBean(oname);
-
- }
-
-
- /**
- * Deregister the MBean for this
- * <code>ContextEnvironment</code> object.
- *
- * @param environment The ContextEnvironment to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(ContextEnvironment environment)
- throws Exception {
-
- String mname = createManagedName(environment);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, environment);
- if( mserver.isRegistered(oname) )
- mserver.unregisterMBean(oname);
-
- }
-
-
- /**
- * Deregister the MBean for this
- * <code>ContextResource</code> object.
- *
- * @param resource The ContextResource to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(ContextResource resource)
- throws Exception {
-
- String mname = createManagedName(resource);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, resource);
- if( mserver.isRegistered(oname ))
- mserver.unregisterMBean(oname);
-
- }
-
-
- /**
- * Deregister the MBean for this
- * <code>ContextResourceLink</code> object.
- *
- * @param resourceLink The ContextResourceLink to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(ContextResourceLink resourceLink)
- throws Exception {
-
- String mname = createManagedName(resourceLink);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, resourceLink);
- if( mserver.isRegistered(oname) )
- mserver.unregisterMBean(oname);
-
- }
-
- /**
- * Deregister the MBean for this
- * <code>Engine</code> object.
- *
- * @param engine The Engine to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(Engine engine)
- throws Exception {
-
- String mname = createManagedName(engine);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, engine);
- if( mserver.isRegistered(oname) )
- mserver.unregisterMBean(oname);
-
- }
-
-
- /**
- * Deregister the MBean for this
- * <code>Host</code> object.
- *
- * @param host The Host to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(Host host)
- throws Exception {
-
- String mname = createManagedName(host);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, host);
- if( mserver.isRegistered(oname) )
- mserver.unregisterMBean(oname);
-
- }
-
-
- /**
- * Deregister the MBean for this
- * <code>Loader</code> object.
- *
- * @param loader The Loader to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(Loader loader)
- throws Exception {
-
- String mname = createManagedName(loader);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, loader);
- if( mserver.isRegistered(oname) )
- mserver.unregisterMBean(oname);
-
- }
-
-
- /**
- * Deregister the MBean for this
- * <code>Manager</code> object.
- *
- * @param manager The Manager to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(Manager manager)
- throws Exception {
-
- String mname = createManagedName(manager);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, manager);
- if( mserver.isRegistered(oname) )
- mserver.unregisterMBean(oname);
-
- }
-
-
- /**
- * Deregister the MBean for this
- * <code>NamingResources</code> object.
- *
- * @param resources The NamingResources to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(NamingResources resources)
- throws Exception {
-
- String mname = createManagedName(resources);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, resources);
- if( mserver.isRegistered(oname) )
- mserver.unregisterMBean(oname);
-
- }
-
-
- /**
- * Deregister the MBean for this
- * <code>Realm</code> object.
- *
- * @param realm The Realm to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(Realm realm)
- throws Exception {
-
- String mname = createManagedName(realm);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, realm);
- if( mserver.isRegistered(oname) )
- mserver.unregisterMBean(oname);
-
- }
-
-
- /**
- * Deregister the MBean for this
- * <code>Server</code> object.
- *
- * @param server The Server to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(Server server)
- throws Exception {
-
- String mname = createManagedName(server);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, server);
- if( mserver.isRegistered(oname) )
- mserver.unregisterMBean(oname);
-
- // Global String cache - fixed name
- oname = new ObjectName("Catalina:type=StringCache");
- if( mserver.isRegistered(oname) )
- mserver.unregisterMBean(oname);
-
- // MBean Factory - fixed name
- oname = new ObjectName("Catalina:type=MBeanFactory");
- if( mserver.isRegistered(oname) )
- mserver.unregisterMBean(oname);
-
- }
-
-
- /**
- * Deregister the MBean for this
- * <code>Service</code> object.
- *
- * @param service The Service to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(Service service)
- throws Exception {
-
- String mname = createManagedName(service);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, service);
- if( mserver.isRegistered(oname) )
- mserver.unregisterMBean(oname);
-
- }
-
-
- /**
- * Deregister the MBean for this
- * <code>Valve</code> object.
- *
- * @param valve The Valve to be managed
- *
- * @exception Exception if an MBean cannot be deregistered
- */
- static void destroyMBean(Valve valve, Container container)
- throws Exception {
-
- ((Contained)valve).setContainer(container);
- String mname = createManagedName(valve);
- ManagedBean managed = registry.findManagedBean(mname);
- if (managed == null) {
- return;
- }
- String domain = managed.getDomain();
- if (domain == null)
- domain = mserver.getDefaultDomain();
- ObjectName oname = createObjectName(domain, valve);
- try {
- ((Contained)valve).setContainer(null);
- } catch (Throwable t) {
- ;
- }
- if( mserver.isRegistered(oname) ) {
- mserver.unregisterMBean(oname);
- }
-
- }
-
-}
Deleted: trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/mbeans/NamingResourcesMBean.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,324 +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.mbeans;
-
-import java.util.ArrayList;
-
-import javax.management.MBeanException;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.RuntimeOperationsException;
-
-import org.apache.catalina.deploy.ContextEnvironment;
-import org.apache.catalina.deploy.ContextResource;
-import org.apache.catalina.deploy.ContextResourceLink;
-import org.apache.catalina.deploy.NamingResources;
-import org.apache.tomcat.util.modeler.BaseModelMBean;
-import org.apache.tomcat.util.modeler.ManagedBean;
-import org.apache.tomcat.util.modeler.Registry;
-
-/**
- * <p>A <strong>ModelMBean</strong> implementation for the
- * <code>org.apache.catalina.deploy.NamingResources</code> component.</p>
- *
- * @author Amy Roh
- * @version $Revision$ $Date$
- */
-
-public class NamingResourcesMBean extends BaseModelMBean {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a <code>ModelMBean</code> with default
- * <code>ModelMBeanInfo</code> information.
- *
- * @exception MBeanException if the initializer of an object
- * throws an exception
- * @exception RuntimeOperationsException if an IllegalArgumentException
- * occurs
- */
- public NamingResourcesMBean()
- throws MBeanException, RuntimeOperationsException {
-
- super();
-
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
- /**
- * The configuration information registry for our managed beans.
- */
- protected Registry registry = MBeanUtils.createRegistry();
-
-
- /**
- * The <code>ManagedBean</code> information describing this MBean.
- */
- protected ManagedBean managed =
- registry.findManagedBean("NamingResources");
-
- // ------------------------------------------------------------- Attributes
-
-
- /**
- * Return the MBean Names of the set of defined environment entries for
- * this web application
- */
- public String[] getEnvironments() {
- ContextEnvironment[] envs =
- ((NamingResources)this.resource).findEnvironments();
- ArrayList results = new ArrayList();
- for (int i = 0; i < envs.length; i++) {
- try {
- ObjectName oname =
- MBeanUtils.createObjectName(managed.getDomain(), envs[i]);
- results.add(oname.toString());
- } catch (MalformedObjectNameException e) {
- IllegalArgumentException iae = new IllegalArgumentException
- ("Cannot create object name for environment " + envs[i]);
- iae.initCause(e);
- throw iae;
- }
- }
- return ((String[]) results.toArray(new String[results.size()]));
-
- }
-
-
- /**
- * Return the MBean Names of all the defined resource references for this
- * application.
- */
- public String[] getResources() {
-
- ContextResource[] resources =
- ((NamingResources)this.resource).findResources();
- ArrayList results = new ArrayList();
- for (int i = 0; i < resources.length; i++) {
- try {
- ObjectName oname =
- MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
- results.add(oname.toString());
- } catch (MalformedObjectNameException e) {
- IllegalArgumentException iae = new IllegalArgumentException
- ("Cannot create object name for resource " + resources[i]);
- iae.initCause(e);
- throw iae;
- }
- }
- return ((String[]) results.toArray(new String[results.size()]));
-
- }
-
-
- /**
- * Return the MBean Names of all the defined resource link references for
- * this application.
- */
- public String[] getResourceLinks() {
-
- ContextResourceLink[] resourceLinks =
- ((NamingResources)this.resource).findResourceLinks();
- ArrayList results = new ArrayList();
- for (int i = 0; i < resourceLinks.length; i++) {
- try {
- ObjectName oname =
- MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]);
- results.add(oname.toString());
- } catch (MalformedObjectNameException e) {
- IllegalArgumentException iae = new IllegalArgumentException
- ("Cannot create object name for resource " + resourceLinks[i]);
- iae.initCause(e);
- throw iae;
- }
- }
- return ((String[]) results.toArray(new String[results.size()]));
-
- }
-
- // ------------------------------------------------------------- Operations
-
-
- /**
- * Add an environment entry for this web application.
- *
- * @param envName New environment entry name
- * @param type The type of the new environment entry
- * @param value The value of the new environment entry
- */
- public String addEnvironment(String envName, String type, String value)
- throws MalformedObjectNameException {
-
- NamingResources nresources = (NamingResources) this.resource;
- if (nresources == null) {
- return null;
- }
- ContextEnvironment env = nresources.findEnvironment(envName);
- if (env != null) {
- throw new IllegalArgumentException
- ("Invalid environment name - already exists '" + envName + "'");
- }
- env = new ContextEnvironment();
- env.setName(envName);
- env.setType(type);
- env.setValue(value);
- nresources.addEnvironment(env);
-
- // Return the corresponding MBean name
- ManagedBean managed = registry.findManagedBean("ContextEnvironment");
- ObjectName oname =
- MBeanUtils.createObjectName(managed.getDomain(), env);
- return (oname.toString());
-
- }
-
-
- /**
- * Add a resource reference for this web application.
- *
- * @param resourceName New resource reference name
- * @param type New resource reference type
- */
- public String addResource(String resourceName, String type)
- throws MalformedObjectNameException {
-
- NamingResources nresources = (NamingResources) this.resource;
- if (nresources == null) {
- return null;
- }
- ContextResource resource = nresources.findResource(resourceName);
- if (resource != null) {
- throw new IllegalArgumentException
- ("Invalid resource name - already exists'" + resourceName + "'");
- }
- resource = new ContextResource();
- resource.setName(resourceName);
- resource.setType(type);
- nresources.addResource(resource);
-
- // Return the corresponding MBean name
- ManagedBean managed = registry.findManagedBean("ContextResource");
- ObjectName oname =
- MBeanUtils.createObjectName(managed.getDomain(), resource);
- return (oname.toString());
- }
-
-
- /**
- * Add a resource link reference for this web application.
- *
- * @param resourceLinkName New resource link reference name
- * @param type New resource link reference type
- */
- public String addResourceLink(String resourceLinkName, String type)
- throws MalformedObjectNameException {
-
- NamingResources nresources = (NamingResources) this.resource;
- if (nresources == null) {
- return null;
- }
- ContextResourceLink resourceLink =
- nresources.findResourceLink(resourceLinkName);
- if (resourceLink != null) {
- throw new IllegalArgumentException
- ("Invalid resource link name - already exists'" +
- resourceLinkName + "'");
- }
- resourceLink = new ContextResourceLink();
- resourceLink.setName(resourceLinkName);
- resourceLink.setType(type);
- nresources.addResourceLink(resourceLink);
-
- // Return the corresponding MBean name
- ManagedBean managed = registry.findManagedBean("ContextResourceLink");
- ObjectName oname =
- MBeanUtils.createObjectName(managed.getDomain(), resourceLink);
- return (oname.toString());
- }
-
-
- /**
- * Remove any environment entry with the specified name.
- *
- * @param envName Name of the environment entry to remove
- */
- public void removeEnvironment(String envName) {
-
- NamingResources nresources = (NamingResources) this.resource;
- if (nresources == null) {
- return;
- }
- ContextEnvironment env = nresources.findEnvironment(envName);
- if (env == null) {
- throw new IllegalArgumentException
- ("Invalid environment name '" + envName + "'");
- }
- nresources.removeEnvironment(envName);
-
- }
-
-
- /**
- * Remove any resource reference with the specified name.
- *
- * @param resourceName Name of the resource reference to remove
- */
- public void removeResource(String resourceName) {
-
- resourceName = ObjectName.unquote(resourceName);
- NamingResources nresources = (NamingResources) this.resource;
- if (nresources == null) {
- return;
- }
- ContextResource resource = nresources.findResource(resourceName);
- if (resource == null) {
- throw new IllegalArgumentException
- ("Invalid resource name '" + resourceName + "'");
- }
- nresources.removeResource(resourceName);
-
- }
-
-
- /**
- * Remove any resource link reference with the specified name.
- *
- * @param resourceLinkName Name of the resource link reference to remove
- */
- public void removeResourceLink(String resourceLinkName) {
-
- resourceLinkName = ObjectName.unquote(resourceLinkName);
- NamingResources nresources = (NamingResources) this.resource;
- if (nresources == null) {
- return;
- }
- ContextResourceLink resourceLink =
- nresources.findResourceLink(resourceLinkName);
- if (resourceLink == null) {
- throw new IllegalArgumentException
- ("Invalid resource Link name '" + resourceLinkName + "'");
- }
- nresources.removeResourceLink(resourceLinkName);
- }
-
-}
Deleted: trunk/java/org/apache/catalina/mbeans/ServerLifecycleListener.java
===================================================================
--- trunk/java/org/apache/catalina/mbeans/ServerLifecycleListener.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/mbeans/ServerLifecycleListener.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,1389 +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.mbeans;
-
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-import javax.management.MBeanException;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.ContainerEvent;
-import org.apache.catalina.ContainerListener;
-import org.apache.catalina.Context;
-import org.apache.catalina.Engine;
-import org.apache.catalina.Globals;
-import org.apache.catalina.Host;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.Loader;
-import org.apache.catalina.Manager;
-import org.apache.catalina.Realm;
-import org.apache.catalina.Server;
-import org.apache.catalina.Service;
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.core.StandardEngine;
-import org.apache.catalina.core.StandardHost;
-import org.apache.catalina.core.StandardServer;
-import org.apache.catalina.core.StandardService;
-import org.apache.catalina.deploy.ContextEnvironment;
-import org.apache.catalina.deploy.ContextResource;
-import org.apache.catalina.deploy.ContextResourceLink;
-import org.apache.catalina.deploy.NamingResources;
-import org.jboss.logging.Logger;
-
-
-/**
- * Implementation of <code>LifecycleListener</code> that
- * instantiates the set of MBeans associated with the components of a
- * running instance of Catalina.
- *
- * @author Craig R. McClanahan
- * @author Amy Roh
- * @version $Revision$ $Date$
- */
-
-public class ServerLifecycleListener
- implements ContainerListener, LifecycleListener, PropertyChangeListener {
-
- private static Logger log = Logger.getLogger(ServerLifecycleListener.class);
-
-
- // ------------------------------------------------------------- Properties
-
-
- /**
- * Semicolon separated list of paths containing MBean desciptor resources.
- */
- protected String descriptors = null;
-
- public String getDescriptors() {
- return (this.descriptors);
- }
-
- public void setDescriptors(String descriptors) {
- this.descriptors = descriptors;
- }
-
-
- // ---------------------------------------------- ContainerListener Methods
-
-
- /**
- * Handle a <code>ContainerEvent</code> from one of the Containers we are
- * interested in.
- *
- * @param event The event that has occurred
- */
- public void containerEvent(ContainerEvent event) {
-
- try {
- String type = event.getType();
- if (Container.ADD_CHILD_EVENT.equals(type)) {
- processContainerAddChild(event.getContainer(),
- (Container) event.getData());
- } else if (Container.REMOVE_CHILD_EVENT.equals(type)) {
- processContainerRemoveChild(event.getContainer(),
- (Container) event.getData());
- }
- } catch (Exception e) {
- log.error("Exception processing event " + event, e);
- }
-
- }
-
-
- // ---------------------------------------------- LifecycleListener Methods
-
-
- /**
- * Primary entry point for startup and shutdown events.
- *
- * @param event The event that has occurred
- */
- public void lifecycleEvent(LifecycleEvent event) {
-
- Lifecycle lifecycle = event.getLifecycle();
- if (Lifecycle.START_EVENT.equals(event.getType())) {
-
- try {
-
- if (lifecycle instanceof Server) {
- MBeanFactory factory = new MBeanFactory();
- factory.setContainer(lifecycle);
- createMBeans(factory);
- createMBeans((Server) lifecycle);
- }
-
- if( lifecycle instanceof Service ) {
- MBeanFactory factory = new MBeanFactory();
- factory.setContainer(lifecycle);
- createMBeans(factory);
- createMBeans((Service)lifecycle);
- }
-
- } catch (MBeanException t) {
-
- Exception e = t.getTargetException();
- if (e == null)
- e = t;
- log.error("createMBeans: MBeanException", e);
-
- } catch (Throwable t) {
-
- log.error("createMBeans: Throwable", t);
-
- }
-
- /*
- // Ignore events from StandardContext objects to avoid
- // reregistering the context
- if (lifecycle instanceof StandardContext)
- return;
- createMBeans();
- */
-
- } else if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) {
- try {
- if (lifecycle instanceof Server) {
- destroyMBeans((Server)lifecycle);
- }
- if (lifecycle instanceof Service) {
- destroyMBeans((Service)lifecycle);
- }
- } catch (MBeanException t) {
-
- Exception e = t.getTargetException();
- if (e == null) {
- e = t;
- }
- log.error("destroyMBeans: MBeanException", e);
-
- } catch (Throwable t) {
-
- log.error("destroyMBeans: Throwable", t);
-
- }
- // FIXME: RMI adaptor should be stopped; however, this is
- // undocumented in MX4J, and reports exist in the MX4J bug DB that
- // this doesn't work
-
- }
-
- if ((Context.RELOAD_EVENT.equals(event.getType()))
- || (Lifecycle.START_EVENT.equals(event.getType()))) {
-
- // Give context a new handle to the MBean server if the
- // context has been reloaded since reloading causes the
- // context to lose its previous handle to the server
- if (lifecycle instanceof StandardContext) {
- // If the context is privileged, give a reference to it
- // in a servlet context attribute
- StandardContext context = (StandardContext)lifecycle;
- if (context.getPrivileged()) {
- context.getServletContext().setAttribute
- (Globals.MBEAN_REGISTRY_ATTR,
- MBeanUtils.createRegistry());
- context.getServletContext().setAttribute
- (Globals.MBEAN_SERVER_ATTR,
- MBeanUtils.createServer());
- }
- }
-
- }
-
- }
-
-
- // ----------------------------------------- PropertyChangeListener Methods
-
-
- /**
- * Handle a <code>PropertyChangeEvent</code> from one of the Containers
- * we are interested in.
- *
- * @param event The event that has occurred
- */
- public void propertyChange(PropertyChangeEvent event) {
-
- if (event.getSource() instanceof Container) {
- try {
- processContainerPropertyChange((Container) event.getSource(),
- event.getPropertyName(),
- event.getOldValue(),
- event.getNewValue());
- } catch (Exception e) {
- log.error("Exception handling Container property change", e);
- }
- }/* else if (event.getSource() instanceof DefaultContext) {
- try {
- processDefaultContextPropertyChange
- ((DefaultContext) event.getSource(),
- event.getPropertyName(),
- event.getOldValue(),
- event.getNewValue());
- } catch (Exception e) {
- log.error("Exception handling DefaultContext property change", e);
- }
- }*/ else if (event.getSource() instanceof NamingResources) {
- try {
- processNamingResourcesPropertyChange
- ((NamingResources) event.getSource(),
- event.getPropertyName(),
- event.getOldValue(),
- event.getNewValue());
- } catch (Exception e) {
- log.error("Exception handling NamingResources property change", e);
- }
- } else if (event.getSource() instanceof Server) {
- try {
- processServerPropertyChange((Server) event.getSource(),
- event.getPropertyName(),
- event.getOldValue(),
- event.getNewValue());
- } catch (Exception e) {
- log.error("Exception handing Server property change", e);
- }
- } else if (event.getSource() instanceof Service) {
- try {
- processServicePropertyChange((Service) event.getSource(),
- event.getPropertyName(),
- event.getOldValue(),
- event.getNewValue());
- } catch (Exception e) {
- log.error("Exception handing Service property change", e);
- }
- }
-
- }
-
-
- // ------------------------------------------------------ Protected Methods
-
-
- /**
- * Create the MBeans for the specified Connector and its nested components.
- *
- * @param connector Connector for which to create MBeans
- *
- * @exception Exception if an exception is thrown during MBean creation
- */
- protected void createMBeans(Connector connector) throws Exception {
-
- // Create the MBean for the Connnector itself
-// if (log.isDebugEnabled())
-// log.debug("Creating MBean for Connector " + connector);
-// MBeanUtils.createMBean(connector);
-
- }
-
-
- /**
- * Create the MBeans for the specified Context and its nested components.
- *
- * @param context Context for which to create MBeans
- *
- * @exception Exception if an exception is thrown during MBean creation
- */
- protected void createMBeans(Context context) throws Exception {
-
- // Create the MBean for the Context itself
-// if (log.isDebugEnabled())
-// log.debug("Creating MBean for Context " + context);
-// MBeanUtils.createMBean(context);
- context.addContainerListener(this);
- if (context instanceof StandardContext) {
- ((StandardContext) context).addPropertyChangeListener(this);
- ((StandardContext) context).addLifecycleListener(this);
- }
-
- // If the context is privileged, give a reference to it
- // in a servlet context attribute
- if (context.getPrivileged()) {
- context.getServletContext().setAttribute
- (Globals.MBEAN_REGISTRY_ATTR,
- MBeanUtils.createRegistry());
- context.getServletContext().setAttribute
- (Globals.MBEAN_SERVER_ATTR,
- MBeanUtils.createServer());
- }
-
- // Create the MBeans for the associated nested components
- Loader cLoader = context.getLoader();
- if (cLoader != null) {
- if (log.isDebugEnabled())
- log.debug("Creating MBean for Loader " + cLoader);
- //MBeanUtils.createMBean(cLoader);
- }
- Manager cManager = context.getManager();
- if (cManager != null) {
- if (log.isDebugEnabled())
- log.debug("Creating MBean for Manager " + cManager);
- //MBeanUtils.createMBean(cManager);
- }
- Realm hRealm = context.getParent().getRealm();
- Realm cRealm = context.getRealm();
- if ((cRealm != null) && (cRealm != hRealm)) {
- if (log.isDebugEnabled())
- log.debug("Creating MBean for Realm " + cRealm);
- //MBeanUtils.createMBean(cRealm);
- }
-
- // Create the MBeans for the NamingResources (if any)
- NamingResources resources = context.getNamingResources();
- createMBeans(resources);
-
- }
-
-
- /**
- * Create the MBeans for the specified ContextEnvironment entry.
- *
- * @param environment ContextEnvironment for which to create MBeans
- *
- * @exception Exception if an exception is thrown during MBean creation
- */
- protected void createMBeans(ContextEnvironment environment)
- throws Exception {
-
- // Create the MBean for the ContextEnvironment itself
- if (log.isDebugEnabled()) {
- log.debug("Creating MBean for ContextEnvironment " + environment);
- }
- MBeanUtils.createMBean(environment);
-
- }
-
-
- /**
- * Create the MBeans for the specified ContextResource entry.
- *
- * @param resource ContextResource for which to create MBeans
- *
- * @exception Exception if an exception is thrown during MBean creation
- */
- protected void createMBeans(ContextResource resource)
- throws Exception {
-
- // Create the MBean for the ContextResource itself
- if (log.isDebugEnabled()) {
- log.debug("Creating MBean for ContextResource " + resource);
- }
- MBeanUtils.createMBean(resource);
-
- }
-
-
- /**
- * Create the MBeans for the specified ContextResourceLink entry.
- *
- * @param resourceLink ContextResourceLink for which to create MBeans
- *
- * @exception Exception if an exception is thrown during MBean creation
- */
- protected void createMBeans(ContextResourceLink resourceLink)
- throws Exception {
-
- // Create the MBean for the ContextResourceLink itself
- if (log.isDebugEnabled()) {
- log.debug("Creating MBean for ContextResourceLink " + resourceLink);
- }
- MBeanUtils.createMBean(resourceLink);
-
- }
-
-
- /**
- * Create the MBeans for the specified DefaultContext and its nested components.
- *
- * @param dcontext DefaultContext for which to create MBeans
- *
- * @exception Exception if an exception is thrown during MBean creation
- */
- /*
- protected void createMBeans(DefaultContext dcontext) throws Exception {
-
- // Create the MBean for the DefaultContext itself
- if (log.isDebugEnabled())
- log.debug("Creating MBean for DefaultContext " + dcontext);
- MBeanUtils.createMBean(dcontext);
-
- dcontext.addPropertyChangeListener(this);
-
- // Create the MBeans for the associated nested components
- Loader dLoader = dcontext.getLoader();
- if (dLoader != null) {
- if (log.isDebugEnabled())
- log.debug("Creating MBean for Loader " + dLoader);
- //MBeanUtils.createMBean(dLoader);
- }
-
- Manager dManager = dcontext.getManager();
- if (dManager != null) {
- if (log.isDebugEnabled())
- log.debug("Creating MBean for Manager " + dManager);
- //MBeanUtils.createMBean(dManager);
- }
-
- // Create the MBeans for the NamingResources (if any)
- NamingResources resources = dcontext.getNamingResources();
- createMBeans(resources);
-
- }
- */
-
-
- /**
- * Create the MBeans for the specified Engine and its nested components.
- *
- * @param engine Engine for which to create MBeans
- *
- * @exception Exception if an exception is thrown during MBean creation
- */
- protected void createMBeans(Engine engine) throws Exception {
-
- // Create the MBean for the Engine itself
- if (log.isDebugEnabled()) {
- log.debug("Creating MBean for Engine " + engine);
- }
- //MBeanUtils.createMBean(engine);
- engine.addContainerListener(this);
- if (engine instanceof StandardEngine) {
- ((StandardEngine) engine).addPropertyChangeListener(this);
- }
-
- // Create the MBeans for the associated nested components
- Realm eRealm = engine.getRealm();
- if (eRealm != null) {
- if (log.isDebugEnabled())
- log.debug("Creating MBean for Realm " + eRealm);
- //MBeanUtils.createMBean(eRealm);
- }
-
- // Create the MBeans for each child Host
- Container hosts[] = engine.findChildren();
- for (int j = 0; j < hosts.length; j++) {
- createMBeans((Host) hosts[j]);
- }
-
- }
-
-
- /**
- * Create the MBeans for the specified Host and its nested components.
- *
- * @param host Host for which to create MBeans
- *
- * @exception Exception if an exception is thrown during MBean creation
- */
- protected void createMBeans(Host host) throws Exception {
-
- // Create the MBean for the Host itself
- if (log.isDebugEnabled()) {
- log.debug("Creating MBean for Host " + host);
- }
- //MBeanUtils.createMBean(host);
- host.addContainerListener(this);
- if (host instanceof StandardHost) {
- ((StandardHost) host).addPropertyChangeListener(this);
- }
-
- // Create the MBeans for the associated nested components
- Realm eRealm = host.getParent().getRealm();
- Realm hRealm = host.getRealm();
- if ((hRealm != null) && (hRealm != eRealm)) {
- if (log.isDebugEnabled())
- log.debug("Creating MBean for Realm " + hRealm);
- //MBeanUtils.createMBean(hRealm);
- }
-
- // Create the MBeans for each child Context
- Container contexts[] = host.findChildren();
- for (int k = 0; k < contexts.length; k++) {
- createMBeans((Context) contexts[k]);
- }
-
- }
-
-
- /**
- * Create the MBeans for MBeanFactory.
- *
- * @param factory MBeanFactory for which to create MBean
- *
- * @exception Exception if an exception is thrown during MBean creation
- */
- protected void createMBeans(MBeanFactory factory) throws Exception {
-
- // Create the MBean for the MBeanFactory
- if (log.isDebugEnabled())
- log.debug("Creating MBean for MBeanFactory " + factory);
- MBeanUtils.createMBean(factory);
-
- }
-
-
- /**
- * Create the MBeans for the specified NamingResources and its
- * nested components.
- *
- * @param resources NamingResources for which to create MBeans
- */
- protected void createMBeans(NamingResources resources) throws Exception {
-
- // Create the MBean for the NamingResources itself
- if (log.isDebugEnabled()) {
- log.debug("Creating MBean for NamingResources " + resources);
- }
- MBeanUtils.createMBean(resources);
- resources.addPropertyChangeListener(this);
-
- // Create the MBeans for each child environment entry
- ContextEnvironment environments[] = resources.findEnvironments();
- for (int i = 0; i < environments.length; i++) {
- createMBeans(environments[i]);
- }
-
- // Create the MBeans for each child resource entry
- ContextResource cresources[] = resources.findResources();
- for (int i = 0; i < cresources.length; i++) {
- createMBeans(cresources[i]);
- }
-
- // Create the MBeans for each child resource link entry
- ContextResourceLink cresourcelinks[] = resources.findResourceLinks();
- for (int i = 0; i < cresourcelinks.length; i++) {
- createMBeans(cresourcelinks[i]);
- }
-
- }
-
-
- /**
- * Create the MBeans for the specified Server and its nested components.
- *
- * @param server Server for which to create MBeans
- *
- * @exception Exception if an exception is thrown during MBean creation
- */
- protected void createMBeans(Server server) throws Exception {
-
- // Create the MBean for the Server itself
- if (log.isDebugEnabled())
- log.debug("Creating MBean for Server " + server);
- //MBeanUtils.createMBean(server);
- if (server instanceof StandardServer) {
- ((StandardServer) server).addPropertyChangeListener(this);
- }
-
- // Create the MBeans for the global NamingResources (if any)
- NamingResources resources = server.getGlobalNamingResources();
- if (resources != null) {
- createMBeans(resources);
- }
-
- // Create the MBeans for each child Service
- Service services[] = server.findServices();
- for (int i = 0; i < services.length; i++) {
- // FIXME - Warp object hierarchy not currently supported
- if (services[i].getContainer().getClass().getName().equals
- ("org.apache.catalina.connector.warp.WarpEngine")) {
- if (log.isDebugEnabled()) {
- log.debug("Skipping MBean for Service " + services[i]);
- }
- continue;
- }
- createMBeans(services[i]);
- }
-
- }
-
-
- /**
- * Create the MBeans for the specified Service and its nested components.
- *
- * @param service Service for which to create MBeans
- *
- * @exception Exception if an exception is thrown during MBean creation
- */
- protected void createMBeans(Service service) throws Exception {
-
- if (service instanceof StandardService) {
- ((StandardService) service).addPropertyChangeListener(this);
- }
-
- // Create the MBeans for the corresponding Connectors
- Connector connectors[] = service.findConnectors();
- for (int j = 0; j < connectors.length; j++) {
- createMBeans(connectors[j]);
- }
-
- // Create the MBean for the associated Engine and friends
- Engine engine = (Engine) service.getContainer();
- if (engine != null) {
- createMBeans(engine);
- }
-
- }
-
-
-
-
- /**
- * Deregister the MBeans for the specified Connector and its nested
- * components.
- *
- * @param connector Connector for which to deregister MBeans
- *
- * @exception Exception if an exception is thrown during MBean destruction
- */
- protected void destroyMBeans(Connector connector, Service service)
- throws Exception {
-
- // deregister the MBean for the Connector itself
- if (log.isDebugEnabled())
- log.debug("Destroying MBean for Connector " + connector);
- MBeanUtils.destroyMBean(connector, service);
-
- }
-
-
- /**
- * Deregister the MBeans for the specified Context and its nested
- * components.
- *
- * @param context Context for which to deregister MBeans
- *
- * @exception Exception if an exception is thrown during MBean destruction
- */
- protected void destroyMBeans(Context context) throws Exception {
-
- // Deregister ourselves as a ContainerListener
- context.removeContainerListener(this);
-
- // Destroy the MBeans for the associated nested components
- Realm hRealm = context.getParent().getRealm();
- Realm cRealm = context.getRealm();
- if ((cRealm != null) && (cRealm != hRealm)) {
- if (log.isDebugEnabled())
- log.debug("Destroying MBean for Realm " + cRealm);
- //MBeanUtils.destroyMBean(cRealm);
- }
- Manager cManager = context.getManager();
- if (cManager != null) {
- if (log.isDebugEnabled())
- log.debug("Destroying MBean for Manager " + cManager);
- //MBeanUtils.destroyMBean(cManager);
- }
- Loader cLoader = context.getLoader();
- if (cLoader != null) {
- if (log.isDebugEnabled())
- log.debug("Destroying MBean for Loader " + cLoader);
- //MBeanUtils.destroyMBean(cLoader);
- }
-
- // Destroy the MBeans for the NamingResources (if any)
- NamingResources resources = context.getNamingResources();
- if (resources != null) {
- destroyMBeans(resources);
- }
-
- // deregister the MBean for the Context itself
- if (log.isDebugEnabled())
- log.debug("Destroying MBean for Context " + context);
- MBeanUtils.destroyMBean(context);
- if (context instanceof StandardContext) {
- ((StandardContext) context).
- removePropertyChangeListener(this);
- }
-
- }
-
-
- /**
- * Deregister the MBeans for the specified ContextEnvironment entry.
- *
- * @param environment ContextEnvironment for which to destroy MBeans
- *
- * @exception Exception if an exception is thrown during MBean destruction
- */
- protected void destroyMBeans(ContextEnvironment environment)
- throws Exception {
-
- // Destroy the MBean for the ContextEnvironment itself
- if (log.isDebugEnabled()) {
- log.debug("Destroying MBean for ContextEnvironment " + environment);
- }
- MBeanUtils.destroyMBean(environment);
-
- }
-
-
- /**
- * Deregister the MBeans for the specified ContextResource entry.
- *
- * @param resource ContextResource for which to destroy MBeans
- *
- * @exception Exception if an exception is thrown during MBean destruction
- */
- protected void destroyMBeans(ContextResource resource)
- throws Exception {
-
- // Destroy the MBean for the ContextResource itself
- if (log.isDebugEnabled()) {
- log.debug("Destroying MBean for ContextResource " + resource);
- }
- MBeanUtils.destroyMBean(resource);
-
- }
-
-
- /**
- * Deregister the MBeans for the specified ContextResourceLink entry.
- *
- * @param resourceLink ContextResourceLink for which to destroy MBeans
- *
- * @exception Exception if an exception is thrown during MBean destruction
- */
- protected void destroyMBeans(ContextResourceLink resourceLink)
- throws Exception {
-
- // Destroy the MBean for the ContextResourceLink itself
- if (log.isDebugEnabled()) {
- log.debug("Destroying MBean for ContextResourceLink " + resourceLink);
- }
- MBeanUtils.destroyMBean(resourceLink);
-
- }
-
-
- /**
- * Deregister the MBeans for the specified DefaultContext and its nested
- * components.
- *
- * @param dcontext DefaultContext for which to deregister MBeans
- *
- * @exception Exception if an exception is thrown during MBean destruction
- */
- /*
- protected void destroyMBeans(DefaultContext dcontext) throws Exception {
-
- Manager dManager = dcontext.getManager();
- if (dManager != null) {
- if (log.isDebugEnabled())
- log.debug("Destroying MBean for Manager " + dManager);
- //MBeanUtils.destroyMBean(dManager);
- }
-
- Loader dLoader = dcontext.getLoader();
- if (dLoader != null) {
- if (log.isDebugEnabled())
- log.debug("Destroying MBean for Loader " + dLoader);
- //MBeanUtils.destroyMBean(dLoader);
- }
-
- // Destroy the MBeans for the NamingResources (if any)
- NamingResources resources = dcontext.getNamingResources();
- if (resources != null) {
- destroyMBeans(resources);
- }
-
- // deregister the MBean for the DefaultContext itself
- if (log.isDebugEnabled())
- log.debug("Destroying MBean for Context " + dcontext);
- MBeanUtils.destroyMBean(dcontext);
- dcontext.removePropertyChangeListener(this);
-
- }
- */
-
-
- /**
- * Deregister the MBeans for the specified Engine and its nested
- * components.
- *
- * @param engine Engine for which to destroy MBeans
- *
- * @exception Exception if an exception is thrown during MBean destruction
- */
- protected void destroyMBeans(Engine engine) throws Exception {
-
- // Deregister ourselves as a ContainerListener
- engine.removeContainerListener(this);
-
- // Deregister the MBeans for each child Host
- Container hosts[] = engine.findChildren();
- for (int k = 0; k < hosts.length; k++) {
- destroyMBeans((Host) hosts[k]);
- }
-
- // Deregister the MBeans for the associated nested components
- Realm eRealm = engine.getRealm();
- if (eRealm != null) {
- if (log.isDebugEnabled())
- log.debug("Destroying MBean for Realm " + eRealm);
- //MBeanUtils.destroyMBean(eRealm);
- }
-
- // Deregister the MBean for the Engine itself
- if (log.isDebugEnabled()) {
- log.debug("Destroying MBean for Engine " + engine);
- }
- MBeanUtils.destroyMBean(engine);
-
- }
-
-
- /**
- * Deregister the MBeans for the specified Host and its nested components.
- *
- * @param host Host for which to destroy MBeans
- *
- * @exception Exception if an exception is thrown during MBean destruction
- */
- protected void destroyMBeans(Host host) throws Exception {
-
- // Deregister ourselves as a ContainerListener
- host.removeContainerListener(this);
-
- // Deregister the MBeans for each child Context
- Container contexts[] = host.findChildren();
- for (int k = 0; k < contexts.length; k++) {
- destroyMBeans((Context) contexts[k]);
- }
-
-
- // Deregister the MBeans for the associated nested components
- Realm eRealm = host.getParent().getRealm();
- Realm hRealm = host.getRealm();
- if ((hRealm != null) && (hRealm != eRealm)) {
- if (log.isDebugEnabled())
- log.debug("Destroying MBean for Realm " + hRealm);
- //MBeanUtils.destroyMBean(hRealm);
- }
-
- // Deregister the MBean for the Host itself
- if (log.isDebugEnabled()) {
- log.debug("Destroying MBean for Host " + host);
- }
- MBeanUtils.destroyMBean(host);
-
- }
-
-
- /**
- * Deregister the MBeans for the specified NamingResources and its
- * nested components.
- *
- * @param resources NamingResources for which to destroy MBeans
- *
- * @exception Exception if an exception is thrown during MBean destruction
- */
- protected void destroyMBeans(NamingResources resources) throws Exception {
-
- // Destroy the MBeans for each child resource entry
- ContextResource cresources[] = resources.findResources();
- for (int i = 0; i < cresources.length; i++) {
- destroyMBeans(cresources[i]);
- }
-
- // Destroy the MBeans for each child resource link entry
- ContextResourceLink cresourcelinks[] = resources.findResourceLinks();
- for (int i = 0; i < cresourcelinks.length; i++) {
- destroyMBeans(cresourcelinks[i]);
- }
-
- // Destroy the MBeans for each child environment entry
- ContextEnvironment environments[] = resources.findEnvironments();
- for (int i = 0; i < environments.length; i++) {
- destroyMBeans(environments[i]);
- }
-
- // Destroy the MBean for the NamingResources itself
- if (log.isDebugEnabled()) {
- log.debug("Destroying MBean for NamingResources " + resources);
- }
- MBeanUtils.destroyMBean(resources);
- resources.removePropertyChangeListener(this);
-
- }
-
-
- /**
- * Deregister the MBeans for the specified Server and its related
- * components.
- *
- * @param server Server for which to destroy MBeans
- *
- * @exception Exception if an exception is thrown during MBean destruction
- */
- protected void destroyMBeans(Server server) throws Exception {
-
- // Destroy the MBeans for the global NamingResources (if any)
- NamingResources resources = server.getGlobalNamingResources();
- if (resources != null) {
- destroyMBeans(resources);
- }
-
- // Destroy the MBeans for each child Service
- Service services[] = server.findServices();
- for (int i = 0; i < services.length; i++) {
- // FIXME - Warp object hierarchy not currently supported
- if (services[i].getContainer().getClass().getName().equals
- ("org.apache.catalina.connector.warp.WarpEngine")) {
- if (log.isDebugEnabled()) {
- log.debug("Skipping MBean for Service " + services[i]);
- }
- continue;
- }
- destroyMBeans(services[i]);
- }
-
- // Destroy the MBean for the Server itself
- if (log.isDebugEnabled()) {
- log.debug("Destroying MBean for Server " + server);
- }
- MBeanUtils.destroyMBean(server);
- if (server instanceof StandardServer) {
- ((StandardServer) server).removePropertyChangeListener(this);
- }
-
- }
-
-
- /**
- * Deregister the MBeans for the specified Service and its nested
- * components.
- *
- * @param service Service for which to destroy MBeans
- *
- * @exception Exception if an exception is thrown during MBean destruction
- */
- protected void destroyMBeans(Service service) throws Exception {
-
- // Deregister the MBeans for the associated Engine
- Engine engine = (Engine) service.getContainer();
- if (engine != null) {
- destroyMBeans(engine);
- }
-
- // Deregister the MBeans for the corresponding Connectors
- Connector connectors[] = service.findConnectors();
- for (int j = 0; j < connectors.length; j++) {
- destroyMBeans(connectors[j], service);
- }
-
- if (service instanceof StandardService) {
- ((StandardService) service).removePropertyChangeListener(this);
- }
-
- }
-
-
- /**
- * Process the addition of a new child Container to a parent Container.
- *
- * @param parent Parent container
- * @param child Child container
- */
- protected void processContainerAddChild(Container parent,
- Container child) {
-
- if (log.isDebugEnabled())
- log.debug("Process addChild[parent=" + parent + ",child=" + child + "]");
-
- try {
- if (child instanceof Context) {
- createMBeans((Context) child);
- } else if (child instanceof Engine) {
- createMBeans((Engine) child);
- } else if (child instanceof Host) {
- createMBeans((Host) child);
- }
- } catch (MBeanException t) {
- Exception e = t.getTargetException();
- if (e == null)
- e = t;
- log.error("processContainerAddChild: MBeanException", e);
- } catch (Throwable t) {
- log.error("processContainerAddChild: Throwable", t);
- }
-
- }
-
-
-
-
- /**
- * Process a property change event on a Container.
- *
- * @param container The container on which this event occurred
- * @param propertyName The name of the property that changed
- * @param oldValue The previous value (may be <code>null</code>)
- * @param newValue The new value (may be <code>null</code>)
- *
- * @exception Exception if an exception is thrown
- */
- protected void processContainerPropertyChange(Container container,
- String propertyName,
- Object oldValue,
- Object newValue)
- throws Exception {
-
- if (log.isTraceEnabled()) {
- log.trace("propertyChange[container=" + container +
- ",propertyName=" + propertyName +
- ",oldValue=" + oldValue +
- ",newValue=" + newValue + "]");
- }
- if ("loader".equals(propertyName)) {
- if (oldValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Removing MBean for Loader " + oldValue);
- }
- MBeanUtils.destroyMBean((Loader) oldValue);
- }
- if (newValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Creating MBean for Loader " + newValue);
- }
- MBeanUtils.createMBean((Loader) newValue);
- }
- } else if ("logger".equals(propertyName)) {
- if (oldValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Removing MBean for Logger " + oldValue);
- }
- // MBeanUtils.destroyMBean((Logger) oldValue);
- }
- if (newValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Creating MBean for Logger " + newValue);
- }
- //MBeanUtils.createMBean((Logger) newValue);
- }
- } else if ("manager".equals(propertyName)) {
- if (oldValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Removing MBean for Manager " + oldValue);
- }
- //MBeanUtils.destroyMBean((Manager) oldValue);
- }
- if (newValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Creating MBean for Manager " + newValue);
- }
- //MBeanUtils.createMBean((Manager) newValue);
- }
- } else if ("realm".equals(propertyName)) {
- if (oldValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Removing MBean for Realm " + oldValue);
- }
- MBeanUtils.destroyMBean((Realm) oldValue);
- }
- if (newValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Creating MBean for Realm " + newValue);
- }
- //MBeanUtils.createMBean((Realm) newValue);
- }
- } else if ("service".equals(propertyName)) {
- if (oldValue != null) {
- destroyMBeans((Service) oldValue);
- }
- if (newValue != null) {
- createMBeans((Service) newValue);
- }
- }
-
- }
-
-
- /**
- * Process a property change event on a DefaultContext.
- *
- * @param defaultContext The DefaultContext on which this event occurred
- * @param propertyName The name of the property that changed
- * @param oldValue The previous value (may be <code>null</code>)
- * @param newValue The new value (may be <code>null</code>)
- *
- * @exception Exception if an exception is thrown
- */
- /*
- protected void processDefaultContextPropertyChange(DefaultContext defaultContext,
- String propertyName,
- Object oldValue,
- Object newValue)
- throws Exception {
-
- if (log.isTraceEnabled()) {
- log.trace("propertyChange[defaultContext=" + defaultContext +
- ",propertyName=" + propertyName +
- ",oldValue=" + oldValue +
- ",newValue=" + newValue + "]");
- }
- if ("loader".equals(propertyName)) {
- if (oldValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Removing MBean for Loader " + oldValue);
- }
- MBeanUtils.destroyMBean((Loader) oldValue);
- }
- if (newValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Creating MBean for Loader " + newValue);
- }
- MBeanUtils.createMBean((Loader) newValue);
- }
- } else if ("logger".equals(propertyName)) {
- if (oldValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Removing MBean for Logger " + oldValue);
- }
- //MBeanUtils.destroyMBean((Logger) oldValue);
- }
- if (newValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Creating MBean for Logger " + newValue);
- }
- //MBeanUtils.createMBean((Logger) newValue);
- }
- } else if ("manager".equals(propertyName)) {
- if (oldValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Removing MBean for Manager " + oldValue);
- }
- MBeanUtils.destroyMBean((Manager) oldValue);
- }
- if (newValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("Creating MBean for Manager " + newValue);
- }
- MBeanUtils.createMBean((Manager) newValue);
- }
- } else if ("realm".equals(propertyName)) {
- if (oldValue != null) {
-// if (log.isDebugEnabled()) {
-// log.debug("Removing MBean for Realm " + oldValue);
-// }
-// //MBeanUtils.destroyMBean((Realm) oldValue);
- }
- if (newValue != null) {
-// if (log.isDebugEnabled()) {
-// log.debug("Creating MBean for Realm " + newValue);
-// }
-// //MBeanUtils.createMBean((Realm) newValue);
- }
- } else if ("service".equals(propertyName)) {
- if (oldValue != null) {
- destroyMBeans((Service) oldValue);
- }
- if (newValue != null) {
- createMBeans((Service) newValue);
- }
- }
-
- }*/
-
-
- /**
- * Process the removal of a child Container from a parent Container.
- *
- * @param parent Parent container
- * @param child Child container
- */
- protected void processContainerRemoveChild(Container parent,
- Container child) {
-
- if (log.isDebugEnabled())
- log.debug("Process removeChild[parent=" + parent + ",child=" +
- child + "]");
-
- try {
- if (child instanceof Context) {
- Context context = (Context) child;
- if (context.getPrivileged()) {
- context.getServletContext().removeAttribute
- (Globals.MBEAN_REGISTRY_ATTR);
- context.getServletContext().removeAttribute
- (Globals.MBEAN_SERVER_ATTR);
- }
- if (log.isDebugEnabled())
- log.debug(" Removing MBean for Context " + context);
- destroyMBeans(context);
- if (context instanceof StandardContext) {
- ((StandardContext) context).
- removePropertyChangeListener(this);
- }
- } else if (child instanceof Host) {
- Host host = (Host) child;
- destroyMBeans(host);
- if (host instanceof StandardHost) {
- ((StandardHost) host).
- removePropertyChangeListener(this);
- }
- }
- } catch (MBeanException t) {
- Exception e = t.getTargetException();
- if (e == null)
- e = t;
- log.error("processContainerRemoveChild: MBeanException", e);
- } catch (Throwable t) {
- log.error("processContainerRemoveChild: Throwable", t);
- }
-
- }
-
-
- /**
- * Process a property change event on a NamingResources.
- *
- * @param resources The global naming resources on which this
- * event occurred
- * @param propertyName The name of the property that changed
- * @param oldValue The previous value (may be <code>null</code>)
- * @param newValue The new value (may be <code>null</code>)
- *
- * @exception Exception if an exception is thrown
- */
- protected void processNamingResourcesPropertyChange
- (NamingResources resources, String propertyName,
- Object oldValue, Object newValue)
- throws Exception {
-
- if (log.isTraceEnabled()) {
- log.trace("propertyChange[namingResources=" + resources +
- ",propertyName=" + propertyName +
- ",oldValue=" + oldValue +
- ",newValue=" + newValue + "]");
- }
-
- // FIXME - Add other resource types when supported by admin tool
- if ("environment".equals(propertyName)) {
- if (oldValue != null) {
- destroyMBeans((ContextEnvironment) oldValue);
- }
- if (newValue != null) {
- createMBeans((ContextEnvironment) newValue);
- }
- } else if ("resource".equals(propertyName)) {
- if (oldValue != null) {
- destroyMBeans((ContextResource) oldValue);
- }
- if (newValue != null) {
- createMBeans((ContextResource) newValue);
- }
- } else if ("resourceLink".equals(propertyName)) {
- if (oldValue != null) {
- destroyMBeans((ContextResourceLink) oldValue);
- }
- if (newValue != null) {
- createMBeans((ContextResourceLink) newValue);
- }
- }
-
- }
-
-
- /**
- * Process a property change event on a Server.
- *
- * @param server The server on which this event occurred
- * @param propertyName The name of the property that changed
- * @param oldValue The previous value (may be <code>null</code>)
- * @param newValue The new value (may be <code>null</code>)
- *
- * @exception Exception if an exception is thrown
- */
- protected void processServerPropertyChange(Server server,
- String propertyName,
- Object oldValue,
- Object newValue)
- throws Exception {
-
- if (log.isTraceEnabled()) {
- log.trace("propertyChange[server=" + server +
- ",propertyName=" + propertyName +
- ",oldValue=" + oldValue +
- ",newValue=" + newValue + "]");
- }
- if ("globalNamingResources".equals(propertyName)) {
- if (oldValue != null) {
- destroyMBeans((NamingResources) oldValue);
- }
- if (newValue != null) {
- createMBeans((NamingResources) newValue);
- }
- } else if ("service".equals(propertyName)) {
- if (oldValue != null) {
- destroyMBeans((Service) oldValue);
- }
- if (newValue != null) {
- createMBeans((Service) newValue);
- }
- }
-
- }
-
-
- /**
- * Process a property change event on a Service.
- *
- * @param service The service on which this event occurred
- * @param propertyName The name of the property that changed
- * @param oldValue The previous value (may be <code>null</code>)
- * @param newValue The new value (may be <code>null</code>)
- *
- * @exception Exception if an exception is thrown
- */
- protected void processServicePropertyChange(Service service,
- String propertyName,
- Object oldValue,
- Object newValue)
- throws Exception {
-
- if (log.isTraceEnabled()) {
- log.trace("propertyChange[service=" + service +
- ",propertyName=" + propertyName +
- ",oldValue=" + oldValue +
- ",newValue=" + newValue + "]");
- }
- if ("connector".equals(propertyName)) {
- if (oldValue != null) {
- destroyMBeans((Connector) oldValue, service);
- }
- if (newValue != null) {
- createMBeans((Connector) newValue);
- }
- } else if ("container".equals(propertyName)) {
- if (oldValue != null) {
- destroyMBeans((Engine) oldValue);
- }
- if (newValue != null) {
- createMBeans((Engine) newValue);
- }
- }
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/mbeans/mbeans-descriptors.xml
===================================================================
--- trunk/java/org/apache/catalina/mbeans/mbeans-descriptors.xml 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/mbeans/mbeans-descriptors.xml 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,405 +0,0 @@
-<?xml version="1.0"?>
-<mbeans-descriptors>
-
- <mbean name="MBeanFactory"
- className="org.apache.catalina.mbeans.MBeanFactory"
- description="Factory for MBeans and corresponding components"
- domain="Catalina">
-
- <!-- IMPLEMENTATION NOTE - all of the createXxxxx methods create a new -->
- <!-- component and attach it to Catalina's component tree. The return -->
- <!-- value is the object name of the corresponding MBean for the new -->
- <!-- component. -->
-
- <operation name="createAccessLoggerValve"
- description="Create a new AccessLoggerValve"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createAjpConnector"
- description="Create a new AjpConnector"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- <parameter name="address"
- description="The IP address on which to bind"
- type="java.lang.String"/>
- <parameter name="port"
- description="TCP port number to listen on"
- type="int"/>
- </operation>
-
- <operation name="createDataSourceRealm"
- description="Create a new DataSource Realm"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- <parameter name="dataSourceName"
- description="The JNDI named JDBC DataSource"
- type="java.lang.String"/>
- <parameter name="roleNameCol"
- description="The column in the user role table that names a role"
- type="java.lang.String"/>
- <parameter name="userCredCol"
- description="The column in the user table that holds the user's
- credentials"
- type="java.lang.String"/>
- <parameter name="userNameCol"
- description="The column in the user table that holds the user's
- username"
- type="java.lang.String"/>
- <parameter name="userRoleTable"
- description="The table that holds the relation between user's and
- roles"
- type="java.lang.String"/>
- <parameter name="userTable"
- description="The table that holds user data"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createFileLogger"
- description="Create a new FileLogger"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createHttpConnector"
- description="Create a new HttpConnector"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- <parameter name="address"
- description="The IP address on which to bind"
- type="java.lang.String"/>
- <parameter name="port"
- description="TCP port number to listen on"
- type="int"/>
- </operation>
-
- <operation name="createHttpsConnector"
- description="Create a new HttpsConnector"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- <parameter name="address"
- description="The IP address on which to bind"
- type="java.lang.String"/>
- <parameter name="port"
- description="TCP port number to listen on"
- type="int"/>
- </operation>
-
- <operation name="createJDBCRealm"
- description="Create a new JDBC Realm"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createJNDIRealm"
- description="Create a new JNDI Realm"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createMemoryRealm"
- description="Create a new Memory Realm"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createRemoteAddrValve"
- description="Create a new Remote Address Filter Valve"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createRemoteHostValve"
- description="Create a new Remote Host Filter Valve"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createRequestDumperValve"
- description="Create a new Request Dumper Valve"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createSingleSignOn"
- description="Create a new Single Sign On Valve"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createStandardContext"
- description="Create a new StandardContext"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- <parameter name="path"
- description="The context path for this Context"
- type="java.lang.String"/>
- <parameter name="docBase"
- description="Document base directory (or WAR) for ths Context"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createStandardEngine"
- description="Create a new StandardEngine"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- <parameter name="name"
- description="Unique name of this Engine"
- type="java.lang.String"/>
- <parameter name="defaultHost"
- description="Default host name for this Engine"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createStandardEngineService"
- description="Create a new StandardEngine and StandardService"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent Service"
- type="java.lang.String"/>
- <parameter name="engineName"
- description="Unique name of this Engine"
- type="java.lang.String"/>
- <parameter name="defaultHost"
- description="Default host name for this Engine"
- type="java.lang.String"/>
- <parameter name="serviceName"
- description="Unique name of this Service"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createStandardHost"
- description="Create a new StandardHost"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- <parameter name="name"
- description="Unique name of this Host"
- type="java.lang.String"/>
- <parameter name="appBase"
- description="set host deployment directory"
- type="java.lang.String"/>
- <parameter name="autoDeploy"
- description="The auto deploy flag for this Host"
- type="boolean"/>
- <parameter name="deployOnStartup"
- description="The deploy on startup flag for this Host"
- type="boolean"/>
- <parameter name="deployXML"
- description="deploy Context XML config files property"
- type="boolean"/>
- <parameter name="unpackWARs"
- description="Unpack WARs property"
- type="boolean"/>
- <parameter name="xmlNamespaceAware"
- description="Attribute value used to turn on/off XML namespace awareness"
- type="boolean"/>
- <parameter name="xmlValidation"
- description="Attribute value used to turn on/off XML validation"
- type="boolean"/>
- </operation>
-
-
-
-
- <operation name="createStandardManager"
- description="Create a new StandardManager"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createStandardService"
- description="Create a new StandardService"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- <parameter name="name"
- description="Unique name of this Service"
- type="java.lang.String"/>
- <parameter name="domain"
- description="The domain of this Service"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createSystemErrLogger"
- description="Create a new System Error Logger"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createSystemOutLogger"
- description="Create a new System Output Logger"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createUserDatabaseRealm"
- description="Create a new UserDatabase Realm"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- <parameter name="resourceName"
- description="Global JNDI resource name of our UserDatabase instance"
- type="java.lang.String"/>
- </operation>
-
- <operation name="createWebappLoader"
- description="Create a new Web Application Loader"
- impact="ACTION"
- returnType="java.lang.String">
- <parameter name="parent"
- description="MBean Name of the associated parent component"
- type="java.lang.String"/>
- </operation>
-
- <!-- IMPLEMENTATION NOTE - all of the removeXxxxx methods cause the -->
- <!-- corresponding Catalina component (and any related child -->
- <!-- components to be stopped (if necessary) and removed, and the -->
- <!-- corresponding MBeans to be destroyed. -->
-
- <operation name="removeConnector"
- description="Remove an existing Connector"
- impact="ACTION"
- returnType="void">
- <parameter name="name"
- description="MBean Name of the component to be removed"
- type="java.lang.String"/>
- </operation>
-
- <operation name="removeContext"
- description="Remove an existing Context"
- impact="ACTION"
- returnType="void">
- <parameter name="name"
- description="MBean Name of the component to be removed"
- type="java.lang.String"/>
- </operation>
-
- <operation name="removeHost"
- description="Remove an existing Host"
- impact="ACTION"
- returnType="void">
- <parameter name="name"
- description="MBean Name of the component to be removed"
- type="java.lang.String"/>
- </operation>
-
- <operation name="removeLoader"
- description="Remove an existing Loader"
- impact="ACTION"
- returnType="void">
- <parameter name="name"
- description="MBean Name of the component to be removed"
- type="java.lang.String"/>
- </operation>
-
- <operation name="removeLogger"
- description="Remove an existing Logger"
- impact="ACTION"
- returnType="void">
- <parameter name="name"
- description="MBean Name of the component to be removed"
- type="java.lang.String"/>
- </operation>
-
- <operation name="removeManager"
- description="Remove an existing Manager"
- impact="ACTION"
- returnType="void">
- <parameter name="name"
- description="MBean Name of the component to be removed"
- type="java.lang.String"/>
- </operation>
-
- <operation name="removeRealm"
- description="Remove an existing Realm"
- impact="ACTION"
- returnType="void">
- <parameter name="name"
- description="MBean Name of the component to be removed"
- type="java.lang.String"/>
- </operation>
-
- <operation name="removeService"
- description="Remove an existing Service"
- impact="ACTION"
- returnType="void">
- <parameter name="name"
- description="MBean Name of the component to be removed"
- type="java.lang.String"/>
- </operation>
-
- <operation name="removeValve"
- description="Remove an existing Valve"
- impact="ACTION"
- returnType="void">
- <parameter name="name"
- description="MBean Name of the component to be removed"
- type="java.lang.String"/>
- </operation>
-
- </mbean>
-
-</mbeans-descriptors>
Modified: trunk/java/org/apache/catalina/realm/DataSourceRealm.java
===================================================================
--- trunk/java/org/apache/catalina/realm/DataSourceRealm.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/realm/DataSourceRealm.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -82,7 +82,7 @@
/**
* Context local datasource.
*/
- protected boolean localDataSource = false;
+ protected boolean localDataSource = true;
/**
@@ -395,7 +395,8 @@
context = ContextBindings.getClassLoader();
context = (Context) context.lookup("comp/env");
} else {
- context = ((StandardServer) getServer()).getGlobalNamingContext();
+ // FIXME: no non local DS
+ context = null;//((StandardServer) getServer()).getGlobalNamingContext();
}
DataSource dataSource = (DataSource)context.lookup(dataSourceName);
return dataSource.getConnection();
Deleted: trunk/java/org/apache/catalina/startup/Bootstrap.java
===================================================================
--- trunk/java/org/apache/catalina/startup/Bootstrap.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/Bootstrap.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,498 +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.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.StringTokenizer;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-
-import org.apache.catalina.security.SecurityClassLoad;
-import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
-
-
-/**
- * Boostrap loader for Catalina. This application constructs a class loader
- * for use in loading the Catalina internal classes (by accumulating all of the
- * JAR files found in the "server" directory under "catalina.home"), and
- * starts the regular execution of the container. The purpose of this
- * roundabout approach is to keep the Catalina internal classes (and any
- * other classes they depend on, such as an XML parser) out of the system
- * class path and therefore not visible to application level classes.
- *
- * @author Craig R. McClanahan
- * @author Remy Maucherat
- * @version $Revision$ $Date$
- */
-
-public final class Bootstrap {
-
- private static Logger log = Logger.getLogger(Bootstrap.class);
-
- // -------------------------------------------------------------- Constants
-
-
- protected static final String CATALINA_HOME_TOKEN = "${catalina.home}";
- protected static final String CATALINA_BASE_TOKEN = "${catalina.base}";
-
-
- // ------------------------------------------------------- Static Variables
-
-
- /**
- * Daemon object used by main.
- */
- private static Bootstrap daemon = null;
-
-
- // -------------------------------------------------------------- Variables
-
-
- /**
- * Daemon reference.
- */
- private Object catalinaDaemon = null;
-
-
- protected ClassLoader commonLoader = null;
- protected ClassLoader catalinaLoader = null;
- protected ClassLoader sharedLoader = null;
-
-
- // -------------------------------------------------------- Private Methods
-
-
- private void initClassLoaders() {
- try {
- commonLoader = createClassLoader("common", null);
- if( commonLoader == null ) {
- // no config file, default to this loader - we might be in a 'single' env.
- commonLoader=this.getClass().getClassLoader();
- }
- catalinaLoader = createClassLoader("server", commonLoader);
- sharedLoader = createClassLoader("shared", commonLoader);
- } catch (Throwable t) {
- log.error("Class loader creation threw exception", t);
- System.exit(1);
- }
- }
-
-
- private ClassLoader createClassLoader(String name, ClassLoader parent)
- throws Exception {
-
- String value = CatalinaProperties.getProperty(name + ".loader");
- if ((value == null) || (value.equals("")))
- return parent;
-
- ArrayList repositoryLocations = new ArrayList();
- ArrayList repositoryTypes = new ArrayList();
- int i;
-
- StringTokenizer tokenizer = new StringTokenizer(value, ",");
- while (tokenizer.hasMoreElements()) {
- String repository = tokenizer.nextToken();
-
- // Local repository
- boolean replace = false;
- String before = repository;
- while ((i=repository.indexOf(CATALINA_HOME_TOKEN))>=0) {
- replace=true;
- if (i>0) {
- repository = repository.substring(0,i) + getCatalinaHome()
- + repository.substring(i+CATALINA_HOME_TOKEN.length());
- } else {
- repository = getCatalinaHome()
- + repository.substring(CATALINA_HOME_TOKEN.length());
- }
- }
- while ((i=repository.indexOf(CATALINA_BASE_TOKEN))>=0) {
- replace=true;
- if (i>0) {
- repository = repository.substring(0,i) + getCatalinaBase()
- + repository.substring(i+CATALINA_BASE_TOKEN.length());
- } else {
- repository = getCatalinaBase()
- + repository.substring(CATALINA_BASE_TOKEN.length());
- }
- }
- if (replace && log.isDebugEnabled())
- log.debug("Expanded " + before + " to " + replace);
-
- // Check for a JAR URL repository
- try {
- URL url=new URL(repository);
- repositoryLocations.add(repository);
- repositoryTypes.add(ClassLoaderFactory.IS_URL);
- continue;
- } catch (MalformedURLException e) {
- // Ignore
- }
-
- if (repository.endsWith("*.jar")) {
- repository = repository.substring
- (0, repository.length() - "*.jar".length());
- repositoryLocations.add(repository);
- repositoryTypes.add(ClassLoaderFactory.IS_GLOB);
- } else if (repository.endsWith(".jar")) {
- repositoryLocations.add(repository);
- repositoryTypes.add(ClassLoaderFactory.IS_JAR);
- } else {
- repositoryLocations.add(repository);
- repositoryTypes.add(ClassLoaderFactory.IS_DIR);
- }
- }
-
- String[] locations = (String[]) repositoryLocations.toArray(new String[0]);
- Integer[] types = (Integer[]) repositoryTypes.toArray(new Integer[0]);
-
- ClassLoader classLoader = ClassLoaderFactory.createClassLoader
- (locations, types, parent);
-
- // Retrieving MBean server
- MBeanServer mBeanServer = null;
- if (MBeanServerFactory.findMBeanServer(null).size() > 0) {
- mBeanServer =
- (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
- } else {
- mBeanServer = MBeanServerFactory.createMBeanServer();
- }
-
- // Register the server classloader
- ObjectName objectName =
- new ObjectName("Catalina:type=ServerClassLoader,name=" + name);
- mBeanServer.registerMBean(classLoader, objectName);
-
- return classLoader;
-
- }
-
-
- /**
- * Initialize daemon.
- */
- public void init()
- throws Exception
- {
-
- // Set Catalina path
- setCatalinaHome();
- setCatalinaBase();
-
- initClassLoaders();
-
- Thread.currentThread().setContextClassLoader(catalinaLoader);
-
- SecurityClassLoad.securityClassLoad(catalinaLoader);
-
- // Load our startup class and call its process() method
- if (log.isDebugEnabled())
- log.debug("Loading startup class");
- Class startupClass =
- catalinaLoader.loadClass
- ("org.apache.catalina.startup.Catalina");
- Object startupInstance = startupClass.newInstance();
-
- // Set the shared extensions class loader
- if (log.isDebugEnabled())
- log.debug("Setting startup class properties");
- String methodName = "setParentClassLoader";
- Class paramTypes[] = new Class[1];
- paramTypes[0] = Class.forName("java.lang.ClassLoader");
- Object paramValues[] = new Object[1];
- paramValues[0] = sharedLoader;
- Method method =
- startupInstance.getClass().getMethod(methodName, paramTypes);
- method.invoke(startupInstance, paramValues);
-
- catalinaDaemon = startupInstance;
-
- }
-
-
- /**
- * Load daemon.
- */
- private void load(String[] arguments)
- throws Exception {
-
- // Call the load() method
- String methodName = "load";
- Object param[];
- Class paramTypes[];
- if (arguments==null || arguments.length==0) {
- paramTypes = null;
- param = null;
- } else {
- paramTypes = new Class[1];
- paramTypes[0] = arguments.getClass();
- param = new Object[1];
- param[0] = arguments;
- }
- Method method =
- catalinaDaemon.getClass().getMethod(methodName, paramTypes);
- if (log.isDebugEnabled())
- log.debug("Calling startup class " + method);
- method.invoke(catalinaDaemon, param);
-
- }
-
-
- // ----------------------------------------------------------- Main Program
-
-
- /**
- * Load the Catalina daemon.
- */
- public void init(String[] arguments)
- throws Exception {
-
- init();
- load(arguments);
-
- }
-
-
- /**
- * Start the Catalina daemon.
- */
- public void start()
- throws Exception {
- if( catalinaDaemon==null ) init();
-
- Method method = catalinaDaemon.getClass().getMethod("start", (Class [] )null);
- method.invoke(catalinaDaemon, (Object [])null);
-
- }
-
-
- /**
- * Stop the Catalina Daemon.
- */
- public void stop()
- throws Exception {
-
- Method method = catalinaDaemon.getClass().getMethod("stop", (Class [] ) null);
- method.invoke(catalinaDaemon, (Object [] ) null);
-
- }
-
-
- /**
- * Stop the standlone server.
- */
- public void stopServer()
- throws Exception {
-
- Method method =
- catalinaDaemon.getClass().getMethod("stopServer", (Class []) null);
- method.invoke(catalinaDaemon, (Object []) null);
-
- }
-
-
- /**
- * Stop the standlone server.
- */
- public void stopServer(String[] arguments)
- throws Exception {
-
- Object param[];
- Class paramTypes[];
- if (arguments==null || arguments.length==0) {
- paramTypes = null;
- param = null;
- } else {
- paramTypes = new Class[1];
- paramTypes[0] = arguments.getClass();
- param = new Object[1];
- param[0] = arguments;
- }
- Method method =
- catalinaDaemon.getClass().getMethod("stopServer", paramTypes);
- method.invoke(catalinaDaemon, param);
-
- }
-
-
- /**
- * Set flag.
- */
- public void setAwait(boolean await)
- throws Exception {
-
- Class paramTypes[] = new Class[1];
- paramTypes[0] = Boolean.TYPE;
- Object paramValues[] = new Object[1];
- paramValues[0] = new Boolean(await);
- Method method =
- catalinaDaemon.getClass().getMethod("setAwait", paramTypes);
- method.invoke(catalinaDaemon, paramValues);
-
- }
-
- public boolean getAwait()
- throws Exception
- {
- Class paramTypes[] = new Class[0];
- Object paramValues[] = new Object[0];
- Method method =
- catalinaDaemon.getClass().getMethod("getAwait", paramTypes);
- Boolean b=(Boolean)method.invoke(catalinaDaemon, paramValues);
- return b.booleanValue();
- }
-
-
- /**
- * Destroy the Catalina Daemon.
- */
- public void destroy() {
-
- // FIXME
-
- }
-
-
- /**
- * Main method, used for testing only.
- *
- * @param args Command line arguments to be processed
- */
- public static void main(String args[]) {
-
- if (daemon == null) {
- daemon = new Bootstrap();
- try {
- daemon.init();
- } catch (Throwable t) {
- t.printStackTrace();
- return;
- }
- }
-
- try {
- String command = "start";
- if (args.length > 0) {
- command = args[args.length - 1];
- }
-
- if (command.equals("startd")) {
- args[0] = "start";
- daemon.load(args);
- daemon.start();
- } else if (command.equals("stopd")) {
- args[0] = "stop";
- daemon.stop();
- } else if (command.equals("start")) {
- daemon.setAwait(true);
- daemon.load(args);
- daemon.start();
- } else if (command.equals("stop")) {
- daemon.stopServer(args);
- } else {
- log.warn("Bootstrap: command \"" + command + "\" does not exist.");
- }
- } catch (Throwable t) {
- t.printStackTrace();
- }
-
- }
-
- public void setCatalinaHome(String s) {
- System.setProperty( "catalina.home", s );
- }
-
- public void setCatalinaBase(String s) {
- System.setProperty( "catalina.base", s );
- }
-
-
- /**
- * Set the <code>catalina.base</code> System property to the current
- * working directory if it has not been set.
- */
- private void setCatalinaBase() {
-
- if (System.getProperty("catalina.base") != null)
- return;
- if (System.getProperty("catalina.home") != null)
- System.setProperty("catalina.base",
- System.getProperty("catalina.home"));
- else
- System.setProperty("catalina.base",
- System.getProperty("user.dir"));
-
- }
-
-
- /**
- * Set the <code>catalina.home</code> System property to the current
- * working directory if it has not been set.
- */
- private void setCatalinaHome() {
-
- if (System.getProperty("catalina.home") != null)
- return;
- File bootstrapJar =
- new File(System.getProperty("user.dir"), "bootstrap.jar");
- if (bootstrapJar.exists()) {
- try {
- System.setProperty
- ("catalina.home",
- (new File(System.getProperty("user.dir"), ".."))
- .getCanonicalPath());
- } catch (Exception e) {
- // Ignore
- System.setProperty("catalina.home",
- System.getProperty("user.dir"));
- }
- } else {
- System.setProperty("catalina.home",
- System.getProperty("user.dir"));
- }
-
- }
-
-
- /**
- * Get the value of the catalina.home environment variable.
- */
- public static String getCatalinaHome() {
- return System.getProperty("catalina.home",
- System.getProperty("user.dir"));
- }
-
-
- /**
- * Get the value of the catalina.base environment variable.
- */
- public static String getCatalinaBase() {
- return System.getProperty("catalina.base", getCatalinaHome());
- }
-
-
-}
Modified: trunk/java/org/apache/catalina/startup/Catalina.java
===================================================================
--- trunk/java/org/apache/catalina/startup/Catalina.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/Catalina.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -20,24 +20,16 @@
import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
import org.apache.catalina.Container;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Server;
-import org.apache.catalina.core.StandardServer;
-import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.Rule;
import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
/**
@@ -179,8 +171,6 @@
public void process(String args[]) {
setAwait(true);
- setCatalinaHome();
- setCatalinaBase();
try {
if (arguments(args)) {
if (starting) {
@@ -256,131 +246,6 @@
}
- /**
- * Create and configure the Digester we will be using for startup.
- */
- protected Digester createStartDigester() {
- long t1=System.currentTimeMillis();
- // Initialize the digester
- Digester digester = new Digester();
- digester.setValidating(false);
- digester.setRulesValidation(true);
- HashMap<Class, List<String>> fakeAttributes = new HashMap<Class, List<String>>();
- ArrayList<String> attrs = new ArrayList<String>();
- attrs.add("className");
- fakeAttributes.put(Object.class, attrs);
- digester.setFakeAttributes(fakeAttributes);
- digester.setClassLoader(StandardServer.class.getClassLoader());
-
- // Configure the actions we will be using
- digester.addObjectCreate("Server",
- "org.apache.catalina.core.StandardServer",
- "className");
- digester.addSetProperties("Server");
- digester.addSetNext("Server",
- "setServer",
- "org.apache.catalina.Server");
-
- digester.addObjectCreate("Server/GlobalNamingResources",
- "org.apache.catalina.deploy.NamingResources");
- digester.addSetProperties("Server/GlobalNamingResources");
- digester.addSetNext("Server/GlobalNamingResources",
- "setGlobalNamingResources",
- "org.apache.catalina.deploy.NamingResources");
-
- digester.addObjectCreate("Server/Listener",
- null, // MUST be specified in the element
- "className");
- digester.addSetProperties("Server/Listener");
- digester.addSetNext("Server/Listener",
- "addLifecycleListener",
- "org.apache.catalina.LifecycleListener");
-
- digester.addObjectCreate("Server/Service",
- "org.apache.catalina.core.StandardService",
- "className");
- digester.addSetProperties("Server/Service");
- digester.addSetNext("Server/Service",
- "addService",
- "org.apache.catalina.Service");
-
- digester.addObjectCreate("Server/Service/Listener",
- null, // MUST be specified in the element
- "className");
- digester.addSetProperties("Server/Service/Listener");
- digester.addSetNext("Server/Service/Listener",
- "addLifecycleListener",
- "org.apache.catalina.LifecycleListener");
-
- //Executor
- digester.addObjectCreate("Server/Service/Executor",
- "org.apache.catalina.core.StandardThreadExecutor",
- "className");
- digester.addSetProperties("Server/Service/Executor");
-
- digester.addSetNext("Server/Service/Executor",
- "addExecutor",
- "org.apache.catalina.Executor");
-
-
- digester.addRule("Server/Service/Connector",
- new ConnectorCreateRule());
- digester.addRule("Server/Service/Connector",
- new SetAllPropertiesRule(new String[]{"executor"}));
- digester.addSetNext("Server/Service/Connector",
- "addConnector",
- "org.apache.catalina.connector.Connector");
-
-
- digester.addObjectCreate("Server/Service/Connector/Listener",
- null, // MUST be specified in the element
- "className");
- digester.addSetProperties("Server/Service/Connector/Listener");
- digester.addSetNext("Server/Service/Connector/Listener",
- "addLifecycleListener",
- "org.apache.catalina.LifecycleListener");
-
- // Add RuleSets for nested elements
- digester.addRuleSet(new NamingRuleSet("Server/GlobalNamingResources/"));
- digester.addRuleSet(new EngineRuleSet("Server/Service/"));
- digester.addRuleSet(new HostRuleSet("Server/Service/Engine/"));
- digester.addRuleSet(new ContextRuleSet("Server/Service/Engine/Host/"));
- digester.addRuleSet(new NamingRuleSet("Server/Service/Engine/Host/Context/"));
-
- // When the 'engine' is found, set the parentClassLoader.
- digester.addRule("Server/Service/Engine",
- new SetParentClassLoaderRule(parentClassLoader));
-
- long t2=System.currentTimeMillis();
- if (log.isDebugEnabled())
- log.debug("Digester for server.xml created " + ( t2-t1 ));
- return (digester);
-
- }
-
-
- /**
- * Create and configure the Digester we will be using for shutdown.
- */
- protected Digester createStopDigester() {
-
- // Initialize the digester
- Digester digester = new Digester();
-
- // Configure the rules we need for shutting down
- digester.addObjectCreate("Server",
- "org.apache.catalina.core.StandardServer",
- "className");
- digester.addSetProperties("Server");
- digester.addSetNext("Server",
- "setServer",
- "org.apache.catalina.Server");
-
- return (digester);
-
- }
-
-
public void stopServer() {
stopServer(null);
}
@@ -391,25 +256,6 @@
arguments(arguments);
}
- if( server == null ) {
- // Create and execute our Digester
- Digester digester = createStopDigester();
- digester.setClassLoader(Thread.currentThread().getContextClassLoader());
- File file = configFile();
- try {
- InputSource is =
- new InputSource("file://" + file.getAbsolutePath());
- FileInputStream fis = new FileInputStream(file);
- is.setByteStream(fis);
- digester.push(this);
- digester.parse(is);
- fis.close();
- } catch (Exception e) {
- log.error("Catalina.stop: ", e);
- System.exit(1);
- }
- }
-
// Stop the existing server
if (server.getPort() < 0) {
return;
@@ -432,92 +278,10 @@
/**
- * Set the <code>catalina.base</code> System property to the current
- * working directory if it has not been set.
- * @deprecated Use initDirs()
- */
- public void setCatalinaBase() {
- initDirs();
- }
-
- /**
- * Set the <code>catalina.home</code> System property to the current
- * working directory if it has not been set.
- * @deprecated Use initDirs()
- */
- public void setCatalinaHome() {
- initDirs();
- }
-
- /**
* Start a new server instance.
*/
public void load() {
- long t1 = System.nanoTime();
-
- initDirs();
-
- // Before digester - it may be needed
-
- initNaming();
-
- // Create and execute our Digester
- Digester digester = createStartDigester();
-
- InputSource inputSource = null;
- InputStream inputStream = null;
- File file = null;
- try {
- file = configFile();
- inputStream = new FileInputStream(file);
- inputSource = new InputSource("file://" + file.getAbsolutePath());
- } catch (Exception e) {
- ;
- }
- if (inputStream == null) {
- try {
- inputStream = getClass().getClassLoader()
- .getResourceAsStream(getConfigFile());
- inputSource = new InputSource
- (getClass().getClassLoader()
- .getResource(getConfigFile()).toString());
- } catch (Exception e) {
- ;
- }
- }
-
- // This should be included in catalina.jar
- // Alternative: don't bother with xml, just create it manually.
- if( inputStream==null ) {
- try {
- inputStream = getClass().getClassLoader()
- .getResourceAsStream("server-embed.xml");
- inputSource = new InputSource
- (getClass().getClassLoader()
- .getResource("server-embed.xml").toString());
- } catch (Exception e) {
- ;
- }
- }
-
-
- if ((inputStream == null) && (file != null)) {
- log.warn("Can't load server.xml from " + file.getAbsolutePath());
- return;
- }
-
- try {
- inputSource.setByteStream(inputStream);
- digester.push(this);
- digester.parse(inputSource);
- inputStream.close();
- } catch (Exception e) {
- log.warn("Catalina.start using "
- + getConfigFile() + ": " , e);
- return;
- }
-
// Stream redirection
initStreams();
@@ -530,10 +294,6 @@
}
}
- long t2 = System.nanoTime();
- if(log.isInfoEnabled())
- log.info("Initialization processed in " + ((t2 - t1) / 1000000) + " ms");
-
}
Deleted: trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,260 +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.net.URL;
-import java.util.ArrayList;
-
-import org.apache.catalina.loader.StandardClassLoader;
-import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
-
-
-/**
- * <p>Utility class for building class loaders for Catalina. The factory
- * method requires the following parameters in order to build a new class
- * loader (with suitable defaults in all cases):</p>
- * <ul>
- * <li>A set of directories containing unpacked classes (and resources)
- * that should be included in the class loader's
- * repositories.</li>
- * <li>A set of directories containing classes and resources in JAR files.
- * Each readable JAR file discovered in these directories will be
- * added to the class loader's repositories.</li>
- * <li><code>ClassLoader</code> instance that should become the parent of
- * the new class loader.</li>
- * </ul>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public final class ClassLoaderFactory {
-
-
- private static Logger log = Logger.getLogger(ClassLoaderFactory.class);
-
- protected static final Integer IS_DIR = new Integer(0);
- protected static final Integer IS_JAR = new Integer(1);
- protected static final Integer IS_GLOB = new Integer(2);
- protected static final Integer IS_URL = new Integer(3);
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Create and return a new class loader, based on the configuration
- * defaults and the specified directory paths:
- *
- * @param unpacked Array of pathnames to unpacked directories that should
- * be added to the repositories of the class loader, or <code>null</code>
- * for no unpacked directories to be considered
- * @param packed Array of pathnames to directories containing JAR files
- * that should be added to the repositories of the class loader,
- * or <code>null</code> for no directories of JAR files to be considered
- * @param parent Parent class loader for the new class loader, or
- * <code>null</code> for the system class loader.
- *
- * @exception Exception if an error occurs constructing the class loader
- */
- public static ClassLoader createClassLoader(File unpacked[],
- File packed[],
- ClassLoader parent)
- throws Exception {
- return createClassLoader(unpacked, packed, null, parent);
- }
-
-
- /**
- * Create and return a new class loader, based on the configuration
- * defaults and the specified directory paths:
- *
- * @param unpacked Array of pathnames to unpacked directories that should
- * be added to the repositories of the class loader, or <code>null</code>
- * for no unpacked directories to be considered
- * @param packed Array of pathnames to directories containing JAR files
- * that should be added to the repositories of the class loader,
- * or <code>null</code> for no directories of JAR files to be considered
- * @param urls Array of URLs to remote repositories, designing either JAR
- * resources or uncompressed directories that should be added to
- * the repositories of the class loader, or <code>null</code> for no
- * directories of JAR files to be considered
- * @param parent Parent class loader for the new class loader, or
- * <code>null</code> for the system class loader.
- *
- * @exception Exception if an error occurs constructing the class loader
- */
- public static ClassLoader createClassLoader(File unpacked[],
- File packed[],
- URL urls[],
- ClassLoader parent)
- throws Exception {
-
- if (log.isDebugEnabled())
- log.debug("Creating new class loader");
-
- // Construct the "class path" for this class loader
- ArrayList list = new ArrayList();
-
- // Add unpacked directories
- if (unpacked != null) {
- for (int i = 0; i < unpacked.length; i++) {
- File file = unpacked[i];
- if (!file.exists() || !file.canRead())
- continue;
- file = new File(file.getCanonicalPath() + File.separator);
- URL url = file.toURI().toURL();
- if (log.isDebugEnabled())
- log.debug(" Including directory " + url);
- list.add(url);
- }
- }
-
- // Add packed directory JAR files
- if (packed != null) {
- for (int i = 0; i < packed.length; i++) {
- File directory = packed[i];
- if (!directory.isDirectory() || !directory.exists() ||
- !directory.canRead())
- continue;
- String filenames[] = directory.list();
- for (int j = 0; j < filenames.length; j++) {
- String filename = filenames[j].toLowerCase();
- if (!filename.endsWith(".jar"))
- continue;
- File file = new File(directory, filenames[j]);
- if (log.isDebugEnabled())
- log.debug(" Including jar file " + file.getAbsolutePath());
- URL url = file.toURI().toURL();
- list.add(url);
- }
- }
- }
-
- // Construct the class loader itself
- URL[] array = (URL[]) list.toArray(new URL[list.size()]);
- StandardClassLoader classLoader = null;
- if (parent == null)
- classLoader = new StandardClassLoader(array);
- else
- classLoader = new StandardClassLoader(array, parent);
- return (classLoader);
-
- }
-
-
- /**
- * Create and return a new class loader, based on the configuration
- * defaults and the specified directory paths:
- *
- * @param locations Array of strings containing class directories, jar files,
- * jar directories or URLS that should be added to the repositories of
- * the class loader. The type is given by the member of param types.
- * @param types Array of types for the members of param locations.
- * Possible values are IS_DIR (class directory), IS_JAR (single jar file),
- * IS_GLOB (directory of jar files) and IS_URL (URL).
- * @param parent Parent class loader for the new class loader, or
- * <code>null</code> for the system class loader.
- *
- * @exception Exception if an error occurs constructing the class loader
- */
- public static ClassLoader createClassLoader(String locations[],
- Integer types[],
- ClassLoader parent)
- throws Exception {
-
- if (log.isDebugEnabled())
- log.debug("Creating new class loader");
-
- // Construct the "class path" for this class loader
- ArrayList list = new ArrayList();
-
- if (locations != null && types != null && locations.length == types.length) {
- for (int i = 0; i < locations.length; i++) {
- String location = locations[i];
- if ( types[i] == IS_URL ) {
- URL url = new URL(location);
- if (log.isDebugEnabled())
- log.debug(" Including URL " + url);
- list.add(url);
- } else if ( types[i] == IS_DIR ) {
- File directory = new File(location);
- directory = new File(directory.getCanonicalPath());
- if (!directory.exists() || !directory.isDirectory() ||
- !directory.canRead())
- continue;
- URL url = directory.toURI().toURL();
- if (log.isDebugEnabled())
- log.debug(" Including directory " + url);
- list.add(url);
- } else if ( types[i] == IS_JAR ) {
- File file=new File(location);
- file = new File(file.getCanonicalPath());
- if (!file.exists() || !file.canRead())
- continue;
- URL url = file.toURI().toURL();
- if (log.isDebugEnabled())
- log.debug(" Including jar file " + url);
- list.add(url);
- } else if ( types[i] == IS_GLOB ) {
- File directory=new File(location);
- if (!directory.exists() || !directory.isDirectory() ||
- !directory.canRead())
- continue;
- if (log.isDebugEnabled())
- log.debug(" Including directory glob "
- + directory.getAbsolutePath());
- String filenames[] = directory.list();
- for (int j = 0; j < filenames.length; j++) {
- String filename = filenames[j].toLowerCase();
- if (!filename.endsWith(".jar"))
- continue;
- File file = new File(directory, filenames[j]);
- file = new File(file.getCanonicalPath());
- if (!file.exists() || !file.canRead())
- continue;
- if (log.isDebugEnabled())
- log.debug(" Including glob jar file "
- + file.getAbsolutePath());
- URL url = file.toURI().toURL();
- list.add(url);
- }
- }
- }
- }
-
- // Construct the class loader itself
- URL[] array = (URL[]) list.toArray(new URL[list.size()]);
- if (log.isDebugEnabled())
- for (int i = 0; i < array.length; i++) {
- log.debug(" location " + i + " is " + array[i]);
- }
- StandardClassLoader classLoader = null;
- if (parent == null)
- classLoader = new StandardClassLoader(array);
- else
- classLoader = new StandardClassLoader(array, parent);
- return (classLoader);
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/ConnectorCreateRule.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ConnectorCreateRule.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/ConnectorCreateRule.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,72 +0,0 @@
-/* $Id$
- *
- * 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 org.apache.catalina.Executor;
-import org.apache.catalina.Service;
-import org.apache.catalina.connector.Connector;
-import org.apache.tomcat.util.IntrospectionUtils;
-import org.apache.tomcat.util.digester.Rule;
-import org.xml.sax.Attributes;
-
-
-/**
- * Rule implementation that creates a connector.
- */
-
-public class ConnectorCreateRule extends Rule {
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Process the beginning of this element.
- *
- * @param attributes The attribute list of this element
- */
- public void begin(Attributes attributes) throws Exception {
- Service svc = (Service)digester.peek();
- Executor ex = null;
- if ( attributes.getValue("executor")!=null ) {
- ex = svc.getExecutor(attributes.getValue("executor"));
- }
- Connector con = new Connector(attributes.getValue("protocol"));
- if ( ex != null ) setExecutor(con,ex);
-
- digester.push(con);
- }
-
- public void setExecutor(Connector con, Executor ex) throws Exception {
- IntrospectionUtils.callMethod1(con.getProtocolHandler(), "setExecutor",
- ex, java.util.concurrent.Executor.class.getName(), getClass().getClassLoader());
- }
-
-
- /**
- * Process the end of this element.
- */
- public void end() throws Exception {
- digester.pop();
- }
-
-
-}
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -47,40 +47,19 @@
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.Collection;
-import java.util.Enumeration;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
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.HttpMethodConstraintElement;
-import javax.servlet.ServletContainerInitializer;
-import javax.servlet.ServletContext;
import javax.servlet.ServletSecurityElement;
-import javax.servlet.annotation.HandlesTypes;
-import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebListener;
@@ -92,9 +71,7 @@
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
-import org.apache.catalina.Globals;
import org.apache.catalina.Host;
-import org.apache.catalina.JarRepository;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
@@ -102,27 +79,15 @@
import org.apache.catalina.Valve;
import org.apache.catalina.Wrapper;
import org.apache.catalina.core.ContainerBase;
-import org.apache.catalina.core.ContextJarRepository;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.core.StandardEngine;
-import org.apache.catalina.core.StandardHost;
import org.apache.catalina.deploy.ErrorPage;
import org.apache.catalina.deploy.FilterDef;
import org.apache.catalina.deploy.FilterMap;
import org.apache.catalina.deploy.LoginConfig;
import org.apache.catalina.deploy.SecurityCollection;
import org.apache.catalina.deploy.SecurityConstraint;
-import org.apache.catalina.deploy.WebAbsoluteOrdering;
-import org.apache.catalina.deploy.WebOrdering;
-import org.apache.catalina.deploy.jsp.TagLibraryInfo;
import org.apache.catalina.util.StringManager;
-import org.apache.naming.resources.JARDirContext;
-import org.apache.naming.resources.ProxyDirContext;
-import org.apache.tomcat.util.digester.Digester;
-import org.apache.tomcat.util.digester.RuleSet;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXParseException;
/**
* Startup event listener for a <b>Context</b> that configures the properties
@@ -181,12 +146,6 @@
/**
- * Any parse error which occurred while parsing XML descriptors.
- */
- protected SAXParseException parseException = null;
-
-
- /**
* Original docBase.
*/
protected String originalDocBase = null;
@@ -200,58 +159,6 @@
/**
- * The <code>Digester</code> we will use to process web application
- * context files.
- */
- protected static Digester contextDigester = null;
-
-
- /**
- * The <code>Digester</code> we will use to process web application
- * deployment descriptor files.
- */
- protected static Digester webDigester = null;
-
-
- /**
- * The <code>Digester</code> we will use to process web application
- * fragment descriptor files.
- */
- protected static Digester webFragmentDigester = null;
-
-
- /**
- * The <code>Digester</code> we will use to process tag library
- * descriptor files.
- */
- protected static Digester tldDigester = null;
-
-
- /**
- * The <code>Digester</code> we will use to parse fragment ordering.
- */
- protected static Digester fragmentOrderingDigester = null;
-
-
- /**
- * The <code>Digester</code> we will use to parse absolute ordering in web.xml.
- */
- protected static Digester orderingDigester = null;
-
-
- /**
- * The <code>Rule</code> used to parse the web.xml.
- */
- protected static WebRuleSet webRuleSet = new WebRuleSet();
-
-
- /**
- * The <code>Rule</code> used to parse web-fragment.xml files.
- */
- protected static WebRuleSet webFragmentRuleSet = new WebRuleSet("", true);
-
-
- /**
* Deployment count.
*/
protected static long deploymentCount = 0L;
@@ -261,21 +168,6 @@
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<?>, ServletContainerInitializerInfo> handlesTypes =
- new HashMap<Class<?>, ServletContainerInitializerInfo>();
-
-
// ------------------------------------------------------------- Properties
@@ -340,29 +232,6 @@
}
- // -------------------------------------------------- WarComponents Methods
-
-
- public Iterator<String> getOverlays() {
- return overlays.iterator();
- }
-
-
- public Iterator<String> getWebFragments() {
- return order.iterator();
- }
-
-
- public Map<String, Set<String>> getTLDs() {
- return TLDs;
- }
-
-
- public Map<String, ServletContainerInitializerInfo> getServletContainerInitializerInfo() {
- return servletContainerInitializerInfos;
- }
-
-
// --------------------------------------------------------- Public Methods
@@ -393,23 +262,6 @@
context.setDocBase(originalDocBase);
originalDocBase = docBase;
}
- // Invoke Servlet container initializer: instantiate and call onStartup
- if (ok) {
- Iterator<ServletContainerInitializerInfo> initializers =
- getServletContainerInitializerInfo().values().iterator();
- while (initializers.hasNext()) {
- ServletContainerInitializerInfo service = initializers.next();
- try {
- ServletContainerInitializer servletContainerInitializer =
- (ServletContainerInitializer) service.getServletContainerInitializer().newInstance();
- servletContainerInitializer.onStartup(service.getStartupNotifySet(), context.getServletContext());
- } catch (Throwable t) {
- log.error(sm.getString("contextConfig.servletContainerInitializer",
- service.getServletContainerInitializer().getName()), t);
- ok = false;
- }
- }
- }
} else if (event.getType().equals(Context.COMPLETE_CONFIG_EVENT)) {
completeConfig();
} else if (event.getType().equals(Lifecycle.STOP_EVENT)) {
@@ -501,218 +353,14 @@
* Process the application configuration file, if it exists.
*/
protected void applicationWebConfig() {
-
- String altDDName = null;
-
- // Open the application web.xml file, if it exists
- InputStream stream = null;
- ServletContext servletContext = context.getServletContext();
- if (servletContext != null) {
- altDDName = (String)servletContext.getAttribute(
- Globals.ALT_DD_ATTR);
- if (altDDName != null) {
- try {
- stream = new FileInputStream(altDDName);
- } catch (FileNotFoundException e) {
- log.error(sm.getString("contextConfig.altDDNotFound",
- altDDName));
- }
- }
- else {
- stream = servletContext.getResourceAsStream
- (Constants.ApplicationWebXml);
- }
- }
- if (stream == null) {
- if (log.isDebugEnabled()) {
- log.debug(sm.getString("contextConfig.applicationMissing") + " " + context);
- }
- return;
- }
-
- URL url=null;
- // Process the application web.xml file
- synchronized (webDigester) {
- try {
- if (altDDName != null) {
- url = new File(altDDName).toURI().toURL();
- } else {
- url = servletContext.getResource(
- Constants.ApplicationWebXml);
- }
- if( url!=null ) {
- InputSource is = new InputSource(url.toExternalForm());
- is.setByteStream(stream);
- if (context instanceof StandardContext) {
- ((StandardContext) context).setReplaceWelcomeFiles(true);
- }
- webDigester.push(context);
- webDigester.setErrorHandler(new ContextErrorHandler());
-
- if(log.isDebugEnabled()) {
- log.debug("Parsing application web.xml file at " + url.toExternalForm());
- }
-
- webDigester.parse(is);
-
- if (parseException != null) {
- ok = false;
- }
- } else {
- log.info("No web.xml, using defaults " + context );
- }
- } catch (SAXParseException e) {
- log.error(sm.getString("contextConfig.applicationParse", url.toExternalForm()), e);
- log.error(sm.getString("contextConfig.applicationPosition",
- "" + e.getLineNumber(),
- "" + e.getColumnNumber()));
- ok = false;
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.applicationParse", url.toExternalForm()), e);
- ok = false;
- } finally {
- webDigester.reset();
- webRuleSet.recycle();
- parseException = null;
- try {
- if (stream != null) {
- stream.close();
- }
- } catch (IOException e) {
- log.error(sm.getString("contextConfig.applicationClose"), e);
- }
- }
- }
-
}
-
/**
* Parse TLDs. This is separate, and is not subject to the order defined. Also,
* all TLDs from all JARs are parsed.
*/
protected void applicationTldConfig() {
- Map<String, Set<String>> TLDs = getTLDs();
- Set<String> warTLDs = TLDs.get("");
- ArrayList<TagLibraryInfo> tagLibraries = new ArrayList<TagLibraryInfo>();
-
- // Parse all TLDs from the WAR
- Iterator<String> warTLDsIterator = warTLDs.iterator();
- InputStream stream = null;
- while (warTLDsIterator.hasNext()) {
- String tldPath = warTLDsIterator.next();
- try {
- stream = context.getServletContext().getResourceAsStream(tldPath);
- if (stream == null) {
- log.error(sm.getString("contextConfig.tldResourcePath", tldPath));
- ok = false;
- } else {
- synchronized (tldDigester) {
- TagLibraryInfo tagLibraryInfo = new TagLibraryInfo();
- try {
- tldDigester.push(tagLibraryInfo);
- tldDigester.parse(new InputSource(stream));
- } finally {
- tldDigester.reset();
- }
- tagLibraryInfo.setLocation("");
- tagLibraryInfo.setPath(tldPath);
- tagLibraries.add(tagLibraryInfo);
- context.addJspTagLibrary(tagLibraryInfo);
- context.addJspTagLibrary(tldPath, tagLibraryInfo);
- }
- }
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.tldFileException", tldPath,
- context.getPath()), e);
- ok = false;
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (Throwable t) {
- // Ignore
- }
- }
- }
-
- }
-
- // Parse all TLDs from JARs
- Iterator<String> jarPaths = TLDs.keySet().iterator();
- while (jarPaths.hasNext()) {
- String jarPath = jarPaths.next();
- if (jarPath.equals("")) {
- continue;
- }
- JarRepository jarRepository = context.getJarRepository();
- JarFile jarFile = jarRepository.findJar(jarPath);
- Iterator<String> jarTLDsIterator = TLDs.get(jarPath).iterator();
- while (jarTLDsIterator.hasNext()) {
- try {
- String tldPath = jarTLDsIterator.next();
- stream = jarFile.getInputStream(jarFile.getEntry(tldPath));
- synchronized (tldDigester) {
- TagLibraryInfo tagLibraryInfo = new TagLibraryInfo();
- try {
- tldDigester.push(tagLibraryInfo);
- tldDigester.parse(new InputSource(stream));
- } finally {
- tldDigester.reset();
- if (stream != null) {
- try {
- stream.close();
- } catch (Throwable t) {
- // Ignore
- }
- }
- }
- tagLibraryInfo.setLocation(jarPath);
- tagLibraryInfo.setPath(tldPath);
- tagLibraries.add(tagLibraryInfo);
- context.addJspTagLibrary(tagLibraryInfo);
- if (tldPath.equals("META-INF/taglib.tld")) {
- context.addJspTagLibrary(jarPath, tagLibraryInfo);
- }
- }
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.tldJarException",
- jarPath, context.getPath()), e);
- ok = false;
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (Throwable t) {
- // Ignore
- }
- }
- }
- }
- }
-
- // Add additional TLDs URIs from explicit web config
- String taglibs[] = context.findTaglibs();
- for (int i = 0; i < taglibs.length; i++) {
- String uri = taglibs[i];
- String path = context.findTaglib(taglibs[i]);
- String location = "";
- if (path.indexOf(':') == -1 && !path.startsWith("/")) {
- path = "/WEB-INF/" + path;
- }
- if (path.endsWith(".jar")) {
- location = path;
- path = "META-INF/taglib.tld";
- }
- for (int j = 0; j < tagLibraries.size(); j++) {
- TagLibraryInfo tagLibraryInfo = tagLibraries.get(j);
- if (tagLibraryInfo.getLocation().equals(location) && tagLibraryInfo.getPath().equals(path)) {
- context.addJspTagLibrary(uri, tagLibraryInfo);
- }
- }
- }
-
}
@@ -832,57 +480,6 @@
}
- /**
- * Create (if necessary) and return a Digester configured to process the
- * web application deployment descriptor (web.xml).
- */
- protected static Digester createWebDigester() {
- return DigesterFactory.newDigester(Globals.XML_NAMESPACE_AWARE, Globals.XML_VALIDATION, webRuleSet);
- }
-
-
- /**
- * Create (if necessary) and return a Digester configured to process the
- * web application fragment descriptors (web-fragment.xml).
- */
- protected static Digester createWebFragmentDigester() {
- return DigesterFactory.newDigester(Globals.XML_NAMESPACE_AWARE, Globals.XML_VALIDATION, webFragmentRuleSet);
- }
-
-
- /**
- * Create (if necessary) and return a Digester configured to process tag
- * library descriptors.
- */
- protected static Digester createTldDigester() {
- return DigesterFactory.newDigester(Globals.XML_NAMESPACE_AWARE, Globals.XML_VALIDATION, new TldRuleSet());
- }
-
-
- /**
- * Create (if necessary) and return a Digester configured to process web fragments ordering.
- */
- protected static Digester createFragmentOrderingDigester() {
- return DigesterFactory.newDigester(Globals.XML_NAMESPACE_AWARE,
- Globals.XML_VALIDATION, new WebOrderingRuleSet());
- }
-
-
- /**
- * Create (if necessary) and return a Digester configured to process the
- * context configuration descriptor for an application.
- */
- protected static Digester createContextDigester() {
- Digester digester = new Digester();
- digester.setValidating(false);
- RuleSet contextRuleSet = new ContextRuleSet("", false);
- digester.addRuleSet(contextRuleSet);
- RuleSet namingRuleSet = new NamingRuleSet("Context/");
- digester.addRuleSet(namingRuleSet);
- return digester;
- }
-
-
protected String getBaseDir() {
Container engineC=context.getParent().getParent();
if( engineC instanceof StandardEngine ) {
@@ -897,779 +494,34 @@
* container servlets can be loaded
*/
protected void defaultWebConfig() {
- long t1=System.currentTimeMillis();
-
- // Open the default web.xml file, if it exists
- if( defaultWebXml==null && context instanceof StandardContext ) {
- defaultWebXml=((StandardContext)context).getDefaultWebXml();
- }
- // set the default if we don't have any overrides
- if( defaultWebXml==null ) getDefaultWebXml();
-
- File file = new File(this.defaultWebXml);
- if (!file.isAbsolute()) {
- file = new File(getBaseDir(),
- this.defaultWebXml);
- }
-
- InputStream stream = null;
- InputSource source = null;
-
- try {
- if ( ! file.exists() ) {
- // Use getResource and getResourceAsStream
- stream = getClass().getClassLoader()
- .getResourceAsStream(defaultWebXml);
- if( stream != null ) {
- source = new InputSource
- (getClass().getClassLoader()
- .getResource(defaultWebXml).toString());
- }
- if( stream== null ) {
- // maybe embedded
- stream = getClass().getClassLoader()
- .getResourceAsStream("web-embed.xml");
- if( stream != null ) {
- source = new InputSource
- (getClass().getClassLoader()
- .getResource("web-embed.xml").toString());
- }
- }
-
- if( stream== null ) {
- log.info("No default web.xml");
- }
- } else {
- source =
- new InputSource("file://" + file.getAbsolutePath());
- stream = new FileInputStream(file);
- context.addWatchedResource(file.getAbsolutePath());
- }
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.defaultMissing")
- + " " + defaultWebXml + " " + file , e);
- }
-
- if (stream != null) {
- processDefaultWebConfig(webDigester, stream, source);
- webRuleSet.recycle();
- }
-
- long t2=System.currentTimeMillis();
- if( (t2-t1) > 200 )
- log.debug("Processed default web.xml " + file + " " + ( t2-t1));
-
- stream = null;
- source = null;
-
- String resourceName = getHostConfigPath(Constants.HostWebXml);
- file = new File(getConfigBase(), resourceName);
- try {
- if ( ! file.exists() ) {
- // Use getResource and getResourceAsStream
- stream = getClass().getClassLoader()
- .getResourceAsStream(resourceName);
- if( stream != null ) {
- source = new InputSource
- (getClass().getClassLoader()
- .getResource(resourceName).toString());
- }
- } else {
- source =
- new InputSource("file://" + file.getAbsolutePath());
- stream = new FileInputStream(file);
- }
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.defaultMissing")
- + " " + resourceName + " " + file , e);
- }
-
- if (stream != null) {
- processDefaultWebConfig(webDigester, stream, source);
- webRuleSet.recycle();
- }
-
}
/**
- * Process a default web.xml.
- */
- protected void processDefaultWebConfig(Digester digester, InputStream stream,
- InputSource source) {
-
- if (log.isDebugEnabled())
- log.debug("Processing context [" + context.getName()
- + "] web configuration resource " + source.getSystemId());
-
- // Process the default web.xml file
- synchronized (digester) {
- try {
- source.setByteStream(stream);
-
- if (context instanceof StandardContext)
- ((StandardContext) context).setReplaceWelcomeFiles(true);
- digester.setClassLoader(this.getClass().getClassLoader());
- digester.setUseContextClassLoader(false);
- digester.push(context);
- digester.setErrorHandler(new ContextErrorHandler());
- digester.parse(source);
- if (parseException != null) {
- ok = false;
- }
- } catch (SAXParseException e) {
- log.error(sm.getString("contextConfig.defaultParse"), e);
- log.error(sm.getString("contextConfig.defaultPosition",
- "" + e.getLineNumber(),
- "" + e.getColumnNumber()));
- ok = false;
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.defaultParse"), e);
- ok = false;
- } finally {
- digester.reset();
- parseException = null;
- try {
- if (stream != null) {
- stream.close();
- }
- } catch (IOException e) {
- log.error(sm.getString("contextConfig.defaultClose"), e);
- }
- }
- }
- }
-
-
- /**
* Parse fragments order.
*/
protected void createFragmentsOrder() {
- WebAbsoluteOrdering absoluteOrdering = context.getWebAbsoluteOrdering();
- List<WebOrdering> orderings = new ArrayList<WebOrdering>();
- HashSet<String> jarsSet = new HashSet<String>();
- boolean fragmentFound = false;
-
- // Parse the ordering defined in web fragments
- JarRepository jarRepository = context.getJarRepository();
- JarFile[] jars = jarRepository.findJars();
- for (int i = 0; i < jars.length; i++) {
- // Find webapp descriptor fragments
- jarsSet.add(jars[i].getName());
- JarFile jarFile = jars[i];
- InputStream is = null;
- ZipEntry entry = jarFile.getEntry(Globals.WEB_FRAGMENT_PATH);
- if (entry != null) {
- fragmentFound = true;
- try {
- webFragments.add(jars[i].getName());
- is = jarFile.getInputStream(entry);
- InputSource input = new InputSource((new File(jars[i].getName())).toURI().toURL().toExternalForm());
- input.setByteStream(is);
- synchronized (fragmentOrderingDigester) {
- try {
- fragmentOrderingDigester.parse(input);
- WebOrdering ordering = (WebOrdering) fragmentOrderingDigester.peek();
- if (ordering != null) {
- ordering.setJar(jars[i].getName());
- orderings.add(ordering);
- }
- } finally {
- fragmentOrderingDigester.reset();
- }
- }
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.fragmentOrderingParse", jars[i].getName()), e);
- ok = false;
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- } catch (IOException e) {
- // Ignore
- }
- }
- } else {
- // If there is no fragment, still consider it for ordering as a
- // fragment specifying no name and no order
- WebOrdering ordering = new WebOrdering();
- ordering.setJar(jars[i].getName());
- orderings.add(ordering);
- }
- }
- if (!fragmentFound) {
- // Drop the order as there is no fragment in the webapp
- orderings.clear();
- }
-
- // Generate web fragments parsing order
- if (absoluteOrdering != null) {
- // Absolute ordering from web.xml, any relative fragment ordering is ignored
- List<String> fragmentNames = absoluteOrdering.getOrder();
- int otherPos = -1;
- for (int i = 0; i < fragmentNames.size(); i++) {
- String fragmentName = fragmentNames.get(i);
- if (fragmentName.equals("*")) {
- if (otherPos >= 0) {
- log.error(sm.getString("contextConfig.invalidAbsoluteOrder"));
- ok = false;
- }
- otherPos = i;
- } else {
- Iterator<WebOrdering> orderingsIterator = orderings.iterator();
- while (orderingsIterator.hasNext()) {
- WebOrdering ordering = orderingsIterator.next();
- if (fragmentName.equals(ordering.getName())) {
- order.add(ordering.getJar());
- jarsSet.remove(ordering.getJar());
- break;
- }
- }
- }
- }
- if (otherPos >= 0) {
- order.addAll(otherPos, jarsSet);
- }
- } else if (orderings.size() > 0) {
- // Resolve relative ordering
- try {
- OrderingResolver.resolveOrder(orderings, order);
- } catch (IllegalStateException e) {
- log.error(e.getMessage(), e);
- ok = false;
- }
- } else {
- // No order specified
- order.addAll(jarsSet);
- }
-
}
/**
- * 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() {
- 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());
- }
-
- // Parse web fragment according to order
- Iterator<String> orderIterator = order.iterator();
- while (orderIterator.hasNext()) {
- String jar = orderIterator.next();
- JarFile jarFile = jarRepository.findJar(jar);
- InputStream is = null;
- ZipEntry entry = jarFile.getEntry(Globals.WEB_FRAGMENT_PATH);
- if (entry != null) {
- try {
- is = jarFile.getInputStream(entry);
- InputSource input = new InputSource((new File(jar)).toURI().toURL().toExternalForm());
- input.setByteStream(is);
- synchronized (webFragmentDigester) {
- try {
- webFragmentDigester.push(context);
- webFragmentDigester.setErrorHandler(new ContextErrorHandler());
- webFragmentDigester.parse(input);
- if (parseException != null) {
- ok = false;
- }
- } finally {
- webFragmentDigester.reset();
- webFragmentRuleSet.recycle();
- parseException = null;
- }
- }
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.applicationParse", jar), e);
- ok = false;
- } finally {
- try {
- if (is != null) {
- is.close();
- }
- } catch (IOException e) {
- // Ignore
- }
- }
- }
- // Scan the JAR for TLDs and annotations
- scanJar(jarFile, true);
- }
-
- // Process any Jar not in the order
- JarFile[] jarFiles = jarRepository.findJars();
- for (int i = 0; i < jarFiles.length; i++) {
- if (!order.contains(jarFiles[i].getName())) {
- // Scan the JAR for TLDs only
- 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)) {
- ServletContainerInitializerInfo 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) {
- log.warn(sm.getString("contextConfig.servletContainerInitializer", file.getName()), e);
- return;
- } 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) {
- log.warn(sm.getString("contextConfig.servletContainerInitializer", file.getName()), t);
- return;
- }
- }
- // Add in jarService map, and add in the local map used to speed up lookups
- ServletContainerInitializerInfo jarServletContainerInitializerService =
- new ServletContainerInitializerInfo(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() {
- // Open the default web.xml file, if it exists
- if( defaultContextXml==null && context instanceof StandardContext ) {
- defaultContextXml = ((StandardContext)context).getDefaultContextXml();
- }
- // set the default if we don't have any overrides
- if( defaultContextXml==null ) getDefaultContextXml();
-
- if (!context.getOverride()) {
- processContextConfig(new File(getBaseDir()), defaultContextXml);
- processContextConfig(getConfigBase(), getHostConfigPath(Constants.HostContextXml));
- }
- if (context.getConfigFile() != null)
- processContextConfig(new File(context.getConfigFile()), null);
-
- if (context.getJarRepository() == null) {
- context.setJarRepository(new ContextJarRepository());
- }
-
}
-
- /**
- * Process a context.xml.
- */
- protected void processContextConfig(File baseDir, String resourceName) {
-
- if (log.isDebugEnabled())
- log.debug("Processing context [" + context.getName()
- + "] configuration file " + baseDir + " " + resourceName);
-
- InputSource source = null;
- InputStream stream = null;
-
- File file = baseDir;
- if (resourceName != null) {
- file = new File(baseDir, resourceName);
- }
-
- try {
- if ( !file.exists() ) {
- if (resourceName != null) {
- // Use getResource and getResourceAsStream
- stream = getClass().getClassLoader()
- .getResourceAsStream(resourceName);
- if( stream != null ) {
- source = new InputSource
- (getClass().getClassLoader()
- .getResource(resourceName).toString());
- }
- }
- } else {
- source =
- new InputSource("file://" + file.getAbsolutePath());
- stream = new FileInputStream(file);
- // Add as watched resource so that cascade reload occurs if a default
- // config file is modified/added/removed
- context.addWatchedResource(file.getAbsolutePath());
- }
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.contextMissing",
- resourceName + " " + file) , e);
- }
-
- if (source == null)
- return;
- synchronized (contextDigester) {
- try {
- source.setByteStream(stream);
- contextDigester.setClassLoader(this.getClass().getClassLoader());
- contextDigester.setUseContextClassLoader(false);
- contextDigester.push(context.getParent());
- contextDigester.push(context);
- contextDigester.setErrorHandler(new ContextErrorHandler());
- contextDigester.parse(source);
- if (parseException != null) {
- ok = false;
- }
- if (log.isDebugEnabled())
- log.debug("Successfully processed context [" + context.getName()
- + "] configuration file " + baseDir + " " + resourceName);
- } catch (SAXParseException e) {
- log.error(sm.getString("contextConfig.contextParse",
- context.getName()), e);
- log.error(sm.getString("contextConfig.defaultPosition",
- "" + e.getLineNumber(),
- "" + e.getColumnNumber()));
- ok = false;
- } catch (Exception e) {
- log.error(sm.getString("contextConfig.contextParse",
- context.getName()), e);
- ok = false;
- } finally {
- contextDigester.reset();
- parseException = null;
- try {
- if (stream != null) {
- stream.close();
- }
- } catch (IOException e) {
- log.error(sm.getString("contextConfig.contextClose"), e);
- }
- }
- }
- }
-
- /**
- * Adjust docBase.
- */
- protected void fixDocBase()
- throws IOException {
-
- Host host = (Host) context.getParent();
- String appBase = host.getAppBase();
-
- boolean unpackWARs = true;
- if (host instanceof StandardHost) {
- unpackWARs = ((StandardHost) host).isUnpackWARs()
- && ((StandardContext) context).getUnpackWAR();
- }
-
- File canonicalAppBase = new File(appBase);
- if (canonicalAppBase.isAbsolute()) {
- canonicalAppBase = canonicalAppBase.getCanonicalFile();
- } else {
- canonicalAppBase =
- new File(System.getProperty("catalina.base"), appBase)
- .getCanonicalFile();
- }
-
- String docBase = context.getDocBase();
- if (docBase == null) {
- // Trying to guess the docBase according to the path
- String path = context.getPath();
- if (path == null) {
- return;
- }
- if (path.equals("")) {
- docBase = "ROOT";
- } else {
- if (path.startsWith("/")) {
- docBase = path.substring(1).replace('/', '#');
- } else {
- docBase = path.replace('/', '#');
- }
- }
- }
-
- File file = new File(docBase);
- if (!file.isAbsolute()) {
- docBase = (new File(canonicalAppBase, docBase)).getPath();
- } else {
- docBase = file.getCanonicalPath();
- }
- file = new File(docBase);
- String origDocBase = docBase;
-
- String contextPath = context.getPath();
- if (contextPath.equals("")) {
- contextPath = "ROOT";
- } else {
- // Context path must start with '/'
- contextPath = "/" + contextPath.substring(1).replace('/','#');
- }
- if (docBase.toLowerCase().endsWith(".war") && !file.isDirectory() && unpackWARs) {
- URL war = new URL("jar:" + (new File(docBase)).toURI().toURL() + "!/");
- docBase = ExpandWar.expand(host, war, contextPath);
- file = new File(docBase);
- docBase = file.getCanonicalPath();
- if (context instanceof StandardContext) {
- ((StandardContext) context).setOriginalDocBase(origDocBase);
- }
- } else if (docBase.toLowerCase().endsWith(".war") &&
- !file.isDirectory() && !unpackWARs) {
- URL war =
- new URL("jar:" + (new File (docBase)).toURI().toURL() + "!/");
- ExpandWar.validate(host, war, contextPath);
- } else {
- File docDir = new File(docBase);
- if (!docDir.exists()) {
- File warFile = new File(docBase + ".war");
- URL war = new URL("jar:" + warFile.toURI().toURL() + "!/");
- if (warFile.exists()) {
- if (unpackWARs) {
- docBase = ExpandWar.expand(host, war, contextPath);
- file = new File(docBase);
- docBase = file.getCanonicalPath();
- } else {
- docBase = warFile.getCanonicalPath();
- ExpandWar.validate(host, war, contextPath);
- }
- }
- if (context instanceof StandardContext) {
- ((StandardContext) context).setOriginalDocBase(origDocBase);
- }
- }
- }
-
- if (docBase.startsWith(canonicalAppBase.getPath() + File.separatorChar)) {
- docBase = docBase.substring(canonicalAppBase.getPath().length());
- docBase = docBase.replace(File.separatorChar, '/');
- if (docBase.startsWith("/")) {
- docBase = docBase.substring(1);
- }
- } else {
- docBase = docBase.replace(File.separatorChar, '/');
- }
-
- context.setDocBase(docBase);
-
- }
-
-
protected void antiLocking() {
if ((context instanceof StandardContext)
@@ -1736,46 +588,10 @@
* Process a "init" event for this Context.
*/
protected void init() {
- // Called from StandardContext.init()
-
- if (webDigester == null){
- webDigester = createWebDigester();
- webDigester.getParser();
- }
-
- if (webFragmentDigester == null){
- webFragmentDigester = createWebFragmentDigester();
- webFragmentDigester.getParser();
- }
-
- if (tldDigester == null){
- tldDigester = createTldDigester();
- tldDigester.getParser();
- }
-
- if (fragmentOrderingDigester == null){
- fragmentOrderingDigester = createFragmentOrderingDigester();
- fragmentOrderingDigester.getParser();
- }
-
- if (contextDigester == null){
- contextDigester = createContextDigester();
- contextDigester.getParser();
- }
-
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled())
log.debug(sm.getString("contextConfig.init"));
context.setConfigured(false);
ok = true;
-
- contextConfig();
-
- try {
- fixDocBase();
- } catch (IOException e) {
- log.error(sm.getString("contextConfig.fixDocBase"), e);
- }
-
}
@@ -1850,52 +666,7 @@
* Process a "start" event for this Context.
*/
protected void completeConfig() {
- // Called from StandardContext.start()
-
- // Scan all Servlet API related annotations
- if (ok && !context.getIgnoreAnnotations()) {
- WebAnnotationSet.loadApplicationAnnotations(context);
- }
- // Resolve security
- if (ok) {
- resolveServletSecurity();
- }
- if (ok) {
- validateSecurityRoles();
- }
-
- // Configure an authenticator if we need one
- if (ok) {
- authenticatorConfig();
- }
-
- // Find and configure 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) {
- if (context.getResources() instanceof ProxyDirContext) {
- ProxyDirContext resources = (ProxyDirContext) context.getResources();
- JARDirContext overlay = new JARDirContext();
- overlay.setJarFile(jars[i], Globals.OVERLAY_PATH);
- resources.addOverlay(overlay);
- } else {
- // Error, overlays need a ProxyDirContext to compose results
- log.error(sm.getString("contextConfig.noOverlay", jars[i].getName()));
- ok = false;
- }
- overlays.add(jars[i].getName());
- }
- }
- }
-
- // Make our application unavailable if problems were encountered
- if (!ok) {
- log.error(sm.getString("contextConfig.unavailable"));
- context.setConfigured(false);
- }
-
+
}
/**
@@ -1930,22 +701,6 @@
context.removeConstraint(securityConstraints[i]);
}
- // Removing Ejbs
- /*
- ContextEjb[] contextEjbs = context.findEjbs();
- for (i = 0; i < contextEjbs.length; i++) {
- context.removeEjb(contextEjbs[i].getName());
- }
- */
-
- // Removing environments
- /*
- ContextEnvironment[] contextEnvironments = context.findEnvironments();
- for (i = 0; i < contextEnvironments.length; i++) {
- context.removeEnvironment(contextEnvironments[i].getName());
- }
- */
-
// Removing errors pages
ErrorPage[] errorPages = context.findErrorPages();
for (i = 0; i < errorPages.length; i++) {
@@ -1964,14 +719,6 @@
context.removeFilterMap(filterMaps[i]);
}
- // Removing local ejbs
- /*
- ContextLocalEjb[] contextLocalEjbs = context.findLocalEjbs();
- for (i = 0; i < contextLocalEjbs.length; i++) {
- context.removeLocalEjb(contextLocalEjbs[i].getName());
- }
- */
-
// Removing Mime mappings
String[] mimeMappings = context.findMimeMappings();
for (i = 0; i < mimeMappings.length; i++) {
@@ -1984,31 +731,6 @@
context.removeParameter(parameters[i]);
}
- // Removing resource env refs
- /*
- String[] resourceEnvRefs = context.findResourceEnvRefs();
- for (i = 0; i < resourceEnvRefs.length; i++) {
- context.removeResourceEnvRef(resourceEnvRefs[i]);
- }
- */
-
- // Removing resource links
- /*
- ContextResourceLink[] contextResourceLinks =
- context.findResourceLinks();
- for (i = 0; i < contextResourceLinks.length; i++) {
- context.removeResourceLink(contextResourceLinks[i].getName());
- }
- */
-
- // Removing resources
- /*
- ContextResource[] contextResources = context.findResources();
- for (i = 0; i < contextResources.length; i++) {
- context.removeResource(contextResources[i].getName());
- }
- */
-
// Removing sercurity role
String[] securityRoles = context.findSecurityRoles();
for (i = 0; i < securityRoles.length; i++) {
@@ -2064,14 +786,6 @@
ExpandWar.delete(docBaseFile, false);
}
- overlays.clear();
- webFragments.clear();
- TLDs.clear();
- servletContainerInitializerInfos.clear();
- order.clear();
- handlesTypesArray = null;
- handlesTypes.clear();
-
ok = true;
}
@@ -2308,45 +1022,4 @@
}
- protected class ContextErrorHandler
- implements ErrorHandler {
-
- public void error(SAXParseException exception) {
- parseException = exception;
- }
-
- public void fatalError(SAXParseException exception) {
- parseException = exception;
- }
-
- public void warning(SAXParseException exception) {
- parseException = exception;
- }
-
- }
-
-
- protected class ServletContainerInitializerInfo {
- protected Class<?> servletContainerInitializer = null;
- protected Class<?>[] interestClasses = null;
- protected HashSet<Class<?>> startupNotifySet = new HashSet<Class<?>>();
- protected ServletContainerInitializerInfo(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/ContextRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextRuleSet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/ContextRuleSet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,215 +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 org.apache.tomcat.util.digester.Digester;
-import org.apache.tomcat.util.digester.RuleSetBase;
-
-
-/**
- * <p><strong>RuleSet</strong> for processing the contents of a
- * Context or DefaultContext definition element. To enable parsing of a
- * DefaultContext, be sure to specify a prefix that ends with "/Default".</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public class ContextRuleSet extends RuleSetBase {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The matching pattern prefix to use for recognizing our elements.
- */
- protected String prefix = null;
-
-
- /**
- * Should the context be created.
- */
- protected boolean create = true;
-
-
- // ------------------------------------------------------------ Constructor
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
- */
- public ContextRuleSet() {
-
- this("");
-
- }
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern prefix.
- *
- * @param prefix Prefix for matching pattern rules (including the
- * trailing slash character)
- */
- public ContextRuleSet(String prefix) {
-
- super();
- this.namespaceURI = null;
- this.prefix = prefix;
-
- }
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern prefix.
- *
- * @param prefix Prefix for matching pattern rules (including the
- * trailing slash character)
- */
- public ContextRuleSet(String prefix, boolean create) {
-
- super();
- this.namespaceURI = null;
- this.prefix = prefix;
- this.create = create;
-
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * <p>Add the set of Rule instances defined in this RuleSet to the
- * specified <code>Digester</code> instance, associating them with
- * our namespace URI (if any). This method should only be called
- * by a Digester instance.</p>
- *
- * @param digester Digester instance to which the new Rule instances
- * should be added.
- */
- public void addRuleInstances(Digester digester) {
-
- if (create) {
- digester.addObjectCreate(prefix + "Context",
- "org.apache.catalina.core.StandardContext", "className");
- digester.addSetProperties(prefix + "Context");
- } else {
- digester.addRule(prefix + "Context", new SetContextPropertiesRule());
- }
-
- if (create) {
- digester.addRule(prefix + "Context",
- new LifecycleListenerRule
- ("org.apache.catalina.startup.ContextConfig",
- "configClass"));
- digester.addSetNext(prefix + "Context",
- "addChild",
- "org.apache.catalina.Container");
- }
- digester.addCallMethod(prefix + "Context/InstanceListener",
- "addInstanceListener", 0);
-
- digester.addObjectCreate(prefix + "Context/Listener",
- null, // MUST be specified in the element
- "className");
- digester.addSetProperties(prefix + "Context/Listener");
- digester.addSetNext(prefix + "Context/Listener",
- "addLifecycleListener",
- "org.apache.catalina.LifecycleListener");
-
- digester.addObjectCreate(prefix + "Context/Loader",
- "org.apache.catalina.loader.WebappLoader",
- "className");
- digester.addSetProperties(prefix + "Context/Loader");
- digester.addSetNext(prefix + "Context/Loader",
- "setLoader",
- "org.apache.catalina.Loader");
-
- digester.addObjectCreate(prefix + "Context/Manager",
- "org.apache.catalina.session.StandardManager",
- "className");
- digester.addSetProperties(prefix + "Context/Manager");
- digester.addSetNext(prefix + "Context/Manager",
- "setManager",
- "org.apache.catalina.Manager");
-
- digester.addObjectCreate(prefix + "Context/Manager/Store",
- null, // MUST be specified in the element
- "className");
- digester.addSetProperties(prefix + "Context/Manager/Store");
- digester.addSetNext(prefix + "Context/Manager/Store",
- "setStore",
- "org.apache.catalina.Store");
-
- digester.addObjectCreate(prefix + "Context/Parameter",
- "org.apache.catalina.deploy.ApplicationParameter");
- digester.addSetProperties(prefix + "Context/Parameter");
- digester.addSetNext(prefix + "Context/Parameter",
- "addApplicationParameter",
- "org.apache.catalina.deploy.ApplicationParameter");
-
- digester.addRuleSet(new RealmRuleSet(prefix + "Context/"));
-
- digester.addObjectCreate(prefix + "Context/Resources",
- "org.apache.naming.resources.FileDirContext",
- "className");
- digester.addSetProperties(prefix + "Context/Resources");
- digester.addSetNext(prefix + "Context/Resources",
- "setResources",
- "javax.naming.directory.DirContext");
-
- digester.addObjectCreate(prefix + "Context/ResourceLink",
- "org.apache.catalina.deploy.ContextResourceLink");
- digester.addSetProperties(prefix + "Context/ResourceLink");
- digester.addRule(prefix + "Context/ResourceLink",
- new SetNextNamingRule("addResourceLink",
- "org.apache.catalina.deploy.ContextResourceLink"));
-
- digester.addObjectCreate(prefix + "Context/SessionCookie",
- "org.apache.catalina.deploy.SessionCookie");
- digester.addSetProperties(prefix + "Context/SessionCookie");
- digester.addSetNext(prefix + "Context/SessionCookie",
- "setSessionCookie", "org.apache.catalina.deploy.SessionCookie");
-
- digester.addObjectCreate(prefix + "Context/Valve",
- null, // MUST be specified in the element
- "className");
- digester.addSetProperties(prefix + "Context/Valve");
- digester.addSetNext(prefix + "Context/Valve",
- "addValve",
- "org.apache.catalina.Valve");
-
- digester.addCallMethod(prefix + "Context/WatchedResource",
- "addWatchedResource", 0);
-
- digester.addCallMethod(prefix + "Context/WrapperLifecycle",
- "addWrapperLifecycle", 0);
-
- digester.addCallMethod(prefix + "Context/WrapperListener",
- "addWrapperListener", 0);
-
- }
-
-}
Deleted: trunk/java/org/apache/catalina/startup/CopyParentClassLoaderRule.java
===================================================================
--- trunk/java/org/apache/catalina/startup/CopyParentClassLoaderRule.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/CopyParentClassLoaderRule.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,77 +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.lang.reflect.Method;
-import org.apache.catalina.Container;
-import org.apache.tomcat.util.digester.Rule;
-import org.xml.sax.Attributes;
-
-
-/**
- * <p>Rule that copies the <code>parentClassLoader</code> property from the
- * next-to-top item on the stack (which must be a <code>Container</code>)
- * to the top item on the stack (which must also be a
- * <code>Container</code>).</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public class CopyParentClassLoaderRule extends Rule {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a new instance of this Rule.
- */
- public CopyParentClassLoaderRule() {
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Handle the beginning of an XML element.
- *
- * @param attributes The attributes of this element
- *
- * @exception Exception if a processing error occurs
- */
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
-
- if (digester.getLogger().isDebugEnabled())
- digester.getLogger().debug("Copying parent class loader");
- Container child = (Container) digester.peek(0);
- Object parent = digester.peek(1);
- Method method =
- parent.getClass().getMethod("getParentClassLoader", new Class[0]);
- ClassLoader classLoader =
- (ClassLoader) method.invoke(parent, new Object[0]);
- child.setParentClassLoader(classLoader);
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/DigesterFactory.java
===================================================================
--- trunk/java/org/apache/catalina/startup/DigesterFactory.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/DigesterFactory.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,188 +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.net.URL;
-
-import org.apache.catalina.util.SchemaResolver;
-import org.apache.tomcat.util.digester.Digester;
-import org.apache.tomcat.util.digester.RuleSet;
-
-/**
- * Wrapper class around the Digester that hide Digester's initialization details
- *
- * @author Jean-Francois Arcand
- */
-public class DigesterFactory {
- /**
- * The log.
- */
- protected static org.jboss.logging.Logger log =
- org.jboss.logging.Logger.getLogger(DigesterFactory.class);
-
- /**
- * Create a <code>Digester</code> parser with no <code>Rule</code>
- * associated and XML validation turned off.
- */
- public static Digester newDigester(){
- return newDigester(false, false, null);
- }
-
-
- /**
- * Create a <code>Digester</code> parser with XML validation turned off.
- * @param rule an instance of <code>RuleSet</code> used for parsing the xml.
- */
- public static Digester newDigester(RuleSet rule){
- return newDigester(false,false,rule);
- }
-
-
- /**
- * Create a <code>Digester</code> parser.
- * @param xmlValidation turn on/off xml validation
- * @param xmlNamespaceAware turn on/off namespace validation
- * @param rule an instance of <code>RuleSet</code> used for parsing the xml.
- */
- public static Digester newDigester(boolean xmlValidation,
- boolean xmlNamespaceAware,
- RuleSet rule) {
- Digester digester = new Digester();
- digester.setNamespaceAware(xmlNamespaceAware);
- digester.setValidating(xmlValidation);
- digester.setUseContextClassLoader(true);
-
- SchemaResolver schemaResolver = new SchemaResolver(digester);
- registerLocalSchema(schemaResolver);
-
- digester.setEntityResolver(schemaResolver);
- if ( rule != null ) {
- digester.addRuleSet(rule);
- }
-
- return (digester);
- }
-
-
- /**
- * Utilities used to force the parser to use local schema, when available,
- * instead of the <code>schemaLocation</code> XML element.
- */
- protected static void registerLocalSchema(SchemaResolver schemaResolver){
- // J2EE
- register(Constants.J2eeSchemaResourcePath_14,
- Constants.J2eeSchemaPublicId_14,
- schemaResolver);
-
- register(Constants.JavaeeSchemaResourcePath_5,
- Constants.JavaeeSchemaPublicId_5,
- schemaResolver);
-
- // W3C
- register(Constants.W3cSchemaResourcePath_10,
- Constants.W3cSchemaPublicId_10,
- schemaResolver);
-
- register(Constants.W3cSchemaDTDResourcePath_10,
- Constants.W3cSchemaDTDPublicId_10,
- schemaResolver);
-
- register(Constants.W3cDatatypesDTDResourcePath_10,
- Constants.W3cDatatypesDTDPublicId_10,
- schemaResolver);
-
- // JSP
- register(Constants.JspSchemaResourcePath_20,
- Constants.JspSchemaPublicId_20,
- schemaResolver);
-
- register(Constants.JspSchemaResourcePath_21,
- Constants.JspSchemaPublicId_21,
- schemaResolver);
-
- // TLD
- register(Constants.TldDtdResourcePath_11,
- Constants.TldDtdPublicId_11,
- schemaResolver);
-
- register(Constants.TldDtdResourcePath_12,
- Constants.TldDtdPublicId_12,
- schemaResolver);
-
- register(Constants.TldSchemaResourcePath_20,
- Constants.TldSchemaPublicId_20,
- schemaResolver);
-
- register(Constants.TldSchemaResourcePath_21,
- Constants.TldSchemaPublicId_21,
- schemaResolver);
-
- // web.xml
- register(Constants.WebDtdResourcePath_22,
- Constants.WebDtdPublicId_22,
- schemaResolver);
-
- register(Constants.WebDtdResourcePath_23,
- Constants.WebDtdPublicId_23,
- schemaResolver);
-
- register(Constants.WebSchemaResourcePath_24,
- Constants.WebSchemaPublicId_24,
- schemaResolver);
-
- register(Constants.WebSchemaResourcePath_25,
- Constants.WebSchemaPublicId_25,
- schemaResolver);
-
- // Web Service
- register(Constants.J2eeWebServiceSchemaResourcePath_11,
- Constants.J2eeWebServiceSchemaPublicId_11,
- schemaResolver);
-
- register(Constants.J2eeWebServiceClientSchemaResourcePath_11,
- Constants.J2eeWebServiceClientSchemaPublicId_11,
- schemaResolver);
-
- register(Constants.JavaeeWebServiceSchemaResourcePath_12,
- Constants.JavaeeWebServiceSchemaPublicId_12,
- schemaResolver);
-
- register(Constants.JavaeeWebServiceClientSchemaResourcePath_12,
- Constants.JavaeeWebServiceClientSchemaPublicId_12,
- schemaResolver);
-
- }
-
-
- /**
- * Load the resource and add it to the resolver.
- */
- protected static void register(String resourceURL, String resourcePublicId,
- SchemaResolver schemaResolver){
- URL url = DigesterFactory.class.getResource(resourceURL);
-
- if(url == null) {
- log.warn("Could not get url for " + resourceURL);
- } else {
- schemaResolver.register(resourcePublicId , url.toString() );
- }
- }
-
-
-}
Modified: trunk/java/org/apache/catalina/startup/Embedded.java
===================================================================
--- trunk/java/org/apache/catalina/startup/Embedded.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/Embedded.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -19,8 +19,6 @@
package org.apache.catalina.startup;
-import java.io.File;
-import java.io.IOException;
import java.net.InetAddress;
import java.util.HashMap;
@@ -32,7 +30,6 @@
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.Loader;
import org.apache.catalina.Realm;
import org.apache.catalina.Valve;
import org.apache.catalina.connector.Connector;
@@ -40,7 +37,6 @@
import org.apache.catalina.core.StandardEngine;
import org.apache.catalina.core.StandardHost;
import org.apache.catalina.core.StandardService;
-import org.apache.catalina.loader.WebappLoader;
import org.apache.catalina.security.SecurityConfig;
import org.apache.catalina.util.LifecycleSupport;
import org.apache.catalina.util.StringManager;
@@ -469,7 +465,7 @@
* @exception IllegalArgumentException if an invalid parameter
* is specified
*/
- public Context createContext(String path, String docBase) {
+ public Context createContext(String path, String docBase, ContextConfig config) {
if( log.isDebugEnabled() )
log.debug("Creating context '" + path + "' with docBase '" +
@@ -480,7 +476,6 @@
context.setDocBase(docBase);
context.setPath(path);
- ContextConfig config = new ContextConfig();
config.setCustomAuthenticators(authenticators);
((Lifecycle) context).addLifecycleListener(config);
@@ -552,25 +547,6 @@
/**
- * Create and return a class loader manager that can be customized, and
- * then attached to a Context, before it is started.
- *
- * @param parent ClassLoader that will be the parent of the one
- * created by this Loader
- */
- public Loader createLoader(ClassLoader parent) {
-
- if( log.isDebugEnabled() )
- log.debug("Creating Loader with parent class loader '" +
- parent + "'");
-
- WebappLoader loader = new WebappLoader(parent);
- return (loader);
-
- }
-
-
- /**
* Return descriptive information about this Server implementation and
* the corresponding version number, in the format
* <code><description>/<version></code>.
@@ -804,12 +780,6 @@
if( log.isInfoEnabled() )
log.info("Starting tomcat server");
- // Validate the setup of our required system properties
- initDirs();
-
- // Initialize some naming specific properties
- initNaming();
-
// Initialise if not already done.
if (!initialized) {
initialized = true;
@@ -880,106 +850,6 @@
// ------------------------------------------------------ Protected Methods
-
- /** Initialize naming - this should only enable java:env and root naming.
- * If tomcat is embeded in an application that already defines those -
- * it shouldn't do it.
- *
- * XXX The 2 should be separated, you may want to enable java: but not
- * the initial context and the reverse
- * XXX Can we "guess" - i.e. lookup java: and if something is returned assume
- * false ?
- * XXX We have a major problem with the current setting for java: url
- */
- protected void initNaming() {
- // Setting additional variables
- if (!useNaming) {
- log.debug( "Catalina naming disabled");
- System.setProperty("catalina.useNaming", "false");
- } else {
- System.setProperty("catalina.useNaming", "true");
- String value = "org.apache.naming";
- String oldValue =
- System.getProperty(javax.naming.Context.URL_PKG_PREFIXES);
- if (oldValue != null) {
- value = value + ":" + oldValue;
- }
- System.setProperty(javax.naming.Context.URL_PKG_PREFIXES, value);
- if( log.isDebugEnabled() )
- log.debug("Setting naming prefix=" + value);
- value = System.getProperty
- (javax.naming.Context.INITIAL_CONTEXT_FACTORY);
- if (value == null) {
- System.setProperty
- (javax.naming.Context.INITIAL_CONTEXT_FACTORY,
- "org.apache.naming.java.javaURLContextFactory");
- } else {
- log.debug( "INITIAL_CONTEXT_FACTORY alread set " + value );
- }
- }
- }
-
-
- protected void initDirs() {
-
- String catalinaHome = System.getProperty("catalina.home");
- if (catalinaHome == null) {
- // Backwards compatibility patch for J2EE RI 1.3
- String j2eeHome = System.getProperty("com.sun.enterprise.home");
- if (j2eeHome != null) {
- catalinaHome=System.getProperty("com.sun.enterprise.home");
- } else if (System.getProperty("catalina.base") != null) {
- catalinaHome = System.getProperty("catalina.base");
- } else {
- // Use IntrospectionUtils and guess the dir
- catalinaHome = IntrospectionUtils.guessInstall
- ("catalina.home", "catalina.base", "catalina.jar");
- if (catalinaHome == null) {
- catalinaHome = IntrospectionUtils.guessInstall
- ("tomcat.install", "catalina.home", "tomcat.jar");
- }
- }
- }
- // last resort - for minimal/embedded cases.
- if(catalinaHome==null) {
- catalinaHome=System.getProperty("user.dir");
- }
- if (catalinaHome != null) {
- File home = new File(catalinaHome);
- if (!home.isAbsolute()) {
- try {
- catalinaHome = home.getCanonicalPath();
- } catch (IOException e) {
- catalinaHome = home.getAbsolutePath();
- }
- }
- System.setProperty("catalina.home", catalinaHome);
- }
-
- if (System.getProperty("catalina.base") == null) {
- System.setProperty("catalina.base",
- catalinaHome);
- } else {
- String catalinaBase = System.getProperty("catalina.base");
- File base = new File(catalinaBase);
- if (!base.isAbsolute()) {
- try {
- catalinaBase = base.getCanonicalPath();
- } catch (IOException e) {
- catalinaBase = base.getAbsolutePath();
- }
- }
- System.setProperty("catalina.base", catalinaBase);
- }
-
- String temp = System.getProperty("java.io.tmpdir");
- if (temp == null || (!(new File(temp)).exists())
- || (!(new File(temp)).isDirectory())) {
- log.error(sm.getString("embedded.notmp", temp));
- }
-
- }
-
protected void initStreams() {
if (redirectStreams) {
Deleted: trunk/java/org/apache/catalina/startup/EngineRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/EngineRuleSet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/EngineRuleSet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,137 +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 org.apache.tomcat.util.digester.Digester;
-import org.apache.tomcat.util.digester.RuleSetBase;
-
-
-/**
- * <p><strong>RuleSet</strong> for processing the contents of a
- * Engine definition element. This <code>RuleSet</code> does NOT include
- * any rules for nested Host or DefaultContext elements, which should
- * be added via instances of <code>HostRuleSet</code> or
- * <code>ContextRuleSet</code>, respectively.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public class EngineRuleSet extends RuleSetBase {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The matching pattern prefix to use for recognizing our elements.
- */
- protected String prefix = null;
-
-
- // ------------------------------------------------------------ Constructor
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
- */
- public EngineRuleSet() {
-
- this("");
-
- }
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern prefix.
- *
- * @param prefix Prefix for matching pattern rules (including the
- * trailing slash character)
- */
- public EngineRuleSet(String prefix) {
-
- super();
- this.namespaceURI = null;
- this.prefix = prefix;
-
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * <p>Add the set of Rule instances defined in this RuleSet to the
- * specified <code>Digester</code> instance, associating them with
- * our namespace URI (if any). This method should only be called
- * by a Digester instance.</p>
- *
- * @param digester Digester instance to which the new Rule instances
- * should be added.
- */
- public void addRuleInstances(Digester digester) {
-
- digester.addObjectCreate(prefix + "Engine",
- "org.apache.catalina.core.StandardEngine",
- "className");
- digester.addSetProperties(prefix + "Engine");
- digester.addRule(prefix + "Engine",
- new LifecycleListenerRule
- ("org.apache.catalina.startup.EngineConfig",
- "engineConfigClass"));
- digester.addSetNext(prefix + "Engine",
- "setContainer",
- "org.apache.catalina.Container");
-
- //Cluster configuration start
- digester.addObjectCreate(prefix + "Engine/Cluster",
- null, // MUST be specified in the element
- "className");
- digester.addSetProperties(prefix + "Engine/Cluster");
- digester.addSetNext(prefix + "Engine/Cluster",
- "setCluster",
- "org.apache.catalina.Cluster");
- //Cluster configuration end
-
- digester.addObjectCreate(prefix + "Engine/Listener",
- null, // MUST be specified in the element
- "className");
- digester.addSetProperties(prefix + "Engine/Listener");
- digester.addSetNext(prefix + "Engine/Listener",
- "addLifecycleListener",
- "org.apache.catalina.LifecycleListener");
-
-
- digester.addRuleSet(new RealmRuleSet(prefix + "Engine/"));
-
- digester.addObjectCreate(prefix + "Engine/Valve",
- null, // MUST be specified in the element
- "className");
- digester.addSetProperties(prefix + "Engine/Valve");
- digester.addSetNext(prefix + "Engine/Valve",
- "addValve",
- "org.apache.catalina.Valve");
-
- }
-
-
-}
Modified: trunk/java/org/apache/catalina/startup/HostConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/HostConfig.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/HostConfig.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -19,35 +19,21 @@
package org.apache.catalina.startup;
-import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedHashMap;
import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
import javax.management.ObjectName;
import org.apache.catalina.Container;
-import org.apache.catalina.Context;
import org.apache.catalina.Engine;
import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.core.ContainerBase;
-import org.apache.catalina.core.StandardHost;
-import org.apache.catalina.util.IOTools;
import org.apache.catalina.util.StringManager;
-import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.modeler.Registry;
@@ -112,26 +98,6 @@
/**
- * Should we deploy XML Context config files?
- */
- protected boolean deployXML = false;
-
-
- /**
- * Should we unpack WAR files when auto-deploying applications in the
- * <code>appBase</code> directory?
- */
- protected boolean unpackWARs = false;
-
-
- /**
- * Map of deployed applications.
- */
- protected HashMap<String, DeployedApplication> deployed =
- new HashMap<String, DeployedApplication>();
-
-
- /**
* List of applications which are being serviced, and shouldn't be
* deployed/undeployed/redeployed at the moment.
*/
@@ -139,11 +105,6 @@
/**
- * The <code>Digester</code> instance used to parse context descriptors.
- */
- protected static Digester digester = createDigester();
-
- /**
* The list of Wars in the appBase to be ignored because they are invalid
* (e.g. contain /../ sequences).
*/
@@ -196,50 +157,6 @@
}
- /**
- * Return the deploy XML config file flag for this component.
- */
- public boolean isDeployXML() {
-
- return (this.deployXML);
-
- }
-
-
- /**
- * Set the deploy XML config file flag for this component.
- *
- * @param deployXML The new deploy XML flag
- */
- public void setDeployXML(boolean deployXML) {
-
- this.deployXML= deployXML;
-
- }
-
-
- /**
- * Return the unpack WARs flag.
- */
- public boolean isUnpackWARs() {
-
- return (this.unpackWARs);
-
- }
-
-
- /**
- * Set the unpack WARs flag.
- *
- * @param unpackWARs The new unpack WARs flag
- */
- public void setUnpackWARs(boolean unpackWARs) {
-
- this.unpackWARs = unpackWARs;
-
- }
-
-
// --------------------------------------------------------- Public Methods
@@ -253,18 +170,6 @@
if (event.getType().equals(Lifecycle.PERIODIC_EVENT))
check();
- // Identify the host we are associated with
- try {
- host = (Host) event.getLifecycle();
- if (host instanceof StandardHost) {
- setDeployXML(((StandardHost) host).isDeployXML());
- setUnpackWARs(((StandardHost) host).isUnpackWARs());
- }
- } catch (ClassCastException e) {
- log.error(sm.getString("hostConfig.cce", event.getLifecycle()), e);
- return;
- }
-
// Process the event that has occurred
if (event.getType().equals(Lifecycle.START_EVENT))
start();
@@ -274,83 +179,10 @@
}
- /**
- * Add a serviced application to the list.
- */
- public synchronized void addServiced(String name) {
- serviced.add(name);
- }
-
-
- /**
- * Is application serviced ?
- * @return state of the application
- */
- public synchronized boolean isServiced(String name) {
- return (serviced.contains(name));
- }
-
-
- /**
- * Removed a serviced application from the list.
- */
- public synchronized void removeServiced(String name) {
- serviced.remove(name);
- }
-
-
- /**
- * Get the instant where an application was deployed.
- * @return 0L if no application with that name is deployed, or the instant
- * on which the application was deployed
- */
- public long getDeploymentTime(String name) {
- DeployedApplication app = deployed.get(name);
- if (app == null) {
- return 0L;
- } else {
- return app.timestamp;
- }
- }
-
-
- /**
- * Has the specified application been deployed? Note applications defined
- * in server.xml will not have been deployed.
- * @return <code>true</code> if the application has been deployed and
- * <code>false</code> if the applciation has not been deployed or does not
- * exist
- */
- public boolean isDeployed(String name) {
- DeployedApplication app = deployed.get(name);
- if (app == null) {
- return false;
- } else {
- return true;
- }
- }
-
-
// ------------------------------------------------------ Protected Methods
/**
- * Create the digester which will be used to parse context config files.
- */
- protected static Digester createDigester() {
- Digester digester = new Digester();
- digester.setValidating(false);
- // Add object creation rule
- digester.addObjectCreate("Context", "org.apache.catalina.core.StandardContext",
- "className");
- // Set the properties on that object (it doesn't matter if extra
- // properties are set)
- digester.addSetProperties("Context");
- return (digester);
- }
-
-
- /**
* Return a File object representing the "application root" directory
* for our associated Host.
*/
@@ -436,766 +268,6 @@
/**
- * Deploy applications for any directories or WAR files that are found
- * in our "application root" directory.
- */
- protected void deployApps() {
-
- File appBase = appBase();
- File configBase = configBase();
- // Deploy XML descriptors from configBase
- deployDescriptors(configBase, configBase.list());
- // Deploy WARs, and loop if additional descriptors are found
- deployWARs(appBase, appBase.list());
- // Deploy expanded folders
- deployDirectories(appBase, appBase.list());
-
- }
-
-
- /**
- * Deploy applications for any directories or WAR files that are found
- * in our "application root" directory.
- */
- protected void deployApps(String name) {
-
- File appBase = appBase();
- File configBase = configBase();
- String baseName = getConfigFile(name);
- String docBase = getDocBase(name);
-
- // Deploy XML descriptors from configBase
- File xml = new File(configBase, baseName + ".xml");
- if (xml.exists())
- deployDescriptor(name, xml, baseName + ".xml");
- // Deploy WARs, and loop if additional descriptors are found
- File war = new File(appBase, docBase + ".war");
- if (war.exists())
- deployWAR(name, war, docBase + ".war");
- // Deploy expanded folders
- File dir = new File(appBase, docBase);
- if (dir.exists())
- deployDirectory(name, dir, docBase);
-
- }
-
-
- /**
- * Deploy XML context descriptors.
- */
- protected void deployDescriptors(File configBase, String[] files) {
-
- if (files == null)
- return;
-
- for (int i = 0; i < files.length; i++) {
-
- if (files[i].equalsIgnoreCase("META-INF"))
- continue;
- if (files[i].equalsIgnoreCase("WEB-INF"))
- continue;
- File contextXml = new File(configBase, files[i]);
- if (files[i].toLowerCase().endsWith(".xml")) {
-
- // Calculate the context path and make sure it is unique
- String nameTmp = files[i].substring(0, files[i].length() - 4);
- String contextPath = "/" + nameTmp.replace('#', '/');
- if (nameTmp.equals("ROOT")) {
- contextPath = "";
- }
-
- if (isServiced(contextPath))
- continue;
-
- String file = files[i];
-
- deployDescriptor(contextPath, contextXml, file);
-
- }
-
- }
-
- }
-
-
- /**
- * @param contextPath
- * @param contextXml
- * @param file
- */
- protected void deployDescriptor(String contextPath, File contextXml, String file) {
- if (deploymentExists(contextPath)) {
- return;
- }
-
- DeployedApplication deployedApp = new DeployedApplication(contextPath);
-
- // Assume this is a configuration descriptor and deploy it
- if(log.isDebugEnabled()) {
- log.debug(sm.getString("hostConfig.deployDescriptor", file));
- }
-
- Context context = null;
- try {
- synchronized (digester) {
- try {
- context = (Context) digester.parse(contextXml);
- if (context == null) {
- log.error(sm.getString("hostConfig.deployDescriptor.error",
- file));
- return;
- }
- } finally {
- digester.reset();
- }
- }
- if (context instanceof Lifecycle) {
- Class<?> clazz = Class.forName(host.getConfigClass());
- LifecycleListener listener =
- (LifecycleListener) clazz.newInstance();
- ((Lifecycle) context).addLifecycleListener(listener);
- }
- context.setConfigFile(contextXml.getAbsolutePath());
- context.setPath(contextPath);
- // Add the associated docBase to the redeployed list if it's a WAR
- boolean isExternalWar = false;
- boolean isExternal = false;
- if (context.getDocBase() != null) {
- File docBase = new File(context.getDocBase());
- if (!docBase.isAbsolute()) {
- docBase = new File(appBase(), context.getDocBase());
- }
- // If external docBase, register .xml as redeploy first
- if (!docBase.getCanonicalPath().startsWith(
- appBase().getAbsolutePath() + File.separator)) {
- isExternal = true;
- deployedApp.redeployResources.put
- (contextXml.getAbsolutePath(), new Long(contextXml.lastModified()));
- deployedApp.redeployResources.put(docBase.getAbsolutePath(),
- new Long(docBase.lastModified()));
- if (docBase.getAbsolutePath().toLowerCase().endsWith(".war")) {
- isExternalWar = true;
- }
- } else {
- log.warn(sm.getString("hostConfig.deployDescriptor.localDocBaseSpecified",
- docBase));
- // Ignore specified docBase
- context.setDocBase(null);
- }
- }
- host.addChild(context);
- // Get paths for WAR and expanded WAR in appBase
- String name = null;
- String path = context.getPath();
- if (path.equals("")) {
- name = "ROOT";
- } else {
- if (path.startsWith("/")) {
- name = path.substring(1);
- } else {
- name = path;
- }
- }
- // default to appBase dir + name
- File expandedDocBase = new File(appBase(), name);
- if (context.getDocBase() != null) {
- // first assume docBase is absolute
- expandedDocBase = new File(context.getDocBase());
- if (!expandedDocBase.isAbsolute()) {
- // if docBase specified and relative, it must be relative to appBase
- expandedDocBase = new File(appBase(), context.getDocBase());
- }
- }
- // Add the eventual unpacked WAR and all the resources which will be
- // watched inside it
- if (isExternalWar && unpackWARs) {
- deployedApp.redeployResources.put(expandedDocBase.getAbsolutePath(),
- new Long(expandedDocBase.lastModified()));
- deployedApp.redeployResources.put
- (contextXml.getAbsolutePath(), new Long(contextXml.lastModified()));
- addWatchedResources(deployedApp, expandedDocBase.getAbsolutePath(), context);
- } else {
- // Find an existing matching war and expanded folder
- if (!isExternal) {
- File warDocBase = new File(expandedDocBase.getAbsolutePath() + ".war");
- if (warDocBase.exists()) {
- deployedApp.redeployResources.put(warDocBase.getAbsolutePath(),
- new Long(warDocBase.lastModified()));
- }
- }
- if (expandedDocBase.exists()) {
- deployedApp.redeployResources.put(expandedDocBase.getAbsolutePath(),
- new Long(expandedDocBase.lastModified()));
- addWatchedResources(deployedApp,
- expandedDocBase.getAbsolutePath(), context);
- } else {
- addWatchedResources(deployedApp, null, context);
- }
- // Add the context XML to the list of files which should trigger a redeployment
- if (!isExternal) {
- deployedApp.redeployResources.put
- (contextXml.getAbsolutePath(), new Long(contextXml.lastModified()));
- }
- }
- } catch (Throwable t) {
- log.error(sm.getString("hostConfig.deployDescriptor.error",
- file), t);
- }
-
- if (context != null && host.findChild(context.getName()) != null) {
- deployed.put(contextPath, deployedApp);
- }
- }
-
-
- /**
- * Deploy WAR files.
- */
- protected void deployWARs(File appBase, String[] files) {
-
- if (files == null)
- return;
-
- for (int i = 0; i < files.length; i++) {
-
- if (files[i].equalsIgnoreCase("META-INF"))
- continue;
- if (files[i].equalsIgnoreCase("WEB-INF"))
- continue;
- File dir = new File(appBase, files[i]);
- if (files[i].toLowerCase().endsWith(".war") && dir.isFile()
- && !invalidWars.contains(files[i]) ) {
-
- // Calculate the context path and make sure it is unique
- String contextPath = "/" + files[i].replace('#','/');
- int period = contextPath.lastIndexOf(".");
- contextPath = contextPath.substring(0, period);
-
- // Check for WARs with /../ /./ or similar sequences in the name
- if (!validateContextPath(appBase, contextPath)) {
- log.error(sm.getString(
- "hostConfig.illegalWarName", files[i]));
- invalidWars.add(files[i]);
- continue;
- }
-
- if (contextPath.equals("/ROOT"))
- contextPath = "";
-
- if (isServiced(contextPath))
- continue;
-
- String file = files[i];
-
- deployWAR(contextPath, dir, file);
-
- }
-
- }
-
- }
-
-
- private boolean validateContextPath(File appBase, String contextPath) {
- // More complicated than the ideal as the canonical path may or may
- // not end with File.separator for a directory
-
- StringBuilder docBase;
- String canonicalDocBase = null;
-
- try {
- String canonicalAppBase = appBase.getCanonicalPath();
- docBase = new StringBuilder(canonicalAppBase);
- if (canonicalAppBase.endsWith(File.separator)) {
- docBase.append(contextPath.substring(1).replace(
- '/', File.separatorChar));
- } else {
- docBase.append(contextPath.replace('/', File.separatorChar));
- }
- // At this point docBase should be canonical but will not end
- // with File.separator
-
- canonicalDocBase =
- (new File(docBase.toString())).getCanonicalPath();
-
- // If the canonicalDocBase ends with File.separator, add one to
- // docBase before they are compared
- if (canonicalDocBase.endsWith(File.separator)) {
- docBase.append(File.separator);
- }
- } catch (IOException ioe) {
- return false;
- }
-
- // Compare the two. If they are not the same, the contextPath must
- // have /../ like sequences in it
- return canonicalDocBase.equals(docBase.toString());
- }
-
- /**
- * @param contextPath
- * @param war
- * @param file
- */
- protected void deployWAR(String contextPath, File war, String file) {
-
- if (deploymentExists(contextPath))
- return;
-
- // Checking for a nested /META-INF/context.xml
- JarFile jar = null;
- JarEntry entry = null;
- InputStream istream = null;
- BufferedOutputStream ostream = null;
- File xml = new File
- (configBase, file.substring(0, file.lastIndexOf(".")) + ".xml");
- if (deployXML && !xml.exists()) {
- try {
- jar = new JarFile(war);
- entry = jar.getJarEntry(Constants.ApplicationContextXml);
- if (entry != null) {
- istream = jar.getInputStream(entry);
-
- configBase.mkdirs();
-
- ostream =
- new BufferedOutputStream
- (new FileOutputStream(xml), 1024);
- byte buffer[] = new byte[1024];
- while (true) {
- int n = istream.read(buffer);
- if (n < 0) {
- break;
- }
- ostream.write(buffer, 0, n);
- }
- ostream.flush();
- ostream.close();
- ostream = null;
- istream.close();
- istream = null;
- entry = null;
- jar.close();
- jar = null;
- }
- } catch (Exception e) {
- // Ignore and continue
- if (ostream != null) {
- try {
- ostream.close();
- } catch (Throwable t) {
- // Ignore
- }
- ostream = null;
- }
- if (istream != null) {
- try {
- istream.close();
- } catch (Throwable t) {
- // Ignore
- }
- istream = null;
- }
- } finally {
- entry = null;
- if (jar != null) {
- try {
- jar.close();
- } catch (Throwable t) {
- // Ignore
- }
- jar = null;
- }
- }
- }
-
- DeployedApplication deployedApp = new DeployedApplication(contextPath);
-
- // Deploy the application in this WAR file
- if(log.isInfoEnabled())
- log.info(sm.getString("hostConfig.deployJar", file));
-
- try {
- Context context = null;
- if (deployXML && xml.exists()) {
- synchronized (digester) {
- try {
- context = (Context) digester.parse(xml);
- if (context == null) {
- log.error(sm.getString("hostConfig.deployDescriptor.error",
- file));
- return;
- }
- } finally {
- digester.reset();
- }
- }
- context.setConfigFile(xml.getAbsolutePath());
- } else {
- context = (Context) Class.forName(contextClass).newInstance();
- }
-
- // Populate redeploy resources with the WAR file
- deployedApp.redeployResources.put
- (war.getAbsolutePath(), new Long(war.lastModified()));
-
- if (deployXML && xml.exists()) {
- deployedApp.redeployResources.put
- (xml.getAbsolutePath(), new Long(xml.lastModified()));
- }
-
- if (context instanceof Lifecycle) {
- Class<?> clazz = Class.forName(host.getConfigClass());
- LifecycleListener listener =
- (LifecycleListener) clazz.newInstance();
- ((Lifecycle) context).addLifecycleListener(listener);
- }
- context.setPath(contextPath);
- context.setDocBase(file);
- host.addChild(context);
- // If we're unpacking WARs, the docBase will be mutated after
- // starting the context
- if (unpackWARs && (context.getDocBase() != null)) {
- String name = null;
- String path = context.getPath();
- if (path.equals("")) {
- name = "ROOT";
- } else {
- if (path.startsWith("/")) {
- name = path.substring(1);
- } else {
- name = path;
- }
- }
- name = name.replace('/', '#');
- File docBase = new File(name);
- if (!docBase.isAbsolute()) {
- docBase = new File(appBase(), name);
- }
- deployedApp.redeployResources.put(docBase.getAbsolutePath(),
- new Long(docBase.lastModified()));
- addWatchedResources(deployedApp, docBase.getAbsolutePath(), context);
- } else {
- addWatchedResources(deployedApp, null, context);
- }
- } catch (Throwable t) {
- log.error(sm.getString("hostConfig.deployJar.error", file), t);
- }
-
- deployed.put(contextPath, deployedApp);
- }
-
-
- /**
- * Deploy directories.
- */
- protected void deployDirectories(File appBase, String[] files) {
-
- if (files == null)
- return;
-
- for (int i = 0; i < files.length; i++) {
-
- if (files[i].equalsIgnoreCase("META-INF"))
- continue;
- if (files[i].equalsIgnoreCase("WEB-INF"))
- continue;
- File dir = new File(appBase, files[i]);
- if (dir.isDirectory()) {
-
- // Calculate the context path and make sure it is unique
- String contextPath = "/" + files[i].replace('#','/');
- if (files[i].equals("ROOT"))
- contextPath = "";
-
- if (isServiced(contextPath))
- continue;
-
- deployDirectory(contextPath, dir, files[i]);
-
- }
-
- }
-
- }
-
-
- /**
- * @param contextPath
- * @param dir
- * @param file
- */
- protected void deployDirectory(String contextPath, File dir, String file) {
- DeployedApplication deployedApp = new DeployedApplication(contextPath);
-
- if (deploymentExists(contextPath))
- return;
-
- // Deploy the application in this directory
- if( log.isDebugEnabled() )
- log.debug(sm.getString("hostConfig.deployDir", file));
- try {
- Context context = null;
- File xml = new File(dir, Constants.ApplicationContextXml);
- File xmlCopy = null;
- if (deployXML && xml.exists()) {
- // Will only do this on initial deployment. On subsequent
- // deployments the copied xml file means we'll use
- // deployDescriptor() instead
- synchronized (digester) {
- try {
- context = (Context) digester.parse(xml);
- if (context == null) {
- log.error(sm.getString("hostConfig.deployDescriptor.error",
- xml));
- return;
- }
- } finally {
- digester.reset();
- }
- }
- configBase.mkdirs();
- xmlCopy = new File(configBase(), file + ".xml");
- InputStream is = null;
- OutputStream os = null;
- try {
- is = new FileInputStream(xml);
- os = new FileOutputStream(xmlCopy);
- IOTools.flow(is, os);
- // Don't catch IOE - let the outer try/catch handle it
- } finally {
- try {
- if (is != null) is.close();
- } catch (IOException e){
- // Ignore
- }
- try {
- if (os != null) os.close();
- } catch (IOException e){
- // Ignore
- }
- }
- context.setConfigFile(xmlCopy.getAbsolutePath());
- } else {
- context = (Context) Class.forName(contextClass).newInstance();
- }
-
- if (context instanceof Lifecycle) {
- Class<?> clazz = Class.forName(host.getConfigClass());
- LifecycleListener listener =
- (LifecycleListener) clazz.newInstance();
- ((Lifecycle) context).addLifecycleListener(listener);
- }
- context.setPath(contextPath);
- context.setDocBase(file);
- host.addChild(context);
- deployedApp.redeployResources.put(dir.getAbsolutePath(),
- new Long(dir.lastModified()));
- if (xmlCopy != null) {
- deployedApp.redeployResources.put
- (xmlCopy.getAbsolutePath(), new Long(xmlCopy.lastModified()));
- }
- addWatchedResources(deployedApp, dir.getAbsolutePath(), context);
- } catch (Throwable t) {
- log.error(sm.getString("hostConfig.deployDir.error", file), t);
- }
-
- deployed.put(contextPath, deployedApp);
- }
-
-
- /**
- * Check if a webapp is already deployed in this host.
- *
- * @param contextPath of the context which will be checked
- */
- protected boolean deploymentExists(String contextPath) {
- return (deployed.containsKey(contextPath) || (host.findChild(contextPath) != null));
- }
-
-
- /**
- * Add watched resources to the specified Context.
- * @param app HostConfig deployed app
- * @param docBase web app docBase
- * @param context web application context
- */
- protected void addWatchedResources(DeployedApplication app, String docBase, Context context) {
- // FIXME: Feature idea. Add support for patterns (ex: WEB-INF/*, WEB-INF/*.xml), where
- // we would only check if at least one resource is newer than app.timestamp
- File docBaseFile = null;
- if (docBase != null) {
- docBaseFile = new File(docBase);
- if (!docBaseFile.isAbsolute()) {
- docBaseFile = new File(appBase(), docBase);
- }
- }
- String[] watchedResources = context.findWatchedResources();
- for (int i = 0; i < watchedResources.length; i++) {
- File resource = new File(watchedResources[i]);
- if (!resource.isAbsolute()) {
- if (docBase != null) {
- resource = new File(docBaseFile, watchedResources[i]);
- } else {
- if(log.isDebugEnabled())
- log.debug("Ignoring non-existent WatchedResource '" + resource.getAbsolutePath() + "'");
- continue;
- }
- }
- if(log.isDebugEnabled())
- log.debug("Watching WatchedResource '" + resource.getAbsolutePath() + "'");
- app.reloadResources.put(resource.getAbsolutePath(),
- new Long(resource.lastModified()));
- }
- }
-
-
- /**
- * Check resources for redeployment and reloading.
- */
- protected synchronized void checkResources(DeployedApplication app) {
- String[] resources =
- app.redeployResources.keySet().toArray(new String[0]);
- for (int i = 0; i < resources.length; i++) {
- File resource = new File(resources[i]);
- if (log.isDebugEnabled())
- log.debug("Checking context[" + app.name + "] redeploy resource " + resource);
- if (resource.exists()) {
- long lastModified =
- app.redeployResources.get(resources[i]).longValue();
- if ((!resource.isDirectory()) && resource.lastModified() > lastModified) {
- // Undeploy application
- if (log.isInfoEnabled())
- log.info(sm.getString("hostConfig.undeploy", app.name));
- ContainerBase context = (ContainerBase) host.findChild(app.name);
- try {
- host.removeChild(context);
- } catch (Throwable t) {
- log.warn(sm.getString
- ("hostConfig.context.remove", app.name), t);
- }
- try {
- context.destroy();
- } catch (Throwable t) {
- log.warn(sm.getString
- ("hostConfig.context.destroy", app.name), t);
- }
- // Delete other redeploy resources
- for (int j = i + 1; j < resources.length; j++) {
- try {
- File current = new File(resources[j]);
- current = current.getCanonicalFile();
- if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath() + File.separator))
- || (current.getAbsolutePath().startsWith(configBase().getAbsolutePath()))) {
- if (log.isDebugEnabled())
- log.debug("Delete " + current);
- ExpandWar.delete(current);
- }
- } catch (IOException e) {
- log.warn(sm.getString
- ("hostConfig.canonicalizing", app.name), e);
- }
- }
- deployed.remove(app.name);
- return;
- }
- } else {
- long lastModified =
- app.redeployResources.get(resources[i]).longValue();
- if (lastModified == 0L) {
- continue;
- }
- // Undeploy application
- if (log.isInfoEnabled())
- log.info(sm.getString("hostConfig.undeploy", app.name));
- ContainerBase context = (ContainerBase) host.findChild(app.name);
- try {
- host.removeChild(context);
- } catch (Throwable t) {
- log.warn(sm.getString
- ("hostConfig.context.remove", app.name), t);
- }
- try {
- context.destroy();
- } catch (Throwable t) {
- log.warn(sm.getString
- ("hostConfig.context.destroy", app.name), t);
- }
- // Delete all redeploy resources
- for (int j = i + 1; j < resources.length; j++) {
- try {
- File current = new File(resources[j]);
- current = current.getCanonicalFile();
- if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath() + File.separator))
- || (current.getAbsolutePath().startsWith(configBase().getAbsolutePath()))) {
- if (log.isDebugEnabled())
- log.debug("Delete " + current);
- ExpandWar.delete(current);
- }
- } catch (IOException e) {
- log.warn(sm.getString
- ("hostConfig.canonicalizing", app.name), e);
- }
- }
- // Delete reload resources as well (to remove any remaining .xml descriptor)
- String[] resources2 =
- app.reloadResources.keySet().toArray(new String[0]);
- for (int j = 0; j < resources2.length; j++) {
- try {
- File current = new File(resources2[j]);
- current = current.getCanonicalFile();
- if ((current.getAbsolutePath().startsWith(appBase().getAbsolutePath() + File.separator))
- || ((current.getAbsolutePath().startsWith(configBase().getAbsolutePath())
- && (current.getAbsolutePath().endsWith(".xml"))))) {
- if (log.isDebugEnabled())
- log.debug("Delete " + current);
- ExpandWar.delete(current);
- }
- } catch (IOException e) {
- log.warn(sm.getString
- ("hostConfig.canonicalizing", app.name), e);
- }
- }
- deployed.remove(app.name);
- return;
- }
- }
- resources = app.reloadResources.keySet().toArray(new String[0]);
- for (int i = 0; i < resources.length; i++) {
- File resource = new File(resources[i]);
- if (log.isDebugEnabled())
- log.debug("Checking context[" + app.name + "] reload resource " + resource);
- long lastModified = app.reloadResources.get(resources[i]).longValue();
- if ((!resource.exists() && lastModified != 0L)
- || (resource.lastModified() != lastModified)) {
- // Reload application
- if(log.isInfoEnabled())
- log.info(sm.getString("hostConfig.reload", app.name));
- Container context = host.findChild(app.name);
- try {
- ((Lifecycle) context).stop();
- } catch (Exception e) {
- log.warn(sm.getString
- ("hostConfig.context.restart", app.name), e);
- }
- // If the context was not started (for example an error
- // in web.xml) we'll still get to try to start
- try {
- ((Lifecycle) context).start();
- } catch (Exception e) {
- log.warn(sm.getString
- ("hostConfig.context.restart", app.name), e);
- }
- // Update times
- app.reloadResources.put(resources[i], new Long(resource.lastModified()));
- app.timestamp = System.currentTimeMillis();
- return;
- }
- }
- }
-
-
- /**
* Process a "start" event for this Host.
*/
public void start() {
@@ -1213,9 +285,6 @@
log.error(sm.getString("hostConfig.jmx.register", oname), e);
}
- if (host.getDeployOnStartup())
- deployApps();
-
}
@@ -1251,20 +320,6 @@
if (log.isDebugEnabled())
log.debug(sm.getString("hostConfig.undeploying"));
- // Soft undeploy all contexts we have deployed
- DeployedApplication[] apps =
- deployed.values().toArray(new DeployedApplication[0]);
- for (int i = 0; i < apps.length; i++) {
- try {
- host.removeChild(host.findChild(apps[i].name));
- } catch (Throwable t) {
- log.warn(sm.getString
- ("hostConfig.context.remove", apps[i].name), t);
- }
- }
-
- deployed.clear();
-
}
@@ -1272,141 +327,7 @@
* Check status of all webapps.
*/
protected void check() {
-
- if (host.getAutoDeploy()) {
- // Check for resources modification to trigger redeployment
- DeployedApplication[] apps =
- deployed.values().toArray(new DeployedApplication[0]);
- for (int i = 0; i < apps.length; i++) {
- if (!isServiced(apps[i].name))
- checkResources(apps[i]);
- }
- // Hotdeploy applications
- deployApps();
- }
-
}
- /**
- * Check status of a specific webapp, for use with stuff like management webapps.
- */
- public void check(String name) {
- DeployedApplication app = deployed.get(name);
- if (app != null) {
- checkResources(app);
- } else {
- deployApps(name);
- }
- }
-
- /**
- * Add a new Context to be managed by us.
- * Entry point for the admin webapp, and other JMX Context controlers.
- */
- public void manageApp(Context context) {
-
- String contextPath = context.getPath();
-
- if (deployed.containsKey(contextPath))
- return;
-
- DeployedApplication deployedApp = new DeployedApplication(contextPath);
-
- // Add the associated docBase to the redeployed list if it's a WAR
- boolean isWar = false;
- if (context.getDocBase() != null) {
- File docBase = new File(context.getDocBase());
- if (!docBase.isAbsolute()) {
- docBase = new File(appBase(), context.getDocBase());
- }
- deployedApp.redeployResources.put(docBase.getAbsolutePath(),
- new Long(docBase.lastModified()));
- if (docBase.getAbsolutePath().toLowerCase().endsWith(".war")) {
- isWar = true;
- }
- }
- host.addChild(context);
- // Add the eventual unpacked WAR and all the resources which will be
- // watched inside it
- if (isWar && unpackWARs) {
- String name = null;
- String path = context.getPath();
- if (path.equals("")) {
- name = "ROOT";
- } else {
- if (path.startsWith("/")) {
- name = path.substring(1);
- } else {
- name = path;
- }
- }
- File docBase = new File(name);
- if (!docBase.isAbsolute()) {
- docBase = new File(appBase(), name);
- }
- deployedApp.redeployResources.put(docBase.getAbsolutePath(),
- new Long(docBase.lastModified()));
- addWatchedResources(deployedApp, docBase.getAbsolutePath(), context);
- } else {
- addWatchedResources(deployedApp, null, context);
- }
- deployed.put(contextPath, deployedApp);
- }
-
- /**
- * Remove a webapp from our control.
- * Entry point for the admin webapp, and other JMX Context controlers.
- */
- public void unmanageApp(String contextPath) {
- if(isServiced(contextPath)) {
- deployed.remove(contextPath);
- host.removeChild(host.findChild(contextPath));
- }
- }
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * This class represents the state of a deployed application, as well as
- * the monitored resources.
- */
- protected class DeployedApplication {
- public DeployedApplication(String name) {
- this.name = name;
- }
-
- /**
- * Application context path. The assertion is that
- * (host.getChild(name) != null).
- */
- public String name;
-
- /**
- * Any modification of the specified (static) resources will cause a
- * redeployment of the application. If any of the specified resources is
- * removed, the application will be undeployed. Typically, this will
- * contain resources like the context.xml file, a compressed WAR path.
- * The value is the last modification time.
- */
- public LinkedHashMap<String, Long> redeployResources =
- new LinkedHashMap<String, Long>();
-
- /**
- * Any modification of the specified (static) resources will cause a
- * reload of the application. This will typically contain resources
- * such as the web.xml of a webapp, but can be configured to contain
- * additional descriptors.
- * The value is the last modification time.
- */
- public HashMap<String, Long> reloadResources =
- new HashMap<String, Long>();
-
- /**
- * Instant where the application was last put in service.
- */
- public long timestamp = System.currentTimeMillis();
- }
-
}
Deleted: trunk/java/org/apache/catalina/startup/HostRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/HostRuleSet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/HostRuleSet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,140 +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 org.apache.tomcat.util.digester.Digester;
-import org.apache.tomcat.util.digester.RuleSetBase;
-
-
-/**
- * <p><strong>RuleSet</strong> for processing the contents of a
- * Host definition element. This <code>RuleSet</code> does NOT include
- * any rules for nested Context or DefaultContext elements, which should
- * be added via instances of <code>ContextRuleSet</code>.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public class HostRuleSet extends RuleSetBase {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The matching pattern prefix to use for recognizing our elements.
- */
- protected String prefix = null;
-
-
- // ------------------------------------------------------------ Constructor
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
- */
- public HostRuleSet() {
-
- this("");
-
- }
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern prefix.
- *
- * @param prefix Prefix for matching pattern rules (including the
- * trailing slash character)
- */
- public HostRuleSet(String prefix) {
-
- super();
- this.namespaceURI = null;
- this.prefix = prefix;
-
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * <p>Add the set of Rule instances defined in this RuleSet to the
- * specified <code>Digester</code> instance, associating them with
- * our namespace URI (if any). This method should only be called
- * by a Digester instance.</p>
- *
- * @param digester Digester instance to which the new Rule instances
- * should be added.
- */
- public void addRuleInstances(Digester digester) {
-
- digester.addObjectCreate(prefix + "Host",
- "org.apache.catalina.core.StandardHost",
- "className");
- digester.addSetProperties(prefix + "Host");
- digester.addRule(prefix + "Host",
- new CopyParentClassLoaderRule());
- digester.addRule(prefix + "Host",
- new LifecycleListenerRule
- ("org.apache.catalina.startup.HostConfig",
- "hostConfigClass"));
- digester.addSetNext(prefix + "Host",
- "addChild",
- "org.apache.catalina.Container");
-
- digester.addCallMethod(prefix + "Host/Alias",
- "addAlias", 0);
-
- //Cluster configuration start
- digester.addObjectCreate(prefix + "Host/Cluster",
- null, // MUST be specified in the element
- "className");
- digester.addSetProperties(prefix + "Host/Cluster");
- digester.addSetNext(prefix + "Host/Cluster",
- "setCluster",
- "org.apache.catalina.Cluster");
- //Cluster configuration end
-
- digester.addObjectCreate(prefix + "Host/Listener",
- null, // MUST be specified in the element
- "className");
- digester.addSetProperties(prefix + "Host/Listener");
- digester.addSetNext(prefix + "Host/Listener",
- "addLifecycleListener",
- "org.apache.catalina.LifecycleListener");
-
- digester.addRuleSet(new RealmRuleSet(prefix + "Host/"));
-
- digester.addObjectCreate(prefix + "Host/Valve",
- null, // MUST be specified in the element
- "className");
- digester.addSetProperties(prefix + "Host/Valve");
- digester.addSetNext(prefix + "Host/Valve",
- "addValve",
- "org.apache.catalina.Valve");
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/LifecycleListenerRule.java
===================================================================
--- trunk/java/org/apache/catalina/startup/LifecycleListenerRule.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/LifecycleListenerRule.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,103 +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 org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleListener;
-import org.apache.tomcat.util.digester.Rule;
-import org.xml.sax.Attributes;
-
-
-/**
- * <p>Rule that creates a new <code>LifecycleListener</code> instance,
- * and associates it with the top object on the stack (which must
- * implement <code>LifecycleListener</code>).</p>
- */
-
-public class LifecycleListenerRule extends Rule {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a new instance of this Rule.
- *
- * @param listenerClass Default name of the LifecycleListener
- * implementation class to be created
- * @param attributeName Name of the attribute that optionally
- * includes an override name of the LifecycleListener class
- */
- public LifecycleListenerRule(String listenerClass, String attributeName) {
-
- this.listenerClass = listenerClass;
- this.attributeName = attributeName;
-
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The attribute name of an attribute that can override the
- * implementation class name.
- */
- private String attributeName;
-
-
- /**
- * The name of the <code>LifecycleListener</code> implementation class.
- */
- private String listenerClass;
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Handle the beginning of an XML element.
- *
- * @param attributes The attributes of this element
- *
- * @exception Exception if a processing error occurs
- */
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
-
- // Instantiate a new LifecyleListener implementation object
- String className = listenerClass;
- if (attributeName != null) {
- String value = attributes.getValue(attributeName);
- if (value != null)
- className = value;
- }
- Class clazz = Class.forName(className);
- LifecycleListener listener =
- (LifecycleListener) clazz.newInstance();
-
- // Add this LifecycleListener to our associated component
- Lifecycle lifecycle = (Lifecycle) digester.peek();
- lifecycle.addLifecycleListener(listener);
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/NamingRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/NamingRuleSet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/NamingRuleSet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,143 +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 org.apache.tomcat.util.digester.Digester;
-import org.apache.tomcat.util.digester.RuleSetBase;
-
-
-/**
- * <p><strong>RuleSet</strong> for processing the JNDI Enterprise Naming
- * Context resource declaration elements.</p>
- *
- * @author Craig R. McClanahan
- * @author Remy Maucherat
- * @version $Revision$ $Date$
- */
-
-public class NamingRuleSet extends RuleSetBase {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The matching pattern prefix to use for recognizing our elements.
- */
- protected String prefix = null;
-
-
- // ------------------------------------------------------------ Constructor
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
- */
- public NamingRuleSet() {
-
- this("");
-
- }
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern prefix.
- *
- * @param prefix Prefix for matching pattern rules (including the
- * trailing slash character)
- */
- public NamingRuleSet(String prefix) {
-
- super();
- this.namespaceURI = null;
- this.prefix = prefix;
-
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * <p>Add the set of Rule instances defined in this RuleSet to the
- * specified <code>Digester</code> instance, associating them with
- * our namespace URI (if any). This method should only be called
- * by a Digester instance.</p>
- *
- * @param digester Digester instance to which the new Rule instances
- * should be added.
- */
- public void addRuleInstances(Digester digester) {
-
- digester.addObjectCreate(prefix + "Ejb",
- "org.apache.catalina.deploy.ContextEjb");
- digester.addRule(prefix + "Ejb", new SetAllPropertiesRule());
- digester.addRule(prefix + "Ejb",
- new SetNextNamingRule("addEjb",
- "org.apache.catalina.deploy.ContextEjb"));
-
- digester.addObjectCreate(prefix + "Environment",
- "org.apache.catalina.deploy.ContextEnvironment");
- digester.addSetProperties(prefix + "Environment");
- digester.addRule(prefix + "Environment",
- new SetNextNamingRule("addEnvironment",
- "org.apache.catalina.deploy.ContextEnvironment"));
-
- digester.addObjectCreate(prefix + "LocalEjb",
- "org.apache.catalina.deploy.ContextLocalEjb");
- digester.addRule(prefix + "LocalEjb", new SetAllPropertiesRule());
- digester.addRule(prefix + "LocalEjb",
- new SetNextNamingRule("addLocalEjb",
- "org.apache.catalina.deploy.ContextLocalEjb"));
-
- digester.addObjectCreate(prefix + "Resource",
- "org.apache.catalina.deploy.ContextResource");
- digester.addRule(prefix + "Resource", new SetAllPropertiesRule());
- digester.addRule(prefix + "Resource",
- new SetNextNamingRule("addResource",
- "org.apache.catalina.deploy.ContextResource"));
-
- digester.addObjectCreate(prefix + "ResourceEnvRef",
- "org.apache.catalina.deploy.ContextResourceEnvRef");
- digester.addRule(prefix + "ResourceEnvRef", new SetAllPropertiesRule());
- digester.addRule(prefix + "ResourceEnvRef",
- new SetNextNamingRule("addResourceEnvRef",
- "org.apache.catalina.deploy.ContextResourceEnvRef"));
-
- digester.addObjectCreate(prefix + "ServiceRef",
- "org.apache.catalina.deploy.ContextService");
- digester.addRule(prefix + "ServiceRef", new SetAllPropertiesRule());
- digester.addRule(prefix + "ServiceRef",
- new SetNextNamingRule("addService",
- "org.apache.catalina.deploy.ContextService"));
-
- digester.addObjectCreate(prefix + "Transaction",
- "org.apache.catalina.deploy.ContextTransaction");
- digester.addRule(prefix + "Transaction", new SetAllPropertiesRule());
- digester.addRule(prefix + "Transaction",
- new SetNextNamingRule("setTransaction",
- "org.apache.catalina.deploy.ContextTransaction"));
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/OrderingResolver.java
===================================================================
--- trunk/java/org/apache/catalina/startup/OrderingResolver.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/OrderingResolver.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,484 +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.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
- * because of the relative complexity.
- *
- * @author Remy Maucherat
- */
-public class OrderingResolver {
-
- 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 Set<Ordering> after = new HashSet<Ordering>();
- protected Set<Ordering> before = new HashSet<Ordering>();
- protected boolean afterOthers = false;
- protected boolean beforeOthers = false;
-
- public boolean addAfter(Ordering ordering) {
- return after.add(ordering);
- }
-
- public boolean addBefore(Ordering ordering) {
- return before.add(ordering);
- }
-
- public void validate() {
- isBefore(new Ordering());
- isAfter(new Ordering());
- }
-
- /**
- * Check (recursively) if a fragment is before the specified fragment.
- *
- * @param ordering
- * @return
- */
- public boolean isBefore(Ordering ordering) {
- return isBeforeInternal(ordering, new HashSet<Ordering>());
- }
-
- 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(sm.getString("ordering.orderConflict", this.ordering.getJar()));
- }
- 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) {
- return isAfterInternal(ordering, new HashSet<Ordering>());
- }
-
- 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(sm.getString("ordering.orderConflict", this.ordering.getJar()));
- }
- 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;
- }
-
- }
-
- /**
- * 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) {
- 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 = workIterator2.next();
- if (name.equals(ordering2.ordering.getName())) {
- if (found) {
- // Duplicate name
- throw new IllegalStateException(sm.getString("ordering.duplicateName", webOrdering.getJar()));
- }
- ordering.addAfter(ordering2);
- ordering2.addBefore(ordering);
- found = true;
- }
- }
- if (!found) {
- // Unknown name
- throw new IllegalStateException(sm.getString("ordering.unkonwnName", webOrdering.getJar()));
- }
- }
- Iterator<String> before = webOrdering.getBefore().iterator();
- while (before.hasNext()) {
- String name = before.next();
- Iterator<Ordering> workIterator2 = work.iterator();
- boolean found = false;
- while (workIterator2.hasNext()) {
- Ordering ordering2 = workIterator2.next();
- if (name.equals(ordering2.ordering.getName())) {
- if (found) {
- // Duplicate name
- throw new IllegalStateException(sm.getString("ordering.duplicateName", webOrdering.getJar()));
- }
- ordering.addBefore(ordering2);
- ordering2.addAfter(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();
- boolean first = ordering.isFirstAfterOthers();
- int firstAfterOthers = tempOrder.size();
- 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();
- 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());
- }
-
- }
-
-
- public static void main(String args[]) {
- ArrayList<String> order = new ArrayList<String>();
- ArrayList<WebOrdering> webOrderings = new ArrayList<WebOrdering>();
- resolveOrder(webOrderings, order);
-
- test1();
- test2();
- test3();
- }
-
- public static void test1() {
-
- ArrayList<String> order = new ArrayList<String>();
- ArrayList<WebOrdering> webOrderings = new ArrayList<WebOrdering>();
-
- WebOrdering A = new WebOrdering();
- A.setName("A");
- A.setJar("A.jar");
- A.setAfterOthers(true);
- A.addAfter("C");
- webOrderings.add(A);
-
- WebOrdering B = new WebOrdering();
- B.setName("B");
- B.setJar("B.jar");
- B.setBeforeOthers(true);
- webOrderings.add(B);
-
- WebOrdering C = new WebOrdering();
- C.setName("C");
- C.setJar("C.jar");
- C.setAfterOthers(true);
- webOrderings.add(C);
-
- WebOrdering D = new WebOrdering();
- D.setName("D");
- D.setJar("D.jar");
- webOrderings.add(D);
-
- WebOrdering E = new WebOrdering();
- E.setName("E");
- E.setJar("E.jar");
- webOrderings.add(E);
-
- WebOrdering F = new WebOrdering();
- F.setName("F");
- F.setJar("F.jar");
- F.setBeforeOthers(true);
- F.addBefore("B");
- webOrderings.add(F);
-
- long n1 = System.nanoTime();
- resolveOrder(webOrderings, order);
- long n2 = System.nanoTime();
-
- System.out.print("Result: ");
- Iterator<String> orderIterator = order.iterator();
- while (orderIterator.hasNext()) {
- System.out.print(orderIterator.next() + " ");
- }
- System.out.println("ns: " + (n2 - n1));
-
- }
-
- public static void test2() {
-
- ArrayList<String> order = new ArrayList<String>();
- ArrayList<WebOrdering> webOrderings = new ArrayList<WebOrdering>();
-
- WebOrdering A = new WebOrdering();
- A.setJar("noid.jar");
- A.setAfterOthers(true);
- A.addBefore("C");
- webOrderings.add(A);
-
- WebOrdering B = new WebOrdering();
- B.setName("B");
- B.setJar("B.jar");
- B.setBeforeOthers(true);
- webOrderings.add(B);
-
- WebOrdering C = new WebOrdering();
- C.setName("C");
- C.setJar("C.jar");
- webOrderings.add(C);
-
- WebOrdering D = new WebOrdering();
- D.setName("D");
- D.setJar("D.jar");
- D.setAfterOthers(true);
- webOrderings.add(D);
-
- WebOrdering E = new WebOrdering();
- E.setName("E");
- E.setJar("E.jar");
- E.setBeforeOthers(true);
- webOrderings.add(E);
-
- WebOrdering F = new WebOrdering();
- F.setName("F");
- F.setJar("F.jar");
- webOrderings.add(F);
-
- long n1 = System.nanoTime();
- resolveOrder(webOrderings, order);
- long n2 = System.nanoTime();
-
- System.out.print("Result: ");
- Iterator<String> orderIterator = order.iterator();
- while (orderIterator.hasNext()) {
- System.out.print(orderIterator.next() + " ");
- }
- System.out.println("ns: " + (n2 - n1));
-
- }
-
- public static void test3() {
-
- ArrayList<String> order = new ArrayList<String>();
- ArrayList<WebOrdering> webOrderings = new ArrayList<WebOrdering>();
-
- WebOrdering A = new WebOrdering();
- A.setName("A");
- A.setJar("A.jar");
- A.addAfter("B");
- webOrderings.add(A);
-
- WebOrdering B = new WebOrdering();
- B.setName("B");
- B.setJar("B.jar");
- webOrderings.add(B);
-
- WebOrdering C = new WebOrdering();
- C.setName("C");
- C.setJar("C.jar");
- C.setBeforeOthers(true);
- webOrderings.add(C);
-
- WebOrdering D = new WebOrdering();
- D.setName("D");
- D.setJar("D.jar");
- webOrderings.add(D);
-
- long n1 = System.nanoTime();
- resolveOrder(webOrderings, order);
- long n2 = System.nanoTime();
-
- System.out.print("Result: ");
- Iterator<String> orderIterator = order.iterator();
- while (orderIterator.hasNext()) {
- System.out.print(orderIterator.next() + " ");
- }
- System.out.println("ns: " + (n2 - n1));
-
- }
-
-}
Deleted: trunk/java/org/apache/catalina/startup/RealmRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/RealmRuleSet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/RealmRuleSet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,109 +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 org.apache.tomcat.util.digester.Digester;
-import org.apache.tomcat.util.digester.RuleSetBase;
-
-
-/**
- * <p><strong>RuleSet</strong> for processing the contents of a Realm definition
- * element. This <code>RuleSet</code> supports Realms such as the
- * <code>CombinedRealm</code> that used nested Realms.</p>
- *
- * @version $Revision: 691805 $ $Date: 2008-09-04 00:18:39 +0200 (Thu, 04 Sep 2008) $
- */
-
-public class RealmRuleSet extends RuleSetBase {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The matching pattern prefix to use for recognizing our elements.
- */
- protected String prefix = null;
-
-
- // ------------------------------------------------------------ Constructor
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
- */
- public RealmRuleSet() {
-
- this("");
-
- }
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern prefix.
- *
- * @param prefix Prefix for matching pattern rules (including the
- * trailing slash character)
- */
- public RealmRuleSet(String prefix) {
-
- super();
- this.namespaceURI = null;
- this.prefix = prefix;
-
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * <p>Add the set of Rule instances defined in this RuleSet to the
- * specified <code>Digester</code> instance, associating them with
- * our namespace URI (if any). This method should only be called
- * by a Digester instance.</p>
- *
- * @param digester Digester instance to which the new Rule instances
- * should be added.
- */
- public void addRuleInstances(Digester digester) {
-
- digester.addObjectCreate(prefix + "Realm",
- null, // MUST be specified in the element,
- "className");
- digester.addSetProperties(prefix + "Realm");
- digester.addSetNext(prefix + "Realm",
- "setRealm",
- "org.apache.catalina.Realm");
-
- digester.addObjectCreate(prefix + "Realm/Realm",
- null, // MUST be specified in the element
- "className");
- digester.addSetProperties(prefix + "Realm/Realm");
- digester.addSetNext(prefix + "Realm/Realm",
- "addRealm",
- "org.apache.catalina.Realm");
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/SetAllPropertiesRule.java
===================================================================
--- trunk/java/org/apache/catalina/startup/SetAllPropertiesRule.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/SetAllPropertiesRule.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,79 +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 org.xml.sax.Attributes;
-
-import org.apache.tomcat.util.IntrospectionUtils;
-import org.apache.tomcat.util.digester.Rule;
-import java.util.HashMap;
-
-/**
- * Rule that uses the introspection utils to set properties.
- *
- * @author Remy Maucherat
- * @author Filip Hanik
- */
-public class SetAllPropertiesRule extends Rule {
-
-
- // ----------------------------------------------------------- Constructors
- public SetAllPropertiesRule() {}
-
- public SetAllPropertiesRule(String[] exclude) {
- for (int i=0; i<exclude.length; i++ ) if (exclude[i]!=null) this.excludes.put(exclude[i],exclude[i]);
- }
-
- // ----------------------------------------------------- Instance Variables
- protected HashMap<String,String> excludes = new HashMap<String,String>();
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Handle the beginning of an XML element.
- *
- * @param attributes The attributes of this element
- *
- * @exception Exception if a processing error occurs
- */
- public void begin(String namespace, String nameX, Attributes attributes)
- throws Exception {
-
- for (int i = 0; i < attributes.getLength(); i++) {
- String name = attributes.getLocalName(i);
- if ("".equals(name)) {
- name = attributes.getQName(i);
- }
- String value = attributes.getValue(i);
- if ( !excludes.containsKey(name)) {
- if (!digester.isFakeAttribute(digester.peek(), name)
- && !IntrospectionUtils.setProperty(digester.peek(), name, value)
- && digester.getRulesValidation()) {
- digester.getLogger().warn("[SetAllPropertiesRule]{" + digester.getMatch() +
- "} Setting property '" + name + "' to '" +
- value + "' did not find a matching property.");
- }
- }
- }
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/SetContextPropertiesRule.java
===================================================================
--- trunk/java/org/apache/catalina/startup/SetContextPropertiesRule.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/SetContextPropertiesRule.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,75 +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 org.xml.sax.Attributes;
-
-import org.apache.tomcat.util.IntrospectionUtils;
-import org.apache.tomcat.util.digester.Rule;
-
-/**
- * Rule that uses the introspection utils to set properties of a context
- * (everything except "path").
- *
- * @author Remy Maucherat
- */
-public class SetContextPropertiesRule extends Rule {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Handle the beginning of an XML element.
- *
- * @param attributes The attributes of this element
- *
- * @exception Exception if a processing error occurs
- */
- public void begin(String namespace, String nameX, Attributes attributes)
- throws Exception {
-
- for (int i = 0; i < attributes.getLength(); i++) {
- String name = attributes.getLocalName(i);
- if ("".equals(name)) {
- name = attributes.getQName(i);
- }
- if ("path".equals(name) || "docBase".equals(name)) {
- continue;
- }
- String value = attributes.getValue(i);
- if (!digester.isFakeAttribute(digester.peek(), name)
- && !IntrospectionUtils.setProperty(digester.peek(), name, value)
- && digester.getRulesValidation()) {
- digester.getLogger().warn("[SetContextPropertiesRule]{" + digester.getMatch() +
- "} Setting property '" + name + "' to '" +
- value + "' did not find a matching property.");
- }
- }
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/SetNextNamingRule.java
===================================================================
--- trunk/java/org/apache/catalina/startup/SetNextNamingRule.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/SetNextNamingRule.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,120 +0,0 @@
-/* $Id$
- *
- * 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 org.apache.catalina.Context;
-import org.apache.catalina.deploy.NamingResources;
-import org.apache.tomcat.util.IntrospectionUtils;
-import org.apache.tomcat.util.digester.Rule;
-
-
-/**
- * <p>Rule implementation that calls a method on the (top-1) (parent)
- * object, passing the top object (child) as an argument. It is
- * commonly used to establish parent-child relationships.</p>
- *
- * <p>This rule now supports more flexible method matching by default.
- * It is possible that this may break (some) code
- * written against release 1.1.1 or earlier.
- * </p>
- */
-
-public class SetNextNamingRule extends Rule {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a "set next" rule with the specified method name.
- *
- * @param methodName Method name of the parent method to call
- * @param paramType Java class of the parent method's argument
- * (if you wish to use a primitive type, specify the corresonding
- * Java wrapper class instead, such as <code>java.lang.Boolean</code>
- * for a <code>boolean</code> parameter)
- */
- public SetNextNamingRule(String methodName,
- String paramType) {
-
- this.methodName = methodName;
- this.paramType = paramType;
-
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The method name to call on the parent object.
- */
- protected String methodName = null;
-
-
- /**
- * The Java class name of the parameter type expected by the method.
- */
- protected String paramType = null;
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Process the end of this element.
- */
- public void end() throws Exception {
-
- // Identify the objects to be used
- Object child = digester.peek(0);
- Object parent = digester.peek(1);
-
- NamingResources namingResources = null;
- if (parent instanceof Context) {
- namingResources = ((Context) parent).getNamingResources();
- } else {
- namingResources = (NamingResources) parent;
- }
-
- // Call the specified method
- IntrospectionUtils.callMethod1(namingResources, methodName,
- child, paramType, digester.getClassLoader());
-
- }
-
-
- /**
- * Render a printable version of this Rule.
- */
- public String toString() {
-
- StringBuilder sb = new StringBuilder("SetNextRule[");
- sb.append("methodName=");
- sb.append(methodName);
- sb.append(", paramType=");
- sb.append(paramType);
- sb.append("]");
- return (sb.toString());
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/TldRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/TldRuleSet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/TldRuleSet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,226 +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 org.apache.tomcat.util.digester.Digester;
-import org.apache.tomcat.util.digester.RuleSetBase;
-
-
-/**
- * <p><strong>RuleSet</strong> for processing the contents of a tag library
- * descriptor resource.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public class TldRuleSet extends RuleSetBase {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The matching pattern prefix to use for recognizing our elements.
- */
- protected String prefix = null;
-
-
- // ------------------------------------------------------------ Constructor
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
- */
- public TldRuleSet() {
-
- this("");
-
- }
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern prefix.
- *
- * @param prefix Prefix for matching pattern rules (including the
- * trailing slash character)
- */
- public TldRuleSet(String prefix) {
-
- super();
- this.namespaceURI = null;
- this.prefix = prefix;
-
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * <p>Add the set of Rule instances defined in this RuleSet to the
- * specified <code>Digester</code> instance, associating them with
- * our namespace URI (if any). This method should only be called
- * by a Digester instance.</p>
- *
- * @param digester Digester instance to which the new Rule instances
- * should be added.
- */
- public void addRuleInstances(Digester digester) {
-
- // uri and prefix attributes
- digester.addSetProperties(prefix + "taglib");
-
- digester.addCallMethod(prefix + "taglib/tlibversion",
- "setTlibversion", 0);
- digester.addCallMethod(prefix + "taglib/tlib-version",
- "setTlibversion", 0);
- digester.addCallMethod(prefix + "taglib/jspversion",
- "setJspversion", 0);
- digester.addCallMethod(prefix + "taglib/jsp-version",
- "setJspversion", 0);
- digester.addCallMethod(prefix + "taglib/shortname",
- "setShortname", 0);
- digester.addCallMethod(prefix + "taglib/short-name",
- "setShortname", 0);
- digester.addCallMethod(prefix + "taglib/uri",
- "setUri", 0);
- digester.addCallMethod(prefix + "taglib/info",
- "setInfo", 0);
- digester.addCallMethod(prefix + "taglib/description",
- "setInfo", 0);
- digester.addCallMethod(prefix + "taglib/listener/listener-class",
- "addListener", 0);
-
- // validator element
- digester.addObjectCreate(prefix + "taglib/validator",
- "org.apache.catalina.deploy.jsp.TagLibraryValidatorInfo");
- digester.addSetNext(prefix + "taglib/validator",
- "setValidator",
- "org.apache.catalina.deploy.jsp.TagLibraryValidatorInfo");
- digester.addCallMethod(prefix + "taglib/validator/validator-class",
- "setValidatorClass", 0);
- digester.addCallMethod(prefix + "taglib/validator/init-param",
- "addInitParam", 2);
- digester.addCallParam(prefix + "taglib/validator/init-param/param-name", 0);
- digester.addCallParam(prefix + "taglib/validator/init-param/param-value", 1);
-
- // tag element
- digester.addObjectCreate(prefix + "taglib/tag",
- "org.apache.catalina.deploy.jsp.TagInfo");
- digester.addSetNext(prefix + "taglib/tag",
- "addTagInfo",
- "org.apache.catalina.deploy.jsp.TagInfo");
- digester.addCallMethod(prefix + "taglib/tag/name",
- "setTagName", 0);
- digester.addCallMethod(prefix + "taglib/tag/tagclass",
- "setTagClassName", 0);
- digester.addCallMethod(prefix + "taglib/tag/tag-class",
- "setTagClassName", 0);
- digester.addCallMethod(prefix + "taglib/tag/teiclass",
- "setTagExtraInfo", 0);
- digester.addCallMethod(prefix + "taglib/tag/tei-class",
- "setTagExtraInfo", 0);
- digester.addCallMethod(prefix + "taglib/tag/bodycontent",
- "setBodyContent", 0);
- digester.addCallMethod(prefix + "taglib/tag/body-content",
- "setBodyContent", 0);
- digester.addCallMethod(prefix + "taglib/tag/display-name",
- "setDisplayName", 0);
- digester.addCallMethod(prefix + "taglib/tag/small-icon",
- "setSmallIcon", 0);
- digester.addCallMethod(prefix + "taglib/tag/large-icon",
- "setLargeIcon", 0);
- digester.addCallMethod(prefix + "taglib/tag/icon/small-icon",
- "setSmallIcon", 0);
- digester.addCallMethod(prefix + "taglib/tag/icon/large-icon",
- "setLargeIcon", 0);
- digester.addCallMethod(prefix + "taglib/tag/info",
- "setInfoString", 0);
- digester.addCallMethod(prefix + "taglib/tag/description",
- "setInfoString", 0);
- digester.addCallMethod(prefix + "taglib/tag/dynamic-attributes",
- "setDynamicAttributes", 0);
-
- // tag/variable element
- digester.addObjectCreate(prefix + "taglib/tag/variable",
- "org.apache.catalina.deploy.jsp.TagVariableInfo");
- digester.addSetNext(prefix + "taglib/tag/variable",
- "addTagVariableInfo",
- "org.apache.catalina.deploy.jsp.TagVariableInfo");
- digester.addCallMethod(prefix + "taglib/tag/variable/name-given",
- "setNameGiven", 0);
- digester.addCallMethod(prefix + "taglib/tag/variable/name-from-attribute",
- "setNameFromAttribute", 0);
- digester.addCallMethod(prefix + "taglib/tag/variable/class",
- "setClassName", 0);
- digester.addCallMethod(prefix + "taglib/tag/variable/declare",
- "setDeclare", 0);
- digester.addCallMethod(prefix + "taglib/tag/variable/scope",
- "setScope", 0);
-
- // tag/attribute element
- digester.addObjectCreate(prefix + "taglib/tag/attribute",
- "org.apache.catalina.deploy.jsp.TagAttributeInfo");
- digester.addSetNext(prefix + "taglib/tag/attribute",
- "addTagAttributeInfo",
- "org.apache.catalina.deploy.jsp.TagAttributeInfo");
- digester.addCallMethod(prefix + "taglib/tag/attribute/name",
- "setName", 0);
- digester.addCallMethod(prefix + "taglib/tag/attribute/type",
- "setType", 0);
- digester.addCallMethod(prefix + "taglib/tag/attribute/rtexprvalue",
- "setReqTime", 0);
- digester.addCallMethod(prefix + "taglib/tag/attribute/required",
- "setRequired", 0);
- digester.addCallMethod(prefix + "taglib/tag/attribute/fragment",
- "setFragment", 0);
- digester.addCallMethod(prefix + "taglib/tag/attribute/description",
- "setDescription", 0);
- digester.addCallMethod(prefix + "taglib/tag/attribute/deferred-value",
- "setDeferredValue", 0);
- digester.addCallMethod(prefix + "taglib/tag/attribute/deferred-value/type",
- "setExpectedTypeName", 0);
- digester.addCallMethod(prefix + "taglib/tag/attribute/deferred-method",
- "setDeferredMethod", 0);
- digester.addCallMethod(prefix + "taglib/tag/attribute/deferred-value/method-signature",
- "setMethodSignature", 0);
-
- // tag/function element
- digester.addObjectCreate(prefix + "taglib/function",
- "org.apache.catalina.deploy.jsp.FunctionInfo");
- digester.addSetNext(prefix + "taglib/function",
- "addFunctionInfo",
- "org.apache.catalina.deploy.jsp.FunctionInfo");
- digester.addCallMethod(prefix + "taglib/function/name",
- "setName", 0);
- digester.addCallMethod(prefix + "taglib/function/description",
- "setDescription", 0);
- digester.addCallMethod(prefix + "taglib/function/function-class",
- "setFunctionClass", 0);
- digester.addCallMethod(prefix + "taglib/function/function-signature",
- "setFunctionSignature", 0);
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/Tomcat.java
===================================================================
--- trunk/java/org/apache/catalina/startup/Tomcat.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/Tomcat.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,817 +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.io.IOException;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.Context;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.LifecycleListener;
-import org.apache.catalina.Realm;
-import org.apache.catalina.connector.Connector;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.core.StandardEngine;
-import org.apache.catalina.core.StandardHost;
-import org.apache.catalina.core.StandardServer;
-import org.apache.catalina.core.StandardService;
-import org.apache.catalina.core.StandardWrapper;
-import org.apache.catalina.realm.GenericPrincipal;
-import org.apache.catalina.realm.RealmBase;
-import org.apache.catalina.session.StandardManager;
-
-// TODO: lazy init for the temp dir - only when a JSP is compiled or
-// get temp dir is called we need to create it. This will avoid the
-// need for the baseDir
-
-// TODO: allow contexts without a base dir - i.e.
-// only programmatic. This would disable the default servlet.
-
-/**
- * Minimal tomcat starter for embedding/unit tests.
- *
- * Tomcat supports multiple styles of configuration and
- * startup - the most common and stable is server.xml-based,
- * implemented in org.apache.catalina.startup.Bootstrap.
- *
- * This class is for use in apps that embed tomcat.
- * Requirements:
- *
- * - all tomcat classes and possibly servlets are in the classpath.
- * ( for example all is in one big jar, or in eclipse CP, or in any other
- * combination )
- *
- * - we need one temporary directory for work files
- *
- * - no config file is required. This class provides methods to
- * use if you have a webapp with a web.xml file, but it is
- * optional - you can use your own servlets.
- *
- * This class provides a main() and few simple CLI arguments,
- * see setters for doc. It can be used for simple tests and
- * demo.
- *
- * @see TestTomcat for examples on how to use this
- * @author Costin Manolache
- */
-public class Tomcat {
- // Single engine, service, server, connector - few cases need more,
- // they can use server.xml
- protected StandardServer server;
- protected StandardService service;
- protected StandardEngine engine;
- protected Connector connector; // for more - customize the classes
-
- // To make it a bit easier to config for the common case
- // ( one host, one context ).
- protected StandardHost host;
-
- // TODO: it's easy to add support for more hosts - but is it
- // really needed ?
-
- // TODO: allow use of in-memory connector
-
- protected int port = 8080;
- protected String hostname = "localhost";
- protected String basedir;
-
- // Default in-memory realm, will be set by default on
- // created contexts. Can be replaced with setRealm() on
- // the context.
- protected Realm defaultRealm;
- private Map<String, String> userPass = new HashMap<String, String>();
- private Map<String, List<String>> userRoles =
- new HashMap<String, List<String>>();
- private Map<String, Principal> userPrincipals = new HashMap<String, Principal>();
-
- public Tomcat() {
- }
-
- /**
- * Tomcat needs a directory for temp files. This should be the
- * first method called.
- *
- * By default, if this method is not called, we use:
- * - system properties - catalina.base, catalina.home
- * - $HOME/tomcat.$PORT
- * ( /tmp doesn't seem a good choice for security ).
- *
- *
- * TODO: better default ? Maybe current dir ?
- * TODO: disable work dir if not needed ( no jsp, etc ).
- */
- public void setBaseDir(String basedir) {
- this.basedir = basedir;
- }
-
- /**
- * Set the port for the default connector. Must
- * be called before start().
- */
- public void setPort(int port) {
- this.port = port;
- }
-
- /**
- * The the hostname of the default host, default is
- * 'localhost'.
- */
- public void setHostname(String s) {
- hostname = s;
- }
-
- /**
- * Add a webapp using normal WEB-INF/web.xml if found.
- *
- * @param contextPath
- * @param baseDir
- * @return
- * @throws ServletException
- */
- public StandardContext addWebapp(String contextPath,
- String baseDir) throws ServletException {
-
- return addWebapp(getHost(), contextPath, baseDir);
- }
-
-
- /**
- * Add a context - programmatic mode, no web.xml used.
- *
- * API calls equivalent with web.xml:
- *
- * context-param
- * ctx.addParameter("name", "value");
- *
- *
- * error-page
- * ErrorPage ep = new ErrorPage();
- * ep.setErrorCode(500);
- * ep.setLocation("/error.html");
- * ctx.addErrorPage(ep);
- *
- * ctx.addMimeMapping("ext", "type");
- *
- * Note: If you reload the Context, all your configuration will be lost. If
- * you need reload support, consider using a LifecycleListener to provide
- * your configuration.
- *
- * TODO: add the rest
- *
- * @param host NULL for the 'default' host
- * @param contextPath "/" for root context.
- * @param dir base dir for the context, for static files. Must exist,
- * relative to the server home
- */
- public StandardContext addContext(String contextPath,
- String baseDir) {
- return addContext(getHost(), contextPath, baseDir);
- }
-
- public StandardWrapper addServlet(String contextPath,
- String servletName,
- String servletClass) {
- Container ctx = getHost().findChild(contextPath);
- return addServlet((StandardContext) ctx,
- servletName, servletClass);
- }
-
- /**
- * Equivalent with
- * <servlet><servlet-name><servlet-class>.
- *
- * In general it is better/faster to use the method that takes a
- * Servlet as param - this one can be used if the servlet is not
- * commonly used, and want to avoid loading all deps.
- * ( for example: jsp servlet )
- *
- * You can customize the returned servlet, ex:
- *
- * wrapper.addInitParameter("name", "value");
- */
- public static StandardWrapper addServlet(StandardContext ctx,
- String servletName,
- String servletClass) {
- // will do class for name and set init params
- StandardWrapper sw = (StandardWrapper)ctx.createWrapper();
- sw.setServletClass(servletClass);
- sw.setName(servletName);
- ctx.addChild(sw);
-
- return sw;
- }
-
- /** Use an existing servlet, no class.forName or initialization will be
- * performed
- */
- public static StandardWrapper addServlet(StandardContext ctx,
- String servletName,
- Servlet servlet) {
- // will do class for name and set init params
- StandardWrapper sw = new ExistingStandardWrapper(servlet);
- sw.setName(servletName);
- ctx.addChild(sw);
-
- return sw;
- }
-
-
- /**
- * Initialize and start the server.
- */
- public void start() throws Exception {
- getServer();
- getConnector();
- server.initialize();
- server.start();
- }
-
- /**
- * Stop the server.
- */
- public void stop() throws Exception {
- getServer().stop();
- }
-
-
- /**
- * Add a user for the in-memory realm. All created apps use this
- * by default, can be replaced using setRealm().
- *
- */
- public void addUser(String user, String pass) {
- userPass.put(user, pass);
- }
-
- /**
- * @see addUser
- */
- public void addRole(String user, String role) {
- List<String> roles = userRoles.get(user);
- if (roles == null) {
- roles = new ArrayList<String>();
- userRoles.put(user, roles);
- }
- roles.add(role);
- }
-
- // ------- Extra customization -------
- // You can tune individual tomcat objects, using internal APIs
-
- /**
- * Get the default http connector. You can set more
- * parameters - the port is already initialized.
- *
- * Alternatively, you can construct a Connector and set any params,
- * then call addConnector(Connector)
- *
- * @return A connector object that can be customized
- */
- public Connector getConnector() throws Exception {
- getServer();
- if (connector != null) {
- return connector;
- }
- // This will load Apr connector if available,
- // default to nio. I'm having strange problems with apr
- // and for the use case the speed benefit wouldn't matter.
-
- //connector = new Connector("HTTP/1.1");
- connector = new Connector("org.apache.coyote.http11.Http11Protocol");
- connector.setPort(port);
- service.addConnector( connector );
- return connector;
- }
-
- public void setConnector(Connector connector) {
- this.connector = connector;
- }
-
- /**
- * Get the service object. Can be used to add more
- * connectors and few other global settings.
- */
- public StandardService getService() {
- getServer();
- return service;
- }
-
- /**
- * Sets the current host - all future webapps will
- * be added to this host. When tomcat starts, the
- * host will be the default host.
- *
- * @param host
- */
- public void setHost(StandardHost host) {
- this.host = host;
- }
-
- public StandardHost getHost() {
- if (host == null) {
- host = new StandardHost();
- host.setName(hostname);
-
- getEngine().addChild( host );
- }
- return host;
- }
-
- /**
- * Set a custom realm for auth. If not called, a simple
- * default will be used, using an internal map.
- *
- * Must be called before adding a context.
- */
- public void setDefaultRealm(Realm realm) {
- defaultRealm = realm;
- }
-
-
- /**
- * Access to the engine, for further customization.
- */
- public StandardEngine getEngine() {
- if(engine == null ) {
- getServer();
- engine = new StandardEngine();
- engine.setName( "Tomcat" );
- engine.setDefaultHost(hostname);
- service.setContainer(engine);
- }
- return engine;
- }
-
- /**
- * Get the server object. You can add listeners and
- * few more customizations.
- */
- public StandardServer getServer() {
-
- if (server != null) {
- return server;
- }
-
- initBaseDir();
-
- System.setProperty("catalina.useNaming", "false");
-
- server = new StandardServer();
- server.setPort( -1 );
-
- service = new StandardService();
- service.setName("Tomcat");
- server.addService( service );
- return server;
- }
-
- public StandardContext addContext(StandardHost host,
- String contextPath,
- String dir) {
- silence(contextPath);
- StandardContext ctx = new StandardContext();
- ctx.setPath( contextPath );
- ctx.setDocBase(dir);
- ctx.addLifecycleListener(new FixContextListener());
-
- if (host == null) {
- host = getHost();
- }
- host.addChild(ctx);
- return ctx;
- }
-
- public StandardContext addWebapp(StandardHost host,
- String url, String path)
- throws ServletException {
- silence(url);
-
- StandardContext ctx = new StandardContext();
- ctx.setPath( url );
- ctx.setDocBase(path);
- if (defaultRealm == null) {
- initSimpleAuth();
- }
- ctx.setRealm(defaultRealm);
- ctx.addLifecycleListener(new DefaultWebXmlListener());
-
- ContextConfig ctxCfg = new ContextConfig();
- ctx.addLifecycleListener( ctxCfg );
- // prevent it from looking ( if it finds one - it'll have dup error )
- ctxCfg.setDefaultWebXml("org/apache/catalin/startup/NO_DEFAULT_XML");
-
- if (host == null) {
- host = getHost();
- }
- host.addChild(ctx);
-
- return ctx;
- }
-
-
-
-
-
- // ---------- Helper methods and classes -------------------
-
- /**
- * Initialize an in-memory realm. You can replace it
- * for contexts with a real one.
- */
- protected void initSimpleAuth() {
- defaultRealm = new RealmBase() {
- @Override
- protected String getName() {
- return "Simple";
- }
-
- @Override
- protected String getPassword(String username) {
- return userPass.get(username);
- }
-
- @Override
- protected Principal getPrincipal(String username) {
- Principal p = userPrincipals.get(username);
- if (p == null) {
- String pass = userPass.get(username);
- if (pass != null) {
- p = new GenericPrincipal(this, username, pass,
- userRoles.get(username));
- userPrincipals.put(username, p);
- }
- }
- return p;
- }
-
- };
- }
-
- protected void initBaseDir() {
- if (basedir == null) {
- basedir = System.getProperty("catalina.base");
- }
- if (basedir == null) {
- basedir = System.getProperty("catalina.home");
- }
- if (basedir == null) {
- // Create a temp dir.
- basedir = System.getProperty("user.dir") +
- "/tomcat." + port;
- File home = new File(basedir);
- home.mkdir();
- if (!home.isAbsolute()) {
- try {
- basedir = home.getCanonicalPath();
- } catch (IOException e) {
- basedir = home.getAbsolutePath();
- }
- }
- }
- System.setProperty("catalina.home", basedir);
- System.setProperty("catalina.base", basedir);
- }
-
- static String[] silences = new String[] {
- "org.apache.coyote.http11.Http11Protocol",
- "org.apache.catalina.core.StandardService",
- "org.apache.catalina.core.StandardEngine",
- "org.apache.catalina.startup.ContextConfig",
- "org.apache.catalina.core.ApplicationContext",
- "org.apache.catalina.core.AprLifecycleListener"
- };
-
- /**
- * Sets the log level to WARN for the loggers that log information on
- * Tomcat start up. This prevents the usual startup information being
- * logged to the console.
- */
- public void setSilent() {
- for (String s : silences) {
- Logger.getLogger(s).setLevel(Level.WARNING);
- }
- }
-
- private void silence(String ctx) {
- String base = "org.apache.catalina.core.ContainerBase.[default].[";
- base += getHost().getName();
- base += "].[";
- base += ctx;
- base += "]";
- Logger.getLogger(base).setLevel(Level.WARNING);
- }
-
- /**
- * Provide default configuration for a context. This is the programmatic
- * equivalent of the default web.xml.
- *
- * TODO: in normal tomcat, if default-web.xml is not found, use this
- * method
- */
- public static void initWebappDefaults(StandardContext ctx) {
- // Default servlet
- StandardWrapper servlet = addServlet(
- ctx, "default", "org.apache.catalina.servlets.DefaultServlet");
- servlet.setLoadOnStartup(1);
-
- // JSP servlet (by class name - to avoid loading all deps)
- servlet = addServlet(
- ctx, "jsp", "org.apache.jasper.servlet.JspServlet");
- servlet.addInitParameter("fork", "false");
- servlet.setLoadOnStartup(3);
-
- // Servlet mappings
- ctx.addServletMapping("/", "default");
- ctx.addServletMapping("*.jsp", "jsp");
- ctx.addServletMapping("*.jspx", "jsp");
-
- // Sessions
- ctx.setManager( new StandardManager());
- ctx.setSessionTimeout(30);
-
- // MIME mappings
- for (int i = 0; i < DEFAULT_MIME_MAPPINGS.length; ) {
- ctx.addMimeMapping(DEFAULT_MIME_MAPPINGS[i++],
- DEFAULT_MIME_MAPPINGS[i++]);
- }
-
- // Welcome files
- ctx.addWelcomeFile("index.html");
- ctx.addWelcomeFile("index.htm");
- ctx.addWelcomeFile("index.jsp");
- }
-
-
- /** Fix startup sequence - required if you don't use web.xml.
- *
- * The start() method in context will set 'configured' to false - and
- * expects a listener to set it back to true.
- */
- public static class FixContextListener implements LifecycleListener {
-
- public void lifecycleEvent(LifecycleEvent event) {
- try {
- Context context = (Context) event.getLifecycle();
- if (event.getType().equals(Lifecycle.START_EVENT)) {
- context.setConfigured(true);
- }
- } catch (ClassCastException e) {
- return;
- }
- }
-
- }
-
-
- /**
- * Fix reload - required if reloading and using programmatic configuration.
- * When a context is reloaded, any programmatic configuration is lost. This
- * listener sets the equivalent of conf/web.xml when the context starts. The
- * context needs to be an instance of StandardContext for this listener to
- * have any effect.
- */
- public static class DefaultWebXmlListener implements LifecycleListener {
- public void lifecycleEvent(LifecycleEvent event) {
- if (Lifecycle.BEFORE_START_EVENT.equals(event.getType()) &&
- event.getLifecycle() instanceof StandardContext) {
- initWebappDefaults((StandardContext) event.getLifecycle());
- }
- }
- }
-
-
- /** Helper class for wrapping existing servlets. This disables servlet
- * lifecycle and normal reloading, but also reduces overhead and provide
- * more direct control over the servlet.
- */
- public static class ExistingStandardWrapper extends StandardWrapper {
- private Servlet existing;
- boolean init = false;
-
- public ExistingStandardWrapper( Servlet existing ) {
- this.existing = existing;
- }
- public synchronized Servlet loadServlet() throws ServletException {
- if (!init) {
- existing.init(facade);
- init = true;
- }
- return existing;
-
- }
- public long getAvailable() {
- return 0;
- }
- public boolean isUnavailable() {
- return false;
- }
- }
-
- /**
- * TODO: would a properties resource be better ? Or just parsing
- * /etc/mime.types ?
- * This is needed because we don't use the default web.xml, where this
- * is encoded.
- */
- public static final String[] DEFAULT_MIME_MAPPINGS = {
- "abs", "audio/x-mpeg",
- "ai", "application/postscript",
- "aif", "audio/x-aiff",
- "aifc", "audio/x-aiff",
- "aiff", "audio/x-aiff",
- "aim", "application/x-aim",
- "art", "image/x-jg",
- "asf", "video/x-ms-asf",
- "asx", "video/x-ms-asf",
- "au", "audio/basic",
- "avi", "video/x-msvideo",
- "avx", "video/x-rad-screenplay",
- "bcpio", "application/x-bcpio",
- "bin", "application/octet-stream",
- "bmp", "image/bmp",
- "body", "text/html",
- "cdf", "application/x-cdf",
- "cer", "application/x-x509-ca-cert",
- "class", "application/java",
- "cpio", "application/x-cpio",
- "csh", "application/x-csh",
- "css", "text/css",
- "dib", "image/bmp",
- "doc", "application/msword",
- "dtd", "application/xml-dtd",
- "dv", "video/x-dv",
- "dvi", "application/x-dvi",
- "eps", "application/postscript",
- "etx", "text/x-setext",
- "exe", "application/octet-stream",
- "gif", "image/gif",
- "gtar", "application/x-gtar",
- "gz", "application/x-gzip",
- "hdf", "application/x-hdf",
- "hqx", "application/mac-binhex40",
- "htc", "text/x-component",
- "htm", "text/html",
- "html", "text/html",
- "hqx", "application/mac-binhex40",
- "ief", "image/ief",
- "jad", "text/vnd.sun.j2me.app-descriptor",
- "jar", "application/java-archive",
- "java", "text/plain",
- "jnlp", "application/x-java-jnlp-file",
- "jpe", "image/jpeg",
- "jpeg", "image/jpeg",
- "jpg", "image/jpeg",
- "js", "text/javascript",
- "jsf", "text/plain",
- "jspf", "text/plain",
- "kar", "audio/x-midi",
- "latex", "application/x-latex",
- "m3u", "audio/x-mpegurl",
- "mac", "image/x-macpaint",
- "man", "application/x-troff-man",
- "mathml", "application/mathml+xml",
- "me", "application/x-troff-me",
- "mid", "audio/x-midi",
- "midi", "audio/x-midi",
- "mif", "application/x-mif",
- "mov", "video/quicktime",
- "movie", "video/x-sgi-movie",
- "mp1", "audio/x-mpeg",
- "mp2", "audio/x-mpeg",
- "mp3", "audio/x-mpeg",
- "mp4", "video/mp4",
- "mpa", "audio/x-mpeg",
- "mpe", "video/mpeg",
- "mpeg", "video/mpeg",
- "mpega", "audio/x-mpeg",
- "mpg", "video/mpeg",
- "mpv2", "video/mpeg2",
- "ms", "application/x-wais-source",
- "nc", "application/x-netcdf",
- "oda", "application/oda",
- "odb", "application/vnd.oasis.opendocument.database",
- "odc", "application/vnd.oasis.opendocument.chart",
- "odf", "application/vnd.oasis.opendocument.formula",
- "odg", "application/vnd.oasis.opendocument.graphics",
- "odi", "application/vnd.oasis.opendocument.image",
- "odm", "application/vnd.oasis.opendocument.text-master",
- "odp", "application/vnd.oasis.opendocument.presentation",
- "ods", "application/vnd.oasis.opendocument.spreadsheet",
- "odt", "application/vnd.oasis.opendocument.text",
- "otg", "application/vnd.oasis.opendocument.graphics-template",
- "oth", "application/vnd.oasis.opendocument.text-web",
- "otp", "application/vnd.oasis.opendocument.presentation-template",
- "ots", "application/vnd.oasis.opendocument.spreadsheet-template ",
- "ott", "application/vnd.oasis.opendocument.text-template",
- "ogx", "application/ogg",
- "ogv", "video/ogg",
- "oga", "audio/ogg",
- "ogg", "audio/ogg",
- "spx", "audio/ogg",
- "faca", "audio/flac",
- "anx", "application/annodex",
- "axa", "audio/annodex",
- "axv", "video/annodex",
- "xspf", "application/xspf+xml",
- "pbm", "image/x-portable-bitmap",
- "pct", "image/pict",
- "pdf", "application/pdf",
- "pgm", "image/x-portable-graymap",
- "pic", "image/pict",
- "pict", "image/pict",
- "pls", "audio/x-scpls",
- "png", "image/png",
- "pnm", "image/x-portable-anymap",
- "pnt", "image/x-macpaint",
- "ppm", "image/x-portable-pixmap",
- "ppt", "application/vnd.ms-powerpoint",
- "pps", "application/vnd.ms-powerpoint",
- "ps", "application/postscript",
- "psd", "image/x-photoshop",
- "qt", "video/quicktime",
- "qti", "image/x-quicktime",
- "qtif", "image/x-quicktime",
- "ras", "image/x-cmu-raster",
- "rdf", "application/rdf+xml",
- "rgb", "image/x-rgb",
- "rm", "application/vnd.rn-realmedia",
- "roff", "application/x-troff",
- "rtf", "application/rtf",
- "rtx", "text/richtext",
- "sh", "application/x-sh",
- "shar", "application/x-shar",
- /*"shtml", "text/x-server-parsed-html",*/
- "smf", "audio/x-midi",
- "sit", "application/x-stuffit",
- "snd", "audio/basic",
- "src", "application/x-wais-source",
- "sv4cpio", "application/x-sv4cpio",
- "sv4crc", "application/x-sv4crc",
- "svg", "image/svg+xml",
- "svgz", "image/svg+xml",
- "swf", "application/x-shockwave-flash",
- "t", "application/x-troff",
- "tar", "application/x-tar",
- "tcl", "application/x-tcl",
- "tex", "application/x-tex",
- "texi", "application/x-texinfo",
- "texinfo", "application/x-texinfo",
- "tif", "image/tiff",
- "tiff", "image/tiff",
- "tr", "application/x-troff",
- "tsv", "text/tab-separated-values",
- "txt", "text/plain",
- "ulw", "audio/basic",
- "ustar", "application/x-ustar",
- "vxml", "application/voicexml+xml",
- "xbm", "image/x-xbitmap",
- "xht", "application/xhtml+xml",
- "xhtml", "application/xhtml+xml",
- "xls", "application/vnd.ms-excel",
- "xml", "application/xml",
- "xpm", "image/x-xpixmap",
- "xsl", "application/xml",
- "xslt", "application/xslt+xml",
- "xul", "application/vnd.mozilla.xul+xml",
- "xwd", "image/x-xwindowdump",
- "vsd", "application/x-visio",
- "wav", "audio/x-wav",
- "wbmp", "image/vnd.wap.wbmp",
- "wml", "text/vnd.wap.wml",
- "wmlc", "application/vnd.wap.wmlc",
- "wmls", "text/vnd.wap.wmlscript",
- "wmlscriptc", "application/vnd.wap.wmlscriptc",
- "wmv", "video/x-ms-wmv",
- "wrl", "x-world/x-vrml",
- "wspolicy", "application/wspolicy+xml",
- "Z", "application/x-compress",
- "z", "application/x-compress",
- "zip", "application/zip"
- };
-}
Deleted: trunk/java/org/apache/catalina/startup/Tool.java
===================================================================
--- trunk/java/org/apache/catalina/startup/Tool.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/Tool.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,244 +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.lang.reflect.Method;
-import java.util.ArrayList;
-
-import org.jboss.logging.Logger;
-import org.jboss.logging.Logger;
-
-
-/**
- * <p>General purpose wrapper for command line tools that should execute in an
- * environment with the common class loader environment set up by Catalina.
- * This should be executed from a command line script that conforms to
- * the following requirements:</p>
- * <ul>
- * <li>Passes the <code>catalina.home</code> system property configured with
- * the pathname of the Tomcat installation directory.</li>
- * <li>Sets the system classpath to include <code>bootstrap.jar</code> and
- * <code>$JAVA_HOME/lib/tools.jar</code>.</li>
- * </ul>
- *
- * <p>The command line to execute the tool looks like:</p>
- * <pre>
- * java -classpath $CLASSPATH org.apache.catalina.startup.Tool \
- * ${options} ${classname} ${arguments}
- * </pre>
- *
- * <p>with the following replacement contents:
- * <ul>
- * <li><strong>${options}</strong> - Command line options for this Tool wrapper.
- * The following options are supported:
- * <ul>
- * <li><em>-ant</em> : Set the <code>ant.home</code> system property
- * to corresponding to the value of <code>catalina.home</code>
- * (useful when your command line tool runs Ant).</li>
- * <li><em>-common</em> : Add <code>common/classes</code> and
- * <code>common/lib</codE) to the class loader repositories.</li>
- * <li><em>-server</em> : Add <code>server/classes</code> and
- * <code>server/lib</code> to the class loader repositories.</li>
- * <li><em>-shared</em> : Add <code>shared/classes</code> and
- * <code>shared/lib</code> to the class loader repositories.</li>
- * </ul>
- * <li><strong>${classname}</strong> - Fully qualified Java class name of the
- * application's main class.</li>
- * <li><strong>${arguments}</strong> - Command line arguments to be passed to
- * the application's <code>main()</code> method.</li>
- * </ul>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- */
-
-public final class Tool {
-
-
- private static Logger log = Logger.getLogger(Tool.class);
-
- // ------------------------------------------------------- Static Variables
-
-
- /**
- * Set <code>ant.home</code> system property?
- */
- private static boolean ant = false;
-
-
- /**
- * The pathname of our installation base directory.
- */
- private static String catalinaHome = System.getProperty("catalina.home");
-
-
- /**
- * Include common classes in the repositories?
- */
- private static boolean common = false;
-
-
- /**
- * Include server classes in the repositories?
- */
- private static boolean server = false;
-
-
- /**
- * Include shared classes in the repositories?
- */
- private static boolean shared = false;
-
-
- // ----------------------------------------------------------- Main Program
-
-
- /**
- * The main program for the bootstrap.
- *
- * @param args Command line arguments to be processed
- */
- public static void main(String args[]) {
-
- // Verify that "catalina.home" was passed.
- if (catalinaHome == null) {
- log.error("Must set 'catalina.home' system property");
- System.exit(1);
- }
-
- // Process command line options
- int index = 0;
- while (true) {
- if (index == args.length) {
- usage();
- System.exit(1);
- }
- if ("-ant".equals(args[index]))
- ant = true;
- else if ("-common".equals(args[index]))
- common = true;
- else if ("-server".equals(args[index]))
- server = true;
- else if ("-shared".equals(args[index]))
- shared = true;
- else
- break;
- index++;
- }
- if (index > args.length) {
- usage();
- System.exit(1);
- }
-
- // Set "ant.home" if requested
- if (ant)
- System.setProperty("ant.home", catalinaHome);
-
- // Construct the class loader we will be using
- ClassLoader classLoader = null;
- try {
- ArrayList packed = new ArrayList();
- ArrayList unpacked = new ArrayList();
- unpacked.add(new File(catalinaHome, "classes"));
- packed.add(new File(catalinaHome, "lib"));
- if (common) {
- unpacked.add(new File(catalinaHome,
- "common" + File.separator + "classes"));
- packed.add(new File(catalinaHome,
- "common" + File.separator + "lib"));
- }
- if (server) {
- unpacked.add(new File(catalinaHome,
- "server" + File.separator + "classes"));
- packed.add(new File(catalinaHome,
- "server" + File.separator + "lib"));
- }
- if (shared) {
- unpacked.add(new File(catalinaHome,
- "shared" + File.separator + "classes"));
- packed.add(new File(catalinaHome,
- "shared" + File.separator + "lib"));
- }
- classLoader =
- ClassLoaderFactory.createClassLoader
- ((File[]) unpacked.toArray(new File[0]),
- (File[]) packed.toArray(new File[0]),
- null);
- } catch (Throwable t) {
- log.error("Class loader creation threw exception", t);
- System.exit(1);
- }
- Thread.currentThread().setContextClassLoader(classLoader);
-
- // Load our application class
- Class clazz = null;
- String className = args[index++];
- try {
- if (log.isDebugEnabled())
- log.debug("Loading application class " + className);
- clazz = classLoader.loadClass(className);
- } catch (Throwable t) {
- log.error("Exception creating instance of " + className, t);
- System.exit(1);
- }
-
- // Locate the static main() method of the application class
- Method method = null;
- String params[] = new String[args.length - index];
- System.arraycopy(args, index, params, 0, params.length);
- try {
- if (log.isDebugEnabled())
- log.debug("Identifying main() method");
- String methodName = "main";
- Class paramTypes[] = new Class[1];
- paramTypes[0] = params.getClass();
- method = clazz.getMethod(methodName, paramTypes);
- } catch (Throwable t) {
- log.error("Exception locating main() method", t);
- System.exit(1);
- }
-
- // Invoke the main method of the application class
- try {
- if (log.isDebugEnabled())
- log.debug("Calling main() method");
- Object paramValues[] = new Object[1];
- paramValues[0] = params;
- method.invoke(null, paramValues);
- } catch (Throwable t) {
- log.error("Exception calling main() method", t);
- System.exit(1);
- }
-
- }
-
-
- /**
- * Display usage information about this tool.
- */
- private static void usage() {
-
- log.info("Usage: java org.apache.catalina.startup.Tool [<options>] <class> [<arguments>]");
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/WebAnnotationSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/WebAnnotationSet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/WebAnnotationSet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,508 +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 javax.annotation.Resource;
-import javax.annotation.Resources;
-import javax.annotation.security.DeclareRoles;
-import javax.servlet.annotation.MultipartConfig;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.Context;
-import org.apache.catalina.core.StandardWrapper;
-import org.apache.catalina.deploy.ContextEnvironment;
-import org.apache.catalina.deploy.ContextResource;
-import org.apache.catalina.deploy.ContextResourceEnvRef;
-import org.apache.catalina.deploy.ContextService;
-import org.apache.catalina.deploy.FilterDef;
-import org.apache.catalina.deploy.MessageDestinationRef;
-import org.apache.catalina.deploy.Multipart;
-
-/**
- * <p><strong>AnnotationSet</strong> for processing the annotations of the web application
- * classes (<code>/WEB-INF/classes</code> and <code>/WEB-INF/lib</code>).</p>
- *
- * @author Fabien Carrion
- * @version $Revision$ $Date$
- */
-
-public class WebAnnotationSet {
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Process the annotations on a context.
- */
- public static void loadApplicationAnnotations(Context context) {
-
- loadApplicationListenerAnnotations(context);
- loadApplicationFilterAnnotations(context);
- loadApplicationServletAnnotations(context);
-
- }
-
-
- // -------------------------------------------------------- protected Methods
-
-
- /**
- * Process the annotations for the listeners.
- */
- protected static void loadApplicationListenerAnnotations(Context context) {
- String[] applicationListeners = context.findApplicationListeners();
- for (int i = 0; i < applicationListeners.length; i++) {
- loadClassAnnotation(context, applicationListeners[i]);
- }
- }
-
-
- /**
- * Process the annotations for the filters.
- */
- protected static void loadApplicationFilterAnnotations(Context context) {
- FilterDef[] filterDefs = context.findFilterDefs();
- for (int i = 0; i < filterDefs.length; i++) {
- loadClassAnnotation(context, filterDefs[i].getFilterClass());
- }
- }
-
-
- /**
- * Process the annotations for the servlets.
- */
- protected static void loadApplicationServletAnnotations(Context context) {
-
- ClassLoader classLoader = context.getLoader().getClassLoader();
- StandardWrapper wrapper = null;
- Class<?> classClass = null;
-
- Container[] children = context.findChildren();
- for (int i = 0; i < children.length; i++) {
- if (children[i] instanceof StandardWrapper) {
-
- wrapper = (StandardWrapper) children[i];
- if (wrapper.getServletClass() == null) {
- continue;
- }
-
- try {
- classClass = classLoader.loadClass(wrapper.getServletClass());
- } catch (ClassNotFoundException e) {
- // We do nothing
- } catch (NoClassDefFoundError e) {
- // We do nothing
- }
-
- if (classClass == null) {
- continue;
- }
-
- loadClassAnnotation(context, wrapper.getServletClass());
-
- // Multipart configuration annotation
- if (classClass.isAnnotationPresent(MultipartConfig.class)) {
- MultipartConfig annotation =
- (MultipartConfig) classClass.getAnnotation(MultipartConfig.class);
- Multipart multipartConfig = new Multipart();
- multipartConfig.setLocation(annotation.location());
- multipartConfig.setMaxRequestSize(annotation.maxRequestSize());
- multipartConfig.setMaxFileSize(annotation.maxFileSize());
- multipartConfig.setFileSizeThreshold(annotation.fileSizeThreshold());
- wrapper.setMultipartConfig(multipartConfig);
- }
-
- // Process JSR 250 access control annotations
- // Process PermitAll, TransportProtected and RolesAllowed on the class
- /*
- boolean classPA = false, classTP = false;
- String[] classRA = null;
- ArrayList<String> methodOmissions = new ArrayList<String>();
- if (classClass.isAnnotationPresent(PermitAll.class)) {
- classPA = true;
- }
- if (classClass.isAnnotationPresent(TransportProtected.class)) {
- TransportProtected annotation = (TransportProtected)
- classClass.getAnnotation(TransportProtected.class);
- classTP = annotation.value();
- }
- if (classClass.isAnnotationPresent(RolesAllowed.class)) {
- RolesAllowed annotation = (RolesAllowed)
- classClass.getAnnotation(RolesAllowed.class);
- classRA = annotation.value();
- }
- if (classClass.isAnnotationPresent(RunAs.class)) {
- RunAs annotation = (RunAs)
- classClass.getAnnotation(RunAs.class);
- wrapper.setRunAs(annotation.value());
- }
-
- // Process HttpServlet methods annotations
- if (HttpServlet.class.isAssignableFrom(classClass)) {
-
- Method[] methods = null;
- final Class<?> classClass2 = classClass;
- if (Globals.IS_SECURITY_ENABLED) {
- methods = AccessController.doPrivileged(
- new PrivilegedAction<Method[]>(){
- public Method[] run(){
- return classClass2.getDeclaredMethods();
- }
- });
- } else {
- methods = classClass.getDeclaredMethods();
- }
- for (Method method : methods) {
- if (!((method.getParameterTypes().length == 2)
- && (method.getParameterTypes()[0] == HttpServletRequest.class)
- && (method.getParameterTypes()[1] == HttpServletResponse.class))) {
- continue;
- }
- String methodName = null;
- if (method.getName().startsWith("do")) {
- methodName = method.getName().substring(2).toUpperCase();
- }
- if (methodName == null) {
- continue;
- }
- boolean methodAnnotation = false;
- boolean methodPA = false, methodDA = false, methodTP = false;
- String[] methodRA = null;
- if (method.isAnnotationPresent(PermitAll.class)) {
- methodPA = true;
- methodAnnotation = true;
- }
- if (method.isAnnotationPresent(DenyAll.class)) {
- methodDA = true;
- methodAnnotation = true;
- }
- if (method.isAnnotationPresent(TransportProtected.class)) {
- TransportProtected annotation = (TransportProtected)
- method.getAnnotation(TransportProtected.class);
- methodTP = annotation.value();
- methodAnnotation = true;
- }
- if (method.isAnnotationPresent(RolesAllowed.class)) {
- RolesAllowed annotation = (RolesAllowed)
- method.getAnnotation(RolesAllowed.class);
- methodRA = annotation.value();
- methodAnnotation = true;
- }
- if (methodAnnotation) {
- methodOmissions.add(methodName);
- // Define a constraint specific for the method
- SecurityConstraint constraint = new SecurityConstraint();
- if (methodDA) {
- constraint.setAuthConstraint(true);
- }
- if (methodPA) {
- constraint.addAuthRole("*");
- }
- if (methodRA != null) {
- for (String role : methodRA) {
- constraint.addAuthRole(role);
- }
- }
- if (methodTP) {
- constraint.setUserConstraint(org.apache.catalina.realm.Constants.CONFIDENTIAL_TRANSPORT);
- }
- SecurityCollection collection = new SecurityCollection();
- collection.addMethod(methodName);
- String[] urlPatterns = wrapper.findMappings();
- for (String urlPattern : urlPatterns) {
- collection.addPattern(urlPattern);
- }
- constraint.addCollection(collection);
- context.addConstraint(constraint);
- }
-
- }
-
- }
-
- if (classPA || classTP || classRA != null) {
- // Define a constraint for the class
- SecurityConstraint constraint = new SecurityConstraint();
- if (classPA) {
- constraint.addAuthRole("*");
- }
- if (classRA != null) {
- for (String role : classRA) {
- constraint.addAuthRole(role);
- }
- }
- if (classTP) {
- constraint.setUserConstraint(org.apache.catalina.realm.Constants.CONFIDENTIAL_TRANSPORT);
- }
- SecurityCollection collection = new SecurityCollection();
- String[] urlPatterns = wrapper.findMappings();
- for (String urlPattern : urlPatterns) {
- collection.addPattern(urlPattern);
- }
- for (String methodOmission : methodOmissions) {
- collection.addMethodOmission(methodOmission);
- }
- constraint.addCollection(collection);
- context.addConstraint(constraint);
- }
- */
- }
- }
-
-
- }
-
-
- /**
- * Process the annotations on a context for a given className.
- */
- protected static void loadClassAnnotation(Context context, String fileString) {
-
- ClassLoader classLoader = context.getLoader().getClassLoader();
- Class<?> classClass = null;
-
- try {
- classClass = classLoader.loadClass(fileString);
- } catch (ClassNotFoundException e) {
- // We do nothing
- } catch (NoClassDefFoundError e) {
- // We do nothing
- }
-
- if (classClass == null) {
- return;
- }
-
- // Initialize the annotations
-
- if (classClass.isAnnotationPresent(Resource.class)) {
- Resource annotation = (Resource)
- classClass.getAnnotation(Resource.class);
- addResource(context, annotation);
- }
- /* Process Resources annotation.
- * Ref JSR 250
- */
- if (classClass.isAnnotationPresent(Resources.class)) {
- Resources annotation = (Resources)
- classClass.getAnnotation(Resources.class);
- for (int i = 0; annotation.value() != null && i < annotation.value().length; i++) {
- addResource(context, annotation.value()[i]);
- }
- }
- /* Process EJB annotation.
- * Ref JSR 224, equivalent to the ejb-ref or ejb-local-ref
- * element in the deployment descriptor.
- if (classClass.isAnnotationPresent(EJB.class)) {
- EJB annotation = (EJB)
- classClass.getAnnotation(EJB.class);
-
- if ((annotation.mappedName().length() == 0) ||
- annotation.mappedName().equals("Local")) {
-
- ContextLocalEjb ejb = new ContextLocalEjb();
-
- ejb.setName(annotation.name());
- ejb.setType(annotation.beanInterface().getCanonicalName());
- ejb.setDescription(annotation.description());
-
- ejb.setHome(annotation.beanName());
-
- context.getNamingResources().addLocalEjb(ejb);
-
- } else if (annotation.mappedName().equals("Remote")) {
-
- ContextEjb ejb = new ContextEjb();
-
- ejb.setName(annotation.name());
- ejb.setType(annotation.beanInterface().getCanonicalName());
- ejb.setDescription(annotation.description());
-
- ejb.setHome(annotation.beanName());
-
- context.getNamingResources().addEjb(ejb);
-
- }
-
- }
- */
- /* Process WebServiceRef annotation.
- * Ref JSR 224, equivalent to the service-ref element in
- * the deployment descriptor.
- * The service-ref registration is not implemented
- if (classClass.isAnnotationPresent(WebServiceRef.class)) {
- WebServiceRef annotation = (WebServiceRef)
- classClass.getAnnotation(WebServiceRef.class);
-
- ContextService service = new ContextService();
-
- service.setName(annotation.name());
- service.setWsdlfile(annotation.wsdlLocation());
-
- service.setType(annotation.type().getCanonicalName());
-
- if (annotation.value() == null)
- service.setServiceinterface(annotation.type().getCanonicalName());
-
- if (annotation.type().getCanonicalName().equals("Service"))
- service.setServiceinterface(annotation.type().getCanonicalName());
-
- if (annotation.value().getCanonicalName().equals("Endpoint"))
- service.setServiceendpoint(annotation.type().getCanonicalName());
-
- service.setPortlink(annotation.type().getCanonicalName());
-
- context.getNamingResources().addService(service);
-
-
- }
- */
- /* Process DeclareRoles annotation.
- * Ref JSR 250, equivalent to the security-role element in
- * the deployment descriptor
- */
- if (classClass.isAnnotationPresent(DeclareRoles.class)) {
- DeclareRoles annotation = (DeclareRoles)
- classClass.getAnnotation(DeclareRoles.class);
- for (int i = 0; annotation.value() != null && i < annotation.value().length; i++) {
- context.addSecurityRole(annotation.value()[i]);
- }
- }
-
-
- }
-
-
- /**
- * Process a Resource annotation to set up a Resource.
- * Ref JSR 250, equivalent to the resource-ref,
- * message-destination-ref, env-ref, resource-env-ref
- * or service-ref element in the deployment descriptor.
- */
- protected static void addResource(Context context, Resource annotation) {
-
- if (annotation.type().getCanonicalName().equals("java.lang.String") ||
- annotation.type().getCanonicalName().equals("java.lang.Character") ||
- annotation.type().getCanonicalName().equals("java.lang.Integer") ||
- annotation.type().getCanonicalName().equals("java.lang.Boolean") ||
- annotation.type().getCanonicalName().equals("java.lang.Double") ||
- annotation.type().getCanonicalName().equals("java.lang.Byte") ||
- annotation.type().getCanonicalName().equals("java.lang.Short") ||
- annotation.type().getCanonicalName().equals("java.lang.Long") ||
- annotation.type().getCanonicalName().equals("java.lang.Float")) {
-
- // env-ref element
- ContextEnvironment resource = new ContextEnvironment();
-
- resource.setName(annotation.name());
- resource.setType(annotation.type().getCanonicalName());
-
- resource.setDescription(annotation.description());
-
- resource.setValue(annotation.mappedName());
-
- context.getNamingResources().addEnvironment(resource);
-
- } else if (annotation.type().getCanonicalName().equals("javax.xml.rpc.Service")) {
-
- // service-ref element
- ContextService service = new ContextService();
-
- service.setName(annotation.name());
- service.setWsdlfile(annotation.mappedName());
-
- service.setType(annotation.type().getCanonicalName());
- service.setDescription(annotation.description());
-
- context.getNamingResources().addService(service);
-
- } else if (annotation.type().getCanonicalName().equals("javax.sql.DataSource") ||
- annotation.type().getCanonicalName().equals("javax.jms.ConnectionFactory") ||
- annotation.type().getCanonicalName()
- .equals("javax.jms.QueueConnectionFactory") ||
- annotation.type().getCanonicalName()
- .equals("javax.jms.TopicConnectionFactory") ||
- annotation.type().getCanonicalName().equals("javax.mail.Session") ||
- annotation.type().getCanonicalName().equals("java.net.URL") ||
- annotation.type().getCanonicalName()
- .equals("javax.resource.cci.ConnectionFactory") ||
- annotation.type().getCanonicalName().equals("org.omg.CORBA_2_3.ORB") ||
- annotation.type().getCanonicalName().endsWith("ConnectionFactory")) {
-
- // resource-ref element
- ContextResource resource = new ContextResource();
-
- resource.setName(annotation.name());
- resource.setType(annotation.type().getCanonicalName());
-
- if (annotation.authenticationType()
- == Resource.AuthenticationType.CONTAINER) {
- resource.setAuth("Container");
- }
- else if (annotation.authenticationType()
- == Resource.AuthenticationType.APPLICATION) {
- resource.setAuth("Application");
- }
-
- resource.setScope(annotation.shareable() ? "Shareable" : "Unshareable");
- resource.setProperty("mappedName", annotation.mappedName());
- resource.setDescription(annotation.description());
-
- context.getNamingResources().addResource(resource);
-
- } else if (annotation.type().getCanonicalName().equals("javax.jms.Queue") ||
- annotation.type().getCanonicalName().equals("javax.jms.Topic")) {
-
- // message-destination-ref
- MessageDestinationRef resource = new MessageDestinationRef();
-
- resource.setName(annotation.name());
- resource.setType(annotation.type().getCanonicalName());
-
- resource.setUsage(annotation.mappedName());
- resource.setDescription(annotation.description());
-
- context.getNamingResources().addMessageDestinationRef(resource);
-
- } else if (annotation.type().getCanonicalName()
- .equals("javax.resource.cci.InteractionSpec") ||
- annotation.type().getCanonicalName()
- .equals("javax.transaction.UserTransaction") ||
- true) {
-
- // resource-env-ref
- ContextResourceEnvRef resource = new ContextResourceEnvRef();
-
- resource.setName(annotation.name());
- resource.setType(annotation.type().getCanonicalName());
-
- resource.setProperty("mappedName", annotation.mappedName());
- resource.setDescription(annotation.description());
-
- context.getNamingResources().addResourceEnvRef(resource);
-
- }
-
-
- }
-
-
-}
Deleted: trunk/java/org/apache/catalina/startup/WebOrderingRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/WebOrderingRuleSet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/WebOrderingRuleSet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,122 +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 org.apache.catalina.deploy.WebOrdering;
-import org.apache.tomcat.util.digester.Digester;
-import org.apache.tomcat.util.digester.Rule;
-import org.apache.tomcat.util.digester.RuleSetBase;
-import org.xml.sax.Attributes;
-
-
-/**
- * <p><strong>RuleSet</strong> for processing the absolute-ordering element
- * of web.xml.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision: 515 $ $Date: 2008-03-17 22:02:23 +0100 (Mon, 17 Mar 2008) $
- */
-
-public class WebOrderingRuleSet extends RuleSetBase {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The matching pattern prefix to use for recognizing our elements.
- */
- protected String prefix = null;
-
-
- // ------------------------------------------------------------ Constructor
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
- */
- public WebOrderingRuleSet() {
-
- this("");
-
- }
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern prefix.
- *
- * @param prefix Prefix for matching pattern rules (including the
- * trailing slash character)
- */
- public WebOrderingRuleSet(String prefix) {
-
- super();
- this.namespaceURI = null;
- this.prefix = prefix;
-
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * <p>Add the set of Rule instances defined in this RuleSet to the
- * specified <code>Digester</code> instance, associating them with
- * our namespace URI (if any). This method should only be called
- * by a Digester instance.</p>
- *
- * @param digester Digester instance to which the new Rule instances
- * should be added.
- */
- public void addRuleInstances(Digester digester) {
-
- digester.addObjectCreate(prefix + "web-fragment",
- "org.apache.catalina.deploy.WebOrdering");
- digester.addCallMethod(prefix + "web-fragment/name",
- "setName", 0);
- digester.addCallMethod(prefix + "web-fragment/ordering/after/name",
- "addAfter", 0);
- digester.addCallMethod(prefix + "web-fragment/ordering/before/name",
- "addBefore", 0);
- digester.addRule(prefix + "web-fragment/ordering/after/others",
- new SetAfterOthersRule());
- digester.addRule(prefix + "web-fragment/ordering/before/others",
- new SetBeforeOthersRule());
-
- }
-
- final class SetAfterOthersRule extends Rule {
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
- WebOrdering ordering = (WebOrdering) digester.peek();
- ordering.setAfterOthers(true);
- }
- }
- final class SetBeforeOthersRule extends Rule {
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
- WebOrdering ordering = (WebOrdering) digester.peek();
- ordering.setBeforeOthers(true);
- }
- }
-}
Deleted: trunk/java/org/apache/catalina/startup/WebRuleSet.java
===================================================================
--- trunk/java/org/apache/catalina/startup/WebRuleSet.java 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/WebRuleSet.java 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,1071 +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.
- *
- *
- * 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.startup;
-
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.Wrapper;
-import org.apache.catalina.deploy.ContextHandler;
-import org.apache.catalina.deploy.ContextService;
-import org.apache.catalina.deploy.SecurityConstraint;
-import org.apache.catalina.deploy.WebAbsoluteOrdering;
-import org.apache.tomcat.util.IntrospectionUtils;
-import org.apache.tomcat.util.digester.CallMethodRule;
-import org.apache.tomcat.util.digester.CallParamRule;
-import org.apache.tomcat.util.digester.Digester;
-import org.apache.tomcat.util.digester.Rule;
-import org.apache.tomcat.util.digester.RuleSetBase;
-import org.apache.tomcat.util.digester.SetNextRule;
-import org.xml.sax.Attributes;
-
-
-/**
- * <p><strong>RuleSet</strong> for processing the contents of a web application
- * deployment descriptor (<code>/WEB-INF/web.xml</code>) resource.</p>
- *
- * @author Craig R. McClanahan
- * @version $Revision$ $Date$
- * FIXME: this needs to implement merging rules
- */
-
-public class WebRuleSet extends RuleSetBase {
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * The fragment flag
- */
- protected boolean fragment;
-
-
- /**
- * The matching pattern prefix to use for recognizing our elements.
- */
- protected String prefix = null;
-
-
- /**
- * The <code>SetSessionConfig</code> rule used to parse the web.xml
- */
- protected SetSessionConfig sessionConfig;
-
-
- /**
- * The <code>SetLoginConfig</code> rule used to parse the web.xml
- */
- protected SetLoginConfig loginConfig;
-
-
- /**
- * The <code>SetJspConfig</code> rule used to parse the web.xml
- */
- protected SetJspConfig jspConfig;
-
-
- // ------------------------------------------------------------ Constructor
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
- */
- public WebRuleSet() {
-
- this("", false);
-
- }
-
-
- /**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern prefix.
- *
- * @param prefix Prefix for matching pattern rules (including the
- * trailing slash character)
- */
- public WebRuleSet(String prefix, boolean fragment) {
-
- super();
- this.fragment = fragment;
- this.namespaceURI = null;
- this.prefix = prefix;
-
- }
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * <p>Add the set of Rule instances defined in this RuleSet to the
- * specified <code>Digester</code> instance, associating them with
- * our namespace URI (if any). This method should only be called
- * by a Digester instance.</p>
- *
- * @param digester Digester instance to which the new Rule instances
- * should be added.
- */
- public void addRuleInstances(Digester digester) {
- String elementName = "web-app";
- if (fragment) {
- elementName = "web-fragment";
- }
- sessionConfig = new SetSessionConfig();
- jspConfig = new SetJspConfig();
- loginConfig = new SetLoginConfig();
-
- digester.addRule(prefix + elementName,
- new SetPublicIdRule("setPublicId"));
- digester.addRule(prefix + elementName,
- new IgnoreAnnotationsRule());
- digester.addRule(prefix + elementName,
- new VersionRule());
-
- digester.addCallMethod(prefix + elementName + "/context-param",
- "addParameter", 2);
- digester.addCallParam(prefix + elementName + "/context-param/param-name", 0);
- digester.addCallParam(prefix + elementName + "/context-param/param-value", 1);
-
- digester.addCallMethod(prefix + elementName + "/display-name",
- "setDisplayName", 0);
-
- digester.addRule(prefix + elementName + "/distributable",
- new SetDistributableRule());
-
- configureNamingRules(digester);
-
- digester.addObjectCreate(prefix + elementName + "/error-page",
- "org.apache.catalina.deploy.ErrorPage");
- digester.addSetNext(prefix + elementName + "/error-page",
- "addErrorPage",
- "org.apache.catalina.deploy.ErrorPage");
-
- digester.addCallMethod(prefix + elementName + "/error-page/error-code",
- "setErrorCode", 0);
- digester.addCallMethod(prefix + elementName + "/error-page/exception-type",
- "setExceptionType", 0);
- digester.addCallMethod(prefix + elementName + "/error-page/location",
- "setLocation", 0);
-
- digester.addObjectCreate(prefix + elementName + "/filter",
- "org.apache.catalina.deploy.FilterDef");
- digester.addSetNext(prefix + elementName + "/filter",
- "addFilterDef",
- "org.apache.catalina.deploy.FilterDef");
-
- digester.addCallMethod(prefix + elementName + "/filter/async-supported",
- "setAsyncSupported", 1, new Class[] { Boolean.TYPE });
- digester.addCallParam(prefix + elementName + "/filter/async-supported", 0);
-
- digester.addCallMethod(prefix + elementName + "/filter/description",
- "setDescription", 0);
- digester.addCallMethod(prefix + elementName + "/filter/display-name",
- "setDisplayName", 0);
- digester.addCallMethod(prefix + elementName + "/filter/filter-class",
- "setFilterClass", 0);
- digester.addCallMethod(prefix + elementName + "/filter/filter-name",
- "setFilterName", 0);
- digester.addCallMethod(prefix + elementName + "/filter/large-icon",
- "setLargeIcon", 0);
- digester.addCallMethod(prefix + elementName + "/filter/small-icon",
- "setSmallIcon", 0);
-
- digester.addCallMethod(prefix + elementName + "/filter/init-param",
- "addInitParameter", 2);
- digester.addCallParam(prefix + elementName + "/filter/init-param/param-name",
- 0);
- digester.addCallParam(prefix + elementName + "/filter/init-param/param-value",
- 1);
-
- digester.addObjectCreate(prefix + elementName + "/filter-mapping",
- "org.apache.catalina.deploy.FilterMap");
- digester.addSetNext(prefix + elementName + "/filter-mapping",
- "addFilterMap",
- "org.apache.catalina.deploy.FilterMap");
-
- digester.addCallMethod(prefix + elementName + "/filter-mapping/filter-name",
- "setFilterName", 0);
- digester.addCallMethod(prefix + elementName + "/filter-mapping/servlet-name",
- "addServletName", 0);
- digester.addCallMethod(prefix + elementName + "/filter-mapping/url-pattern",
- "addURLPattern", 0);
-
- digester.addCallMethod(prefix + elementName + "/filter-mapping/dispatcher",
- "setDispatcher", 0);
-
- digester.addRule(prefix + elementName + "/jsp-config",
- jspConfig);
-
- digester.addCallMethod(prefix + elementName + "/jsp-config/taglib",
- "addTaglib", 2);
- digester.addCallParam(prefix + elementName + "/jsp-config/taglib/taglib-location", 1);
- digester.addCallParam(prefix + elementName + "/jsp-config/taglib/taglib-uri", 0);
-
- digester.addObjectCreate(prefix + elementName + "/jsp-config/jsp-property-group",
- "org.apache.catalina.deploy.JspPropertyGroup");
- digester.addSetNext(prefix + elementName + "/jsp-config/jsp-property-group",
- "addJspPropertyGroup", "org.apache.catalina.deploy.JspPropertyGroup");
-
- digester.addCallMethod(prefix + elementName + "/jsp-config/jsp-property-group/url-pattern",
- "addUrlPattern", 0);
- digester.addCallMethod(prefix + elementName + "/jsp-config/jsp-property-group/el-ignored",
- "setElIgnored", 0);
- digester.addCallMethod(prefix + elementName + "/jsp-config/jsp-property-group/page-encoding",
- "setPageEncoding", 0);
- digester.addCallMethod(prefix + elementName + "/jsp-config/jsp-property-group/scripting-invalid",
- "setScriptingInvalid", 0);
- digester.addCallMethod(prefix + elementName + "/jsp-config/jsp-property-group/is-xml",
- "setIsXml", 0);
- digester.addCallMethod(prefix + elementName + "/jsp-config/jsp-property-group/include-prelude",
- "addIncludePrelude", 0);
- digester.addCallMethod(prefix + elementName + "/jsp-config/jsp-property-group/include-coda",
- "addIncludeCoda", 0);
- digester.addCallMethod(prefix + elementName + "/jsp-config/jsp-property-group/deferred-syntax-allowed-as-literal",
- "setDeferredSyntaxAllowedAsLiteral", 0);
- digester.addCallMethod(prefix + elementName + "/jsp-config/jsp-property-group/trim-directive-whitespaces",
- "setTrimDirectiveWhitespaces", 0);
- digester.addCallMethod(prefix + elementName + "/jsp-config/jsp-property-group/default-content-type",
- "setDefaultContentType", 0);
- digester.addCallMethod(prefix + elementName + "/jsp-config/jsp-property-group/buffer",
- "setBuffer", 0);
- digester.addCallMethod(prefix + elementName + "/jsp-config/jsp-property-group/error-on-undeclared-namespace",
- "setErrorOnUndeclaredNamespace", 0);
-
- digester.addCallMethod(prefix + elementName + "/listener/listener-class",
- "addApplicationListener", 0);
-
- digester.addRule(prefix + elementName + "/login-config",
- loginConfig);
-
- digester.addObjectCreate(prefix + elementName + "/login-config",
- "org.apache.catalina.deploy.LoginConfig");
- digester.addSetNext(prefix + elementName + "/login-config",
- "setLoginConfig",
- "org.apache.catalina.deploy.LoginConfig");
-
- digester.addCallMethod(prefix + elementName + "/login-config/auth-method",
- "setAuthMethod", 0);
- digester.addCallMethod(prefix + elementName + "/login-config/realm-name",
- "setRealmName", 0);
- digester.addCallMethod(prefix + elementName + "/login-config/form-login-config/form-error-page",
- "setErrorPage", 0);
- digester.addCallMethod(prefix + elementName + "/login-config/form-login-config/form-login-page",
- "setLoginPage", 0);
-
- digester.addCallMethod(prefix + elementName + "/mime-mapping",
- "addMimeMapping", 2);
- digester.addCallParam(prefix + elementName + "/mime-mapping/extension", 0);
- digester.addCallParam(prefix + elementName + "/mime-mapping/mime-type", 1);
-
-
- digester.addObjectCreate(prefix + elementName + "/security-constraint",
- "org.apache.catalina.deploy.SecurityConstraint");
- digester.addSetNext(prefix + elementName + "/security-constraint",
- "addConstraint",
- "org.apache.catalina.deploy.SecurityConstraint");
-
- digester.addRule(prefix + elementName + "/security-constraint/auth-constraint",
- new SetAuthConstraintRule());
- digester.addCallMethod(prefix + elementName + "/security-constraint/auth-constraint/role-name",
- "addAuthRole", 0);
- digester.addCallMethod(prefix + elementName + "/security-constraint/display-name",
- "setDisplayName", 0);
- digester.addCallMethod(prefix + elementName + "/security-constraint/user-data-constraint/transport-guarantee",
- "setUserConstraint", 0);
-
- digester.addObjectCreate(prefix + elementName + "/security-constraint/web-resource-collection",
- "org.apache.catalina.deploy.SecurityCollection");
- digester.addSetNext(prefix + elementName + "/security-constraint/web-resource-collection",
- "addCollection",
- "org.apache.catalina.deploy.SecurityCollection");
- digester.addCallMethod(prefix + elementName + "/security-constraint/web-resource-collection/http-method",
- "addMethod", 0);
- digester.addCallMethod(prefix + elementName + "/security-constraint/web-resource-collection/http-method-omission",
- "addMethodOmission", 0);
- digester.addCallMethod(prefix + elementName + "/security-constraint/web-resource-collection/url-pattern",
- "addPattern", 0);
- digester.addCallMethod(prefix + elementName + "/security-constraint/web-resource-collection/web-resource-name",
- "setName", 0);
-
- digester.addCallMethod(prefix + elementName + "/security-role/role-name",
- "addSecurityRole", 0);
-
- digester.addRule(prefix + elementName + "/servlet",
- new WrapperCreateRule());
- digester.addSetNext(prefix + elementName + "/servlet",
- "addChild",
- "org.apache.catalina.Container");
-
- digester.addCallMethod(prefix + elementName + "/servlet/async-supported",
- "setAsyncSupported", 1, new Class[] { Boolean.TYPE });
- digester.addCallParam(prefix + elementName + "/servlet/async-supported", 0);
-
- digester.addCallMethod(prefix + elementName + "/servlet/description",
- "setDescription", 0);
-
- digester.addCallMethod(prefix + elementName + "/servlet/enabled",
- "setEnabled", 1, new Class[] { Boolean.TYPE });
- digester.addCallParam(prefix + elementName + "/servlet/enabled", 0);
-
- digester.addCallMethod(prefix + elementName + "/servlet/init-param",
- "addInitParameter", 2);
- digester.addCallParam(prefix + elementName + "/servlet/init-param/param-name",
- 0);
- digester.addCallParam(prefix + elementName + "/servlet/init-param/param-value",
- 1);
-
- digester.addCallMethod(prefix + elementName + "/servlet/jsp-file",
- "setJspFile", 0);
- digester.addCallMethod(prefix + elementName + "/servlet/load-on-startup",
- "setLoadOnStartupString", 0);
- digester.addCallMethod(prefix + elementName + "/servlet/run-as/role-name",
- "setRunAs", 0);
-
- digester.addCallMethod(prefix + elementName + "/servlet/security-role-ref",
- "addSecurityReference", 2);
- digester.addCallParam(prefix + elementName + "/servlet/security-role-ref/role-link", 1);
- digester.addCallParam(prefix + elementName + "/servlet/security-role-ref/role-name", 0);
-
- digester.addCallMethod(prefix + elementName + "/servlet/servlet-class",
- "setServletClass", 0);
- digester.addCallMethod(prefix + elementName + "/servlet/servlet-name",
- "setName", 0);
-
- digester.addRule(prefix + elementName + "/servlet-mapping",
- new CallMethodMultiRule("addServletMapping", 2, 0));
- digester.addCallParam(prefix + elementName + "/servlet-mapping/servlet-name", 1);
- digester.addRule(prefix + elementName + "/servlet-mapping/url-pattern", new CallParamMultiRule(0));
-
- digester.addRule(prefix + elementName + "/session-config",
- sessionConfig);
-
- digester.addCallMethod(prefix + elementName + "/session-config/session-timeout",
- "setSessionTimeout", 1,
- new Class[] { Integer.TYPE });
- digester.addCallParam(prefix + elementName + "/session-config/session-timeout", 0);
- digester.addCallMethod(prefix + elementName + "/session-config/tracking-mode", "addSessionTrackingMode", 0);
-
- digester.addObjectCreate(prefix + elementName + "/session-config/cookie-config",
- "org.apache.catalina.deploy.SessionCookie");
- digester.addSetNext(prefix + elementName + "/session-config/cookie-config",
- "setSessionCookie",
- "org.apache.catalina.deploy.SessionCookie");
- digester.addCallMethod(prefix + elementName + "/session-config/cookie-config/cookie-name",
- "setName", 0);
- digester.addCallMethod(prefix + elementName + "/session-config/cookie-config/cookie-domain",
- "setDomain", 0);
- digester.addCallMethod(prefix + elementName + "/session-config/cookie-config/cookie-path",
- "setPath", 0);
- digester.addCallMethod(prefix + elementName + "/session-config/cookie-config/cookie-comment",
- "setComment", 0);
- digester.addCallMethod(prefix + elementName + "/session-config/cookie-config/http-only",
- "setHttpOnly", 1, new Class[] { Boolean.TYPE });
- digester.addCallParam(prefix + elementName + "/session-config/cookie-config/http-only", 0);
- digester.addCallMethod(prefix + elementName + "/session-config/cookie-config/secure",
- "setSecure", 1, new Class[] { Boolean.TYPE });
- digester.addCallParam(prefix + elementName + "/session-config/cookie-config/secure", 0);
- digester.addCallMethod(prefix + elementName + "/session-config/cookie-config/max-age",
- "setMaxAge", 1, new Class[] { Integer.TYPE });
- digester.addCallParam(prefix + elementName + "/session-config/cookie-config/max-age", 0);
-
- digester.addCallMethod(prefix + elementName + "/taglib",
- "addTaglib", 2);
- digester.addCallParam(prefix + elementName + "/taglib/taglib-location", 1);
- digester.addCallParam(prefix + elementName + "/taglib/taglib-uri", 0);
-
- digester.addCallMethod(prefix + elementName + "/welcome-file-list/welcome-file",
- "addWelcomeFile", 0);
-
- digester.addCallMethod(prefix + elementName + "/locale-encoding-mapping-list/locale-encoding-mapping",
- "addLocaleEncodingMappingParameter", 2);
- digester.addCallParam(prefix + elementName + "/locale-encoding-mapping-list/locale-encoding-mapping/locale", 0);
- digester.addCallParam(prefix + elementName + "/locale-encoding-mapping-list/locale-encoding-mapping/encoding", 1);
-
- // absolute-ordering rules
- if (!fragment) {
- digester.addCallMethod(prefix + elementName + "/name", "setLogicalName", 0);
- digester.addObjectCreate(prefix + elementName + "/absolute-ordering",
- "org.apache.catalina.deploy.WebAbsoluteOrdering");
- digester.addSetNext(prefix + elementName + "/absolute-ordering",
- "setWebAbsoluteOrdering",
- "org.apache.catalina.deploy.WebAbsoluteOrdering");
- digester.addCallMethod(prefix + elementName + "/absolute-ordering/name",
- "addName", 0);
- digester.addRule(prefix + elementName + "/absolute-ordering/others",
- new AddOthersRule());
- }
-
- }
-
- protected void configureNamingRules(Digester digester) {
- String elementName = "web-app";
- if (fragment) {
- elementName = "web-fragment";
- }
- //ejb-local-ref
- digester.addObjectCreate(prefix + elementName + "/ejb-local-ref",
- "org.apache.catalina.deploy.ContextLocalEjb");
- digester.addRule(prefix + elementName + "/ejb-local-ref",
- new SetNextNamingRule("addLocalEjb",
- "org.apache.catalina.deploy.ContextLocalEjb"));
-
- digester.addCallMethod(prefix + elementName + "/ejb-local-ref/description",
- "setDescription", 0);
- digester.addCallMethod(prefix + elementName + "/ejb-local-ref/ejb-link",
- "setLink", 0);
- digester.addCallMethod(prefix + elementName + "/ejb-local-ref/ejb-ref-name",
- "setName", 0);
- digester.addCallMethod(prefix + elementName + "/ejb-local-ref/ejb-ref-type",
- "setType", 0);
- digester.addCallMethod(prefix + elementName + "/ejb-local-ref/local",
- "setLocal", 0);
- digester.addCallMethod(prefix + elementName + "/ejb-local-ref/local-home",
- "setHome", 0);
- configureInjectionRules(digester, elementName + "/ejb-local-ref/");
-
- //ejb-ref
- digester.addObjectCreate(prefix + elementName + "/ejb-ref",
- "org.apache.catalina.deploy.ContextEjb");
- digester.addRule(prefix + elementName + "/ejb-ref",
- new SetNextNamingRule("addEjb",
- "org.apache.catalina.deploy.ContextEjb"));
-
- digester.addCallMethod(prefix + elementName + "/ejb-ref/description",
- "setDescription", 0);
- digester.addCallMethod(prefix + elementName + "/ejb-ref/ejb-link",
- "setLink", 0);
- digester.addCallMethod(prefix + elementName + "/ejb-ref/ejb-ref-name",
- "setName", 0);
- digester.addCallMethod(prefix + elementName + "/ejb-ref/ejb-ref-type",
- "setType", 0);
- digester.addCallMethod(prefix + elementName + "/ejb-ref/home",
- "setHome", 0);
- digester.addCallMethod(prefix + elementName + "/ejb-ref/remote",
- "setRemote", 0);
- configureInjectionRules(digester, elementName + "/ejb-ref/");
-
- //env-entry
- digester.addObjectCreate(prefix + elementName + "/env-entry",
- "org.apache.catalina.deploy.ContextEnvironment");
- digester.addRule(prefix + elementName + "/env-entry",
- new SetNextNamingRule("addEnvironment",
- "org.apache.catalina.deploy.ContextEnvironment"));
-
- digester.addCallMethod(prefix + elementName + "/env-entry/description",
- "setDescription", 0);
- digester.addCallMethod(prefix + elementName + "/env-entry/env-entry-name",
- "setName", 0);
- digester.addCallMethod(prefix + elementName + "/env-entry/env-entry-type",
- "setType", 0);
- digester.addCallMethod(prefix + elementName + "/env-entry/env-entry-value",
- "setValue", 0);
- configureInjectionRules(digester, elementName + "/env-entry/");
-
- //resource-env-ref
- digester.addObjectCreate(prefix + elementName + "/resource-env-ref",
- "org.apache.catalina.deploy.ContextResourceEnvRef");
- digester.addRule(prefix + elementName + "/resource-env-ref",
- new SetNextNamingRule("addResourceEnvRef",
- "org.apache.catalina.deploy.ContextResourceEnvRef"));
-
- digester.addCallMethod(prefix + elementName + "/resource-env-ref/resource-env-ref-name",
- "setName", 0);
- digester.addCallMethod(prefix + elementName + "/resource-env-ref/resource-env-ref-type",
- "setType", 0);
- configureInjectionRules(digester, elementName + "/ejb-local-ref/");
-
- //message-destination
- digester.addObjectCreate(prefix + elementName + "/message-destination",
- "org.apache.catalina.deploy.MessageDestination");
- digester.addSetNext(prefix + elementName + "/message-destination",
- "addMessageDestination",
- "org.apache.catalina.deploy.MessageDestination");
-
- digester.addCallMethod(prefix + elementName + "/message-destination/description",
- "setDescription", 0);
- digester.addCallMethod(prefix + elementName + "/message-destination/display-name",
- "setDisplayName", 0);
- digester.addCallMethod(prefix + elementName + "/message-destination/icon/large-icon",
- "setLargeIcon", 0);
- digester.addCallMethod(prefix + elementName + "/message-destination/icon/small-icon",
- "setSmallIcon", 0);
- digester.addCallMethod(prefix + elementName + "/message-destination/message-destination-name",
- "setName", 0);
-
- //message-destination-ref
- digester.addObjectCreate(prefix + elementName + "/message-destination-ref",
- "org.apache.catalina.deploy.MessageDestinationRef");
- digester.addSetNext(prefix + elementName + "/message-destination-ref",
- "addMessageDestinationRef",
- "org.apache.catalina.deploy.MessageDestinationRef");
-
- digester.addCallMethod(prefix + elementName + "/message-destination-ref/description",
- "setDescription", 0);
- digester.addCallMethod(prefix + elementName + "/message-destination-ref/message-destination-link",
- "setLink", 0);
- digester.addCallMethod(prefix + elementName + "/message-destination-ref/message-destination-ref-name",
- "setName", 0);
- digester.addCallMethod(prefix + elementName + "/message-destination-ref/message-destination-type",
- "setType", 0);
- digester.addCallMethod(prefix + elementName + "/message-destination-ref/message-destination-usage",
- "setUsage", 0);
-
- configureInjectionRules(digester, elementName + "/message-destination-ref/");
-
- //resource-ref
- digester.addObjectCreate(prefix + elementName + "/resource-ref",
- "org.apache.catalina.deploy.ContextResource");
- digester.addRule(prefix + elementName + "/resource-ref",
- new SetNextNamingRule("addResource",
- "org.apache.catalina.deploy.ContextResource"));
-
- digester.addCallMethod(prefix + elementName + "/resource-ref/description",
- "setDescription", 0);
- digester.addCallMethod(prefix + elementName + "/resource-ref/res-auth",
- "setAuth", 0);
- digester.addCallMethod(prefix + elementName + "/resource-ref/res-ref-name",
- "setName", 0);
- digester.addCallMethod(prefix + elementName + "/resource-ref/res-sharing-scope",
- "setScope", 0);
- digester.addCallMethod(prefix + elementName + "/resource-ref/res-type",
- "setType", 0);
- configureInjectionRules(digester, elementName + "/resource-ref/");
-
- //service-ref
- digester.addObjectCreate(prefix + elementName + "/service-ref",
- "org.apache.catalina.deploy.ContextService");
- digester.addRule(prefix + elementName + "/service-ref",
- new SetNextNamingRule("addService",
- "org.apache.catalina.deploy.ContextService"));
-
- digester.addCallMethod(prefix + elementName + "/service-ref/description",
- "setDescription", 0);
- digester.addCallMethod(prefix + elementName + "/service-ref/display-name",
- "setDisplayname", 0);
- digester.addCallMethod(prefix + elementName + "/service-ref/icon",
- "setIcon", 0);
- digester.addCallMethod(prefix + elementName + "/service-ref/service-ref-name",
- "setName", 0);
- digester.addCallMethod(prefix + elementName + "/service-ref/service-interface",
- "setType", 0);
- digester.addCallMethod(prefix + elementName + "/service-ref/wsdl-file",
- "setWsdlfile", 0);
- digester.addCallMethod(prefix + elementName + "/service-ref/jaxrpc-mapping-file",
- "setJaxrpcmappingfile", 0);
- digester.addRule(prefix + elementName + "/service-ref/service-qname", new ServiceQnameRule());
-
- digester.addRule(prefix + elementName + "/service-ref/port-component-ref",
- new CallMethodMultiRule("addPortcomponent", 2, 1));
- digester.addCallParam(prefix + elementName + "/service-ref/port-component-ref/service-endpoint-interface", 0);
- digester.addRule(prefix + elementName + "/service-ref/port-component-ref/port-component-link",
- new CallParamMultiRule(1));
-
- digester.addObjectCreate(prefix + elementName + "/service-ref/handler",
- "org.apache.catalina.deploy.ContextHandler");
- digester.addRule(prefix + elementName + "/service-ref/handler",
- new SetNextRule("addHandler",
- "org.apache.catalina.deploy.ContextHandler"));
-
- digester.addCallMethod(prefix + elementName + "/service-ref/handler/handler-name",
- "setName", 0);
- digester.addCallMethod(prefix + elementName + "/service-ref/handler/handler-class",
- "setHandlerclass", 0);
-
- digester.addCallMethod(prefix + elementName + "/service-ref/handler/init-param",
- "setProperty", 2);
- digester.addCallParam(prefix + elementName + "/service-ref/handler/init-param/param-name",
- 0);
- digester.addCallParam(prefix + elementName + "/service-ref/handler/init-param/param-value",
- 1);
-
- digester.addRule(prefix + elementName + "/service-ref/handler/soap-header", new SoapHeaderRule());
-
- digester.addCallMethod(prefix + elementName + "/service-ref/handler/soap-role",
- "addSoapRole", 0);
- digester.addCallMethod(prefix + elementName + "/service-ref/handler/port-name",
- "addPortName", 0);
- configureInjectionRules(digester, elementName + "/service-ref/");
-
-
- }
-
- protected void configureInjectionRules(Digester digester, String base) {
-
- digester.addCallMethod(prefix + base + "injection-target", "addInjectionTarget", 2);
- digester.addCallParam(prefix + base + "injection-target/injection-target-class", 0);
- digester.addCallParam(prefix + base + "injection-target/injection-target-name", 1);
-
- }
-
-
- /**
- * Reset counter used for validating the web.xml file.
- */
- public void recycle(){
- jspConfig.isJspConfigSet = false;
- sessionConfig.isSessionConfigSet = false;
- loginConfig.isLoginConfigSet = false;
- }
-}
-
-
-// ----------------------------------------------------------- Private Classes
-
-
-/**
- * Rule to check that the <code>login-config</code> is occuring
- * only 1 time within the web.xml
- */
-final class SetLoginConfig extends Rule {
- protected boolean isLoginConfigSet = false;
- public SetLoginConfig() {
- }
-
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
- if (isLoginConfigSet){
- throw new IllegalArgumentException(
- "<login-config> element is limited to 1 occurrence");
- }
- isLoginConfigSet = true;
- }
-
-}
-
-
-/**
- * Rule to check that the <code>jsp-config</code> is occuring
- * only 1 time within the web.xml
- */
-final class SetJspConfig extends Rule {
- protected boolean isJspConfigSet = false;
- public SetJspConfig() {
- }
-
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
- if (isJspConfigSet){
- throw new IllegalArgumentException(
- "<jsp-config> element is limited to 1 occurrence");
- }
- isJspConfigSet = true;
- }
-
-}
-
-
-/**
- * Rule to check that the <code>session-config</code> is occuring
- * only 1 time within the web.xml
- */
-final class SetSessionConfig extends Rule {
- protected boolean isSessionConfigSet = false;
- public SetSessionConfig() {
- }
-
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
- if (isSessionConfigSet){
- throw new IllegalArgumentException(
- "<session-config> element is limited to 1 occurrence");
- }
- isSessionConfigSet = true;
- }
-
-}
-
-/**
- * A Rule that calls the <code>setAuthConstraint(true)</code> method of
- * the top item on the stack, which must be of type
- * <code>org.apache.catalina.deploy.SecurityConstraint</code>.
- */
-
-final class SetAuthConstraintRule extends Rule {
-
- public SetAuthConstraintRule() {
- }
-
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
- SecurityConstraint securityConstraint =
- (SecurityConstraint) digester.peek();
- securityConstraint.setAuthConstraint(true);
- if (digester.getLogger().isDebugEnabled()) {
- digester.getLogger()
- .debug("Calling SecurityConstraint.setAuthConstraint(true)");
- }
- }
-
-}
-
-
-/**
- * Class that calls <code>setDistributable(true)</code> for the top object
- * on the stack, which must be a <code>org.apache.catalina.Context</code>.
- */
-
-final class SetDistributableRule extends Rule {
-
- public SetDistributableRule() {
- }
-
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
- Context context = (Context) digester.peek();
- context.setDistributable(true);
- if (digester.getLogger().isDebugEnabled()) {
- digester.getLogger().debug
- (context.getClass().getName() + ".setDistributable( true)");
- }
- }
-
-}
-
-
-/**
- * Class that calls a property setter for the top object on the stack,
- * passing the public ID of the entity we are currently processing.
- */
-
-final class SetPublicIdRule extends Rule {
-
- public SetPublicIdRule(String method) {
- this.method = method;
- }
-
- private String method = null;
-
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
-
- Context context = (Context) digester.peek(digester.getCount() - 1);
- Object top = digester.peek();
- Class paramClasses[] = new Class[1];
- paramClasses[0] = "String".getClass();
- String paramValues[] = new String[1];
- paramValues[0] = digester.getPublicId();
-
- Method m = null;
- try {
- m = top.getClass().getMethod(method, paramClasses);
- } catch (NoSuchMethodException e) {
- digester.getLogger().error("Can't find method " + method + " in "
- + top + " CLASS " + top.getClass());
- return;
- }
-
- m.invoke(top, (Object [])paramValues);
- if (digester.getLogger().isDebugEnabled())
- digester.getLogger().debug("" + top.getClass().getName() + "."
- + method + "(" + paramValues[0] + ")");
-
- }
-
-}
-
-
-/**
- * A Rule that calls the factory method on the specified Context to
- * create the object that is to be added to the stack.
- */
-
-final class WrapperCreateRule extends Rule {
-
- public WrapperCreateRule() {
- }
-
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
- Context context =
- (Context) digester.peek(digester.getCount() - 1);
- Wrapper wrapper = context.createWrapper();
- digester.push(wrapper);
- if (digester.getLogger().isDebugEnabled())
- digester.getLogger().debug("new " + wrapper.getClass().getName());
- }
-
- public void end(String namespace, String name)
- throws Exception {
- Wrapper wrapper = (Wrapper) digester.pop();
- if (digester.getLogger().isDebugEnabled())
- digester.getLogger().debug("pop " + wrapper.getClass().getName());
- }
-
-}
-
-
-/**
- * A Rule that can be used to call multiple times a method as many times as needed
- * (used for addServletMapping).
- */
-final class CallParamMultiRule extends CallParamRule {
-
- public CallParamMultiRule(int paramIndex) {
- super(paramIndex);
- }
-
- public void end(String namespace, String name) {
- if (bodyTextStack != null && !bodyTextStack.empty()) {
- // what we do now is push one parameter onto the top set of parameters
- Object parameters[] = (Object[]) digester.peekParams();
- ArrayList params = (ArrayList) parameters[paramIndex];
- if (params == null) {
- params = new ArrayList();
- parameters[paramIndex] = params;
- }
- params.add(bodyTextStack.pop());
- }
- }
-
-}
-
-
-/**
- * A Rule that can be used to call multiple times a method as many times as needed
- * (used for addServletMapping).
- */
-final class CallMethodMultiRule extends CallMethodRule {
-
- protected int multiParamIndex = 0;
-
- public CallMethodMultiRule(String methodName, int paramCount, int multiParamIndex) {
- super(methodName, paramCount);
- this.multiParamIndex = multiParamIndex;
- }
-
- public void end() throws Exception {
-
- // Retrieve or construct the parameter values array
- Object parameters[] = null;
- if (paramCount > 0) {
- parameters = (Object[]) digester.popParams();
- } else {
- super.end();
- }
-
- ArrayList multiParams = (ArrayList) parameters[multiParamIndex];
-
- // Construct the parameter values array we will need
- // We only do the conversion if the param value is a String and
- // the specified paramType is not String.
- Object paramValues[] = new Object[paramTypes.length];
- for (int i = 0; i < paramTypes.length; i++) {
- if (i != multiParamIndex) {
- // convert nulls and convert stringy parameters
- // for non-stringy param types
- if(parameters[i] == null || (parameters[i] instanceof String
- && !String.class.isAssignableFrom(paramTypes[i]))) {
- paramValues[i] =
- IntrospectionUtils.convert((String) parameters[i], paramTypes[i]);
- } else {
- paramValues[i] = parameters[i];
- }
- }
- }
-
- // Determine the target object for the method call
- Object target;
- if (targetOffset >= 0) {
- target = digester.peek(targetOffset);
- } else {
- target = digester.peek(digester.getCount() + targetOffset);
- }
-
- if (target == null) {
- StringBuilder sb = new StringBuilder();
- sb.append("[CallMethodRule]{");
- sb.append("");
- sb.append("} Call target is null (");
- sb.append("targetOffset=");
- sb.append(targetOffset);
- sb.append(",stackdepth=");
- sb.append(digester.getCount());
- sb.append(")");
- throw new org.xml.sax.SAXException(sb.toString());
- }
-
- if (multiParams == null) {
- paramValues[multiParamIndex] = null;
- Object result = IntrospectionUtils.callMethodN(target, methodName,
- paramValues, paramTypes);
- return;
- }
-
- for (int j = 0; j < multiParams.size(); j++) {
- Object param = multiParams.get(j);
- if(param == null || (param instanceof String
- && !String.class.isAssignableFrom(paramTypes[multiParamIndex]))) {
- paramValues[multiParamIndex] =
- IntrospectionUtils.convert((String) param, paramTypes[multiParamIndex]);
- } else {
- paramValues[multiParamIndex] = param;
- }
- Object result = IntrospectionUtils.callMethodN(target, methodName,
- paramValues, paramTypes);
- }
-
- }
-
-}
-
-
-
-/**
- * A Rule that check if the annotations have to be loaded.
- *
- */
-
-final class IgnoreAnnotationsRule extends Rule {
-
- public IgnoreAnnotationsRule() {
- }
-
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
- Context context = (Context) digester.peek(digester.getCount() - 1);
- String value = attributes.getValue("metadata-complete");
- if ("true".equals(value)) {
- context.setIgnoreAnnotations(true);
- }
- if (digester.getLogger().isDebugEnabled()) {
- digester.getLogger().debug
- (context.getClass().getName() + ".setIgnoreAnnotations( " +
- context.getIgnoreAnnotations() + ")");
- }
- }
-
-}
-
-/**
- * A Rule that sets the version field on the context.
- */
-final class VersionRule extends Rule {
-
- public VersionRule() {
- }
-
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
- Context context = (Context) digester.peek(digester.getCount() - 1);
- String value = attributes.getValue("version");
- if (value != null) {
- context.setVersion(value);
- }
- if (digester.getLogger().isDebugEnabled()) {
- digester.getLogger().debug
- (context.getClass().getName() + ".setVersion( " +
- context.getVersion() + ")");
- }
- }
-
-}
-
-/**
- * A Rule that sets soap headers on the ContextHandler.
- *
- */
-final class SoapHeaderRule extends Rule {
-
- public SoapHeaderRule() {
- }
-
- public void body(String text)
- throws Exception {
- String namespaceuri = null;
- String localpart = text;
- int colon = text.indexOf(':');
- if (colon >= 0) {
- String prefix = text.substring(0,colon);
- namespaceuri = digester.findNamespaceURI(prefix);
- localpart = text.substring(colon+1);
- }
- ContextHandler contextHandler = (ContextHandler)digester.peek();
- contextHandler.addSoapHeaders(localpart,namespaceuri);
- }
-}
-
-/**
- * A Rule that sets service qname on the ContextService.
- *
- */
-final class ServiceQnameRule extends Rule {
-
- public ServiceQnameRule() {
- }
-
- public void body(String text)
- throws Exception {
- String namespaceuri = null;
- String localpart = text;
- int colon = text.indexOf(':');
- if (colon >= 0) {
- String prefix = text.substring(0,colon);
- namespaceuri = digester.findNamespaceURI(prefix);
- localpart = text.substring(colon+1);
- }
- ContextService contextService = (ContextService)digester.peek();
- contextService.setServiceqnameLocalpart(localpart);
- contextService.setServiceqnameNamespaceURI(namespaceuri);
- }
-}
-
-final class AddOthersRule extends Rule {
- public AddOthersRule() {
- }
-
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
- WebAbsoluteOrdering ordering = (WebAbsoluteOrdering) digester.peek();
- ordering.addName("*");
- }
-
-}
Modified: trunk/java/org/apache/catalina/startup/catalina.properties
===================================================================
--- trunk/java/org/apache/catalina/startup/catalina.properties 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/java/org/apache/catalina/startup/catalina.properties 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,64 +1,14 @@
-#
-# List of comma-separated packages that start with or equal this string
-# will cause a security exception to be thrown when
-# passed to checkPackageAccess unless the
-# corresponding RuntimePermission ("accessClassInPackage."+package) has
-# been granted.
-package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans.
-#
-# List of comma-separated packages that start with or equal this string
-# will cause a security exception to be thrown when
-# passed to checkPackageDefinition unless the
-# corresponding RuntimePermission ("defineClassInPackage."+package) has
-# been granted.
-#
-# by default, no packages are restricted for definition, and none of
-# the class loaders supplied with the JDK call checkPackageDefinition.
-#
-package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.
+# JBoss AS configuration
+org.apache.catalina.STRICT_SERVLET_COMPLIANCE=true
+org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true
+org.apache.jasper.Constants.INJECT_TAGS=false
+org.apache.jasper.Constants.USE_INSTANCE_MANAGER_FOR_TAGS=false
+org.apache.catalina.connector.Connector.X_POWERED_BY=true
+org.apache.catalina.connector.Request.SESSION_ID_CHECK=true
+org.apache.catalina.connector.CoyoteAdapter.X_POWERED_BY=Servlet/3.0; JBossAS-6
+org.apache.catalina.core.StandardHost.configClass=org.jboss.web.tomcat.service.deployers.JBossContextConfig
+org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR=false
-#
-#
-# List of comma-separated paths defining the contents of the "common"
-# classloader. Prefixes should be used to define what is the repository type.
-# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.
-# If left as blank,the JVM system loader will be used as Catalina's "common"
-# loader.
-# Examples:
-# "foo": Add this folder as a class repository
-# "foo/*.jar": Add all the JARs of the specified folder as class
-# repositories
-# "foo/bar.jar": Add bar.jar as a class repository
-common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar
-
-#
-# List of comma-separated paths defining the contents of the "server"
-# classloader. Prefixes should be used to define what is the repository type.
-# Path may be relative to the CATALINA_HOME or CATALINA_BASE path or absolute.
-# If left as blank, the "common" loader will be used as Catalina's "server"
-# loader.
-# Examples:
-# "foo": Add this folder as a class repository
-# "foo/*.jar": Add all the JARs of the specified folder as class
-# repositories
-# "foo/bar.jar": Add bar.jar as a class repository
-server.loader=
-
-#
-# List of comma-separated paths defining the contents of the "shared"
-# classloader. Prefixes should be used to define what is the repository type.
-# Path may be relative to the CATALINA_BASE path or absolute. If left as blank,
-# the "common" loader will be used as Catalina's "shared" loader.
-# Examples:
-# "foo": Add this folder as a class repository
-# "foo/*.jar": Add all the JARs of the specified folder as class
-# repositories
-# "foo/bar.jar": Add bar.jar as a class repository
-# Please note that for single jars, e.g. bar.jar, you need the URL form
-# starting with file:.
-shared.loader=
-
-#
# String cache configuration.
org.apache.tomcat.util.buf.StringCache.byte.enabled=true
#org.apache.tomcat.util.buf.StringCache.char.enabled=true
Deleted: trunk/res/jboss/org/apache/catalina/startup/catalina.properties
===================================================================
--- trunk/res/jboss/org/apache/catalina/startup/catalina.properties 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/res/jboss/org/apache/catalina/startup/catalina.properties 2010-03-12 12:52:22 UTC (rev 1407)
@@ -1,22 +0,0 @@
-# JBoss AS configuration
-org.apache.catalina.STRICT_SERVLET_COMPLIANCE=true
-org.apache.catalina.core.StandardService.DELAY_CONNECTOR_STARTUP=true
-org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true
-org.apache.jasper.Constants.INJECT_TAGS=false
-org.apache.jasper.Constants.USE_INSTANCE_MANAGER_FOR_TAGS=false
-org.apache.catalina.connector.Connector.X_POWERED_BY=true
-org.apache.catalina.connector.Request.SESSION_ID_CHECK=true
-org.apache.catalina.connector.CoyoteAdapter.X_POWERED_BY=Servlet/3.0; JBossAS-6
-org.apache.catalina.core.CONFIGBASE_MKDIRS=false
-org.apache.catalina.core.StandardHost.autoDeploy=false
-org.apache.catalina.core.StandardHost.configClass=org.jboss.web.tomcat.service.deployers.JBossContextConfig
-org.apache.catalina.core.StandardHost.deployOnStartup=false
-org.apache.catalina.core.StandardHost.deployXML=false
-org.apache.catalina.core.StandardHost.startChildren=false
-org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR=false
-
-# String cache configuration.
-org.apache.tomcat.util.buf.StringCache.byte.enabled=true
-#org.apache.tomcat.util.buf.StringCache.char.enabled=true
-#org.apache.tomcat.util.buf.StringCache.trainThreshold=500000
-#org.apache.tomcat.util.buf.StringCache.cacheSize=5000
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2010-03-11 23:12:22 UTC (rev 1406)
+++ trunk/webapps/docs/changelog.xml 2010-03-12 12:52:22 UTC (rev 1407)
@@ -37,6 +37,9 @@
<fix>
<bug>48760</bug>: Fix possible race condition reading resources. (markt)
</fix>
+ <update>
+ Drop standalone code: XML parsing, webapp deployer, annotation processing, naming support. (remm)
+ </update>
</changelog>
</subsection>
<subsection name="Coyote">
14 years, 1 month
JBossWeb SVN: r1406 - branches.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-03-11 18:12:22 -0500 (Thu, 11 Mar 2010)
New Revision: 1406
Added:
branches/3.0.x-standalone/
Log:
- Branch standalone JBW, just in case ...
Copied: branches/3.0.x-standalone (from rev 1405, trunk)
14 years, 1 month
JBossWeb SVN: r1405 - trunk.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-03-09 13:04:12 -0500 (Tue, 09 Mar 2010)
New Revision: 1405
Modified:
trunk/dist.xml
Log:
- Drop the EE API JARs.
Modified: trunk/dist.xml
===================================================================
--- trunk/dist.xml 2010-03-09 13:55:51 UTC (rev 1404)
+++ trunk/dist.xml 2010-03-09 18:04:12 UTC (rev 1405)
@@ -300,10 +300,12 @@
<property name="maven.repository.id" value="snapshots.jboss.org"/>-->
<!-- Linux/Unix execs -->
+ <!--
<exec dir="." executable="/bin/sh" os="Linux">
<arg value="-c" />
<arg value="mvn deploy:deploy-file -Dfile=${tomcat.jars}/el-api.jar -DpomFile=${tomcat.jars}/el-api-pom.xml -Durl=${maven.repository.url} -Dpackaging=jar -DrepositoryId=${maven.repository.id}"/>
</exec>
+ -->
<exec dir="." executable="/bin/sh" os="Linux">
<arg value="-c" />
<arg value="mvn deploy:deploy-file -Dfile=${tomcat.jars}/jasper-jdt.jar -DpomFile=${tomcat.jars}/jasper-jdt-pom.xml -Durl=${maven.repository.url} -Dpackaging=jar -DrepositoryId=${maven.repository.id}"/>
@@ -312,6 +314,7 @@
<arg value="-c" />
<arg value="mvn deploy:deploy-file -Dfile=${tomcat.jars}/jbossweb.jar -DpomFile=${tomcat.jars}/jbossweb-pom.xml -Durl=${maven.repository.url} -Dpackaging=jar -DrepositoryId=${maven.repository.id}"/>
</exec>
+ <!--
<exec dir="." executable="/bin/sh" os="Linux">
<arg value="-c" />
<arg value="mvn deploy:deploy-file -Dfile=${tomcat.jars}/jsp-api.jar -DpomFile=${tomcat.jars}/jsp-api-pom.xml -Durl=${maven.repository.url} -Dpackaging=jar -DrepositoryId=${maven.repository.id}"/>
@@ -320,16 +323,19 @@
<arg value="-c" />
<arg value="mvn deploy:deploy-file -Dfile=${tomcat.jars}/servlet-api.jar -DpomFile=${tomcat.jars}/servlet-api-pom.xml -Durl=${maven.repository.url} -Dpackaging=jar -DrepositoryId=${maven.repository.id}"/>
</exec>
+ -->
<exec dir="." executable="/bin/sh" os="Linux">
<arg value="-c" />
<arg value="mvn deploy:deploy-file -Dfile=${tomcat.jars}/jbossweb-src.zip -Durl=${maven.repository.url} -Dpackaging=jar -DrepositoryId=${maven.repository.id} -DgroupId=jboss.web -DartifactId=jbossweb -Dversion=${version} -Dclassifier=sources"/>
</exec>
<!-- Windows exec -->
+ <!--
<exec dir="." executable="cmd" os="Windows NT">
<arg value="/c" />
<arg value="mvn deploy:deploy-file -Dfile=${tomcat.jars}/el-api.jar -DpomFile=${tomcat.jars}/el-api-pom.xml -Durl=${maven.repository.url} -Dpackaging=jar -DrepositoryId=${maven.repository.id}"/>
</exec>
+ -->
<exec dir="." executable="cmd" os="Windows NT">
<arg value="/c" />
<arg value="mvn deploy:deploy-file -Dfile=${tomcat.jars}/jasper-jdt.jar -DpomFile=${tomcat.jars}/jasper-jdt-pom.xml -Durl=${maven.repository.url} -Dpackaging=jar -DrepositoryId=${maven.repository.id}"/>
@@ -338,6 +344,7 @@
<arg value="/c" />
<arg value="mvn deploy:deploy-file -Dfile=${tomcat.jars}/jbossweb.jar -DpomFile=${tomcat.jars}/jbossweb-pom.xml -Durl=${maven.repository.url} -Dpackaging=jar -DrepositoryId=${maven.repository.id}"/>
</exec>
+ <!--
<exec dir="." executable="cmd" os="Windows NT">
<arg value="/c" />
<arg value="mvn deploy:deploy-file -Dfile=${tomcat.jars}/jsp-api.jar -DpomFile=${tomcat.jars}/jsp-api-pom.xml -Durl=${maven.repository.url} -Dpackaging=jar -DrepositoryId=${maven.repository.id}"/>
@@ -346,6 +353,7 @@
<arg value="/c" />
<arg value="mvn deploy:deploy-file -Dfile=${tomcat.jars}/servlet-api.jar -DpomFile=${tomcat.jars}/servlet-api-pom.xml -Durl=${maven.repository.url} -Dpackaging=jar -DrepositoryId=${maven.repository.id}"/>
</exec>
+ -->
<exec dir="." executable="cmd" os="Windows NT">
<arg value="/c" />
<arg value="mvn deploy:deploy-file -Dfile=${tomcat.jars}/jbossweb-src.zip -Durl=${maven.repository.url} -Dpackaging=jar -DrepositoryId=${maven.repository.id} -DgroupId=jboss.web -DartifactId=jbossweb -Dversion=${version} -Dclassifier=sources"/>
14 years, 1 month
JBossWeb SVN: r1404 - in trunk: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-03-09 08:55:51 -0500 (Tue, 09 Mar 2010)
New Revision: 1404
Modified:
trunk/java/org/apache/naming/resources/FileDirContext.java
trunk/java/org/apache/naming/resources/WARDirContext.java
trunk/webapps/docs/changelog.xml
Log:
- Port 48760: Possible race condition reading resources.
Modified: trunk/java/org/apache/naming/resources/FileDirContext.java
===================================================================
--- trunk/java/org/apache/naming/resources/FileDirContext.java 2010-03-08 23:07:34 UTC (rev 1403)
+++ trunk/java/org/apache/naming/resources/FileDirContext.java 2010-03-09 13:55:51 UTC (rev 1404)
@@ -920,7 +920,9 @@
public InputStream streamContent()
throws IOException {
if (binaryContent == null) {
- inputStream = new FileInputStream(file);
+ FileInputStream fis = new FileInputStream(file);
+ inputStream = fis;
+ return fis;
}
return super.streamContent();
}
Modified: trunk/java/org/apache/naming/resources/WARDirContext.java
===================================================================
--- trunk/java/org/apache/naming/resources/WARDirContext.java 2010-03-08 23:07:34 UTC (rev 1403)
+++ trunk/java/org/apache/naming/resources/WARDirContext.java 2010-03-09 13:55:51 UTC (rev 1404)
@@ -938,7 +938,9 @@
throws IOException {
try {
if (binaryContent == null) {
- inputStream = base.getInputStream(entry);
+ InputStream is = base.getInputStream(entry);
+ inputStream = is;
+ return is;
}
} catch (ZipException e) {
throw new IOException(e.getMessage());
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2010-03-08 23:07:34 UTC (rev 1403)
+++ trunk/webapps/docs/changelog.xml 2010-03-09 13:55:51 UTC (rev 1404)
@@ -34,6 +34,9 @@
<fix>
<bug>48589</bug>: JNDI realm extensibility. (markt)
</fix>
+ <fix>
+ <bug>48760</bug>: Fix possible race condition reading resources. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
14 years, 1 month
JBossWeb SVN: r1403 - in branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache: catalina/startup and 1 other directories.
by jbossweb-commits@lists.jboss.org
Author: mmillson
Date: 2010-03-08 18:07:34 -0500 (Mon, 08 Mar 2010)
New Revision: 1403
Modified:
branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/loader/LocalStrings.properties
branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/loader/WebappClassLoader.java
branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/ContextConfig.java
branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/ExpandWar.java
branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/HostConfig.java
branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/LocalStrings.properties
branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/tomcat/util/net/jsse/JSSESupport.java
Log:
Fix CVE-2009-2693, CVE-2009-2901, CVE-2009-2902, CVE-2009-3555 for [JBPAPP-3848].
Modified: branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/loader/LocalStrings.properties
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/loader/LocalStrings.properties 2010-03-08 22:04:08 UTC (rev 1402)
+++ branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/loader/LocalStrings.properties 2010-03-08 23:07:34 UTC (rev 1403)
@@ -13,7 +13,9 @@
standardLoader.removeRepository=Removing repository {0}
standardLoader.starting=Starting this Loader
standardLoader.stopping=Stopping this Loader
+webappClassLoader.illegalJarPath=Illegal JAR entry detected with name {0}
webappClassLoader.stopped=Illegal access: this web application instance has been stopped already. Could not load {0}. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
+webappClassLoader.validationErrorJarPath=Unable to validate JAR entry with name {0}
webappLoader.addRepository=Adding repository {0}
webappLoader.deploy=Deploying class repositories to work directory {0}
webappLoader.jarDeploy=Deploy JAR {0} to {1}
Modified: branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/loader/WebappClassLoader.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/loader/WebappClassLoader.java 2010-03-08 22:04:08 UTC (rev 1402)
+++ branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/loader/WebappClassLoader.java 2010-03-08 23:07:34 UTC (rev 1403)
@@ -325,8 +325,8 @@
* Path where resources loaded from JARs will be extracted.
*/
protected File loaderDir = null;
+ protected String canonicalLoaderDir = null;
-
/**
* The PermissionCollection for each CodeSource for a web
* application context.
@@ -518,6 +518,18 @@
*/
public void setWorkDir(File workDir) {
this.loaderDir = new File(workDir, "loader");
+ if (loaderDir == null) {
+ canonicalLoaderDir = null;
+ } else {
+ try {
+ canonicalLoaderDir = loaderDir.getCanonicalPath();
+ if (!canonicalLoaderDir.endsWith(File.separator)) {
+ canonicalLoaderDir += File.separator;
+ }
+ } catch (IOException ioe) {
+ canonicalLoaderDir = null;
+ }
+ }
}
/**
@@ -2005,6 +2017,18 @@
(".class"))) {
resourceFile = new File
(loaderDir, jarEntry2.getName());
+ try {
+ if (!resourceFile.getCanonicalPath().startsWith(
+ canonicalLoaderDir)) {
+ throw new IllegalArgumentException(
+ sm.getString("webappClassLoader.illegalJarPath",
+ jarEntry2.getName()));
+ }
+ } catch (IOException ioe) {
+ throw new IllegalArgumentException(
+ sm.getString("webappClassLoader.validationErrorJarPath",
+ jarEntry2.getName()), ioe);
+ }
resourceFile.getParentFile().mkdirs();
FileOutputStream os = null;
InputStream is = null;
Modified: branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/ContextConfig.java 2010-03-08 22:04:08 UTC (rev 1402)
+++ branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/ContextConfig.java 2010-03-08 23:07:34 UTC (rev 1403)
@@ -874,9 +874,8 @@
if (contextPath.equals("")) {
contextPath = "ROOT";
} else {
- if (contextPath.lastIndexOf('/') > 0) {
- contextPath = "/" + contextPath.substring(1).replace('/','#');
- }
+ // Context path must start with '/'
+ contextPath = "/" + contextPath.substring(1).replace('/','#');
}
if (docBase.toLowerCase().endsWith(".war") && !file.isDirectory() && unpackWARs) {
URL war = new URL("jar:" + (new File(docBase)).toURI().toURL() + "!/");
@@ -886,19 +885,24 @@
if (context instanceof StandardContext) {
((StandardContext) context).setOriginalDocBase(origDocBase);
}
+ } else if (docBase.toLowerCase().endsWith(".war") &&
+ !file.isDirectory() && !unpackWARs) {
+ URL war =
+ new URL("jar:" + (new File (docBase)).toURI().toURL() + "!/");
+ ExpandWar.validate(host, war, contextPath);
} else {
File docDir = new File(docBase);
if (!docDir.exists()) {
File warFile = new File(docBase + ".war");
+ URL war = new URL("jar:" + warFile.toURI().toURL() + "!/");
if (warFile.exists()) {
if (unpackWARs) {
- URL war =
- new URL("jar:" + warFile.toURI().toURL() + "!/");
docBase = ExpandWar.expand(host, war, contextPath);
file = new File(docBase);
docBase = file.getCanonicalPath();
} else {
docBase = warFile.getCanonicalPath();
+ ExpandWar.validate(host, war, contextPath);
}
}
if (context instanceof StandardContext) {
@@ -1259,7 +1263,8 @@
if (!docBaseFile.isAbsolute()) {
docBaseFile = new File(appBase, docBase);
}
- ExpandWar.delete(docBaseFile);
+ // No need to log failure - it is expected in this case
+ ExpandWar.delete(docBaseFile, false);
}
ok = true;
Modified: branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/ExpandWar.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/ExpandWar.java 2010-03-08 22:04:08 UTC (rev 1402)
+++ branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/ExpandWar.java 2010-03-08 23:07:34 UTC (rev 1403)
@@ -105,7 +105,8 @@
* (must start with "jar:")
* @param pathname Context path name for web application
*
- * @exception IllegalArgumentException if this is not a "jar:" URL
+ * @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
*/
@@ -123,6 +124,7 @@
(sm.getString("hostConfig.appBase",
appBase.getAbsolutePath()));
}
+
File docBase = new File(appBase, pathname);
if (docBase.exists()) {
// War file is already installed
@@ -133,16 +135,29 @@
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,
@@ -155,21 +170,24 @@
input = jarFile.getInputStream(jarEntry);
// Bugzilla 33636
- File expandedFile = expand(input, docBase, name);
+ expand(input, expandedFile);
long lastModified = jarEntry.getTime();
- if ((lastModified != -1) && (lastModified != 0) && (expandedFile != null)) {
+ if ((lastModified != -1) && (lastModified != 0)) {
expandedFile.setLastModified(lastModified);
}
input.close();
input = null;
}
+ success = true;
} catch (IOException e) {
- // If something went wrong, delete expanded dir to keep things
- // clean
- deleteDir(docBase);
throw e;
} finally {
+ if (!success) {
+ // If something went wrong, delete expanded dir to keep things
+ // clean
+ deleteDir(docBase);
+ }
if (input != null) {
try {
input.close();
@@ -195,6 +213,69 @@
/**
+ * 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
@@ -254,27 +335,62 @@
/**
* Delete the specified directory, including all of its contents and
- * subdirectories recursively.
+ * sub-directories recursively. Any failure will be logged.
*
* @param dir File object representing the directory to be deleted
*/
public static boolean delete(File dir) {
+ // Log failure by default
+ return delete(dir, true);
+ }
+
+ /**
+ * Delete the specified directory, including all of its contents and
+ * sub-directories recursively.
+ *
+ * @param dir File object representing the directory to be deleted
+ * @param logFailure <code>true</code> if failure to delete the resource
+ * should be logged
+ */
+ public static boolean delete(File dir, boolean logFailure) {
+ boolean result;
if (dir.isDirectory()) {
- return deleteDir(dir);
+ result = deleteDir(dir, logFailure);
} else {
- return dir.delete();
+ if (dir.exists()) {
+ result = dir.delete();
+ } else {
+ result = true;
+ }
}
+ if (logFailure && !result) {
+ log.error(sm.getString(
+ "expandWar.deleteFailed", dir.getAbsolutePath()));
+ }
+ return result;
}
/**
* Delete the specified directory, including all of its contents and
- * subdirectories recursively.
+ * sub-directories recursively. Any failure will be logged.
*
* @param dir File object representing the directory to be deleted
*/
public static boolean deleteDir(File dir) {
+ return deleteDir(dir, true);
+ }
+ /**
+ * Delete the specified directory, including all of its contents and
+ * sub-directories recursively.
+ *
+ * @param dir File object representing the directory to be deleted
+ * @param logFailure <code>true</code> if failure to delete the resource
+ * should be logged
+ */
+ public static boolean deleteDir(File dir, boolean logFailure) {
+
String files[] = dir.list();
if (files == null) {
files = new String[0];
@@ -282,13 +398,26 @@
for (int i = 0; i < files.length; i++) {
File file = new File(dir, files[i]);
if (file.isDirectory()) {
- deleteDir(file);
+ deleteDir(file, logFailure);
} else {
file.delete();
}
}
- return dir.delete();
+ boolean result;
+ if (dir.exists()) {
+ result = dir.delete();
+ } else {
+ result = true;
+ }
+
+ if (logFailure && !result) {
+ log.error(sm.getString(
+ "expandWar.deleteFailed", dir.getAbsolutePath()));
+ }
+
+ return result;
+
}
@@ -302,11 +431,27 @@
* @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;
+ }
- File file = new File(docBase, name);
+
+ /**
+ * 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 =
@@ -327,8 +472,6 @@
}
}
}
-
- return file;
}
Modified: branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/HostConfig.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/HostConfig.java 2010-03-08 22:04:08 UTC (rev 1402)
+++ branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/HostConfig.java 2010-03-08 23:07:34 UTC (rev 1403)
@@ -26,7 +26,9 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -149,6 +151,11 @@
*/
protected static Digester digester = createDigester();
+ /**
+ * The list of Wars in the appBase to be ignored because they are invalid
+ * (e.g. contain /../ sequences).
+ */
+ protected Set<String> invalidWars = new HashSet<String>();
// ------------------------------------------------------------- Properties
@@ -696,13 +703,23 @@
if (files[i].equalsIgnoreCase("WEB-INF"))
continue;
File dir = new File(appBase, files[i]);
- if (files[i].toLowerCase().endsWith(".war")) {
+ if (files[i].toLowerCase().endsWith(".war") && dir.isFile()
+ && !invalidWars.contains(files[i]) ) {
// Calculate the context path and make sure it is unique
String contextPath = "/" + files[i].replace('#','/');
int period = contextPath.lastIndexOf(".");
if (period >= 0)
contextPath = contextPath.substring(0, period);
+
+ // Check for WARs with /../ /./ or similar sequences in the name
+ if (!validateContextPath(appBase, contextPath)) {
+ log.error(sm.getString(
+ "hostConfig.illegalWarName", files[i]));
+ invalidWars.add(files[i]);
+ continue;
+ }
+
if (contextPath.equals("/ROOT"))
contextPath = "";
@@ -720,6 +737,42 @@
}
+ private boolean validateContextPath(File appBase, String contextPath) {
+ // More complicated than the ideal as the canonical path may or may
+ // not end with File.separator for a directory
+
+ StringBuilder docBase;
+ String canonicalDocBase = null;
+
+ try {
+ String canonicalAppBase = appBase.getCanonicalPath();
+ docBase = new StringBuilder(canonicalAppBase);
+ if (canonicalAppBase.endsWith(File.separator)) {
+ docBase.append(contextPath.substring(1).replace(
+ '/', File.separatorChar));
+ } else {
+ docBase.append(contextPath.replace('/', File.separatorChar));
+ }
+ // At this point docBase should be canonical but will not end
+ // with File.separator
+
+ canonicalDocBase =
+ (new File(docBase.toString())).getCanonicalPath();
+
+ // If the canonicalDocBase ends with File.separator, add one to
+ // docBase before they are compared
+ if (canonicalDocBase.endsWith(File.separator)) {
+ docBase.append(File.separator);
+ }
+ } catch (IOException ioe) {
+ return false;
+ }
+
+ // Compare the two. If they are not the same, the contextPath must
+ // have /../ like sequences in it
+ return canonicalDocBase.equals(docBase.toString());
+ }
+
/**
* @param contextPath
* @param dir
Modified: branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/LocalStrings.properties
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/LocalStrings.properties 2010-03-08 22:04:08 UTC (rev 1402)
+++ branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/catalina/startup/LocalStrings.properties 2010-03-08 23:07:34 UTC (rev 1403)
@@ -42,6 +42,8 @@
engineConfig.start=EngineConfig: Processing START
engineConfig.stop=EngineConfig: Processing STOP
expandWar.copy=Error copying {0} to {1}
+expandWar.deleteFailed=[{0}] could not be completely deleted. The presence of the remaining files may cause problems
+expandWar.illegalPath=The archive [{0}] is malformed and will be ignored: an entry contains an illegal path [{1}]
hostConfig.appBase=Application base directory {0} does not exist
hostConfig.canonicalizing=Error delete redeploy resources from context [{0}]
hostConfig.cce=Lifecycle event data object {0} is not a Host
@@ -61,6 +63,7 @@
hostConfig.expand=Expanding web application archive {0}
hostConfig.expand.error=Exception while expanding web application archive {0}
hostConfig.expanding=Expanding discovered web application archives
+hostConfig.illegalWarName=The war name [{0}] is invalid. The archive will be ignored.
hostConfig.jmx.register=Register context [{0}] failed
hostConfig.jmx.unregister=Unregister context [{0}] failed
hostConfig.reload=Reloading context [{0}]
Modified: branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java 2010-03-08 22:04:08 UTC (rev 1402)
+++ branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/tomcat/util/net/jsse/JSSESocketFactory.java 2010-03-08 23:07:34 UTC (rev 1403)
@@ -42,6 +42,8 @@
import java.util.Vector;
import javax.net.ssl.CertPathTrustManagerParameters;
+import javax.net.ssl.HandshakeCompletedEvent;
+import javax.net.ssl.HandshakeCompletedListener;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.ManagerFactoryParameters;
@@ -95,6 +97,7 @@
protected String clientAuth = "false";
protected SSLServerSocketFactory sslProxy = null;
protected String[] enabledCiphers;
+ protected boolean allowUnsafeLegacyRenegotiation = false;
/**
* Flag to state that we require client authentication.
@@ -145,13 +148,36 @@
SSLSocket asock = null;
try {
asock = (SSLSocket)socket.accept();
+ if (!allowUnsafeLegacyRenegotiation) {
+ asock.addHandshakeCompletedListener(
+ new DisableSslRenegotiation());
+ }
configureClientAuth(asock);
} catch (SSLException e){
throw new SocketException("SSL handshake error" + e.toString());
}
return asock;
}
+
+ private static class DisableSslRenegotiation
+ implements HandshakeCompletedListener {
+ private volatile boolean completed = false;
+ public void handshakeCompleted(HandshakeCompletedEvent event) {
+ if (completed) {
+ try {
+ log.warn("SSL renegotiation is disabled, closing connection");
+ event.getSession().invalidate();
+ event.getSocket().close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ completed = true;
+ }
+ }
+
+
public void handshake(Socket sock) throws IOException {
((SSLSocket)sock).startHandshake();
}
Modified: branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/tomcat/util/net/jsse/JSSESupport.java
===================================================================
--- branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/tomcat/util/net/jsse/JSSESupport.java 2010-03-08 22:04:08 UTC (rev 1402)
+++ branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/src/share/classes/org/apache/tomcat/util/net/jsse/JSSESupport.java 2010-03-08 23:07:34 UTC (rev 1403)
@@ -170,7 +170,10 @@
break;
}
}
- ssl.setSoTimeout(oldTimeout);
+ // If legacy re-negotiation is disabled, socked could be closed here
+ if (!ssl.isClosed()) {
+ ssl.setSoTimeout(oldTimeout);
+ }
if (listener.completed == false) {
throw new SocketException("SSL Cert handshake timeout");
}
14 years, 2 months
JBossWeb SVN: r1402 - branches.
by jbossweb-commits@lists.jboss.org
Author: mmillson
Date: 2010-03-08 17:04:08 -0500 (Mon, 08 Mar 2010)
New Revision: 1402
Added:
branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848/
Log:
Create JBPAPP-3848 patch branch from JBOSSWEB_2_0_0_GA_CP12 tag
Copied: branches/JBOSSWEB_2_0_0_GA_CP12_JBPAPP-3848 (from rev 1401, tags/JBOSSWEB_2_0_0_GA_CP12)
14 years, 2 months
JBossWeb SVN: r1401 - trunk.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-03-08 14:48:54 -0500 (Mon, 08 Mar 2010)
New Revision: 1401
Modified:
trunk/PATCHES.txt
Log:
- Add some explicitly dropped patches.
Modified: trunk/PATCHES.txt
===================================================================
--- trunk/PATCHES.txt 2010-03-08 15:36:09 UTC (rev 1400)
+++ trunk/PATCHES.txt 2010-03-08 19:48:54 UTC (rev 1401)
@@ -83,3 +83,9 @@
890139
EL coercion patch
+
+918851 919914 920055 920110
+Parser changes to "fix" EL processing when EL is disabled, likely to cause regressions
+
+920449
+Generating broken pages using included error pages
14 years, 2 months
JBossWeb SVN: r1400 - trunk/java/org/apache/catalina/core.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-03-08 10:36:09 -0500 (Mon, 08 Mar 2010)
New Revision: 1400
Modified:
trunk/java/org/apache/catalina/core/AprLifecycleListener.java
Log:
- Move to debug less useful start/stop messages.
Modified: trunk/java/org/apache/catalina/core/AprLifecycleListener.java
===================================================================
--- trunk/java/org/apache/catalina/core/AprLifecycleListener.java 2010-03-08 12:22:22 UTC (rev 1399)
+++ trunk/java/org/apache/catalina/core/AprLifecycleListener.java 2010-03-08 15:36:09 UTC (rev 1400)
@@ -178,17 +178,13 @@
TCN_RECOMMENDED_PV));
}
}
- if (!log.isDebugEnabled()) {
- log.info(sm.getString("aprListener.tcnValid", major + "."
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("aprListener.tcnValid", major + "."
+ minor + "." + patch));
+ // Log APR flags
+ log.debug(sm.getString("aprListener.flags", Library.APR_HAVE_IPV6, Library.APR_HAS_SENDFILE,
+ Library.APR_HAS_RANDOM));
}
- else {
- log.debug(sm.getString("aprListener.tcnValid", major + "."
- + minor + "." + patch));
- }
- // Log APR flags
- log.info(sm.getString("aprListener.flags", Library.APR_HAVE_IPV6, Library.APR_HAS_SENDFILE,
- Library.APR_HAS_RANDOM));
return true;
}
14 years, 2 months
JBossWeb SVN: r1399 - tags.
by jbossweb-commits@lists.jboss.org
Author: jfrederic.clere(a)jboss.com
Date: 2010-03-08 07:22:22 -0500 (Mon, 08 Mar 2010)
New Revision: 1399
Added:
tags/JBOSSWEB_2_0_0_GA_CP13/
Log:
For EAP 4.2 CP09 and EAP 4.3 CP08.
Copied: tags/JBOSSWEB_2_0_0_GA_CP13 (from rev 1398, branches/JBOSSWEB_2_0_0_GA_CP)
14 years, 2 months
JBossWeb SVN: r1398 - in trunk: webapps/docs and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2010-03-05 13:26:22 -0500 (Fri, 05 Mar 2010)
New Revision: 1398
Modified:
trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
trunk/webapps/docs/changelog.xml
Log:
- Revert.
Modified: trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
===================================================================
--- trunk/java/org/apache/coyote/http11/Http11AprProtocol.java 2010-03-05 16:30:48 UTC (rev 1397)
+++ trunk/java/org/apache/coyote/http11/Http11AprProtocol.java 2010-03-05 18:26:22 UTC (rev 1398)
@@ -101,7 +101,7 @@
public boolean hasIoEvents() {
- return !isSSLEnabled();
+ return true;
}
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2010-03-05 16:30:48 UTC (rev 1397)
+++ trunk/webapps/docs/changelog.xml 2010-03-05 18:26:22 UTC (rev 1398)
@@ -23,10 +23,6 @@
Add LDAP connection timeout in JNDI realm. (markt)
</fix>
<fix>
- <bug>48050</bug>: createSubcontext method returns Context with wrong name. Based on a
- suggestion by gingyang.xu. (markt)
- </fix>
- <fix>
<bug>48318</bug>: Handle unreadable resources in WebDAV. (markt)
</fix>
<fix>
14 years, 2 months