You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2024/02/04 16:37:52 UTC
(tomcat) branch 10.1.x updated (4dd2382e29 -> ee7012fd35)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a change to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
from 4dd2382e29 Remove unused code
new c43c667944 Format clean-ups
new 341c308a7d Remove unused code
new 5184bc57af Code clean-up - formatting. No functional change.
new ee7012fd35 Align with 11.0.x
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
java/org/apache/catalina/startup/Bootstrap.java | 98 +-
java/org/apache/catalina/startup/Catalina.java | 220 ++--
.../catalina/startup/CatalinaProperties.java | 4 +-
.../catalina/startup/CertificateCreateRule.java | 11 +-
.../catalina/startup/ClassLoaderFactory.java | 131 +--
.../catalina/startup/ConnectorCreateRule.java | 35 +-
java/org/apache/catalina/startup/Constants.java | 20 +-
.../org/apache/catalina/startup/ContextConfig.java | 664 +++++-------
.../apache/catalina/startup/ContextRuleSet.java | 191 ++--
.../startup/CopyParentClassLoaderRule.java | 15 +-
.../catalina/startup/CredentialHandlerRuleSet.java | 38 +-
java/org/apache/catalina/startup/EngineConfig.java | 10 +-
.../org/apache/catalina/startup/EngineRuleSet.java | 74 +-
java/org/apache/catalina/startup/ExpandWar.java | 105 +-
.../org/apache/catalina/startup/FailedContext.java | 1096 +++++++++++++++-----
.../apache/catalina/startup/HomesUserDatabase.java | 5 +-
java/org/apache/catalina/startup/HostConfig.java | 393 +++----
java/org/apache/catalina/startup/HostRuleSet.java | 79 +-
.../catalina/startup/LifecycleListenerRule.java | 33 +-
.../catalina/startup/ListenerCreateRule.java | 19 +-
.../org/apache/catalina/startup/NamingRuleSet.java | 64 +-
.../catalina/startup/PasswdUserDatabase.java | 4 +-
java/org/apache/catalina/startup/RealmRuleSet.java | 31 +-
.../startup/SafeForkJoinWorkerThreadFactory.java | 8 +-
.../apache/catalina/startup/SetNextNamingRule.java | 32 +-
java/org/apache/catalina/startup/Tomcat.java | 547 +++++-----
java/org/apache/catalina/startup/Tool.java | 80 +-
java/org/apache/catalina/startup/UserConfig.java | 32 +-
java/org/apache/catalina/startup/UserDatabase.java | 3 +-
.../catalina/startup/VersionLoggerListener.java | 49 +-
.../apache/catalina/startup/WebAnnotationSet.java | 152 +--
.../catalina/startup/WebappServiceLoader.java | 44 +-
32 files changed, 2108 insertions(+), 2179 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 02/04: Remove unused code
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 341c308a7db6d7d2b86ffc4f0711af8e1bfcfa16
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sun Feb 4 16:08:20 2024 +0000
Remove unused code
---
.../apache/catalina/startup/WebAnnotationSet.java | 70 ----------------------
1 file changed, 70 deletions(-)
diff --git a/java/org/apache/catalina/startup/WebAnnotationSet.java b/java/org/apache/catalina/startup/WebAnnotationSet.java
index a7cf7de6fc..02273443de 100644
--- a/java/org/apache/catalina/startup/WebAnnotationSet.java
+++ b/java/org/apache/catalina/startup/WebAnnotationSet.java
@@ -182,76 +182,6 @@ public class WebAnnotationSet {
addResource(context, resource);
}
}
- /* Process EJB annotation.
- * Ref JSR 224, equivalent to the ejb-ref or ejb-local-ref
- * element in the deployment descriptor.
- {
- EJB annotation = clazz.getAnnotation(EJB.class);
- if (annotation != null) {
-
- 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
- {
- WebServiceRef annotation = clazz
- .getAnnotation(WebServiceRef.class);
- if (annotation != null) {
- 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
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 03/04: Code clean-up - formatting. No functional change.
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 5184bc57af1c088388ae3f8d2813109431251aeb
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sun Feb 4 16:36:49 2024 +0000
Code clean-up - formatting. No functional change.
---
java/org/apache/catalina/startup/Bootstrap.java | 98 +-
java/org/apache/catalina/startup/Catalina.java | 220 ++--
.../catalina/startup/CatalinaProperties.java | 4 +-
.../catalina/startup/CertificateCreateRule.java | 11 +-
.../catalina/startup/ClassLoaderFactory.java | 131 +--
.../catalina/startup/ConnectorCreateRule.java | 35 +-
java/org/apache/catalina/startup/Constants.java | 20 +-
.../org/apache/catalina/startup/ContextConfig.java | 658 +++++-------
.../apache/catalina/startup/ContextRuleSet.java | 191 ++--
.../startup/CopyParentClassLoaderRule.java | 15 +-
.../catalina/startup/CredentialHandlerRuleSet.java | 38 +-
java/org/apache/catalina/startup/EngineConfig.java | 10 +-
.../org/apache/catalina/startup/EngineRuleSet.java | 74 +-
java/org/apache/catalina/startup/ExpandWar.java | 105 +-
.../org/apache/catalina/startup/FailedContext.java | 1096 +++++++++++++++-----
.../apache/catalina/startup/HomesUserDatabase.java | 5 +-
java/org/apache/catalina/startup/HostConfig.java | 383 +++----
java/org/apache/catalina/startup/HostRuleSet.java | 79 +-
.../catalina/startup/LifecycleListenerRule.java | 33 +-
.../catalina/startup/ListenerCreateRule.java | 19 +-
.../org/apache/catalina/startup/NamingRuleSet.java | 64 +-
.../catalina/startup/PasswdUserDatabase.java | 4 +-
java/org/apache/catalina/startup/RealmRuleSet.java | 31 +-
.../startup/SafeForkJoinWorkerThreadFactory.java | 8 +-
.../apache/catalina/startup/SetNextNamingRule.java | 29 +-
java/org/apache/catalina/startup/Tomcat.java | 547 +++++-----
java/org/apache/catalina/startup/Tool.java | 78 +-
java/org/apache/catalina/startup/UserConfig.java | 32 +-
java/org/apache/catalina/startup/UserDatabase.java | 3 +-
.../catalina/startup/VersionLoggerListener.java | 49 +-
.../apache/catalina/startup/WebAnnotationSet.java | 82 +-
.../catalina/startup/WebappServiceLoader.java | 44 +-
32 files changed, 2094 insertions(+), 2102 deletions(-)
diff --git a/java/org/apache/catalina/startup/Bootstrap.java b/java/org/apache/catalina/startup/Bootstrap.java
index edf2ea81e5..cbd1424b09 100644
--- a/java/org/apache/catalina/startup/Bootstrap.java
+++ b/java/org/apache/catalina/startup/Bootstrap.java
@@ -36,13 +36,11 @@ import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
/**
- * Bootstrap 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.
+ * Bootstrap 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
@@ -105,8 +103,7 @@ public final class Bootstrap {
}
catalinaHomeFile = homeFile;
- System.setProperty(
- Constants.CATALINA_HOME_PROP, catalinaHomeFile.getPath());
+ System.setProperty(Constants.CATALINA_HOME_PROP, catalinaHomeFile.getPath());
// Then base
String base = System.getProperty(Constants.CATALINA_BASE_PROP);
@@ -121,8 +118,7 @@ public final class Bootstrap {
}
catalinaBaseFile = baseFile;
}
- System.setProperty(
- Constants.CATALINA_BASE_PROP, catalinaBaseFile.getPath());
+ System.setProperty(Constants.CATALINA_BASE_PROP, catalinaBaseFile.getPath());
}
// -------------------------------------------------------------- Variables
@@ -185,8 +181,7 @@ public final class Bootstrap {
// Local repository
if (repository.endsWith("*.jar")) {
- repository = repository.substring
- (0, repository.length() - "*.jar".length());
+ repository = repository.substring(0, repository.length() - "*.jar".length());
repositories.add(new Repository(repository, RepositoryType.GLOB));
} else if (repository.endsWith(".jar")) {
repositories.add(new Repository(repository, RepositoryType.JAR));
@@ -203,6 +198,7 @@ public final class Bootstrap {
* System property replacement in the given string.
*
* @param str The original string
+ *
* @return the modified string
*/
protected String replace(String str) {
@@ -247,6 +243,7 @@ public final class Bootstrap {
/**
* Initialize daemon.
+ *
* @throws Exception Fatal initialization error
*/
public void init() throws Exception {
@@ -273,8 +270,7 @@ public final class Bootstrap {
paramTypes[0] = Class.forName("java.lang.ClassLoader");
Object paramValues[] = new Object[1];
paramValues[0] = sharedLoader;
- Method method =
- startupInstance.getClass().getMethod(methodName, paramTypes);
+ Method method = startupInstance.getClass().getMethod(methodName, paramTypes);
method.invoke(startupInstance, paramValues);
catalinaDaemon = startupInstance;
@@ -290,7 +286,7 @@ public final class Bootstrap {
String methodName = "load";
Object param[];
Class<?> paramTypes[];
- if (arguments==null || arguments.length==0) {
+ if (arguments == null || arguments.length == 0) {
paramTypes = null;
param = null;
} else {
@@ -299,8 +295,7 @@ public final class Bootstrap {
param = new Object[1];
param[0] = arguments;
}
- Method method =
- catalinaDaemon.getClass().getMethod(methodName, paramTypes);
+ Method method = catalinaDaemon.getClass().getMethod(methodName, paramTypes);
if (log.isDebugEnabled()) {
log.debug("Calling startup class " + method);
}
@@ -324,7 +319,9 @@ public final class Bootstrap {
/**
* Load the Catalina daemon.
+ *
* @param arguments Initialization arguments
+ *
* @throws Exception Fatal initialization error
*/
public void init(String[] arguments) throws Exception {
@@ -336,6 +333,7 @@ public final class Bootstrap {
/**
* Start the Catalina daemon.
+ *
* @throws Exception Fatal start error
*/
public void start() throws Exception {
@@ -343,36 +341,39 @@ public final class Bootstrap {
init();
}
- Method method = catalinaDaemon.getClass().getMethod("start", (Class [])null);
- method.invoke(catalinaDaemon, (Object [])null);
+ Method method = catalinaDaemon.getClass().getMethod("start", (Class[]) null);
+ method.invoke(catalinaDaemon, (Object[]) null);
}
/**
* Stop the Catalina Daemon.
+ *
* @throws Exception Fatal stop error
*/
public void stop() throws Exception {
- Method method = catalinaDaemon.getClass().getMethod("stop", (Class []) null);
- method.invoke(catalinaDaemon, (Object []) null);
+ Method method = catalinaDaemon.getClass().getMethod("stop", (Class[]) null);
+ method.invoke(catalinaDaemon, (Object[]) null);
}
/**
* Stop the standalone server.
+ *
* @throws Exception Fatal stop error
*/
public void stopServer() throws Exception {
- Method method =
- catalinaDaemon.getClass().getMethod("stopServer", (Class []) null);
- method.invoke(catalinaDaemon, (Object []) null);
+ Method method = catalinaDaemon.getClass().getMethod("stopServer", (Class[]) null);
+ method.invoke(catalinaDaemon, (Object[]) null);
}
- /**
+ /**
* Stop the standalone server.
+ *
* @param arguments Command line arguments
+ *
* @throws Exception Fatal stop error
*/
public void stopServer(String[] arguments) throws Exception {
@@ -388,35 +389,33 @@ public final class Bootstrap {
param = new Object[1];
param[0] = arguments;
}
- Method method =
- catalinaDaemon.getClass().getMethod("stopServer", paramTypes);
+ Method method = catalinaDaemon.getClass().getMethod("stopServer", paramTypes);
method.invoke(catalinaDaemon, param);
}
/**
* Set flag.
+ *
* @param await <code>true</code> if the daemon should block
+ *
* @throws Exception Reflection error
*/
- public void setAwait(boolean await)
- throws Exception {
+ public void setAwait(boolean await) throws Exception {
Class<?> paramTypes[] = new Class[1];
paramTypes[0] = Boolean.TYPE;
Object paramValues[] = new Object[1];
paramValues[0] = Boolean.valueOf(await);
- Method method =
- catalinaDaemon.getClass().getMethod("setAwait", paramTypes);
+ 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);
+ Method method = catalinaDaemon.getClass().getMethod("getAwait", paramTypes);
+ Boolean b = (Boolean) method.invoke(catalinaDaemon, paramValues);
return b.booleanValue();
}
@@ -432,8 +431,7 @@ public final class Bootstrap {
/**
- * Main method and entry point when starting Tomcat via the provided
- * scripts.
+ * Main method and entry point when starting Tomcat via the provided scripts.
*
* @param args Command line arguments to be processed
*/
@@ -492,8 +490,7 @@ public final class Bootstrap {
}
} catch (Throwable t) {
// Unwrap the Exception for clearer error reporting
- if (t instanceof InvocationTargetException &&
- t.getCause() != null) {
+ if (t instanceof InvocationTargetException && t.getCause() != null) {
t = t.getCause();
}
handleThrowable(t);
@@ -504,8 +501,9 @@ public final class Bootstrap {
/**
- * Obtain the name of configured home (binary) directory. Note that home and
- * base may be the same (and are by default).
+ * Obtain the name of configured home (binary) directory. Note that home and base may be the same (and are by
+ * default).
+ *
* @return the catalina home
*/
public static String getCatalinaHome() {
@@ -514,9 +512,9 @@ public final class Bootstrap {
/**
- * Obtain the name of the configured base (instance) directory. Note that
- * home and base may be the same (and are by default). If this is not set
- * the value returned by {@link #getCatalinaHome()} will be used.
+ * Obtain the name of the configured base (instance) directory. Note that home and base may be the same (and are by
+ * default). If this is not set the value returned by {@link #getCatalinaHome()} will be used.
+ *
* @return the catalina base
*/
public static String getCatalinaBase() {
@@ -525,8 +523,8 @@ public final class Bootstrap {
/**
- * Obtain the configured home (binary) directory. Note that home and
- * base may be the same (and are by default).
+ * Obtain the configured home (binary) directory. Note that home and base may be the same (and are by default).
+ *
* @return the catalina home as a file
*/
public static File getCatalinaHomeFile() {
@@ -535,9 +533,9 @@ public final class Bootstrap {
/**
- * Obtain the configured base (instance) directory. Note that
- * home and base may be the same (and are by default). If this is not set
- * the value returned by {@link #getCatalinaHomeFile()} will be used.
+ * Obtain the configured base (instance) directory. Note that home and base may be the same (and are by default). If
+ * this is not set the value returned by {@link #getCatalinaHomeFile()} will be used.
+ *
* @return the catalina base as a file
*/
public static File getCatalinaBaseFile() {
@@ -597,7 +595,7 @@ public final class Bootstrap {
// been configured.
throw new IllegalArgumentException(
"The double quote [\"] character can only be used to quote paths. It must " +
- "not appear in a path. This loader path is not valid: [" + value + "]");
+ "not appear in a path. This loader path is not valid: [" + value + "]");
} else {
// Not quoted - NO-OP
}
diff --git a/java/org/apache/catalina/startup/Catalina.java b/java/org/apache/catalina/startup/Catalina.java
index 9d0223df02..49b4504d9a 100644
--- a/java/org/apache/catalina/startup/Catalina.java
+++ b/java/org/apache/catalina/startup/Catalina.java
@@ -55,18 +55,16 @@ import org.xml.sax.InputSource;
/**
- * Startup/Shutdown shell program for Catalina. The following command line
- * options are recognized:
+ * Startup/Shutdown shell program for Catalina. The following command line options are recognized:
* <ul>
- * <li><b>-config {pathname}</b> - Set the pathname of the configuration file
- * to be processed. If a relative path is specified, it will be
- * interpreted as relative to the directory pathname specified by the
- * "catalina.base" system property. [conf/server.xml]</li>
- * <li><b>-help</b> - Display usage information.</li>
- * <li><b>-nonaming</b> - Disable naming support.</li>
+ * <li><b>-config {pathname}</b> - Set the pathname of the configuration file to be processed. If a relative path is
+ * specified, it will be interpreted as relative to the directory pathname specified by the "catalina.base" system
+ * property. [conf/server.xml]</li>
+ * <li><b>-help</b> - Display usage information.</li>
+ * <li><b>-nonaming</b> - Disable naming support.</li>
* <li><b>configtest</b> - Try to test the config</li>
- * <li><b>start</b> - Start an instance of Catalina.</li>
- * <li><b>stop</b> - Stop the currently running instance of Catalina.</li>
+ * <li><b>start</b> - Start an instance of Catalina.</li>
+ * <li><b>stop</b> - Stop the currently running instance of Catalina.</li>
* </ul>
*
* @author Craig R. McClanahan
@@ -78,8 +76,7 @@ public class Catalina {
/**
* The string manager for this package.
*/
- protected static final StringManager sm =
- StringManager.getManager(Constants.Package);
+ protected static final StringManager sm = StringManager.getManager(Constants.Package);
public static final String SERVER_XML = "conf/server.xml";
@@ -99,8 +96,7 @@ public class Catalina {
/**
* The shared extensions class loader for this server.
*/
- protected ClassLoader parentClassLoader =
- Catalina.class.getClassLoader();
+ protected ClassLoader parentClassLoader = Catalina.class.getClassLoader();
/**
@@ -136,8 +132,7 @@ public class Catalina {
/**
* Rethrow exceptions on init failure.
*/
- protected boolean throwOnInitFailure =
- Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE");
+ protected boolean throwOnInitFailure = Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE");
/**
@@ -241,8 +236,7 @@ public class Catalina {
/**
- * @return <code>true</code> if an exception should be thrown if an error
- * occurs during server init
+ * @return <code>true</code> if an exception should be thrown if an error occurs during server init
*/
public boolean getThrowOnInitFailure() {
return throwOnInitFailure;
@@ -251,6 +245,7 @@ public class Catalina {
/**
* Set the behavior regarding errors that could occur during server init.
+ *
* @param throwOnInitFailure the new flag value
*/
public void setThrowOnInitFailure(boolean throwOnInitFailure) {
@@ -316,6 +311,7 @@ public class Catalina {
* Process the specified command line arguments.
*
* @param args Command line arguments to process
+ *
* @return <code>true</code> if we should continue processing
*/
protected boolean arguments(String args[]) {
@@ -370,6 +366,7 @@ public class Catalina {
/**
* Return a File object representing our configuration file.
+ *
* @return the main configuration file
*/
protected File configFile() {
@@ -385,6 +382,7 @@ public class Catalina {
/**
* Create and configure the Digester we will be using for startup.
+ *
* @return the main digester to parse server.xml
*/
protected Digester createStartDigester() {
@@ -392,7 +390,7 @@ public class Catalina {
Digester digester = new Digester();
digester.setValidating(false);
digester.setRulesValidation(true);
- Map<Class<?>, List<String>> fakeAttributes = new HashMap<>();
+ Map<Class<?>,List<String>> fakeAttributes = new HashMap<>();
// Ignore className on all elements
List<String> objectAttrs = new ArrayList<>();
objectAttrs.add("className");
@@ -409,107 +407,75 @@ public class Catalina {
digester.setUseContextClassLoader(true);
// Configure the actions we will be using
- digester.addObjectCreate("Server",
- "org.apache.catalina.core.StandardServer",
- "className");
+ digester.addObjectCreate("Server", "org.apache.catalina.core.StandardServer", "className");
digester.addSetProperties("Server");
- digester.addSetNext("Server",
- "setServer",
- "org.apache.catalina.Server");
+ digester.addSetNext("Server", "setServer", "org.apache.catalina.Server");
- digester.addObjectCreate("Server/GlobalNamingResources",
- "org.apache.catalina.deploy.NamingResourcesImpl");
+ digester.addObjectCreate("Server/GlobalNamingResources", "org.apache.catalina.deploy.NamingResourcesImpl");
digester.addSetProperties("Server/GlobalNamingResources");
- digester.addSetNext("Server/GlobalNamingResources",
- "setGlobalNamingResources",
- "org.apache.catalina.deploy.NamingResourcesImpl");
+ digester.addSetNext("Server/GlobalNamingResources", "setGlobalNamingResources",
+ "org.apache.catalina.deploy.NamingResourcesImpl");
- digester.addRule("Server/Listener",
- new ListenerCreateRule(null, "className"));
+ digester.addRule("Server/Listener", new ListenerCreateRule(null, "className"));
digester.addSetProperties("Server/Listener");
- digester.addSetNext("Server/Listener",
- "addLifecycleListener",
- "org.apache.catalina.LifecycleListener");
+ digester.addSetNext("Server/Listener", "addLifecycleListener", "org.apache.catalina.LifecycleListener");
- digester.addObjectCreate("Server/Service",
- "org.apache.catalina.core.StandardService",
- "className");
+ digester.addObjectCreate("Server/Service", "org.apache.catalina.core.StandardService", "className");
digester.addSetProperties("Server/Service");
- digester.addSetNext("Server/Service",
- "addService",
- "org.apache.catalina.Service");
+ digester.addSetNext("Server/Service", "addService", "org.apache.catalina.Service");
- digester.addObjectCreate("Server/Service/Listener",
- null, // MUST be specified in the element
- "className");
+ 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.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.addSetNext("Server/Service/Executor", "addExecutor", "org.apache.catalina.Executor");
- digester.addRule("Server/Service/Connector",
- new ConnectorCreateRule());
+ digester.addRule("Server/Service/Connector", new ConnectorCreateRule());
digester.addSetProperties("Server/Service/Connector",
- new String[]{"executor", "sslImplementationName", "protocol"});
- digester.addSetNext("Server/Service/Connector",
- "addConnector",
- "org.apache.catalina.connector.Connector");
+ new String[] { "executor", "sslImplementationName", "protocol" });
+ digester.addSetNext("Server/Service/Connector", "addConnector", "org.apache.catalina.connector.Connector");
digester.addRule("Server/Service/Connector", new AddPortOffsetRule());
- digester.addObjectCreate("Server/Service/Connector/SSLHostConfig",
- "org.apache.tomcat.util.net.SSLHostConfig");
+ digester.addObjectCreate("Server/Service/Connector/SSLHostConfig", "org.apache.tomcat.util.net.SSLHostConfig");
digester.addSetProperties("Server/Service/Connector/SSLHostConfig");
- digester.addSetNext("Server/Service/Connector/SSLHostConfig",
- "addSslHostConfig",
+ digester.addSetNext("Server/Service/Connector/SSLHostConfig", "addSslHostConfig",
"org.apache.tomcat.util.net.SSLHostConfig");
- digester.addRule("Server/Service/Connector/SSLHostConfig/Certificate",
- new CertificateCreateRule());
- digester.addSetProperties("Server/Service/Connector/SSLHostConfig/Certificate", new String[]{"type"});
- digester.addSetNext("Server/Service/Connector/SSLHostConfig/Certificate",
- "addCertificate",
- "org.apache.tomcat.util.net.SSLHostConfigCertificate");
+ digester.addRule("Server/Service/Connector/SSLHostConfig/Certificate", new CertificateCreateRule());
+ digester.addSetProperties("Server/Service/Connector/SSLHostConfig/Certificate", new String[] { "type" });
+ digester.addSetNext("Server/Service/Connector/SSLHostConfig/Certificate", "addCertificate",
+ "org.apache.tomcat.util.net.SSLHostConfigCertificate");
digester.addObjectCreate("Server/Service/Connector/SSLHostConfig/OpenSSLConf",
- "org.apache.tomcat.util.net.openssl.OpenSSLConf");
+ "org.apache.tomcat.util.net.openssl.OpenSSLConf");
digester.addSetProperties("Server/Service/Connector/SSLHostConfig/OpenSSLConf");
- digester.addSetNext("Server/Service/Connector/SSLHostConfig/OpenSSLConf",
- "setOpenSslConf",
- "org.apache.tomcat.util.net.openssl.OpenSSLConf");
+ digester.addSetNext("Server/Service/Connector/SSLHostConfig/OpenSSLConf", "setOpenSslConf",
+ "org.apache.tomcat.util.net.openssl.OpenSSLConf");
digester.addObjectCreate("Server/Service/Connector/SSLHostConfig/OpenSSLConf/OpenSSLConfCmd",
- "org.apache.tomcat.util.net.openssl.OpenSSLConfCmd");
+ "org.apache.tomcat.util.net.openssl.OpenSSLConfCmd");
digester.addSetProperties("Server/Service/Connector/SSLHostConfig/OpenSSLConf/OpenSSLConfCmd");
- digester.addSetNext("Server/Service/Connector/SSLHostConfig/OpenSSLConf/OpenSSLConfCmd",
- "addCmd",
- "org.apache.tomcat.util.net.openssl.OpenSSLConfCmd");
+ digester.addSetNext("Server/Service/Connector/SSLHostConfig/OpenSSLConf/OpenSSLConfCmd", "addCmd",
+ "org.apache.tomcat.util.net.openssl.OpenSSLConfCmd");
- digester.addObjectCreate("Server/Service/Connector/Listener",
- null, // MUST be specified in the element
- "className");
+ 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");
+ digester.addSetNext("Server/Service/Connector/Listener", "addLifecycleListener",
+ "org.apache.catalina.LifecycleListener");
- digester.addObjectCreate("Server/Service/Connector/UpgradeProtocol",
- null, // MUST be specified in the element
- "className");
+ digester.addObjectCreate("Server/Service/Connector/UpgradeProtocol", null, // MUST be specified in the element
+ "className");
digester.addSetProperties("Server/Service/Connector/UpgradeProtocol");
- digester.addSetNext("Server/Service/Connector/UpgradeProtocol",
- "addUpgradeProtocol",
- "org.apache.coyote.UpgradeProtocol");
+ digester.addSetNext("Server/Service/Connector/UpgradeProtocol", "addUpgradeProtocol",
+ "org.apache.coyote.UpgradeProtocol");
// Add RuleSets for nested elements
digester.addRuleSet(new NamingRuleSet("Server/GlobalNamingResources/"));
@@ -520,8 +486,7 @@ public class Catalina {
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));
+ digester.addRule("Server/Service/Engine", new SetParentClassLoaderRule(parentClassLoader));
addClusterRuleSet(digester, "Server/Service/Engine/Cluster/");
return digester;
@@ -541,17 +506,16 @@ public class Catalina {
digester.addRuleSet(ruleSet);
} catch (Exception e) {
if (log.isDebugEnabled()) {
- log.debug(sm.getString("catalina.noCluster",
- e.getClass().getName() + ": " + e.getMessage()), e);
+ log.debug(sm.getString("catalina.noCluster", e.getClass().getName() + ": " + e.getMessage()), e);
} else if (log.isInfoEnabled()) {
- log.info(sm.getString("catalina.noCluster",
- e.getClass().getName() + ": " + e.getMessage()));
+ log.info(sm.getString("catalina.noCluster", e.getClass().getName() + ": " + e.getMessage()));
}
}
}
/**
* Create and configure the Digester we will be using for shutdown.
+ *
* @return the digester to process the stop operation
*/
protected Digester createStopDigester() {
@@ -561,13 +525,9 @@ public class Catalina {
digester.setUseContextClassLoader(true);
// Configure the rules we need for shutting down
- digester.addObjectCreate("Server",
- "org.apache.catalina.core.StandardServer",
- "className");
+ digester.addObjectCreate("Server", "org.apache.catalina.core.StandardServer", "className");
digester.addSetProperties("Server");
- digester.addSetNext("Server",
- "setServer",
- "org.apache.catalina.Server");
+ digester.addSetNext("Server", "setServer", "org.apache.catalina.Server");
return digester;
@@ -576,15 +536,16 @@ public class Catalina {
protected void parseServerXml(boolean start) {
// Set configuration source
- ConfigFileLoader.setSource(new CatalinaBaseConfigurationSource(Bootstrap.getCatalinaBaseFile(), getConfigFile()));
+ ConfigFileLoader
+ .setSource(new CatalinaBaseConfigurationSource(Bootstrap.getCatalinaBaseFile(), getConfigFile()));
File file = configFile();
if (useGeneratedCode && !Digester.isGeneratedCodeLoaderSet()) {
// Load loader
String loaderClassName = generatedCodePackage + ".DigesterGeneratedCodeLoader";
try {
- Digester.GeneratedCodeLoader loader = (Digester.GeneratedCodeLoader)
- Catalina.class.getClassLoader().loadClass(loaderClassName).getDeclaredConstructor().newInstance();
+ Digester.GeneratedCodeLoader loader = (Digester.GeneratedCodeLoader) Catalina.class.getClassLoader()
+ .loadClass(loaderClassName).getDeclaredConstructor().newInstance();
Digester.setGeneratedCodeLoader(loader);
} catch (Exception e) {
if (log.isDebugEnabled()) {
@@ -642,8 +603,8 @@ public class Catalina {
digester.parse(inputSource);
if (generateCode) {
generateClassFooter(digester);
- try (FileWriter writer = new FileWriter(new File(serverXmlLocation,
- start ? "ServerXml.java" : "ServerXmlStop.java"))) {
+ try (FileWriter writer = new FileWriter(
+ new File(serverXmlLocation, start ? "ServerXml.java" : "ServerXmlStop.java"))) {
writer.write(digester.getGeneratedCode().toString());
}
digester.endGeneratingCode();
@@ -753,8 +714,9 @@ public class Catalina {
}
}
- if(log.isInfoEnabled()) {
- log.info(sm.getString("catalina.init", Long.toString(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - t1))));
+ if (log.isInfoEnabled()) {
+ log.info(sm.getString("catalina.init",
+ Long.toString(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - t1))));
}
}
@@ -804,7 +766,8 @@ public class Catalina {
}
if (log.isInfoEnabled()) {
- log.info(sm.getString("catalina.startup", Long.toString(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - t1))));
+ log.info(sm.getString("catalina.startup",
+ Long.toString(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - t1))));
}
if (generateCode) {
@@ -824,8 +787,7 @@ public class Catalina {
// if JULI's hook completes before the CatalinaShutdownHook()
LogManager logManager = LogManager.getLogManager();
if (logManager instanceof ClassLoaderLogManager) {
- ((ClassLoaderLogManager) logManager).setUseShutdownHook(
- false);
+ ((ClassLoaderLogManager) logManager).setUseShutdownHook(false);
}
}
@@ -851,8 +813,7 @@ public class Catalina {
// log messages are not lost
LogManager logManager = LogManager.getLogManager();
if (logManager instanceof ClassLoaderLogManager) {
- ((ClassLoaderLogManager) logManager).setUseShutdownHook(
- true);
+ ((ClassLoaderLogManager) logManager).setUseShutdownHook(true);
}
}
} catch (Throwable t) {
@@ -865,8 +826,7 @@ public class Catalina {
try {
Server s = getServer();
LifecycleState state = s.getState();
- if (LifecycleState.STOPPING_PREP.compareTo(state) <= 0
- && LifecycleState.DESTROYED.compareTo(state) >= 0) {
+ if (LifecycleState.STOPPING_PREP.compareTo(state) <= 0 && LifecycleState.DESTROYED.compareTo(state) >= 0) {
// Nothing to do. stop() was already called
} else {
s.stop();
@@ -914,23 +874,20 @@ public class Catalina {
} else {
System.setProperty("catalina.useNaming", "true");
String value = "org.apache.naming";
- String oldValue =
- System.getProperty(javax.naming.Context.URL_PKG_PREFIXES);
+ 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() ) {
+ if (log.isDebugEnabled()) {
log.debug("Setting naming prefix=" + value);
}
- value = System.getProperty
- (javax.naming.Context.INITIAL_CONTEXT_FACTORY);
+ 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");
+ System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.naming.java.javaURLContextFactory");
} else {
- log.debug("INITIAL_CONTEXT_FACTORY already set " + value );
+ log.debug("INITIAL_CONTEXT_FACTORY already set " + value);
}
}
}
@@ -939,7 +896,7 @@ public class Catalina {
/**
* Set the security package access/protection.
*/
- protected void setSecurityProtection(){
+ protected void setSecurityProtection() {
SecurityConfig securityConfig = SecurityConfig.newInstance();
securityConfig.setPackageDefinition();
securityConfig.setPackageAccess();
@@ -951,7 +908,8 @@ public class Catalina {
StringBuilder code = new StringBuilder();
code.append("package ").append(generatedCodePackage).append(';').append(System.lineSeparator());
code.append("public class ").append(loaderClassName);
- code.append(" implements org.apache.tomcat.util.digester.Digester.GeneratedCodeLoader {").append(System.lineSeparator());
+ code.append(" implements org.apache.tomcat.util.digester.Digester.GeneratedCodeLoader {")
+ .append(System.lineSeparator());
code.append("public Object loadGeneratedCode(String className) {").append(System.lineSeparator());
code.append("switch (className) {").append(System.lineSeparator());
for (String generatedClassName : Digester.getGeneratedClasses()) {
@@ -1029,8 +987,7 @@ public class Catalina {
/**
- * Rule that sets the parent class loader for the top object on the stack,
- * which must be a <code>Container</code>.
+ * Rule that sets the parent class loader for the top object on the stack, which must be a <code>Container</code>.
*/
final class SetParentClassLoaderRule extends Rule {
@@ -1044,8 +1001,7 @@ public class Catalina {
ClassLoader parentClassLoader = null;
@Override
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
+ public void begin(String namespace, String name, Attributes attributes) throws Exception {
if (digester.getLogger().isDebugEnabled()) {
digester.getLogger().debug("Setting parent class loader");
diff --git a/java/org/apache/catalina/startup/CatalinaProperties.java b/java/org/apache/catalina/startup/CatalinaProperties.java
index 2bf690705b..3566e1a9a7 100644
--- a/java/org/apache/catalina/startup/CatalinaProperties.java
+++ b/java/org/apache/catalina/startup/CatalinaProperties.java
@@ -47,6 +47,7 @@ public class CatalinaProperties {
/**
* @param name The property name
+ *
* @return specified property value
*/
public static String getProperty(String name) {
@@ -89,8 +90,7 @@ public class CatalinaProperties {
if (is == null) {
try {
- is = CatalinaProperties.class.getResourceAsStream
- ("/org/apache/catalina/startup/catalina.properties");
+ is = CatalinaProperties.class.getResourceAsStream("/org/apache/catalina/startup/catalina.properties");
} catch (Throwable t) {
handleThrowable(t);
}
diff --git a/java/org/apache/catalina/startup/CertificateCreateRule.java b/java/org/apache/catalina/startup/CertificateCreateRule.java
index 5c305e49c3..a6f176040f 100644
--- a/java/org/apache/catalina/startup/CertificateCreateRule.java
+++ b/java/org/apache/catalina/startup/CertificateCreateRule.java
@@ -45,7 +45,8 @@ public class CertificateCreateRule extends Rule {
StringBuilder code = digester.getGeneratedCode();
if (code != null) {
- code.append(SSLHostConfigCertificate.class.getName()).append(' ').append(digester.toVariableName(certificate));
+ code.append(SSLHostConfigCertificate.class.getName()).append(' ')
+ .append(digester.toVariableName(certificate));
code.append(" = new ").append(SSLHostConfigCertificate.class.getName());
code.append('(').append(digester.toVariableName(sslHostConfig));
code.append(", ").append(Type.class.getName().replace('$', '.')).append('.').append(type).append(");");
@@ -57,11 +58,9 @@ public class CertificateCreateRule extends Rule {
/**
* Process the end of this element.
*
- * @param namespace the namespace URI of the matching element, or an
- * empty string if the parser is not namespace aware or the element has
- * no namespace
- * @param name the local name if the parser is namespace aware, or just
- * the element name otherwise
+ * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace
+ * aware or the element has no namespace
+ * @param name the local name if the parser is namespace aware, or just the element name otherwise
*/
@Override
public void end(String namespace, String name) throws Exception {
diff --git a/java/org/apache/catalina/startup/ClassLoaderFactory.java b/java/org/apache/catalina/startup/ClassLoaderFactory.java
index a451ccfb0c..138ca6bc81 100644
--- a/java/org/apache/catalina/startup/ClassLoaderFactory.java
+++ b/java/org/apache/catalina/startup/ClassLoaderFactory.java
@@ -34,18 +34,16 @@ import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
/**
- * <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>
+ * <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>
+ * <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
@@ -59,25 +57,20 @@ public final class ClassLoaderFactory {
/**
- * Create and return a new class loader, based on the configuration
- * defaults and the specified directory paths:
+ * 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.
*
- * @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.
* @return the new class loader
*
* @exception Exception if an error occurs constructing the class loader
*/
- public static ClassLoader createClassLoader(File unpacked[],
- File packed[],
- final ClassLoader parent)
- throws Exception {
+ public static ClassLoader createClassLoader(File unpacked[], File packed[], final ClassLoader parent)
+ throws Exception {
if (log.isDebugEnabled()) {
log.debug("Creating new class loader");
@@ -128,33 +121,30 @@ public final class ClassLoaderFactory {
// Construct the class loader itself
final URL[] array = set.toArray(new URL[0]);
- return AccessController.doPrivileged(
- (PrivilegedAction<URLClassLoader>) () -> {
- if (parent == null) {
- return new URLClassLoader(array);
- } else {
- return new URLClassLoader(array, parent);
- }
- });
+ return AccessController.doPrivileged((PrivilegedAction<URLClassLoader>) () -> {
+ if (parent == null) {
+ return new URLClassLoader(array);
+ } else {
+ return new URLClassLoader(array, parent);
+ }
+ });
}
/**
- * Create and return a new class loader, based on the configuration
- * defaults and the specified directory paths:
+ * Create and return a new class loader, based on the configuration defaults and the specified directory paths:
+ *
+ * @param repositories List of class directories, jar files, jar directories or URLS that should be added to the
+ * repositories of the class loader.
+ * @param parent Parent class loader for the new class loader, or <code>null</code> for the system class
+ * loader.
*
- * @param repositories List of class directories, jar files, jar directories
- * or URLS that should be added to the repositories of
- * the class loader.
- * @param parent Parent class loader for the new class loader, or
- * <code>null</code> for the system class loader.
* @return the new class loader
*
* @exception Exception if an error occurs constructing the class loader
*/
- public static ClassLoader createClassLoader(List<Repository> repositories,
- final ClassLoader parent)
- throws Exception {
+ public static ClassLoader createClassLoader(List<Repository> repositories, final ClassLoader parent)
+ throws Exception {
if (log.isDebugEnabled()) {
log.debug("Creating new class loader");
@@ -164,7 +154,7 @@ public final class ClassLoaderFactory {
Set<URL> set = new LinkedHashSet<>();
if (repositories != null) {
- for (Repository repository : repositories) {
+ for (Repository repository : repositories) {
if (repository.getType() == RepositoryType.URL) {
URL url = buildClassLoaderUrl(repository.getLocation());
if (log.isDebugEnabled()) {
@@ -183,7 +173,7 @@ public final class ClassLoaderFactory {
}
set.add(url);
} else if (repository.getType() == RepositoryType.JAR) {
- File file=new File(repository.getLocation());
+ File file = new File(repository.getLocation());
file = file.getCanonicalFile();
if (!validateFile(file, RepositoryType.JAR)) {
continue;
@@ -194,14 +184,13 @@ public final class ClassLoaderFactory {
}
set.add(url);
} else if (repository.getType() == RepositoryType.GLOB) {
- File directory=new File(repository.getLocation());
+ File directory = new File(repository.getLocation());
directory = directory.getCanonicalFile();
if (!validateFile(directory, RepositoryType.GLOB)) {
continue;
}
if (log.isDebugEnabled()) {
- log.debug(" Including directory glob "
- + directory.getAbsolutePath());
+ log.debug(" Including directory glob " + directory.getAbsolutePath());
}
String filenames[] = directory.list();
if (filenames == null) {
@@ -218,8 +207,7 @@ public final class ClassLoaderFactory {
continue;
}
if (log.isDebugEnabled()) {
- log.debug(" Including glob jar file "
- + file.getAbsolutePath());
+ log.debug(" Including glob jar file " + file.getAbsolutePath());
}
URL url = buildClassLoaderUrl(file);
set.add(url);
@@ -236,37 +224,32 @@ public final class ClassLoaderFactory {
}
}
- return AccessController.doPrivileged(
- (PrivilegedAction<URLClassLoader>) () -> {
- if (parent == null) {
- return new URLClassLoader(array);
- } else {
- return new URLClassLoader(array, parent);
- }
- });
+ return AccessController.doPrivileged((PrivilegedAction<URLClassLoader>) () -> {
+ if (parent == null) {
+ return new URLClassLoader(array);
+ } else {
+ return new URLClassLoader(array, parent);
+ }
+ });
}
- private static boolean validateFile(File file,
- RepositoryType type) throws IOException {
+ private static boolean validateFile(File file, RepositoryType type) throws IOException {
if (RepositoryType.DIR == type || RepositoryType.GLOB == type) {
if (!file.isDirectory() || !file.canRead()) {
- String msg = "Problem with directory [" + file +
- "], exists: [" + file.exists() +
- "], isDirectory: [" + file.isDirectory() +
- "], canRead: [" + file.canRead() + "]";
+ String msg = "Problem with directory [" + file + "], exists: [" + file.exists() + "], isDirectory: [" +
+ file.isDirectory() + "], canRead: [" + file.canRead() + "]";
- File home = new File (Bootstrap.getCatalinaHome());
+ File home = new File(Bootstrap.getCatalinaHome());
home = home.getCanonicalFile();
- File base = new File (Bootstrap.getCatalinaBase());
+ File base = new File(Bootstrap.getCatalinaBase());
base = base.getCanonicalFile();
File defaultValue = new File(base, "lib");
// Existence of ${catalina.base}/lib directory is optional.
// Hide the warning if Tomcat runs with separate catalina.home
// and catalina.base and that directory is absent.
- if (!home.getPath().equals(base.getPath())
- && file.getPath().equals(defaultValue.getPath())
- && !file.exists()) {
+ if (!home.getPath().equals(base.getPath()) && file.getPath().equals(defaultValue.getPath()) &&
+ !file.exists()) {
log.debug(msg);
} else {
log.warn(msg);
@@ -275,9 +258,8 @@ public final class ClassLoaderFactory {
}
} else if (RepositoryType.JAR == type) {
if (!file.canRead()) {
- log.warn("Problem with JAR file [" + file +
- "], exists: [" + file.exists() +
- "], canRead: [" + file.canRead() + "]");
+ log.warn("Problem with JAR file [" + file + "], exists: [" + file.exists() + "], canRead: [" +
+ file.canRead() + "]");
return false;
}
}
@@ -286,9 +268,8 @@ public final class ClassLoaderFactory {
/*
- * These two methods would ideally be in the utility class
- * org.apache.tomcat.util.buf.UriUtil but that class is not visible until
- * after the class loaders have been constructed.
+ * These two methods would ideally be in the utility class org.apache.tomcat.util.buf.UriUtil but that class is not
+ * visible until after the class loaders have been constructed.
*/
private static URL buildClassLoaderUrl(String urlString) throws MalformedURLException, URISyntaxException {
// URLs passed to class loaders may point to directories that contain
diff --git a/java/org/apache/catalina/startup/ConnectorCreateRule.java b/java/org/apache/catalina/startup/ConnectorCreateRule.java
index aa297fbd89..d1eae0435d 100644
--- a/java/org/apache/catalina/startup/ConnectorCreateRule.java
+++ b/java/org/apache/catalina/startup/ConnectorCreateRule.java
@@ -45,20 +45,17 @@ public class ConnectorCreateRule extends Rule {
/**
* Process the beginning of this element.
*
- * @param namespace the namespace URI of the matching element, or an
- * empty string if the parser is not namespace aware or the element has
- * no namespace
- * @param name the local name if the parser is namespace aware, or just
- * the element name otherwise
+ * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace
+ * aware or the element has no namespace
+ * @param name the local name if the parser is namespace aware, or just the element name otherwise
* @param attributes The attribute list for this element
*/
@Override
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
+ public void begin(String namespace, String name, Attributes attributes) throws Exception {
Service svc = (Service) digester.peek();
Executor ex = null;
String executorName = attributes.getValue("executor");
- if (executorName != null ) {
+ if (executorName != null) {
ex = svc.getExecutor(executorName);
}
String protocolName = attributes.getValue("protocol");
@@ -95,18 +92,20 @@ public class ConnectorCreateRule extends Rule {
}
private static void setExecutor(Connector con, Executor ex) throws Exception {
- Method m = IntrospectionUtils.findMethod(con.getProtocolHandler().getClass(),"setExecutor",new Class[] {java.util.concurrent.Executor.class});
- if (m!=null) {
- m.invoke(con.getProtocolHandler(), new Object[] {ex});
- }else {
+ Method m = IntrospectionUtils.findMethod(con.getProtocolHandler().getClass(), "setExecutor",
+ new Class[] { java.util.concurrent.Executor.class });
+ if (m != null) {
+ m.invoke(con.getProtocolHandler(), new Object[] { ex });
+ } else {
log.warn(sm.getString("connector.noSetExecutor", con));
}
}
private static void setSSLImplementationName(Connector con, String sslImplementationName) throws Exception {
- Method m = IntrospectionUtils.findMethod(con.getProtocolHandler().getClass(),"setSslImplementationName",new Class[] {String.class});
+ Method m = IntrospectionUtils.findMethod(con.getProtocolHandler().getClass(), "setSslImplementationName",
+ new Class[] { String.class });
if (m != null) {
- m.invoke(con.getProtocolHandler(), new Object[] {sslImplementationName});
+ m.invoke(con.getProtocolHandler(), new Object[] { sslImplementationName });
} else {
log.warn(sm.getString("connector.noSetSSLImplementationName", con));
}
@@ -115,11 +114,9 @@ public class ConnectorCreateRule extends Rule {
/**
* Process the end of this element.
*
- * @param namespace the namespace URI of the matching element, or an
- * empty string if the parser is not namespace aware or the element has
- * no namespace
- * @param name the local name if the parser is namespace aware, or just
- * the element name otherwise
+ * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace
+ * aware or the element has no namespace
+ * @param name the local name if the parser is namespace aware, or just the element name otherwise
*/
@Override
public void end(String namespace, String name) throws Exception {
diff --git a/java/org/apache/catalina/startup/Constants.java b/java/org/apache/catalina/startup/Constants.java
index 2b8414264d..1a593803c3 100644
--- a/java/org/apache/catalina/startup/Constants.java
+++ b/java/org/apache/catalina/startup/Constants.java
@@ -17,10 +17,9 @@
package org.apache.catalina.startup;
/**
- * String constants for the startup package.
- * <br>
- * Note that some values include a leading '/' and that some do not. This is
- * intentional based on how the values are used.
+ * String constants for the startup package. <br>
+ * Note that some values include a leading '/' and that some do not. This is intentional based on how the values are
+ * used.
*
* @author Craig R. McClanahan
*/
@@ -38,12 +37,9 @@ public final class Constants {
public static final String WarTracker = "/META-INF/war-tracker";
/**
- * A value that points to a non-existent file used to suppress loading the
- * default web.xml file.
- *
+ * A value that points to a non-existent file used to suppress loading the default web.xml file.
* <p>
- * It is useful when embedding Tomcat, when the default configuration is
- * done programmatically, e.g. by calling
+ * It is useful when embedding Tomcat, when the default configuration is done programmatically, e.g. by calling
* <code>Tomcat.initWebappDefaults(context)</code>.
*
* @see Tomcat
@@ -51,14 +47,12 @@ public final class Constants {
public static final String NoDefaultWebXml = "org/apache/catalina/startup/NO_DEFAULT_XML";
/**
- * Name of the system property containing
- * the tomcat product installation path
+ * Name of the system property containing the tomcat product installation path
*/
public static final String CATALINA_HOME_PROP = "catalina.home";
/**
- * Name of the system property containing
- * the tomcat instance installation path
+ * Name of the system property containing the tomcat instance installation path
*/
public static final String CATALINA_BASE_PROP = "catalina.base";
}
diff --git a/java/org/apache/catalina/startup/ContextConfig.java b/java/org/apache/catalina/startup/ContextConfig.java
index 4e6cad771d..c7378d9c53 100644
--- a/java/org/apache/catalina/startup/ContextConfig.java
+++ b/java/org/apache/catalina/startup/ContextConfig.java
@@ -116,8 +116,8 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXParseException;
/**
- * Startup event listener for a <b>Context</b> that configures the properties
- * of that Context, and the associated defined servlets.
+ * Startup event listener for a <b>Context</b> that configures the properties of that Context, and the associated
+ * defined servlets.
*
* @author Craig R. McClanahan
*/
@@ -128,26 +128,23 @@ public class ContextConfig implements LifecycleListener {
/**
* The string resources for this package.
*/
- protected static final StringManager sm =
- StringManager.getManager(Constants.Package);
+ protected static final StringManager sm = StringManager.getManager(Constants.Package);
- protected static final LoginConfig DUMMY_LOGIN_CONFIG =
- new LoginConfig("NONE", null, null, null);
+ protected static final LoginConfig DUMMY_LOGIN_CONFIG = new LoginConfig("NONE", null, null, null);
/**
- * The set of Authenticators that we know how to configure. The key is
- * the name of the implemented authentication method, and the value is
- * the fully qualified Java class name of the corresponding Valve.
+ * The set of Authenticators that we know how to configure. The key is the name of the implemented authentication
+ * method, and the value is the fully qualified Java class name of the corresponding Valve.
*/
protected static final Properties authenticators;
static {
// Load our mapping properties for the standard authenticators
Properties props = new Properties();
- try (InputStream is = ContextConfig.class.getClassLoader().getResourceAsStream(
- "org/apache/catalina/startup/Authenticators.properties")) {
+ try (InputStream is = ContextConfig.class.getClassLoader()
+ .getResourceAsStream("org/apache/catalina/startup/Authenticators.properties")) {
if (is != null) {
props.load(is);
}
@@ -166,13 +163,11 @@ public class ContextConfig implements LifecycleListener {
/**
* Cache of default web.xml fragments per Host
*/
- protected static final Map<Host,DefaultWebXmlCacheEntry> hostWebXmlCache =
- new ConcurrentHashMap<>();
+ protected static final Map<Host,DefaultWebXmlCacheEntry> hostWebXmlCache = new ConcurrentHashMap<>();
/**
- * Set used as the value for {@code JavaClassCacheEntry.sciSet} when there
- * are no SCIs associated with a class.
+ * Set used as the value for {@code JavaClassCacheEntry.sciSet} when there are no SCIs associated with a class.
*/
private static final Set<ServletContainerInitializer> EMPTY_SCI_SET = Collections.emptySet();
@@ -209,8 +204,8 @@ public class ContextConfig implements LifecycleListener {
/**
- * Anti-locking docBase. It is a path to a copy of the web application
- * in the java.io.tmpdir directory. This path is always an absolute one.
+ * Anti-locking docBase. It is a path to a copy of the web application in the java.io.tmpdir directory. This path is
+ * always an absolute one.
*/
private File antiLockingDocBase = null;
@@ -218,25 +213,20 @@ public class ContextConfig implements LifecycleListener {
/**
* Map of ServletContainerInitializer to classes they expressed interest in.
*/
- protected final Map<ServletContainerInitializer, Set<Class<?>>> initializerClassMap =
- new LinkedHashMap<>();
+ protected final Map<ServletContainerInitializer,Set<Class<?>>> initializerClassMap = new LinkedHashMap<>();
/**
- * Map of Types to ServletContainerInitializer that are interested in those
- * types.
+ * Map of Types to ServletContainerInitializer that are interested in those types.
*/
- protected final Map<Class<?>, Set<ServletContainerInitializer>> typeInitializerMap =
- new HashMap<>();
+ protected final Map<Class<?>,Set<ServletContainerInitializer>> typeInitializerMap = new HashMap<>();
/**
- * Flag that indicates if at least one {@link HandlesTypes} entry is present
- * that represents an annotation.
+ * Flag that indicates if at least one {@link HandlesTypes} entry is present that represents an annotation.
*/
protected boolean handlesTypesAnnotations = false;
/**
- * Flag that indicates if at least one {@link HandlesTypes} entry is present
- * that represents a non-annotation.
+ * Flag that indicates if at least one {@link HandlesTypes} entry is present that represents a non-annotation.
*/
protected boolean handlesTypesNonAnnotations = false;
@@ -246,8 +236,7 @@ public class ContextConfig implements LifecycleListener {
/**
* Obtain the location of the default deployment descriptor.
*
- * @return The path to the default web.xml. If not absolute, it is relative
- * to CATALINA_BASE.
+ * @return The path to the default web.xml. If not absolute, it is relative to CATALINA_BASE.
*/
public String getDefaultWebXml() {
if (defaultWebXml == null) {
@@ -260,8 +249,7 @@ public class ContextConfig implements LifecycleListener {
/**
* Set the location of the default deployment descriptor.
*
- * @param path The path to the default web.xml. If not absolute, it is
- * relative to CATALINA_BASE.
+ * @param path The path to the default web.xml. If not absolute, it is relative to CATALINA_BASE.
*/
public void setDefaultWebXml(String path) {
this.defaultWebXml = path;
@@ -271,11 +259,9 @@ public class ContextConfig implements LifecycleListener {
/**
* Sets custom mappings of login methods to authenticators.
*
- * @param customAuthenticators Custom mappings of login methods to
- * authenticators
+ * @param customAuthenticators Custom mappings of login methods to authenticators
*/
- public void setCustomAuthenticators(
- Map<String,Authenticator> customAuthenticators) {
+ public void setCustomAuthenticators(Map<String,Authenticator> customAuthenticators) {
this.customAuthenticators = customAuthenticators;
}
@@ -328,21 +314,19 @@ public class ContextConfig implements LifecycleListener {
*/
protected void applicationAnnotationsConfig() {
- long t1=System.currentTimeMillis();
+ long t1 = System.currentTimeMillis();
WebAnnotationSet.loadApplicationAnnotations(context);
- long t2=System.currentTimeMillis();
+ long t2 = System.currentTimeMillis();
if (context instanceof StandardContext) {
- ((StandardContext) context).setStartupTime(t2-t1+
- ((StandardContext) context).getStartupTime());
+ ((StandardContext) context).setStartupTime(t2 - t1 + ((StandardContext) context).getStartupTime());
}
}
/**
- * Set up an Authenticator automatically if required, and one has not
- * already been configured.
+ * Set up an Authenticator automatically if required, and one has not already been configured.
*/
protected void authenticatorConfig() {
@@ -366,9 +350,8 @@ public class ContextConfig implements LifecycleListener {
}
/*
- * First check to see if there is a custom mapping for the login
- * method. If so, use it. Otherwise, check if there is a mapping in
- * org/apache/catalina/startup/Authenticators.properties.
+ * First check to see if there is a custom mapping for the login method. If so, use it. Otherwise, check if
+ * there is a mapping in org/apache/catalina/startup/Authenticators.properties.
*/
Valve authenticator = null;
if (customAuthenticators != null) {
@@ -385,8 +368,7 @@ public class ContextConfig implements LifecycleListener {
// Identify the class name of the Valve we should configure
String authenticatorName = authenticators.getProperty(loginConfig.getAuthMethod());
if (authenticatorName == null) {
- log.error(sm.getString("contextConfig.authenticatorMissing",
- loginConfig.getAuthMethod()));
+ log.error(sm.getString("contextConfig.authenticatorMissing", loginConfig.getAuthMethod()));
ok = false;
return;
}
@@ -397,10 +379,7 @@ public class ContextConfig implements LifecycleListener {
authenticator = (Valve) authenticatorClass.getConstructor().newInstance();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
- log.error(sm.getString(
- "contextConfig.authenticatorInstantiate",
- authenticatorName),
- t);
+ log.error(sm.getString("contextConfig.authenticatorInstantiate", authenticatorName), t);
ok = false;
}
}
@@ -410,9 +389,7 @@ public class ContextConfig implements LifecycleListener {
if (pipeline != null) {
pipeline.addValve(authenticator);
if (log.isDebugEnabled()) {
- log.debug(sm.getString(
- "contextConfig.authenticatorConfigured",
- loginConfig.getAuthMethod()));
+ log.debug(sm.getString("contextConfig.authenticatorConfigured", loginConfig.getAuthMethod()));
}
}
}
@@ -420,15 +397,16 @@ public class ContextConfig implements LifecycleListener {
/**
- * Create (if necessary) and return a Digester configured to process the
- * context configuration descriptor for an application.
+ * Create (if necessary) and return a Digester configured to process the context configuration descriptor for an
+ * application.
+ *
* @return the digester for context.xml files
*/
protected Digester createContextDigester() {
Digester digester = new Digester();
digester.setValidating(false);
digester.setRulesValidation(true);
- Map<Class<?>, List<String>> fakeAttributes = new HashMap<>();
+ Map<Class<?>,List<String>> fakeAttributes = new HashMap<>();
List<String> objectAttrs = new ArrayList<>();
objectAttrs.add("className");
fakeAttributes.put(Object.class, objectAttrs);
@@ -558,6 +536,7 @@ public class ContextConfig implements LifecycleListener {
/**
* Process the default configuration file, if it exists.
+ *
* @param digester The digester that will be used for XML parsing
*/
protected void contextConfig(Digester digester) {
@@ -574,7 +553,7 @@ public class ContextConfig implements LifecycleListener {
// Open the default context.xml file, if it exists
if (context instanceof StandardContext) {
- defaultContextXml = ((StandardContext)context).getDefaultContextXml();
+ defaultContextXml = ((StandardContext) context).getDefaultContextXml();
}
// set the default if we don't have any overrides
if (defaultContextXml == null) {
@@ -600,7 +579,8 @@ public class ContextConfig implements LifecycleListener {
try (ConfigurationSource.Resource contextXmlResource =
ConfigFileLoader.getSource().getResource(defaultContextXml)) {
if (generateCode) {
- contextXmlJavaSource = getContextXmlJavaSource(contextXmlPackageName, contextXmlSimpleClassName);
+ contextXmlJavaSource =
+ getContextXmlJavaSource(contextXmlPackageName, contextXmlSimpleClassName);
if (contextXmlJavaSource != null) {
digester.startGeneratingCode();
generateClassHeader(digester, contextXmlPackageName, contextXmlSimpleClassName);
@@ -641,7 +621,8 @@ public class ContextConfig implements LifecycleListener {
try (ConfigurationSource.Resource contextXmlResource =
ConfigFileLoader.getSource().getResource(hostContextFile)) {
if (generateCode) {
- contextXmlJavaSource = getContextXmlJavaSource(contextXmlPackageName, contextXmlSimpleClassName);
+ contextXmlJavaSource =
+ getContextXmlJavaSource(contextXmlPackageName, contextXmlSimpleClassName);
digester.startGeneratingCode();
generateClassHeader(digester, contextXmlPackageName, contextXmlSimpleClassName);
}
@@ -700,15 +681,15 @@ public class ContextConfig implements LifecycleListener {
/**
* Process a context.xml.
- * @param digester The digester that will be used for XML parsing
+ *
+ * @param digester The digester that will be used for XML parsing
* @param contextXml The URL to the context.xml configuration
- * @param stream The XML resource stream
+ * @param stream The XML resource stream
*/
protected void processContextConfig(Digester digester, URL contextXml, InputStream stream) {
if (log.isDebugEnabled()) {
- log.debug("Processing context [" + context.getName()
- + "] configuration file [" + contextXml + "]");
+ log.debug("Processing context [" + context.getName() + "] configuration file [" + contextXml + "]");
}
InputSource source = null;
@@ -721,8 +702,7 @@ public class ContextConfig implements LifecycleListener {
stream = xmlConn.getInputStream();
}
} catch (Exception e) {
- log.error(sm.getString("contextConfig.contextMissing",
- contextXml) , e);
+ log.error(sm.getString("contextConfig.contextMissing", contextXml), e);
}
if (source == null) {
@@ -738,25 +718,20 @@ public class ContextConfig implements LifecycleListener {
XmlErrorHandler errorHandler = new XmlErrorHandler();
digester.setErrorHandler(errorHandler);
digester.parse(source);
- if (errorHandler.getWarnings().size() > 0 ||
- errorHandler.getErrors().size() > 0) {
+ if (errorHandler.getWarnings().size() > 0 || errorHandler.getErrors().size() > 0) {
errorHandler.logFindings(log, contextXml.toString());
ok = false;
}
if (log.isDebugEnabled()) {
- log.debug("Successfully processed context [" + context.getName()
- + "] configuration file [" + contextXml + "]");
+ log.debug("Successfully processed context [" + context.getName() + "] configuration file [" +
+ contextXml + "]");
}
} catch (SAXParseException e) {
- log.error(sm.getString("contextConfig.contextParse",
- context.getName()), e);
- log.error(sm.getString("contextConfig.defaultPosition",
- "" + e.getLineNumber(),
- "" + e.getColumnNumber()));
+ 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);
+ log.error(sm.getString("contextConfig.contextParse", context.getName()), e);
ok = false;
} finally {
try {
@@ -772,6 +747,7 @@ public class ContextConfig implements LifecycleListener {
/**
* Adjust docBase.
+ *
* @throws IOException cannot access the context base path
*/
protected void fixDocBase() throws IOException {
@@ -810,7 +786,7 @@ public class ContextConfig implements LifecycleListener {
if (host instanceof StandardHost) {
unpackWARs = ((StandardHost) host).isUnpackWARs();
if (unpackWARs && context instanceof StandardContext) {
- unpackWARs = ((StandardContext) context).getUnpackWAR();
+ unpackWARs = ((StandardContext) context).getUnpackWAR();
}
}
@@ -882,8 +858,7 @@ public class ContextConfig implements LifecycleListener {
protected void antiLocking() {
- if ((context instanceof StandardContext)
- && ((StandardContext) context).getAntiResourceLocking()) {
+ if ((context instanceof StandardContext) && ((StandardContext) context).getAntiResourceLocking()) {
Host host = (Host) context.getParent();
String docBase = context.getDocBase();
@@ -919,8 +894,7 @@ public class ContextConfig implements LifecycleListener {
antiLockingDocBase = antiLockingDocBase.getAbsoluteFile();
if (log.isDebugEnabled()) {
- log.debug("Anti locking context[" + context.getName()
- + "] setting docBase to " +
+ log.debug("Anti locking context[" + context.getName() + "] setting docBase to " +
antiLockingDocBase.getPath());
}
@@ -963,8 +937,7 @@ public class ContextConfig implements LifecycleListener {
try {
fixDocBase();
} catch (IOException e) {
- log.error(sm.getString(
- "contextConfig.fixDocBase", context.getName()), e);
+ log.error(sm.getString("contextConfig.fixDocBase", context.getName()), e);
}
antiLocking();
@@ -982,10 +955,8 @@ public class ContextConfig implements LifecycleListener {
}
if (log.isDebugEnabled()) {
- log.debug(sm.getString("contextConfig.xmlSettings",
- context.getName(),
- Boolean.valueOf(context.getXmlValidation()),
- Boolean.valueOf(context.getXmlNamespaceAware())));
+ log.debug(sm.getString("contextConfig.xmlSettings", context.getName(),
+ Boolean.valueOf(context.getXmlValidation()), Boolean.valueOf(context.getXmlNamespaceAware())));
}
webConfig();
@@ -1162,7 +1133,7 @@ public class ContextConfig implements LifecycleListener {
return null;
}
- Service s = ((Engine)c).getService();
+ Service s = ((Engine) c).getService();
if (s == null) {
return null;
@@ -1172,11 +1143,9 @@ public class ContextConfig implements LifecycleListener {
}
/**
- * Validate the usage of security role names in the web application
- * deployment descriptor. If any problems are found, issue warning
- * messages (for backwards compatibility) and add the missing roles.
- * (To make these problems fatal instead, simply set the <code>ok</code>
- * instance variable to <code>false</code> as well).
+ * Validate the usage of security role names in the web application deployment descriptor. If any problems are
+ * found, issue warning messages (for backwards compatibility) and add the missing roles. (To make these problems
+ * fatal instead, simply set the <code>ok</code> instance variable to <code>false</code> as well).
*/
protected void validateSecurityRoles() {
@@ -1185,8 +1154,7 @@ public class ContextConfig implements LifecycleListener {
for (SecurityConstraint constraint : constraints) {
String roles[] = constraint.findAuthRoles();
for (String role : roles) {
- if (!"*".equals(role) &&
- !context.findSecurityRole(role)) {
+ if (!"*".equals(role) && !context.findSecurityRole(role)) {
log.warn(sm.getString("contextConfig.role.auth", role));
context.addSecurityRole(role);
}
@@ -1218,52 +1186,43 @@ public class ContextConfig implements LifecycleListener {
protected File getHostConfigBase() {
File file = null;
if (context.getParent() instanceof Host) {
- file = ((Host)context.getParent()).getConfigBaseFile();
+ file = ((Host) context.getParent()).getConfigBaseFile();
}
return file;
}
/**
- * Scan the web.xml files that apply to the web application and merge them
- * using the rules defined in the spec. For the global web.xml files,
- * where there is duplicate configuration, the most specific level wins. ie
- * an application's web.xml takes precedence over the host level or global
- * web.xml file.
+ * Scan the web.xml files that apply to the web application and merge them using the rules defined in the spec. For
+ * the global web.xml files, where there is duplicate configuration, the most specific level wins. ie an
+ * application's web.xml takes precedence over the host level or global web.xml file.
*/
protected void webConfig() {
/*
- * Anything and everything can override the global and host defaults.
- * This is implemented in two parts:
+ * Anything and everything can override the global and host defaults. This is implemented in two parts:
*
- * - Handle as a web fragment that gets added after everything else so
- * everything else takes priority
+ * - Handle as a web fragment that gets added after everything else so everything else takes priority
*
- * - Mark Servlets as overridable so SCI configuration can replace
- * configuration from the defaults
+ * - Mark Servlets as overridable so SCI configuration can replace configuration from the defaults
*/
/*
- * The rules for annotation scanning are not as clear-cut as one might
- * think. Tomcat implements the following process:
+ * The rules for annotation scanning are not as clear-cut as one might think. Tomcat implements the following
+ * process:
*
- * - As per SRV.1.6.2, Tomcat will scan for annotations regardless of
- * which Servlet spec version is declared in web.xml. The EG has
- * confirmed this is the expected behaviour.
+ * - As per SRV.1.6.2, Tomcat will scan for annotations regardless of which Servlet spec version is declared in
+ * web.xml. The EG has confirmed this is the expected behaviour.
*
- * - As per http://java.net/jira/browse/SERVLET_SPEC-36, if the main
- * web.xml is marked as metadata-complete, JARs are still processed
- * for SCIs.
+ * - As per http://java.net/jira/browse/SERVLET_SPEC-36, if the main web.xml is marked as metadata-complete,
+ * JARs are still processed for SCIs.
*
- * - If metadata-complete=true and an absolute ordering is specified,
- * JARs excluded from the ordering are also excluded from the SCI
- * processing.
+ * - If metadata-complete=true and an absolute ordering is specified, JARs excluded from the ordering are also
+ * excluded from the SCI processing.
*
- * - If an SCI has a @HandlesType annotation then all classes (except
- * those in JARs excluded from an absolute ordering) need to be
- * scanned to check if they match.
+ * - If an SCI has a @HandlesType annotation then all classes (except those in JARs excluded from an absolute
+ * ordering) need to be scanned to check if they match.
*/
- WebXmlParser webXmlParser = new WebXmlParser(context.getXmlNamespaceAware(),
- context.getXmlValidation(), context.getXmlBlockExternal());
+ WebXmlParser webXmlParser = new WebXmlParser(context.getXmlNamespaceAware(), context.getXmlValidation(),
+ context.getXmlBlockExternal());
Set<WebXml> defaults = new HashSet<>();
defaults.add(getDefaultWebXmlFragment(webXmlParser));
@@ -1291,15 +1250,14 @@ public class ContextConfig implements LifecycleListener {
// Step 2. Order the fragments.
Set<WebXml> orderedFragments = null;
- orderedFragments =
- WebXml.orderWebFragments(webXml, fragments, sContext);
+ orderedFragments = WebXml.orderWebFragments(webXml, fragments, sContext);
// Step 3. Look for ServletContainerInitializer implementations
if (ok) {
processServletContainerInitializers();
}
- if (!webXml.isMetadataComplete() || typeInitializerMap.size() > 0) {
+ if (!webXml.isMetadataComplete() || typeInitializerMap.size() > 0) {
// Steps 4 & 5.
processClasses(webXml, orderedFragments);
}
@@ -1359,15 +1317,11 @@ public class ContextConfig implements LifecycleListener {
// Step 11. Apply the ServletContainerInitializer config to the
// context
if (ok) {
- for (Map.Entry<ServletContainerInitializer,
- Set<Class<?>>> entry :
- initializerClassMap.entrySet()) {
+ for (Map.Entry<ServletContainerInitializer,Set<Class<?>>> entry : initializerClassMap.entrySet()) {
if (entry.getValue().isEmpty()) {
- context.addServletContainerInitializer(
- entry.getKey(), null);
+ context.addServletContainerInitializer(entry.getKey(), null);
} else {
- context.addServletContainerInitializer(
- entry.getKey(), entry.getValue());
+ context.addServletContainerInitializer(entry.getKey(), entry.getValue());
}
}
}
@@ -1378,7 +1332,7 @@ public class ContextConfig implements LifecycleListener {
// Step 4. Process /WEB-INF/classes for annotations and
// @HandlesTypes matches
- Map<String, JavaClassCacheEntry> javaClassCache;
+ Map<String,JavaClassCacheEntry> javaClassCache;
if (context.getParallelAnnotationScanning()) {
javaClassCache = new ConcurrentHashMap<>();
@@ -1387,8 +1341,7 @@ public class ContextConfig implements LifecycleListener {
}
if (ok) {
- WebResource[] webResources =
- context.getResources().listResources("/WEB-INF/classes");
+ WebResource[] webResources = context.getResources().listResources("/WEB-INF/classes");
for (WebResource webResource : webResources) {
// Skip the META-INF directory from any JARs that have been
@@ -1396,8 +1349,7 @@ public class ContextConfig implements LifecycleListener {
if ("META-INF".equals(webResource.getName())) {
continue;
}
- processAnnotationsWebResource(webResource, webXml,
- webXml.isMetadataComplete(), javaClassCache);
+ processAnnotationsWebResource(webResource, webXml, webXml.isMetadataComplete(), javaClassCache);
}
}
@@ -1406,8 +1358,7 @@ public class ContextConfig implements LifecycleListener {
// are going to use (remember orderedFragments includes any
// container fragments)
if (ok) {
- processAnnotations(
- orderedFragments, webXml.isMetadataComplete(), javaClassCache);
+ processAnnotations(orderedFragments, webXml.isMetadataComplete(), javaClassCache);
}
// Cache, if used, is no longer required so clear it
@@ -1425,11 +1376,10 @@ public class ContextConfig implements LifecycleListener {
context.setEffectiveMajorVersion(webxml.getMajorVersion());
context.setEffectiveMinorVersion(webxml.getMinorVersion());
- for (Entry<String, String> entry : webxml.getContextParams().entrySet()) {
+ for (Entry<String,String> entry : webxml.getContextParams().entrySet()) {
context.addParameter(entry.getKey(), entry.getValue());
}
- context.setDenyUncoveredHttpMethods(
- webxml.getDenyUncoveredHttpMethods());
+ context.setDenyUncoveredHttpMethods(webxml.getDenyUncoveredHttpMethods());
context.setDisplayName(webxml.getDisplayName());
context.setDistributable(webxml.isDistributable());
for (ContextLocalEjb ejbLocalRef : webxml.getEjbLocalRefs().values()) {
@@ -1457,31 +1407,26 @@ public class ContextConfig implements LifecycleListener {
for (String listener : webxml.getListeners()) {
context.addApplicationListener(listener);
}
- for (Entry<String, String> entry :
- webxml.getLocaleEncodingMappings().entrySet()) {
- context.addLocaleEncodingMappingParameter(entry.getKey(),
- entry.getValue());
+ for (Entry<String,String> entry : webxml.getLocaleEncodingMappings().entrySet()) {
+ context.addLocaleEncodingMappingParameter(entry.getKey(), entry.getValue());
}
// Prevents IAE
if (webxml.getLoginConfig() != null) {
context.setLoginConfig(webxml.getLoginConfig());
}
- for (MessageDestinationRef mdr :
- webxml.getMessageDestinationRefs().values()) {
+ for (MessageDestinationRef mdr : webxml.getMessageDestinationRefs().values()) {
context.getNamingResources().addMessageDestinationRef(mdr);
}
// messageDestinations were ignored in Tomcat 6, so ignore here
context.setIgnoreAnnotations(webxml.isMetadataComplete());
- for (Entry<String, String> entry :
- webxml.getMimeMappings().entrySet()) {
+ for (Entry<String,String> entry : webxml.getMimeMappings().entrySet()) {
context.addMimeMapping(entry.getKey(), entry.getValue());
}
context.setRequestCharacterEncoding(webxml.getRequestCharacterEncoding());
// Name is just used for ordering
- for (ContextResourceEnvRef resource :
- webxml.getResourceEnvRefs().values()) {
+ for (ContextResourceEnvRef resource : webxml.getResourceEnvRefs().values()) {
context.getNamingResources().addResourceEnvRef(resource);
}
for (ContextResource resource : webxml.getResourceRefs().values()) {
@@ -1489,8 +1434,7 @@ public class ContextConfig implements LifecycleListener {
}
context.setResponseCharacterEncoding(webxml.getResponseCharacterEncoding());
boolean allAuthenticatedUsersIsAppRole =
- webxml.getSecurityRoles().contains(
- SecurityConstraint.ROLE_ALL_AUTHENTICATED_USERS);
+ webxml.getSecurityRoles().contains(SecurityConstraint.ROLE_ALL_AUTHENTICATED_USERS);
for (SecurityConstraint constraint : webxml.getSecurityConstraints()) {
if (allAuthenticatedUsersIsAppRole) {
constraint.treatAllAuthenticatedUsersAsApplicationRole();
@@ -1519,14 +1463,13 @@ public class ContextConfig implements LifecycleListener {
}
wrapper.setName(servlet.getServletName());
Map<String,String> params = servlet.getParameterMap();
- for (Entry<String, String> entry : params.entrySet()) {
+ for (Entry<String,String> entry : params.entrySet()) {
wrapper.addInitParameter(entry.getKey(), entry.getValue());
}
wrapper.setRunAs(servlet.getRunAs());
Set<SecurityRoleRef> roleRefs = servlet.getSecurityRoleRefs();
for (SecurityRoleRef roleRef : roleRefs) {
- wrapper.addSecurityReference(
- roleRef.getName(), roleRef.getLink());
+ wrapper.addSecurityReference(roleRef.getName(), roleRef.getLink());
}
wrapper.setServletClass(servlet.getServletClass());
MultipartDef multipartdef = servlet.getMultipartDef();
@@ -1535,38 +1478,32 @@ public class ContextConfig implements LifecycleListener {
long maxRequestSize = -1;
int fileSizeThreshold = 0;
- if(null != multipartdef.getMaxFileSize()) {
+ if (null != multipartdef.getMaxFileSize()) {
maxFileSize = Long.parseLong(multipartdef.getMaxFileSize());
}
- if(null != multipartdef.getMaxRequestSize()) {
+ if (null != multipartdef.getMaxRequestSize()) {
maxRequestSize = Long.parseLong(multipartdef.getMaxRequestSize());
}
- if(null != multipartdef.getFileSizeThreshold()) {
+ if (null != multipartdef.getFileSizeThreshold()) {
fileSizeThreshold = Integer.parseInt(multipartdef.getFileSizeThreshold());
}
- wrapper.setMultipartConfigElement(new MultipartConfigElement(
- multipartdef.getLocation(),
- maxFileSize,
- maxRequestSize,
- fileSizeThreshold));
+ wrapper.setMultipartConfigElement(new MultipartConfigElement(multipartdef.getLocation(), maxFileSize,
+ maxRequestSize, fileSizeThreshold));
}
if (servlet.getAsyncSupported() != null) {
- wrapper.setAsyncSupported(
- servlet.getAsyncSupported().booleanValue());
+ wrapper.setAsyncSupported(servlet.getAsyncSupported().booleanValue());
}
wrapper.setOverridable(servlet.isOverridable());
context.addChild(wrapper);
}
- for (Entry<String, String> entry :
- webxml.getServletMappings().entrySet()) {
+ for (Entry<String,String> entry : webxml.getServletMappings().entrySet()) {
context.addServletMappingDecoded(entry.getKey(), entry.getValue());
}
SessionConfig sessionConfig = webxml.getSessionConfig();
if (sessionConfig != null) {
if (sessionConfig.getSessionTimeout() != null) {
- context.setSessionTimeout(
- sessionConfig.getSessionTimeout().intValue());
+ context.setSessionTimeout(sessionConfig.getSessionTimeout().intValue());
}
SessionCookieConfig scc = context.getServletContext().getSessionCookieConfig();
scc.setName(sessionConfig.getCookieName());
@@ -1575,8 +1512,7 @@ public class ContextConfig implements LifecycleListener {
scc.setAttribute(attribute.getKey(), attribute.getValue());
}
if (sessionConfig.getSessionTrackingModes().size() > 0) {
- context.getServletContext().setSessionTrackingModes(
- sessionConfig.getSessionTrackingModes());
+ context.getServletContext().setSessionTrackingModes(sessionConfig.getSessionTrackingModes());
}
}
@@ -1584,11 +1520,8 @@ public class ContextConfig implements LifecycleListener {
for (String welcomeFile : webxml.getWelcomeFiles()) {
/*
- * The following will result in a welcome file of "" so don't add
- * that to the context
- * <welcome-file-list>
- * <welcome-file/>
- * </welcome-file-list>
+ * The following will result in a welcome file of "" so don't add that to the context <welcome-file-list>
+ * <welcome-file/> </welcome-file-list>
*/
if (welcomeFile != null && welcomeFile.length() > 0) {
context.addWelcomeFile(welcomeFile);
@@ -1596,8 +1529,7 @@ public class ContextConfig implements LifecycleListener {
}
// Do this last as it depends on servlets
- for (JspPropertyGroup jspPropertyGroup :
- webxml.getJspPropertyGroups()) {
+ for (JspPropertyGroup jspPropertyGroup : webxml.getJspPropertyGroups()) {
String jspServletName = context.findServletMapping("*.jsp");
if (jspServletName == null) {
jspServletName = "jsp";
@@ -1607,22 +1539,19 @@ public class ContextConfig implements LifecycleListener {
context.addServletMappingDecoded(urlPattern, jspServletName, true);
}
} else {
- if(log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
for (String urlPattern : jspPropertyGroup.getUrlPatterns()) {
- log.debug("Skipping " + urlPattern + " , no servlet " +
- jspServletName);
+ log.debug("Skipping " + urlPattern + " , no servlet " + jspServletName);
}
}
}
}
- for (Entry<String, String> entry :
- webxml.getPostConstructMethods().entrySet()) {
+ for (Entry<String,String> entry : webxml.getPostConstructMethods().entrySet()) {
context.addPostConstructMethod(entry.getKey(), entry.getValue());
}
- for (Entry<String, String> entry :
- webxml.getPreDestroyMethods().entrySet()) {
+ for (Entry<String,String> entry : webxml.getPreDestroyMethods().entrySet()) {
context.addPreDestroyMethod(entry.getKey(), entry.getValue());
}
}
@@ -1744,8 +1673,7 @@ public class ContextConfig implements LifecycleListener {
// This is unusual enough to log
log.info(sm.getString("contextConfig.defaultMissing"));
} else {
- if (!webXmlParser.parseWebXml(
- globalWebXml, webXmlDefaultFragment, false)) {
+ if (!webXmlParser.parseWebXml(globalWebXml, webXmlDefaultFragment, false)) {
ok = false;
}
}
@@ -1754,15 +1682,13 @@ public class ContextConfig implements LifecycleListener {
// Additive apart from welcome pages
webXmlDefaultFragment.setReplaceWelcomeFiles(true);
- if (!webXmlParser.parseWebXml(
- hostWebXml, webXmlDefaultFragment, false)) {
+ if (!webXmlParser.parseWebXml(hostWebXml, webXmlDefaultFragment, false)) {
ok = false;
}
// Don't update the cache if an error occurs
if (globalTimeStamp != -1 && hostTimeStamp != -1) {
- entry = new DefaultWebXmlCacheEntry(webXmlDefaultFragment,
- globalTimeStamp, hostTimeStamp);
+ entry = new DefaultWebXmlCacheEntry(webXmlDefaultFragment, globalTimeStamp, hostTimeStamp);
hostWebXmlCache.put(host, entry);
// Add a Lifecycle listener to the Host that will remove it from
// the hostWebXmlCache once the Host is destroyed
@@ -1789,32 +1715,29 @@ public class ContextConfig implements LifecycleListener {
} else {
jspInitParams = jspServlet.getParameterMap();
}
- for (ServletDef servletDef: webXml.getServlets().values()) {
+ for (ServletDef servletDef : webXml.getServlets().values()) {
if (servletDef.getJspFile() != null) {
convertJsp(servletDef, jspInitParams);
}
}
}
- private void convertJsp(ServletDef servletDef,
- Map<String,String> jspInitParams) {
+ private void convertJsp(ServletDef servletDef, Map<String,String> jspInitParams) {
servletDef.setServletClass(org.apache.catalina.core.Constants.JSP_SERVLET_CLASS);
String jspFile = servletDef.getJspFile();
if ((jspFile != null) && !jspFile.startsWith("/")) {
if (context.isServlet22()) {
- if(log.isDebugEnabled()) {
- log.debug(sm.getString("contextConfig.jspFile.warning",
- jspFile));
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("contextConfig.jspFile.warning", jspFile));
}
jspFile = "/" + jspFile;
} else {
- throw new IllegalArgumentException
- (sm.getString("contextConfig.jspFile.error", jspFile));
+ throw new IllegalArgumentException(sm.getString("contextConfig.jspFile.error", jspFile));
}
}
servletDef.getParameterMap().put("jspFile", jspFile);
servletDef.setJspFile(null);
- for (Map.Entry<String, String> initParam: jspInitParams.entrySet()) {
+ for (Map.Entry<String,String> initParam : jspInitParams.entrySet()) {
servletDef.addInitParameter(initParam.getKey(), initParam.getValue());
}
}
@@ -1833,10 +1756,7 @@ public class ContextConfig implements LifecycleListener {
WebappServiceLoader<ServletContainerInitializer> loader = new WebappServiceLoader<>(context);
detectedScis = loader.load(ServletContainerInitializer.class);
} catch (IOException e) {
- log.error(sm.getString(
- "contextConfig.servletContainerInitializerFail",
- context.getName()),
- e);
+ log.error(sm.getString("contextConfig.servletContainerInitializerFail", context.getName()), e);
ok = false;
return;
}
@@ -1849,12 +1769,9 @@ public class ContextConfig implements LifecycleListener {
ht = sci.getClass().getAnnotation(HandlesTypes.class);
} catch (Exception e) {
if (log.isDebugEnabled()) {
- log.info(sm.getString("contextConfig.sci.debug",
- sci.getClass().getName()),
- e);
+ log.info(sm.getString("contextConfig.sci.debug", sci.getClass().getName()), e);
} else {
- log.info(sm.getString("contextConfig.sci.info",
- sci.getClass().getName()));
+ log.info(sm.getString("contextConfig.sci.info", sci.getClass().getName()));
}
continue;
}
@@ -1879,12 +1796,11 @@ public class ContextConfig implements LifecycleListener {
/**
- * Scan JARs that contain web-fragment.xml files that will be used to
- * configure this application to see if they also contain static resources.
- * If static resources are found, add them to the context. Resources are
- * added in web-fragment.xml priority order.
- * @param fragments The set of fragments that will be scanned for
- * static resources
+ * Scan JARs that contain web-fragment.xml files that will be used to configure this application to see if they also
+ * contain static resources. If static resources are found, add them to the context. Resources are added in
+ * web-fragment.xml priority order.
+ *
+ * @param fragments The set of fragments that will be scanned for static resources
*/
protected void processResourceJARs(Set<WebXml> fragments) {
for (WebXml fragment : fragments) {
@@ -1897,8 +1813,7 @@ public class ContextConfig implements LifecycleListener {
while (entryName != null) {
if (entryName.startsWith("META-INF/resources/")) {
context.getResources().createWebResourceSet(
- WebResourceRoot.ResourceSetType.RESOURCE_JAR,
- "/", url, "/META-INF/resources");
+ WebResourceRoot.ResourceSetType.RESOURCE_JAR, "/", url, "/META-INF/resources");
break;
}
jar.nextEntry();
@@ -1909,22 +1824,20 @@ public class ContextConfig implements LifecycleListener {
File file = new File(url.toURI());
File resources = new File(file, "META-INF/resources/");
if (resources.isDirectory()) {
- context.getResources().createWebResourceSet(
- WebResourceRoot.ResourceSetType.RESOURCE_JAR,
- "/", resources.getAbsolutePath(), null, "/");
+ context.getResources().createWebResourceSet(WebResourceRoot.ResourceSetType.RESOURCE_JAR, "/",
+ resources.getAbsolutePath(), null, "/");
}
}
} catch (IOException | URISyntaxException e) {
- log.error(sm.getString("contextConfig.resourceJarFail", url,
- context.getName()));
+ log.error(sm.getString("contextConfig.resourceJarFail", url, context.getName()));
}
}
}
/**
- * Identify the default web.xml to be used and obtain an input source for
- * it.
+ * Identify the default web.xml to be used and obtain an input source for it.
+ *
* @return an input source to the default web.xml
*/
protected InputSource getGlobalWebXmlSource() {
@@ -1946,8 +1859,8 @@ public class ContextConfig implements LifecycleListener {
/**
- * Identify the host web.xml to be used and obtain an input source for
- * it.
+ * Identify the host web.xml to be used and obtain an input source for it.
+ *
* @return an input source to the default per host web.xml
*/
protected InputSource getHostWebXmlSource() {
@@ -1960,8 +1873,8 @@ public class ContextConfig implements LifecycleListener {
}
/**
- * Identify the application web.xml to be used and obtain an input source
- * for it.
+ * Identify the application web.xml to be used and obtain an input source for it.
+ *
* @return an input source to the context web.xml
*/
protected InputSource getContextWebXmlSource() {
@@ -1975,23 +1888,20 @@ public class ContextConfig implements LifecycleListener {
ServletContext servletContext = context.getServletContext();
try {
if (servletContext != null) {
- altDDName = (String)servletContext.getAttribute(Globals.ALT_DD_ATTR);
+ altDDName = (String) servletContext.getAttribute(Globals.ALT_DD_ATTR);
if (altDDName != null) {
try {
stream = new FileInputStream(altDDName);
url = new File(altDDName).toURI().toURL();
} catch (FileNotFoundException e) {
- log.error(sm.getString("contextConfig.altDDNotFound",
- altDDName));
+ log.error(sm.getString("contextConfig.altDDNotFound", altDDName));
} catch (MalformedURLException e) {
log.error(sm.getString("contextConfig.applicationUrl"));
}
} else {
- stream = servletContext.getResourceAsStream
- (Constants.ApplicationWebXml);
+ stream = servletContext.getResourceAsStream(Constants.ApplicationWebXml);
try {
- url = servletContext.getResource(
- Constants.ApplicationWebXml);
+ url = servletContext.getResource(Constants.ApplicationWebXml);
} catch (MalformedURLException e) {
log.error(sm.getString("contextConfig.applicationUrl"));
}
@@ -2041,10 +1951,10 @@ public class ContextConfig implements LifecycleListener {
/**
* Utility method to create an input source from the specified XML file.
- * @param filename Name of the file (possibly with one or more leading path
- * segments) to read
- * @param global true if processing a shared resource, false if processing
- * a host based resource
+ *
+ * @param filename Name of the file (possibly with one or more leading path segments) to read
+ * @param global true if processing a shared resource, false if processing a host based resource
+ *
* @return the input source
*/
protected InputSource getWebXmlSource(String filename, boolean global) {
@@ -2091,18 +2001,17 @@ public class ContextConfig implements LifecycleListener {
/**
- * Scan /WEB-INF/lib for JARs and for each one found add it and any
- * /META-INF/web-fragment.xml to the resulting Map. web-fragment.xml files
- * will be parsed before being added to the map. Every JAR will be added and
- * <code>null</code> will be used if no web-fragment.xml was found. Any JARs
- * known not contain fragments will be skipped.
+ * Scan /WEB-INF/lib for JARs and for each one found add it and any /META-INF/web-fragment.xml to the resulting Map.
+ * web-fragment.xml files will be parsed before being added to the map. Every JAR will be added and
+ * <code>null</code> will be used if no web-fragment.xml was found. Any JARs known not contain fragments will be
+ * skipped.
*
- * @param application The main web.xml metadata
+ * @param application The main web.xml metadata
* @param webXmlParser The parser to use to process the web.xml file
+ *
* @return A map of JAR name to processed web fragment (if any)
*/
- protected Map<String,WebXml> processJarsForWebFragments(WebXml application,
- WebXmlParser webXmlParser) {
+ protected Map<String,WebXml> processJarsForWebFragments(WebXml application, WebXmlParser webXmlParser) {
JarScanner jarScanner = context.getJarScanner();
boolean delegate = false;
@@ -2111,18 +2020,15 @@ public class ContextConfig implements LifecycleListener {
}
boolean parseRequired = true;
Set<String> absoluteOrder = application.getAbsoluteOrdering();
- if (absoluteOrder != null && absoluteOrder.isEmpty() &&
- !context.getXmlValidation()) {
+ if (absoluteOrder != null && absoluteOrder.isEmpty() && !context.getXmlValidation()) {
// Skip parsing when there is an empty absolute ordering and
// validation is not enabled
parseRequired = false;
}
- FragmentJarScannerCallback callback =
- new FragmentJarScannerCallback(webXmlParser, delegate, parseRequired);
+ FragmentJarScannerCallback callback = new FragmentJarScannerCallback(webXmlParser, delegate, parseRequired);
- jarScanner.scan(JarScanType.PLUGGABILITY,
- context.getServletContext(), callback);
+ jarScanner.scan(JarScanType.PLUGGABILITY, context.getServletContext(), callback);
if (!callback.isOk()) {
ok = false;
@@ -2130,8 +2036,8 @@ public class ContextConfig implements LifecycleListener {
return callback.getFragments();
}
- protected void processAnnotations(Set<WebXml> fragments,
- boolean handlesTypesOnly, Map<String, JavaClassCacheEntry> javaClassCache) {
+ protected void processAnnotations(Set<WebXml> fragments, boolean handlesTypesOnly,
+ Map<String,JavaClassCacheEntry> javaClassCache) {
if (context.getParallelAnnotationScanning()) {
processAnnotationsInParallel(fragments, handlesTypesOnly, javaClassCache);
@@ -2142,16 +2048,16 @@ public class ContextConfig implements LifecycleListener {
}
}
- private void scanWebXmlFragment(boolean handlesTypesOnly, WebXml fragment, Map<String, JavaClassCacheEntry> javaClassCache) {
+ private void scanWebXmlFragment(boolean handlesTypesOnly, WebXml fragment,
+ Map<String,JavaClassCacheEntry> javaClassCache) {
// Only need to scan for @HandlesTypes matches if any of the
// following are true:
// - it has already been determined only @HandlesTypes is required
- // (e.g. main web.xml has metadata-complete="true"
+ // (e.g. main web.xml has metadata-complete="true"
// - this fragment is for a container JAR (Servlet 3.1 section 8.1)
// - this fragment has metadata-complete="true"
- boolean htOnly = handlesTypesOnly || !fragment.getWebappJar() ||
- fragment.isMetadataComplete();
+ boolean htOnly = handlesTypesOnly || !fragment.getWebappJar() || fragment.isMetadataComplete();
WebXml annotations = new WebXml();
// no impact on distributable
@@ -2165,15 +2071,16 @@ public class ContextConfig implements LifecycleListener {
}
/**
- * Executable task to scan a segment for annotations. Each task does the
- * same work as the for loop inside processAnnotations();
+ * Executable task to scan a segment for annotations. Each task does the same work as the for loop inside
+ * processAnnotations();
*/
private class AnnotationScanTask implements Runnable {
private final WebXml fragment;
private final boolean handlesTypesOnly;
- private Map<String, JavaClassCacheEntry> javaClassCache;
+ private Map<String,JavaClassCacheEntry> javaClassCache;
- private AnnotationScanTask(WebXml fragment, boolean handlesTypesOnly, Map<String, JavaClassCacheEntry> javaClassCache) {
+ private AnnotationScanTask(WebXml fragment, boolean handlesTypesOnly,
+ Map<String,JavaClassCacheEntry> javaClassCache) {
this.fragment = fragment;
this.handlesTypesOnly = handlesTypesOnly;
this.javaClassCache = javaClassCache;
@@ -2187,15 +2094,15 @@ public class ContextConfig implements LifecycleListener {
}
/**
- * Parallelized version of processAnnotationsInParallel(). Constructs tasks,
- * submits them as they're created, then waits for completion.
+ * Parallelized version of processAnnotationsInParallel(). Constructs tasks, submits them as they're created, then
+ * waits for completion.
*
* @param fragments Set of parallelizable scans
* @param handlesTypesOnly Important parameter for the underlying scan
- * @param javaClassCache The class cache
+ * @param javaClassCache The class cache
*/
protected void processAnnotationsInParallel(Set<WebXml> fragments, boolean handlesTypesOnly,
- Map<String, JavaClassCacheEntry> javaClassCache) {
+ Map<String,JavaClassCacheEntry> javaClassCache) {
Server s = getServer();
ExecutorService pool = (s == null) ? null : s.getUtilityExecutor();
if (pool != null) {
@@ -2219,38 +2126,31 @@ public class ContextConfig implements LifecycleListener {
}
}
- protected void processAnnotationsWebResource(WebResource webResource,
- WebXml fragment, boolean handlesTypesOnly,
+ protected void processAnnotationsWebResource(WebResource webResource, WebXml fragment, boolean handlesTypesOnly,
Map<String,JavaClassCacheEntry> javaClassCache) {
if (webResource.isDirectory()) {
- WebResource[] webResources =
- webResource.getWebResourceRoot().listResources(
- webResource.getWebappPath());
+ WebResource[] webResources = webResource.getWebResourceRoot().listResources(webResource.getWebappPath());
if (webResources.length > 0) {
if (log.isDebugEnabled()) {
- log.debug(sm.getString(
- "contextConfig.processAnnotationsWebDir.debug",
- webResource.getURL()));
+ log.debug(sm.getString("contextConfig.processAnnotationsWebDir.debug", webResource.getURL()));
}
for (WebResource r : webResources) {
processAnnotationsWebResource(r, fragment, handlesTypesOnly, javaClassCache);
}
}
- } else if (webResource.isFile() &&
- webResource.getName().endsWith(".class")) {
+ } else if (webResource.isFile() && webResource.getName().endsWith(".class")) {
try (InputStream is = webResource.getInputStream()) {
processAnnotationsStream(is, fragment, handlesTypesOnly, javaClassCache);
} catch (IOException | ClassFormatException e) {
- log.error(sm.getString("contextConfig.inputStreamWebResource",
- webResource.getWebappPath()),e);
+ log.error(sm.getString("contextConfig.inputStreamWebResource", webResource.getWebappPath()), e);
}
}
}
- protected void processAnnotationsUrl(URL url, WebXml fragment,
- boolean handlesTypesOnly, Map<String,JavaClassCacheEntry> javaClassCache) {
+ protected void processAnnotationsUrl(URL url, WebXml fragment, boolean handlesTypesOnly,
+ Map<String,JavaClassCacheEntry> javaClassCache) {
if (url == null) {
// Nothing to do.
return;
@@ -2258,26 +2158,23 @@ public class ContextConfig implements LifecycleListener {
processAnnotationsJar(url, fragment, handlesTypesOnly, javaClassCache);
} else if ("file".equals(url.getProtocol())) {
try {
- processAnnotationsFile(
- new File(url.toURI()), fragment, handlesTypesOnly, javaClassCache);
+ processAnnotationsFile(new File(url.toURI()), fragment, handlesTypesOnly, javaClassCache);
} catch (URISyntaxException e) {
log.error(sm.getString("contextConfig.fileUrl", url), e);
}
} else {
- log.error(sm.getString("contextConfig.unknownUrlProtocol",
- url.getProtocol(), url));
+ log.error(sm.getString("contextConfig.unknownUrlProtocol", url.getProtocol(), url));
}
}
- protected void processAnnotationsJar(URL url, WebXml fragment,
- boolean handlesTypesOnly, Map<String,JavaClassCacheEntry> javaClassCache) {
+ protected void processAnnotationsJar(URL url, WebXml fragment, boolean handlesTypesOnly,
+ Map<String,JavaClassCacheEntry> javaClassCache) {
try (Jar jar = JarFactory.newInstance(url)) {
if (log.isDebugEnabled()) {
- log.debug(sm.getString(
- "contextConfig.processAnnotationsJar.debug", url));
+ log.debug(sm.getString("contextConfig.processAnnotationsJar.debug", url));
}
jar.nextEntry();
@@ -2287,8 +2184,7 @@ public class ContextConfig implements LifecycleListener {
try (InputStream is = jar.getEntryInputStream()) {
processAnnotationsStream(is, fragment, handlesTypesOnly, javaClassCache);
} catch (IOException | ClassFormatException e) {
- log.error(sm.getString("contextConfig.inputStreamJar",
- entryName, url),e);
+ log.error(sm.getString("contextConfig.inputStreamJar", entryName, url), e);
}
}
jar.nextEntry();
@@ -2300,36 +2196,32 @@ public class ContextConfig implements LifecycleListener {
}
- protected void processAnnotationsFile(File file, WebXml fragment,
- boolean handlesTypesOnly, Map<String,JavaClassCacheEntry> javaClassCache) {
+ protected void processAnnotationsFile(File file, WebXml fragment, boolean handlesTypesOnly,
+ Map<String,JavaClassCacheEntry> javaClassCache) {
if (file.isDirectory()) {
// Returns null if directory is not readable
String[] dirs = file.list();
if (dirs != null) {
if (log.isDebugEnabled()) {
- log.debug(sm.getString(
- "contextConfig.processAnnotationsDir.debug", file));
+ log.debug(sm.getString("contextConfig.processAnnotationsDir.debug", file));
}
for (String dir : dirs) {
- processAnnotationsFile(
- new File(file,dir), fragment, handlesTypesOnly, javaClassCache);
+ processAnnotationsFile(new File(file, dir), fragment, handlesTypesOnly, javaClassCache);
}
}
} else if (file.getName().endsWith(".class") && file.canRead()) {
try (FileInputStream fis = new FileInputStream(file)) {
processAnnotationsStream(fis, fragment, handlesTypesOnly, javaClassCache);
} catch (IOException | ClassFormatException e) {
- log.error(sm.getString("contextConfig.inputStreamFile",
- file.getAbsolutePath()),e);
+ log.error(sm.getString("contextConfig.inputStreamFile", file.getAbsolutePath()), e);
}
}
}
- protected void processAnnotationsStream(InputStream is, WebXml fragment,
- boolean handlesTypesOnly, Map<String,JavaClassCacheEntry> javaClassCache)
- throws ClassFormatException, IOException {
+ protected void processAnnotationsStream(InputStream is, WebXml fragment, boolean handlesTypesOnly,
+ Map<String,JavaClassCacheEntry> javaClassCache) throws ClassFormatException, IOException {
ClassParser parser = new ClassParser(is);
JavaClass clazz = parser.parse();
@@ -2351,9 +2243,9 @@ public class ContextConfig implements LifecycleListener {
String type = ae.getAnnotationType();
if ("Ljakarta/servlet/annotation/WebServlet;".equals(type)) {
processAnnotationWebServlet(className, ae, fragment);
- }else if ("Ljakarta/servlet/annotation/WebFilter;".equals(type)) {
+ } else if ("Ljakarta/servlet/annotation/WebFilter;".equals(type)) {
processAnnotationWebFilter(className, ae, fragment);
- }else if ("Ljakarta/servlet/annotation/WebListener;".equals(type)) {
+ } else if ("Ljakarta/servlet/annotation/WebListener;".equals(type)) {
fragment.addListener(className);
} else {
// Unknown annotation - ignore
@@ -2364,22 +2256,20 @@ public class ContextConfig implements LifecycleListener {
/**
- * For classes packaged with the web application, the class and each
- * super class needs to be checked for a match with {@link HandlesTypes} or
- * for an annotation that matches {@link HandlesTypes}.
- * @param javaClass the class to check
+ * For classes packaged with the web application, the class and each super class needs to be checked for a match
+ * with {@link HandlesTypes} or for an annotation that matches {@link HandlesTypes}.
+ *
+ * @param javaClass the class to check
* @param javaClassCache a class cache
*/
- protected void checkHandlesTypes(JavaClass javaClass,
- Map<String,JavaClassCacheEntry> javaClassCache) {
+ protected void checkHandlesTypes(JavaClass javaClass, Map<String,JavaClassCacheEntry> javaClassCache) {
// Skip this if we can
if (typeInitializerMap.size() == 0) {
return;
}
- if ((javaClass.getAccessFlags() &
- org.apache.tomcat.util.bcel.Const.ACC_ANNOTATION) != 0) {
+ if ((javaClass.getAccessFlags() & org.apache.tomcat.util.bcel.Const.ACC_ANNOTATION) != 0) {
// Skip annotations.
return;
}
@@ -2395,10 +2285,8 @@ public class ContextConfig implements LifecycleListener {
try {
populateSCIsForCacheEntry(entry, javaClassCache);
} catch (StackOverflowError soe) {
- throw new IllegalStateException(sm.getString(
- "contextConfig.annotationsStackOverflow",
- context.getName(),
- classHierarchyToString(className, entry, javaClassCache)));
+ throw new IllegalStateException(sm.getString("contextConfig.annotationsStackOverflow",
+ context.getName(), classHierarchyToString(className, entry, javaClassCache)));
}
}
if (!entry.getSciSet().isEmpty()) {
@@ -2419,16 +2307,13 @@ public class ContextConfig implements LifecycleListener {
if (handlesTypesAnnotations) {
AnnotationEntry[] annotationEntries = javaClass.getAllAnnotationEntries();
if (annotationEntries != null) {
- for (Map.Entry<Class<?>, Set<ServletContainerInitializer>> entry :
- typeInitializerMap.entrySet()) {
+ for (Map.Entry<Class<?>,Set<ServletContainerInitializer>> entry : typeInitializerMap.entrySet()) {
if (entry.getKey().isAnnotation()) {
String entryClassName = entry.getKey().getName();
for (AnnotationEntry annotationEntry : annotationEntries) {
- if (entryClassName.equals(
- getClassName(annotationEntry.getAnnotationType()))) {
+ if (entryClassName.equals(getClassName(annotationEntry.getAnnotationType()))) {
if (clazz == null) {
- clazz = Introspection.loadClass(
- context, className);
+ clazz = Introspection.loadClass(context, className);
if (clazz == null) {
// Can't load the class so no point
// continuing
@@ -2448,8 +2333,8 @@ public class ContextConfig implements LifecycleListener {
}
- private String classHierarchyToString(String className,
- JavaClassCacheEntry entry, Map<String,JavaClassCacheEntry> javaClassCache) {
+ private String classHierarchyToString(String className, JavaClassCacheEntry entry,
+ Map<String,JavaClassCacheEntry> javaClassCache) {
JavaClassCacheEntry start = entry;
StringBuilder msg = new StringBuilder(className);
msg.append("->");
@@ -2462,7 +2347,7 @@ public class ContextConfig implements LifecycleListener {
msg.append(parentName);
msg.append("->");
- count ++;
+ count++;
parentName = parent.getSuperclassName();
parent = javaClassCache.get(parentName);
}
@@ -2488,8 +2373,7 @@ public class ContextConfig implements LifecycleListener {
}
}
- private void populateJavaClassCache(String className,
- Map<String,JavaClassCacheEntry> javaClassCache) {
+ private void populateJavaClassCache(String className, Map<String,JavaClassCacheEntry> javaClassCache) {
if (!javaClassCache.containsKey(className)) {
String name = className.replace('.', '/') + ".class";
try (InputStream is = context.getLoader().getClassLoader().getResourceAsStream(name)) {
@@ -2500,8 +2384,7 @@ public class ContextConfig implements LifecycleListener {
JavaClass clazz = parser.parse();
populateJavaClassCache(clazz.getClassName(), clazz, javaClassCache);
} catch (ClassFormatException | IOException e) {
- log.debug(sm.getString("contextConfig.invalidSciHandlesTypes",
- className), e);
+ log.debug(sm.getString("contextConfig.invalidSciHandlesTypes", className), e);
}
}
}
@@ -2512,8 +2395,7 @@ public class ContextConfig implements LifecycleListener {
// Super class
String superClassName = cacheEntry.getSuperclassName();
- JavaClassCacheEntry superClassCacheEntry =
- javaClassCache.get(superClassName);
+ JavaClassCacheEntry superClassCacheEntry = javaClassCache.get(superClassName);
// Avoid an infinite loop with java.lang.Object
if (cacheEntry.equals(superClassCacheEntry)) {
@@ -2532,8 +2414,7 @@ public class ContextConfig implements LifecycleListener {
// Interfaces
for (String interfaceName : cacheEntry.getInterfaceNames()) {
- JavaClassCacheEntry interfaceEntry =
- javaClassCache.get(interfaceName);
+ JavaClassCacheEntry interfaceEntry = javaClassCache.get(interfaceName);
// A null could mean that the class not present in application or
// that there is nothing of interest. Either way, nothing to do here
// so move along
@@ -2550,8 +2431,7 @@ public class ContextConfig implements LifecycleListener {
}
private Set<ServletContainerInitializer> getSCIsForClass(String className) {
- for (Map.Entry<Class<?>, Set<ServletContainerInitializer>> entry :
- typeInitializerMap.entrySet()) {
+ for (Map.Entry<Class<?>,Set<ServletContainerInitializer>> entry : typeInitializerMap.entrySet()) {
Class<?> clazz = entry.getKey();
if (!clazz.isAnnotation()) {
if (clazz.getName().equals(className)) {
@@ -2568,12 +2448,10 @@ public class ContextConfig implements LifecycleListener {
}
// Assume starts with L, ends with ; and uses / rather than .
- return internalForm.substring(1,
- internalForm.length() - 1).replace('/', '.');
+ return internalForm.substring(1, internalForm.length() - 1).replace('/', '.');
}
- protected void processAnnotationWebServlet(String className,
- AnnotationEntry ae, WebXml fragment) {
+ protected void processAnnotationWebServlet(String className, AnnotationEntry ae, WebXml fragment) {
String servletName = null;
// must search for name s. Spec Servlet API 3.0 - 8.2.3.3.n.ii page 81
List<ElementValuePair> evps = ae.getElementValuePairs();
@@ -2608,8 +2486,8 @@ public class ContextConfig implements LifecycleListener {
String name = evp.getNameString();
if ("value".equals(name) || "urlPatterns".equals(name)) {
if (urlPatternsSet) {
- throw new IllegalArgumentException(sm.getString(
- "contextConfig.urlPatternValue", "WebServlet", className));
+ throw new IllegalArgumentException(
+ sm.getString("contextConfig.urlPatternValue", "WebServlet", className));
}
urlPatternsSet = true;
urlPatterns = processAnnotationsStringArray(evp.getValue());
@@ -2631,32 +2509,24 @@ public class ContextConfig implements LifecycleListener {
}
} else if ("asyncSupported".equals(name)) {
if (servletDef.getAsyncSupported() == null) {
- servletDef.setAsyncSupported(evp.getValue()
- .stringifyValue());
+ servletDef.setAsyncSupported(evp.getValue().stringifyValue());
}
} else if ("loadOnStartup".equals(name)) {
if (servletDef.getLoadOnStartup() == null) {
- servletDef
- .setLoadOnStartup(evp.getValue().stringifyValue());
+ servletDef.setLoadOnStartup(evp.getValue().stringifyValue());
}
} else if ("initParams".equals(name)) {
- Map<String, String> initParams = processAnnotationWebInitParams(evp
- .getValue());
+ Map<String,String> initParams = processAnnotationWebInitParams(evp.getValue());
if (isWebXMLservletDef) {
- Map<String, String> webXMLInitParams = servletDef
- .getParameterMap();
- for (Map.Entry<String, String> entry : initParams
- .entrySet()) {
+ Map<String,String> webXMLInitParams = servletDef.getParameterMap();
+ for (Map.Entry<String,String> entry : initParams.entrySet()) {
if (webXMLInitParams.get(entry.getKey()) == null) {
- servletDef.addInitParameter(entry.getKey(), entry
- .getValue());
+ servletDef.addInitParameter(entry.getKey(), entry.getValue());
}
}
} else {
- for (Map.Entry<String, String> entry : initParams
- .entrySet()) {
- servletDef.addInitParameter(entry.getKey(), entry
- .getValue());
+ for (Map.Entry<String,String> entry : initParams.entrySet()) {
+ servletDef.addInitParameter(entry.getKey(), entry.getValue());
}
}
}
@@ -2675,15 +2545,14 @@ public class ContextConfig implements LifecycleListener {
}
/**
- * process filter annotation and merge with existing one!
- * FIXME: refactoring method too long and has redundant subroutines with
- * processAnnotationWebServlet!
+ * process filter annotation and merge with existing one! FIXME: refactoring method too long and has redundant
+ * subroutines with processAnnotationWebServlet!
+ *
* @param className The filter class name
- * @param ae The filter annotation
- * @param fragment The corresponding fragment
+ * @param ae The filter annotation
+ * @param fragment The corresponding fragment
*/
- protected void processAnnotationWebFilter(String className,
- AnnotationEntry ae, WebXml fragment) {
+ protected void processAnnotationWebFilter(String className, AnnotationEntry ae, WebXml fragment) {
String filterName = null;
// must search for name s. Spec Servlet API 3.0 - 8.2.3.3.n.ii page 81
List<ElementValuePair> evps = ae.getElementValuePairs();
@@ -2720,8 +2589,8 @@ public class ContextConfig implements LifecycleListener {
String name = evp.getNameString();
if ("value".equals(name) || "urlPatterns".equals(name)) {
if (urlPatternsSet) {
- throw new IllegalArgumentException(sm.getString(
- "contextConfig.urlPatternValue", "WebFilter", className));
+ throw new IllegalArgumentException(
+ sm.getString("contextConfig.urlPatternValue", "WebFilter", className));
}
urlPatterns = processAnnotationsStringArray(evp.getValue());
urlPatternsSet = urlPatterns.length > 0;
@@ -2730,15 +2599,13 @@ public class ContextConfig implements LifecycleListener {
filterMap.addURLPattern(urlPattern);
}
} else if ("servletNames".equals(name)) {
- String[] servletNames = processAnnotationsStringArray(evp
- .getValue());
+ String[] servletNames = processAnnotationsStringArray(evp.getValue());
servletNamesSet = servletNames.length > 0;
for (String servletName : servletNames) {
filterMap.addServletName(servletName);
}
} else if ("dispatcherTypes".equals(name)) {
- String[] dispatcherTypes = processAnnotationsStringArray(evp
- .getValue());
+ String[] dispatcherTypes = processAnnotationsStringArray(evp.getValue());
dispatchTypesSet = dispatcherTypes.length > 0;
for (String dispatcherType : dispatcherTypes) {
filterMap.setDispatcher(dispatcherType);
@@ -2761,27 +2628,20 @@ public class ContextConfig implements LifecycleListener {
}
} else if ("asyncSupported".equals(name)) {
if (filterDef.getAsyncSupported() == null) {
- filterDef
- .setAsyncSupported(evp.getValue().stringifyValue());
+ filterDef.setAsyncSupported(evp.getValue().stringifyValue());
}
} else if ("initParams".equals(name)) {
- Map<String, String> initParams = processAnnotationWebInitParams(evp
- .getValue());
+ Map<String,String> initParams = processAnnotationWebInitParams(evp.getValue());
if (isWebXMLfilterDef) {
- Map<String, String> webXMLInitParams = filterDef
- .getParameterMap();
- for (Map.Entry<String, String> entry : initParams
- .entrySet()) {
+ Map<String,String> webXMLInitParams = filterDef.getParameterMap();
+ for (Map.Entry<String,String> entry : initParams.entrySet()) {
if (webXMLInitParams.get(entry.getKey()) == null) {
- filterDef.addInitParameter(entry.getKey(), entry
- .getValue());
+ filterDef.addInitParameter(entry.getKey(), entry.getValue());
}
}
} else {
- for (Map.Entry<String, String> entry : initParams
- .entrySet()) {
- filterDef.addInitParameter(entry.getKey(), entry
- .getValue());
+ for (Map.Entry<String,String> entry : initParams.entrySet()) {
+ filterDef.addInitParameter(entry.getKey(), entry.getValue());
}
}
@@ -2805,16 +2665,14 @@ public class ContextConfig implements LifecycleListener {
}
if (descMap != null) {
String[] urlsPatterns = descMap.getURLPatterns();
- if (urlPatternsSet
- && (urlsPatterns == null || urlsPatterns.length == 0)) {
+ if (urlPatternsSet && (urlsPatterns == null || urlsPatterns.length == 0)) {
for (String urlPattern : filterMap.getURLPatterns()) {
// % decoded (if required) using UTF-8
descMap.addURLPattern(urlPattern);
}
}
String[] dispatcherNames = descMap.getDispatcherNames();
- if (dispatchTypesSet
- && (dispatcherNames == null || dispatcherNames.length == 0)) {
+ if (dispatchTypesSet && (dispatcherNames == null || dispatcherNames.length == 0)) {
for (String dis : filterMap.getDispatcherNames()) {
descMap.setDispatcher(dis);
}
@@ -2827,8 +2685,7 @@ public class ContextConfig implements LifecycleListener {
protected String[] processAnnotationsStringArray(ElementValue ev) {
List<String> values = new ArrayList<>();
if (ev instanceof ArrayElementValue) {
- ElementValue[] arrayValues =
- ((ArrayElementValue) ev).getElementValuesArray();
+ ElementValue[] arrayValues = ((ArrayElementValue) ev).getElementValuesArray();
for (ElementValue value : arrayValues) {
values.add(value.stringifyValue());
}
@@ -2838,16 +2695,14 @@ public class ContextConfig implements LifecycleListener {
return values.toArray(new String[0]);
}
- protected Map<String,String> processAnnotationWebInitParams(
- ElementValue ev) {
- Map<String, String> result = new HashMap<>();
+ protected Map<String,String> processAnnotationWebInitParams(ElementValue ev) {
+ Map<String,String> result = new HashMap<>();
if (ev instanceof ArrayElementValue) {
- ElementValue[] arrayValues =
- ((ArrayElementValue) ev).getElementValuesArray();
+ ElementValue[] arrayValues = ((ArrayElementValue) ev).getElementValuesArray();
for (ElementValue value : arrayValues) {
if (value instanceof AnnotationElementValue) {
- List<ElementValuePair> evps = ((AnnotationElementValue) value)
- .getAnnotationEntry().getElementValuePairs();
+ List<ElementValuePair> evps =
+ ((AnnotationElementValue) value).getAnnotationEntry().getElementValuePairs();
String initParamName = null;
String initParamValue = null;
for (ElementValuePair evp : evps) {
@@ -2871,8 +2726,7 @@ public class ContextConfig implements LifecycleListener {
private final long globalTimeStamp;
private final long hostTimeStamp;
- DefaultWebXmlCacheEntry(WebXml webXml, long globalTimeStamp,
- long hostTimeStamp) {
+ DefaultWebXmlCacheEntry(WebXml webXml, long globalTimeStamp, long hostTimeStamp) {
this.webXml = webXml;
this.globalTimeStamp = globalTimeStamp;
this.hostTimeStamp = hostTimeStamp;
diff --git a/java/org/apache/catalina/startup/ContextRuleSet.java b/java/org/apache/catalina/startup/ContextRuleSet.java
index fb054df88b..4009b6dad9 100644
--- a/java/org/apache/catalina/startup/ContextRuleSet.java
+++ b/java/org/apache/catalina/startup/ContextRuleSet.java
@@ -20,8 +20,7 @@ import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
/**
- * <strong>RuleSet</strong> for processing the contents of a
- * Context definition element.
+ * <strong>RuleSet</strong> for processing the contents of a Context definition element.
*
* @author Craig R. McClanahan
*/
@@ -44,8 +43,7 @@ public class ContextRuleSet implements RuleSet {
// ------------------------------------------------------------ Constructor
/**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
+ * Construct an instance of this <code>RuleSet</code> with the default matching pattern prefix.
*/
public ContextRuleSet() {
this("");
@@ -53,11 +51,9 @@ public class ContextRuleSet implements RuleSet {
/**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern 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)
+ * @param prefix Prefix for matching pattern rules (including the trailing slash character)
*/
public ContextRuleSet(String prefix) {
this(prefix, true);
@@ -65,13 +61,10 @@ public class ContextRuleSet implements RuleSet {
/**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern 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)
- * @param create <code>true</code> if the main context instance should be
- * created
+ * @param prefix Prefix for matching pattern rules (including the trailing slash character)
+ * @param create <code>true</code> if the main context instance should be created
*/
public ContextRuleSet(String prefix, boolean create) {
this.prefix = prefix;
@@ -82,171 +75,125 @@ public class ContextRuleSet implements RuleSet {
// --------------------------------------------------------- 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>
+ * <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.
+ * @param digester Digester instance to which the new Rule instances should be added.
*/
@Override
public void addRuleInstances(Digester digester) {
if (create) {
- digester.addObjectCreate(prefix + "Context",
- "org.apache.catalina.core.StandardContext", "className");
+ digester.addObjectCreate(prefix + "Context", "org.apache.catalina.core.StandardContext", "className");
digester.addSetProperties(prefix + "Context");
} else {
- digester.addSetProperties(prefix + "Context", new String[]{"path", "docBase"});
+ digester.addSetProperties(prefix + "Context", new String[] { "path", "docBase" });
}
if (create) {
digester.addRule(prefix + "Context",
- new LifecycleListenerRule
- ("org.apache.catalina.startup.ContextConfig",
- "configClass"));
- digester.addSetNext(prefix + "Context",
- "addChild",
- "org.apache.catalina.Container");
+ new LifecycleListenerRule("org.apache.catalina.startup.ContextConfig", "configClass"));
+ digester.addSetNext(prefix + "Context", "addChild", "org.apache.catalina.Container");
}
- digester.addObjectCreate(prefix + "Context/Listener",
- null, // MUST be specified in the element
- "className");
+ 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.addSetNext(prefix + "Context/Listener", "addLifecycleListener",
+ "org.apache.catalina.LifecycleListener");
- digester.addObjectCreate(prefix + "Context/Loader",
- "org.apache.catalina.loader.WebappLoader",
- "className");
+ 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.addSetNext(prefix + "Context/Loader", "setLoader", "org.apache.catalina.Loader");
- digester.addObjectCreate(prefix + "Context/Manager",
- "org.apache.catalina.session.StandardManager",
- "className");
+ 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.addSetNext(prefix + "Context/Manager", "setManager", "org.apache.catalina.Manager");
- digester.addObjectCreate(prefix + "Context/Manager/Store",
- null, // MUST be specified in the element
- "className");
+ 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.addSetNext(prefix + "Context/Manager/Store", "setStore", "org.apache.catalina.Store");
digester.addObjectCreate(prefix + "Context/Manager/SessionIdGenerator",
- "org.apache.catalina.util.StandardSessionIdGenerator",
- "className");
+ "org.apache.catalina.util.StandardSessionIdGenerator", "className");
digester.addSetProperties(prefix + "Context/Manager/SessionIdGenerator");
- digester.addSetNext(prefix + "Context/Manager/SessionIdGenerator",
- "setSessionIdGenerator",
- "org.apache.catalina.SessionIdGenerator");
+ digester.addSetNext(prefix + "Context/Manager/SessionIdGenerator", "setSessionIdGenerator",
+ "org.apache.catalina.SessionIdGenerator");
digester.addObjectCreate(prefix + "Context/Parameter",
- "org.apache.tomcat.util.descriptor.web.ApplicationParameter");
+ "org.apache.tomcat.util.descriptor.web.ApplicationParameter");
digester.addSetProperties(prefix + "Context/Parameter");
- digester.addSetNext(prefix + "Context/Parameter",
- "addApplicationParameter",
- "org.apache.tomcat.util.descriptor.web.ApplicationParameter");
+ digester.addSetNext(prefix + "Context/Parameter", "addApplicationParameter",
+ "org.apache.tomcat.util.descriptor.web.ApplicationParameter");
digester.addRuleSet(new RealmRuleSet(prefix + "Context/"));
- digester.addObjectCreate(prefix + "Context/Resources",
- "org.apache.catalina.webresources.StandardRoot",
- "className");
+ digester.addObjectCreate(prefix + "Context/Resources", "org.apache.catalina.webresources.StandardRoot",
+ "className");
digester.addSetProperties(prefix + "Context/Resources");
- digester.addSetNext(prefix + "Context/Resources",
- "setResources",
- "org.apache.catalina.WebResourceRoot");
+ digester.addSetNext(prefix + "Context/Resources", "setResources", "org.apache.catalina.WebResourceRoot");
- digester.addObjectCreate(prefix + "Context/Resources/CacheStrategy",
- null, // MUST be specified in the element
- "className");
+ digester.addObjectCreate(prefix + "Context/Resources/CacheStrategy", null, // MUST be specified in the element
+ "className");
digester.addSetProperties(prefix + "Context/Resources/CacheStrategy");
- digester.addSetNext(prefix + "Context/Resources/CacheStrategy",
- "setCacheStrategy",
- "org.apache.catalina.WebResourceRoot$CacheStrategy");
+ digester.addSetNext(prefix + "Context/Resources/CacheStrategy", "setCacheStrategy",
+ "org.apache.catalina.WebResourceRoot$CacheStrategy");
- digester.addObjectCreate(prefix + "Context/Resources/PreResources",
- null, // MUST be specified in the element
- "className");
+ digester.addObjectCreate(prefix + "Context/Resources/PreResources", null, // MUST be specified in the element
+ "className");
digester.addSetProperties(prefix + "Context/Resources/PreResources");
- digester.addSetNext(prefix + "Context/Resources/PreResources",
- "addPreResources",
- "org.apache.catalina.WebResourceSet");
+ digester.addSetNext(prefix + "Context/Resources/PreResources", "addPreResources",
+ "org.apache.catalina.WebResourceSet");
- digester.addObjectCreate(prefix + "Context/Resources/JarResources",
- null, // MUST be specified in the element
- "className");
+ digester.addObjectCreate(prefix + "Context/Resources/JarResources", null, // MUST be specified in the element
+ "className");
digester.addSetProperties(prefix + "Context/Resources/JarResources");
- digester.addSetNext(prefix + "Context/Resources/JarResources",
- "addJarResources",
- "org.apache.catalina.WebResourceSet");
+ digester.addSetNext(prefix + "Context/Resources/JarResources", "addJarResources",
+ "org.apache.catalina.WebResourceSet");
- digester.addObjectCreate(prefix + "Context/Resources/PostResources",
- null, // MUST be specified in the element
- "className");
+ digester.addObjectCreate(prefix + "Context/Resources/PostResources", null, // MUST be specified in the element
+ "className");
digester.addSetProperties(prefix + "Context/Resources/PostResources");
- digester.addSetNext(prefix + "Context/Resources/PostResources",
- "addPostResources",
- "org.apache.catalina.WebResourceSet");
+ digester.addSetNext(prefix + "Context/Resources/PostResources", "addPostResources",
+ "org.apache.catalina.WebResourceSet");
digester.addObjectCreate(prefix + "Context/ResourceLink",
"org.apache.tomcat.util.descriptor.web.ContextResourceLink");
digester.addSetProperties(prefix + "Context/ResourceLink");
digester.addRule(prefix + "Context/ResourceLink",
- new SetNextNamingRule("addResourceLink",
- "org.apache.tomcat.util.descriptor.web.ContextResourceLink"));
+ new SetNextNamingRule("addResourceLink", "org.apache.tomcat.util.descriptor.web.ContextResourceLink"));
- digester.addObjectCreate(prefix + "Context/Valve",
- null, // MUST be specified in the element
- "className");
+ 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.addSetNext(prefix + "Context/Valve", "addValve", "org.apache.catalina.Valve");
- digester.addCallMethod(prefix + "Context/WatchedResource",
- "addWatchedResource", 0);
+ digester.addCallMethod(prefix + "Context/WatchedResource", "addWatchedResource", 0);
- digester.addCallMethod(prefix + "Context/WrapperLifecycle",
- "addWrapperLifecycle", 0);
+ digester.addCallMethod(prefix + "Context/WrapperLifecycle", "addWrapperLifecycle", 0);
- digester.addCallMethod(prefix + "Context/WrapperListener",
- "addWrapperListener", 0);
+ digester.addCallMethod(prefix + "Context/WrapperListener", "addWrapperListener", 0);
- digester.addObjectCreate(prefix + "Context/JarScanner",
- "org.apache.tomcat.util.scan.StandardJarScanner",
- "className");
+ digester.addObjectCreate(prefix + "Context/JarScanner", "org.apache.tomcat.util.scan.StandardJarScanner",
+ "className");
digester.addSetProperties(prefix + "Context/JarScanner");
- digester.addSetNext(prefix + "Context/JarScanner",
- "setJarScanner",
- "org.apache.tomcat.JarScanner");
+ digester.addSetNext(prefix + "Context/JarScanner", "setJarScanner", "org.apache.tomcat.JarScanner");
digester.addObjectCreate(prefix + "Context/JarScanner/JarScanFilter",
- "org.apache.tomcat.util.scan.StandardJarScanFilter",
- "className");
+ "org.apache.tomcat.util.scan.StandardJarScanFilter", "className");
digester.addSetProperties(prefix + "Context/JarScanner/JarScanFilter");
- digester.addSetNext(prefix + "Context/JarScanner/JarScanFilter",
- "setJarScanFilter",
- "org.apache.tomcat.JarScanFilter");
+ digester.addSetNext(prefix + "Context/JarScanner/JarScanFilter", "setJarScanFilter",
+ "org.apache.tomcat.JarScanFilter");
digester.addObjectCreate(prefix + "Context/CookieProcessor",
- "org.apache.tomcat.util.http.Rfc6265CookieProcessor",
- "className");
+ "org.apache.tomcat.util.http.Rfc6265CookieProcessor", "className");
digester.addSetProperties(prefix + "Context/CookieProcessor");
- digester.addSetNext(prefix + "Context/CookieProcessor",
- "setCookieProcessor",
- "org.apache.tomcat.util.http.CookieProcessor");
+ digester.addSetNext(prefix + "Context/CookieProcessor", "setCookieProcessor",
+ "org.apache.tomcat.util.http.CookieProcessor");
}
}
diff --git a/java/org/apache/catalina/startup/CopyParentClassLoaderRule.java b/java/org/apache/catalina/startup/CopyParentClassLoaderRule.java
index a7f4998ef2..e271113fbf 100644
--- a/java/org/apache/catalina/startup/CopyParentClassLoaderRule.java
+++ b/java/org/apache/catalina/startup/CopyParentClassLoaderRule.java
@@ -25,10 +25,8 @@ import org.xml.sax.Attributes;
/**
- * 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>).
+ * 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>).
*
* @author Craig R. McClanahan
*/
@@ -56,18 +54,15 @@ public class CopyParentClassLoaderRule extends Rule {
* @exception Exception if a processing error occurs
*/
@Override
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
+ 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]);
+ Method method = parent.getClass().getMethod("getParentClassLoader", new Class[0]);
+ ClassLoader classLoader = (ClassLoader) method.invoke(parent, new Object[0]);
child.setParentClassLoader(classLoader);
StringBuilder code = digester.getGeneratedCode();
diff --git a/java/org/apache/catalina/startup/CredentialHandlerRuleSet.java b/java/org/apache/catalina/startup/CredentialHandlerRuleSet.java
index 68404e718c..4d804f0042 100644
--- a/java/org/apache/catalina/startup/CredentialHandlerRuleSet.java
+++ b/java/org/apache/catalina/startup/CredentialHandlerRuleSet.java
@@ -20,17 +20,15 @@ import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
/**
- * <strong>RuleSet</strong> for processing the contents of a
- * CredentialHandler definition element. This <code>RuleSet</code> supports
- * CredentialHandler such as the <code>NestedCredentialHandler</code> that used
- * nested CredentialHandlers.
+ * <strong>RuleSet</strong> for processing the contents of a CredentialHandler definition element. This
+ * <code>RuleSet</code> supports CredentialHandler such as the <code>NestedCredentialHandler</code> that used nested
+ * CredentialHandlers.
*/
public class CredentialHandlerRuleSet implements RuleSet {
- private static final int MAX_NESTED_LEVELS = Integer.getInteger(
- "org.apache.catalina.startup.CredentialHandlerRuleSet.MAX_NESTED_LEVELS",
- 3).intValue();
+ private static final int MAX_NESTED_LEVELS =
+ Integer.getInteger("org.apache.catalina.startup.CredentialHandlerRuleSet.MAX_NESTED_LEVELS", 3).intValue();
// ----------------------------------------------------- Instance Variables
@@ -45,8 +43,7 @@ public class CredentialHandlerRuleSet implements RuleSet {
/**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
+ * Construct an instance of this <code>RuleSet</code> with the default matching pattern prefix.
*/
public CredentialHandlerRuleSet() {
this("");
@@ -54,11 +51,9 @@ public class CredentialHandlerRuleSet implements RuleSet {
/**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern 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)
+ * @param prefix Prefix for matching pattern rules (including the trailing slash character)
*/
public CredentialHandlerRuleSet(String prefix) {
this.prefix = prefix;
@@ -69,13 +64,12 @@ public class CredentialHandlerRuleSet implements RuleSet {
/**
- * <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>
+ * <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.
+ * @param digester Digester instance to which the new Rule instances should be added.
*/
@Override
public void addRuleInstances(Digester digester) {
@@ -85,14 +79,12 @@ public class CredentialHandlerRuleSet implements RuleSet {
pattern.append('/');
}
pattern.append("CredentialHandler");
- addRuleInstances(digester, pattern.toString(), i == 0 ? "setCredentialHandler"
- : "addCredentialHandler");
+ addRuleInstances(digester, pattern.toString(), i == 0 ? "setCredentialHandler" : "addCredentialHandler");
}
}
private void addRuleInstances(Digester digester, String pattern, String methodName) {
- digester.addObjectCreate(pattern, null /* MUST be specified in the element */,
- "className");
+ digester.addObjectCreate(pattern, null /* MUST be specified in the element */, "className");
digester.addSetProperties(pattern);
digester.addSetNext(pattern, methodName, "org.apache.catalina.CredentialHandler");
}
diff --git a/java/org/apache/catalina/startup/EngineConfig.java b/java/org/apache/catalina/startup/EngineConfig.java
index 59867a5fbe..2b8b920a3e 100644
--- a/java/org/apache/catalina/startup/EngineConfig.java
+++ b/java/org/apache/catalina/startup/EngineConfig.java
@@ -27,13 +27,12 @@ import org.apache.tomcat.util.res.StringManager;
/**
- * Startup event listener for an <b>Engine</b> that configures the properties
- * of that Engine, and the associated defined contexts.
+ * Startup event listener for an <b>Engine</b> that configures the properties of that Engine, and the associated defined
+ * contexts.
*
* @author Craig R. McClanahan
*/
-public class EngineConfig
- implements LifecycleListener {
+public class EngineConfig implements LifecycleListener {
private static final Log log = LogFactory.getLog(EngineConfig.class);
@@ -50,8 +49,7 @@ public class EngineConfig
/**
* The string resources for this package.
*/
- protected static final StringManager sm =
- StringManager.getManager(Constants.Package);
+ protected static final StringManager sm = StringManager.getManager(Constants.Package);
// --------------------------------------------------------- Public Methods
diff --git a/java/org/apache/catalina/startup/EngineRuleSet.java b/java/org/apache/catalina/startup/EngineRuleSet.java
index 30601f8752..0e1bc5dbd2 100644
--- a/java/org/apache/catalina/startup/EngineRuleSet.java
+++ b/java/org/apache/catalina/startup/EngineRuleSet.java
@@ -20,10 +20,8 @@ import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
/**
- * <strong>RuleSet</strong> for processing the contents of a
- * Engine definition element. This <code>RuleSet</code> does NOT include
- * any rules for nested Host elements, which should be added via instances of
- * <code>HostRuleSet</code>.
+ * <strong>RuleSet</strong> for processing the contents of a Engine definition element. This <code>RuleSet</code> does
+ * NOT include any rules for nested Host elements, which should be added via instances of <code>HostRuleSet</code>.
*
* @author Craig R. McClanahan
*/
@@ -40,8 +38,7 @@ public class EngineRuleSet implements RuleSet {
// ------------------------------------------------------------ Constructor
/**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
+ * Construct an instance of this <code>RuleSet</code> with the default matching pattern prefix.
*/
public EngineRuleSet() {
this("");
@@ -49,11 +46,9 @@ public class EngineRuleSet implements RuleSet {
/**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern 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)
+ * @param prefix Prefix for matching pattern rules (including the trailing slash character)
*/
public EngineRuleSet(String prefix) {
this.prefix = prefix;
@@ -63,56 +58,41 @@ public class EngineRuleSet implements RuleSet {
// --------------------------------------------------------- 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>
+ * <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.
+ * @param digester Digester instance to which the new Rule instances should be added.
*/
@Override
public void addRuleInstances(Digester digester) {
- digester.addObjectCreate(prefix + "Engine",
- "org.apache.catalina.core.StandardEngine",
- "className");
+ 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.Engine");
-
- //Cluster configuration start
- digester.addObjectCreate(prefix + "Engine/Cluster",
- null, // MUST be specified in the element
- "className");
+ new LifecycleListenerRule("org.apache.catalina.startup.EngineConfig", "engineConfigClass"));
+ digester.addSetNext(prefix + "Engine", "setContainer", "org.apache.catalina.Engine");
+
+ // 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.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.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.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");
+ digester.addSetNext(prefix + "Engine/Valve", "addValve", "org.apache.catalina.Valve");
}
}
diff --git a/java/org/apache/catalina/startup/ExpandWar.java b/java/org/apache/catalina/startup/ExpandWar.java
index 4d7cf78e85..a100dfd2db 100644
--- a/java/org/apache/catalina/startup/ExpandWar.java
+++ b/java/org/apache/catalina/startup/ExpandWar.java
@@ -52,32 +52,26 @@ public class ExpandWar {
/**
* The string resources for this package.
*/
- protected static final StringManager sm =
- StringManager.getManager(Constants.Package);
+ protected static final StringManager sm = StringManager.getManager(Constants.Package);
/**
- * Expand the WAR file found at the specified URL into an unpacked
- * directory structure.
+ * Expand the WAR file found at the specified URL into an unpacked directory structure.
*
- * @param host Host war is being installed for
- * @param war URL of the web application archive to be expanded
- * (must start with "jar:")
+ * @param host Host war is being installed for
+ * @param war URL of the web application archive to be expanded (must start with "jar:")
* @param pathname Context path name for web application
*
- * @exception IllegalArgumentException if this is not a "jar:" URL or if the
- * WAR file is invalid
- * @exception IOException if an input/output error was encountered
- * during expansion
+ * @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
*
* @return The absolute path to the expanded directory for the given WAR
*/
- public static String expand(Host host, URL war, String pathname)
- throws IOException {
+ public static String expand(Host host, URL war, String pathname) throws IOException {
- /* Obtaining the last modified time opens an InputStream and there is no
- * explicit close method. We have to obtain and then close the
- * InputStream to avoid a file leak and the associated locked file.
+ /*
+ * Obtaining the last modified time opens an InputStream and there is no explicit close method. We have to
+ * obtain and then close the InputStream to avoid a file leak and the associated locked file.
*/
JarURLConnection juc = (JarURLConnection) war.openConnection();
juc.setUseCaches(false);
@@ -113,7 +107,7 @@ public class ExpandWar {
}
// Create the new document base directory
- if(!docBase.mkdir() && !docBase.isDirectory()) {
+ if (!docBase.mkdir() && !docBase.isDirectory()) {
throw new IOException(sm.getString("expandWar.createFailed", docBase));
}
@@ -136,18 +130,14 @@ public class ExpandWar {
if (!expandedFile.getCanonicalFile().toPath().startsWith(canonicalDocBasePath)) {
// Trying to expand outside the docBase
// Throw an exception to stop the deployment
- throw new IllegalArgumentException(
- sm.getString("expandWar.illegalPath",war, name,
- expandedFile.getCanonicalPath(),
- canonicalDocBasePath));
+ throw new IllegalArgumentException(sm.getString("expandWar.illegalPath", war, name,
+ expandedFile.getCanonicalPath(), canonicalDocBasePath));
}
int last = name.lastIndexOf('/');
if (last >= 0) {
- File parent = new File(docBase,
- name.substring(0, last));
+ File parent = new File(docBase, name.substring(0, last));
if (!parent.mkdirs() && !parent.isDirectory()) {
- throw new IOException(
- sm.getString("expandWar.createFailed", parent));
+ throw new IOException(sm.getString("expandWar.createFailed", parent));
}
}
if (name.endsWith("/")) {
@@ -156,8 +146,7 @@ public class ExpandWar {
try (InputStream input = jarFile.getInputStream(jarEntry)) {
if (null == input) {
- throw new ZipException(sm.getString("expandWar.missingJarEntry",
- jarEntry.getName()));
+ throw new ZipException(sm.getString("expandWar.missingJarEntry", jarEntry.getName()));
}
// Bugzilla 33636
@@ -165,8 +154,7 @@ public class ExpandWar {
long lastModified = jarEntry.getTime();
if ((lastModified != -1) && (lastModified != 0)) {
if (!expandedFile.setLastModified(lastModified)) {
- throw new IOException(
- sm.getString("expandWar.lastModifiedFailed", expandedFile));
+ throw new IOException(sm.getString("expandWar.lastModifiedFailed", expandedFile));
}
}
}
@@ -200,15 +188,12 @@ public class ExpandWar {
/**
* 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 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
+ * @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 {
@@ -227,10 +212,8 @@ public class ExpandWar {
if (!expandedFile.getCanonicalFile().toPath().startsWith(canonicalDocBasePath)) {
// Entry located outside the docBase
// Throw an exception to stop the deployment
- throw new IllegalArgumentException(
- sm.getString("expandWar.illegalPath",war, name,
- expandedFile.getCanonicalPath(),
- canonicalDocBasePath));
+ throw new IllegalArgumentException(sm.getString("expandWar.illegalPath", war, name,
+ expandedFile.getCanonicalPath(), canonicalDocBasePath));
}
}
} catch (IOException e) {
@@ -242,8 +225,9 @@ public class ExpandWar {
/**
* Copy the specified file or directory to the destination.
*
- * @param src File object representing the source
+ * @param src File object representing the source
* @param dest File object representing the destination
+ *
* @return <code>true</code> if the copy was successful
*/
public static boolean copy(File src, File dest) {
@@ -291,10 +275,11 @@ public class ExpandWar {
/**
- * Delete the specified directory, including all of its contents and
- * sub-directories recursively. Any failure will be logged.
+ * Delete the specified directory, including all of its contents and sub-directories recursively. Any failure will
+ * be logged.
*
* @param dir File object representing the directory to be deleted
+ *
* @return <code>true</code> if the deletion was successful
*/
public static boolean delete(File dir) {
@@ -304,12 +289,11 @@ public class ExpandWar {
/**
- * Delete the specified directory, including all of its contents and
- * sub-directories recursively.
+ * 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
*
- * @param dir File object representing the directory to be deleted
- * @param logFailure <code>true</code> if failure to delete the resource
- * should be logged
* @return <code>true</code> if the deletion was successful
*/
public static boolean delete(File dir, boolean logFailure) {
@@ -324,18 +308,18 @@ public class ExpandWar {
}
}
if (logFailure && !result) {
- log.error(sm.getString(
- "expandWar.deleteFailed", dir.getAbsolutePath()));
+ log.error(sm.getString("expandWar.deleteFailed", dir.getAbsolutePath()));
}
return result;
}
/**
- * Delete the specified directory, including all of its contents and
- * sub-directories recursively. Any failure will be logged.
+ * Delete the specified directory, including all of its contents and sub-directories recursively. Any failure will
+ * be logged.
*
* @param dir File object representing the directory to be deleted
+ *
* @return <code>true</code> if the deletion was successful
*/
public static boolean deleteDir(File dir) {
@@ -344,12 +328,11 @@ public class ExpandWar {
/**
- * Delete the specified directory, including all of its contents and
- * sub-directories recursively.
+ * 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
*
- * @param dir File object representing the directory to be deleted
- * @param logFailure <code>true</code> if failure to delete the resource
- * should be logged
* @return <code>true</code> if the deletion was successful
*/
public static boolean deleteDir(File dir, boolean logFailure) {
@@ -375,8 +358,7 @@ public class ExpandWar {
}
if (logFailure && !result) {
- log.error(sm.getString(
- "expandWar.deleteFailed", dir.getAbsolutePath()));
+ log.error(sm.getString("expandWar.deleteFailed", dir.getAbsolutePath()));
}
return result;
@@ -387,13 +369,12 @@ public class ExpandWar {
* Expand the specified input stream into the specified file.
*
* @param input InputStream to be copied
- * @param file The file to be created
+ * @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 {
- try (BufferedOutputStream output =
- new BufferedOutputStream(new FileOutputStream(file))) {
+ try (BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(file))) {
byte buffer[] = new byte[2048];
while (true) {
int n = input.read(buffer);
diff --git a/java/org/apache/catalina/startup/FailedContext.java b/java/org/apache/catalina/startup/FailedContext.java
index 7bbfdfcfb0..eb249a1d16 100644
--- a/java/org/apache/catalina/startup/FailedContext.java
+++ b/java/org/apache/catalina/startup/FailedContext.java
@@ -65,58 +65,89 @@ import org.apache.tomcat.util.http.CookieProcessor;
import org.apache.tomcat.util.res.StringManager;
/**
- * An implementation of {@link Context} that is used as a place-holder for
- * deployed applications when their deployment fails and a Context instance
- * (usually {@link org.apache.catalina.core.StandardContext} but may be any
- * Context implementation) cannot be created.
+ * An implementation of {@link Context} that is used as a place-holder for deployed applications when their deployment
+ * fails and a Context instance (usually {@link org.apache.catalina.core.StandardContext} but may be any Context
+ * implementation) cannot be created.
*/
public class FailedContext extends LifecycleMBeanBase implements Context {
- protected static final StringManager sm =
- StringManager.getManager(Constants.Package);
+ protected static final StringManager sm = StringManager.getManager(Constants.Package);
// --------------------- Methods that need to work even for a failed context
private URL configFile;
+
@Override
- public URL getConfigFile() { return configFile; }
+ public URL getConfigFile() {
+ return configFile;
+ }
+
@Override
- public void setConfigFile(URL configFile) { this.configFile = configFile; }
+ public void setConfigFile(URL configFile) {
+ this.configFile = configFile;
+ }
private String docBase;
+
@Override
- public String getDocBase() { return docBase; }
- @Override
- public void setDocBase(String docBase) { this.docBase = docBase; }
+ public String getDocBase() {
+ return docBase;
+ }
+ @Override
+ public void setDocBase(String docBase) {
+ this.docBase = docBase;
+ }
private String name = null;
+
@Override
- public String getName() { return name; }
+ public String getName() {
+ return name;
+ }
+
@Override
- public void setName(String name) { this.name = name; }
+ public void setName(String name) {
+ this.name = name;
+ }
private Container parent;
+
@Override
- public Container getParent() { return parent; }
+ public Container getParent() {
+ return parent;
+ }
+
@Override
- public void setParent(Container parent) { this.parent = parent; }
+ public void setParent(Container parent) {
+ this.parent = parent;
+ }
private String path = null;
+
@Override
- public String getPath() { return path; }
+ public String getPath() {
+ return path;
+ }
+
@Override
- public void setPath(String path) { this.path = path; }
+ public void setPath(String path) {
+ this.path = path;
+ }
private String webappVersion = null;
+
@Override
- public String getWebappVersion() { return webappVersion; }
+ public String getWebappVersion() {
+ return webappVersion;
+ }
+
@Override
public void setWebappVersion(String webappVersion) {
this.webappVersion = webappVersion;
@@ -172,8 +203,7 @@ public class FailedContext extends LifecycleMBeanBase implements Context {
@Override
protected String getObjectNameKeyProperties() {
- StringBuilder keyProperties =
- new StringBuilder("j2eeType=WebModule,name=//");
+ StringBuilder keyProperties = new StringBuilder("j2eeType=WebModule,name=//");
String hostname = getParent().getName();
if (hostname == null) {
@@ -196,8 +226,7 @@ public class FailedContext extends LifecycleMBeanBase implements Context {
@Override
protected void startInternal() throws LifecycleException {
- throw new LifecycleException(
- sm.getString("failedContext.start", getName()));
+ throw new LifecycleException(sm.getString("failedContext.start", getName()));
}
@@ -210,21 +239,40 @@ public class FailedContext extends LifecycleMBeanBase implements Context {
// Only need to read these
@Override
- public void addWatchedResource(String name) { /* NO-OP */ }
+ public void addWatchedResource(String name) {
+ // NO-OP
+ }
+
@Override
- public String[] findWatchedResources() { return new String[0]; }
+ public String[] findWatchedResources() {
+ return new String[0];
+ }
+
@Override
- public void removeWatchedResource(String name) { /* NO-OP */ }
+ public void removeWatchedResource(String name) {
+ // NO-OP
+ }
@Override
- public void addChild(Container child) { /* NO-OP */ }
+ public void addChild(Container child) {
+ // NO-OP
+ }
+
@Override
- public Container findChild(String name) { return null; }
+ public Container findChild(String name) {
+ return null;
+ }
+
@Override
- public Container[] findChildren() { return new Container[0]; }
+ public Container[] findChildren() {
+ return new Container[0];
+ }
+
@Override
- public void removeChild(Container child) { /* NO-OP */ }
+ public void removeChild(Container child) {
+ // NO-OP
+ }
@Override
public String toString() {
@@ -233,507 +281,975 @@ public class FailedContext extends LifecycleMBeanBase implements Context {
// -------------------------------------------- All NO-OPs beyond this point
@Override
- public Loader getLoader() { return null; }
+ public Loader getLoader() {
+ return null;
+ }
+
@Override
- public void setLoader(Loader loader) { /* NO-OP */ }
+ public void setLoader(Loader loader) {
+ // NO-OP
+ }
@Override
- public Log getLogger() { return null; }
+ public Log getLogger() {
+ return null;
+ }
@Override
- public String getLogName() { return null; }
+ public String getLogName() {
+ return null;
+ }
@Override
- public Manager getManager() { return null; }
+ public Manager getManager() {
+ return null;
+ }
+
@Override
- public void setManager(Manager manager) { /* NO-OP */ }
+ public void setManager(Manager manager) {
+ // NO-OP
+ }
@Override
- public Pipeline getPipeline() { return null; }
+ public Pipeline getPipeline() {
+ return null;
+ }
@Override
- public Cluster getCluster() { return null; }
+ public Cluster getCluster() {
+ return null;
+ }
+
@Override
- public void setCluster(Cluster cluster) { /* NO-OP */ }
+ public void setCluster(Cluster cluster) {
+ // NO-OP
+ }
@Override
- public int getBackgroundProcessorDelay() { return -1; }
+ public int getBackgroundProcessorDelay() {
+ return -1;
+ }
+
@Override
- public void setBackgroundProcessorDelay(int delay) { /* NO-OP */ }
+ public void setBackgroundProcessorDelay(int delay) {
+ // NO-OP
+ }
@Override
- public ClassLoader getParentClassLoader() { return null; }
+ public ClassLoader getParentClassLoader() {
+ return null;
+ }
+
@Override
- public void setParentClassLoader(ClassLoader parent) { /* NO-OP */ }
+ public void setParentClassLoader(ClassLoader parent) {
+ // NO-OP
+ }
@Override
- public Realm getRealm() { return null; }
+ public Realm getRealm() {
+ return null;
+ }
+
@Override
- public void setRealm(Realm realm) { /* NO-OP */ }
+ public void setRealm(Realm realm) {
+ // NO-OP
+ }
@Override
- public WebResourceRoot getResources() { return null; }
+ public WebResourceRoot getResources() {
+ return null;
+ }
+
@Override
- public void setResources(WebResourceRoot resources) { /* NO-OP */ }
+ public void setResources(WebResourceRoot resources) {
+ // NO-OP
+ }
@Override
- public void backgroundProcess() { /* NO-OP */ }
+ public void backgroundProcess() {
+ // NO-OP
+ }
@Override
- public void addContainerListener(ContainerListener listener) { /* NO-OP */ }
+ public void addContainerListener(ContainerListener listener) {
+ // NO-OP
+ }
+
@Override
- public ContainerListener[] findContainerListeners() { return null; }
+ public ContainerListener[] findContainerListeners() {
+ return null;
+ }
+
@Override
- public void removeContainerListener(ContainerListener listener) { /* NO-OP */ }
+ public void removeContainerListener(ContainerListener listener) {
+ // NO-OP
+ }
@Override
- public void addPropertyChangeListener(PropertyChangeListener listener) { /* NO-OP */ }
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ // NO-OP
+ }
+
@Override
- public void removePropertyChangeListener(PropertyChangeListener listener) { /* NO-OP */ }
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ // NO-OP
+ }
@Override
- public void fireContainerEvent(String type, Object data) { /* NO-OP */ }
+ public void fireContainerEvent(String type, Object data) {
+ // NO-OP
+ }
@Override
- public void logAccess(Request request, Response response, long time,
- boolean useDefault) { /* NO-OP */ }
+ public void logAccess(Request request, Response response, long time, boolean useDefault) {
+ // NO-OP
+ }
@Override
- public AccessLog getAccessLog() { return null; }
+ public AccessLog getAccessLog() {
+ return null;
+ }
@Override
- public int getStartStopThreads() { return 0; }
+ public int getStartStopThreads() {
+ return 0;
+ }
+
@Override
- public void setStartStopThreads(int startStopThreads) { /* NO-OP */ }
+ public void setStartStopThreads(int startStopThreads) {
+ // NO-OP
+ }
@Override
- public boolean getAllowCasualMultipartParsing() { return false; }
+ public boolean getAllowCasualMultipartParsing() {
+ return false;
+ }
+
@Override
- public void setAllowCasualMultipartParsing(
- boolean allowCasualMultipartParsing) { /* NO-OP */ }
+ public void setAllowCasualMultipartParsing(boolean allowCasualMultipartParsing) {
+ // NO-OP
+ }
@Override
- public Object[] getApplicationEventListeners() { return null; }
+ public Object[] getApplicationEventListeners() {
+ return null;
+ }
+
@Override
- public void setApplicationEventListeners(Object[] listeners) { /* NO-OP */ }
+ public void setApplicationEventListeners(Object[] listeners) {
+ // NO-OP
+ }
@Override
- public Object[] getApplicationLifecycleListeners() { return null; }
+ public Object[] getApplicationLifecycleListeners() {
+ return null;
+ }
+
@Override
- public void setApplicationLifecycleListeners(Object[] listeners) { /* NO-OP */ }
+ public void setApplicationLifecycleListeners(Object[] listeners) {
+ // NO-OP
+ }
@Override
- public String getCharset(Locale locale) { return null; }
+ public String getCharset(Locale locale) {
+ return null;
+ }
@Override
- public boolean getConfigured() { return false; }
+ public boolean getConfigured() {
+ return false;
+ }
+
@Override
- public void setConfigured(boolean configured) { /* NO-OP */ }
+ public void setConfigured(boolean configured) {
+ // NO-OP
+ }
@Override
- public boolean getCookies() { return false; }
+ public boolean getCookies() {
+ return false;
+ }
+
@Override
- public void setCookies(boolean cookies) { /* NO-OP */ }
+ public void setCookies(boolean cookies) {
+ // NO-OP
+ }
@Override
- public String getSessionCookieName() { return null; }
+ public String getSessionCookieName() {
+ return null;
+ }
+
@Override
- public void setSessionCookieName(String sessionCookieName) { /* NO-OP */ }
+ public void setSessionCookieName(String sessionCookieName) {
+ // NO-OP
+ }
@Override
- public boolean getUseHttpOnly() { return false; }
+ public boolean getUseHttpOnly() {
+ return false;
+ }
+
@Override
- public void setUseHttpOnly(boolean useHttpOnly) { /* NO-OP */ }
+ public void setUseHttpOnly(boolean useHttpOnly) {
+ // NO-OP
+ }
@Override
- public boolean getUsePartitioned() { return false; }
+ public boolean getUsePartitioned() {
+ return false;
+ }
+
@Override
- public void setUsePartitioned(boolean usePartitioned) { /* NO-OP */ }
+ public void setUsePartitioned(boolean usePartitioned) {
+ // NO-OP
+ }
@Override
- public String getSessionCookieDomain() { return null; }
+ public String getSessionCookieDomain() {
+ return null;
+ }
+
@Override
- public void setSessionCookieDomain(String sessionCookieDomain) { /* NO-OP */ }
+ public void setSessionCookieDomain(String sessionCookieDomain) {
+ // NO-OP
+ }
@Override
- public String getSessionCookiePath() { return null; }
+ public String getSessionCookiePath() {
+ return null;
+ }
+
@Override
- public void setSessionCookiePath(String sessionCookiePath) { /* NO-OP */ }
+ public void setSessionCookiePath(String sessionCookiePath) {
+ // NO-OP
+ }
@Override
- public boolean getSessionCookiePathUsesTrailingSlash() { return false; }
+ public boolean getSessionCookiePathUsesTrailingSlash() {
+ return false;
+ }
+
@Override
- public void setSessionCookiePathUsesTrailingSlash(
- boolean sessionCookiePathUsesTrailingSlash) { /* NO-OP */ }
+ public void setSessionCookiePathUsesTrailingSlash(boolean sessionCookiePathUsesTrailingSlash) {
+ // NO-OP
+ }
@Override
- public boolean getCrossContext() { return false; }
+ public boolean getCrossContext() {
+ return false;
+ }
+
@Override
- public void setCrossContext(boolean crossContext) { /* NO-OP */ }
+ public void setCrossContext(boolean crossContext) {
+ // NO-OP
+ }
@Override
- public String getAltDDName() { return null; }
+ public String getAltDDName() {
+ return null;
+ }
+
@Override
- public void setAltDDName(String altDDName) { /* NO-OP */ }
+ public void setAltDDName(String altDDName) {
+ // NO-OP
+ }
@Override
- public boolean getDenyUncoveredHttpMethods() { return false; }
+ public boolean getDenyUncoveredHttpMethods() {
+ return false;
+ }
+
@Override
public void setDenyUncoveredHttpMethods(boolean denyUncoveredHttpMethods) {
// NO-OP
}
@Override
- public String getDisplayName() { return null; }
+ public String getDisplayName() {
+ return null;
+ }
+
@Override
- public void setDisplayName(String displayName) { /* NO-OP */ }
+ public void setDisplayName(String displayName) {
+ // NO-OP
+ }
@Override
- public boolean getDistributable() { return false; }
+ public boolean getDistributable() {
+ return false;
+ }
+
@Override
- public void setDistributable(boolean distributable) { /* NO-OP */ }
+ public void setDistributable(boolean distributable) {
+ // NO-OP
+ }
@Override
- public String getEncodedPath() { return null; }
+ public String getEncodedPath() {
+ return null;
+ }
@Override
- public boolean getIgnoreAnnotations() { return false; }
+ public boolean getIgnoreAnnotations() {
+ return false;
+ }
+
@Override
- public void setIgnoreAnnotations(boolean ignoreAnnotations) { /* NO-OP */ }
+ public void setIgnoreAnnotations(boolean ignoreAnnotations) {
+ // NO-OP
+ }
@Override
- public LoginConfig getLoginConfig() { return null; }
+ public LoginConfig getLoginConfig() {
+ return null;
+ }
+
@Override
- public void setLoginConfig(LoginConfig config) { /* NO-OP */ }
+ public void setLoginConfig(LoginConfig config) {
+ // NO-OP
+ }
@Override
- public NamingResourcesImpl getNamingResources() { return null; }
+ public NamingResourcesImpl getNamingResources() {
+ return null;
+ }
+
@Override
- public void setNamingResources(NamingResourcesImpl namingResources) { /* NO-OP */ }
+ public void setNamingResources(NamingResourcesImpl namingResources) {
+ // NO-OP
+ }
@Override
- public String getPublicId() { return null; }
+ public String getPublicId() {
+ return null;
+ }
+
@Override
- public void setPublicId(String publicId) { /* NO-OP */ }
+ public void setPublicId(String publicId) {
+ // NO-OP
+ }
@Override
- public boolean getReloadable() { return false; }
+ public boolean getReloadable() {
+ return false;
+ }
+
@Override
- public void setReloadable(boolean reloadable) { /* NO-OP */ }
+ public void setReloadable(boolean reloadable) {
+ // NO-OP
+ }
@Override
- public boolean getOverride() { return false; }
+ public boolean getOverride() {
+ return false;
+ }
+
@Override
- public void setOverride(boolean override) { /* NO-OP */ }
+ public void setOverride(boolean override) {
+ // NO-OP
+ }
@Override
- public boolean getPrivileged() { return false; }
+ public boolean getPrivileged() {
+ return false;
+ }
+
@Override
- public void setPrivileged(boolean privileged) { /* NO-OP */ }
+ public void setPrivileged(boolean privileged) {
+ // NO-OP
+ }
@Override
- public ServletContext getServletContext() { return null; }
+ public ServletContext getServletContext() {
+ return null;
+ }
@Override
- public int getSessionTimeout() { return 0; }
+ public int getSessionTimeout() {
+ return 0;
+ }
+
@Override
- public void setSessionTimeout(int timeout) { /* NO-OP */ }
+ public void setSessionTimeout(int timeout) {
+ // NO-OP
+ }
@Override
- public boolean getSwallowAbortedUploads() { return false; }
+ public boolean getSwallowAbortedUploads() {
+ return false;
+ }
+
@Override
- public void setSwallowAbortedUploads(boolean swallowAbortedUploads) { /* NO-OP */ }
+ public void setSwallowAbortedUploads(boolean swallowAbortedUploads) {
+ // NO-OP
+ }
@Override
- public boolean getSwallowOutput() { return false; }
+ public boolean getSwallowOutput() {
+ return false;
+ }
+
@Override
- public void setSwallowOutput(boolean swallowOutput) { /* NO-OP */ }
+ public void setSwallowOutput(boolean swallowOutput) {
+ // NO-OP
+ }
@Override
- public String getWrapperClass() { return null; }
+ public String getWrapperClass() {
+ return null;
+ }
+
@Override
- public void setWrapperClass(String wrapperClass) { /* NO-OP */ }
+ public void setWrapperClass(String wrapperClass) {
+ // NO-OP
+ }
@Override
- public boolean getXmlNamespaceAware() { return false; }
+ public boolean getXmlNamespaceAware() {
+ return false;
+ }
+
@Override
- public void setXmlNamespaceAware(boolean xmlNamespaceAware) { /* NO-OP */ }
+ public void setXmlNamespaceAware(boolean xmlNamespaceAware) {
+ // NO-OP
+ }
@Override
- public boolean getXmlValidation() { return false; }
+ public boolean getXmlValidation() {
+ return false;
+ }
+
@Override
- public void setXmlValidation(boolean xmlValidation) { /* NO-OP */ }
+ public void setXmlValidation(boolean xmlValidation) {
+ // NO-OP
+ }
@Override
- public boolean getXmlBlockExternal() { return true; }
+ public boolean getXmlBlockExternal() {
+ return true;
+ }
+
@Override
- public void setXmlBlockExternal(boolean xmlBlockExternal) { /* NO-OP */ }
+ public void setXmlBlockExternal(boolean xmlBlockExternal) {
+ // NO-OP
+ }
@Override
- public boolean getTldValidation() { return false; }
+ public boolean getTldValidation() {
+ return false;
+ }
+
@Override
- public void setTldValidation(boolean tldValidation){ /* NO-OP */ }
+ public void setTldValidation(boolean tldValidation) {
+ // NO-OP
+ }
@Override
- public JarScanner getJarScanner() { return null; }
+ public JarScanner getJarScanner() {
+ return null;
+ }
+
@Override
- public void setJarScanner(JarScanner jarScanner) { /* NO-OP */ }
+ public void setJarScanner(JarScanner jarScanner) {
+ // NO-OP
+ }
@Override
- public Authenticator getAuthenticator() { return null; }
+ public Authenticator getAuthenticator() {
+ return null;
+ }
@Override
- public void setLogEffectiveWebXml(boolean logEffectiveWebXml) { /* NO-OP */ }
+ public void setLogEffectiveWebXml(boolean logEffectiveWebXml) {
+ // NO-OP
+ }
+
@Override
- public boolean getLogEffectiveWebXml() { return false; }
+ public boolean getLogEffectiveWebXml() {
+ return false;
+ }
@Override
- public void addApplicationListener(String listener) { /* NO-OP */ }
+ public void addApplicationListener(String listener) {
+ // NO-OP
+ }
+
@Override
- public String[] findApplicationListeners() { return null; }
+ public String[] findApplicationListeners() {
+ return null;
+ }
+
@Override
- public void removeApplicationListener(String listener) { /* NO-OP */ }
+ public void removeApplicationListener(String listener) {
+ // NO-OP
+ }
@Override
- public void addApplicationParameter(ApplicationParameter parameter) { /* NO-OP */ }
+ public void addApplicationParameter(ApplicationParameter parameter) {
+ // NO-OP
+ }
+
@Override
- public ApplicationParameter[] findApplicationParameters() { return null; }
+ public ApplicationParameter[] findApplicationParameters() {
+ return null;
+ }
+
@Override
- public void removeApplicationParameter(String name) { /* NO-OP */ }
+ public void removeApplicationParameter(String name) {
+ // NO-OP
+ }
@Override
- public void addConstraint(SecurityConstraint constraint) { /* NO-OP */ }
+ public void addConstraint(SecurityConstraint constraint) {
+ // NO-OP
+ }
+
@Override
- public SecurityConstraint[] findConstraints() { return null; }
+ public SecurityConstraint[] findConstraints() {
+ return null;
+ }
+
@Override
- public void removeConstraint(SecurityConstraint constraint) { /* NO-OP */ }
+ public void removeConstraint(SecurityConstraint constraint) {
+ // NO-OP
+ }
@Override
- public void addErrorPage(ErrorPage errorPage) { /* NO-OP */ }
+ public void addErrorPage(ErrorPage errorPage) {
+ // NO-OP
+ }
+
@Override
- public ErrorPage findErrorPage(int errorCode) { return null; }
+ public ErrorPage findErrorPage(int errorCode) {
+ return null;
+ }
+
@Override
- public ErrorPage findErrorPage(Throwable throwable) { return null; }
+ public ErrorPage findErrorPage(Throwable throwable) {
+ return null;
+ }
+
@Override
- public ErrorPage[] findErrorPages() { return null; }
+ public ErrorPage[] findErrorPages() {
+ return null;
+ }
+
@Override
- public void removeErrorPage(ErrorPage errorPage) { /* NO-OP */ }
+ public void removeErrorPage(ErrorPage errorPage) {
+ // NO-OP
+ }
@Override
- public void addFilterDef(FilterDef filterDef) { /* NO-OP */ }
+ public void addFilterDef(FilterDef filterDef) {
+ // NO-OP
+ }
+
@Override
- public FilterDef findFilterDef(String filterName) { return null; }
+ public FilterDef findFilterDef(String filterName) {
+ return null;
+ }
+
@Override
- public FilterDef[] findFilterDefs() { return null; }
+ public FilterDef[] findFilterDefs() {
+ return null;
+ }
+
@Override
- public void removeFilterDef(FilterDef filterDef) { /* NO-OP */ }
+ public void removeFilterDef(FilterDef filterDef) {
+ // NO-OP
+ }
@Override
- public void addFilterMap(FilterMap filterMap) { /* NO-OP */ }
+ public void addFilterMap(FilterMap filterMap) {
+ // NO-OP
+ }
+
@Override
- public void addFilterMapBefore(FilterMap filterMap) { /* NO-OP */ }
+ public void addFilterMapBefore(FilterMap filterMap) {
+ // NO-OP
+ }
+
@Override
- public FilterMap[] findFilterMaps() { return null; }
+ public FilterMap[] findFilterMaps() {
+ return null;
+ }
+
@Override
- public void removeFilterMap(FilterMap filterMap) { /* NO-OP */ }
+ public void removeFilterMap(FilterMap filterMap) {
+ // NO-OP
+ }
@Override
- public void addLocaleEncodingMappingParameter(String locale, String encoding) { /* NO-OP */ }
+ public void addLocaleEncodingMappingParameter(String locale, String encoding) {
+ // NO-OP
+ }
@Override
- public void addMimeMapping(String extension, String mimeType) { /* NO-OP */ }
+ public void addMimeMapping(String extension, String mimeType) {
+ // NO-OP
+ }
+
@Override
- public String findMimeMapping(String extension) { return null; }
+ public String findMimeMapping(String extension) {
+ return null;
+ }
+
@Override
- public String[] findMimeMappings() { return null; }
+ public String[] findMimeMappings() {
+ return null;
+ }
+
@Override
- public void removeMimeMapping(String extension) { /* NO-OP */ }
+ public void removeMimeMapping(String extension) {
+ // NO-OP
+ }
@Override
- public void addParameter(String name, String value) { /* NO-OP */ }
+ public void addParameter(String name, String value) {
+ // NO-OP
+ }
+
@Override
- public String findParameter(String name) { return null; }
+ public String findParameter(String name) {
+ return null;
+ }
+
@Override
- public String[] findParameters() { return null; }
+ public String[] findParameters() {
+ return null;
+ }
+
@Override
- public void removeParameter(String name) { /* NO-OP */ }
+ public void removeParameter(String name) {
+ // NO-OP
+ }
@Override
- public void addRoleMapping(String role, String link) { /* NO-OP */ }
+ public void addRoleMapping(String role, String link) {
+ // NO-OP
+ }
+
@Override
- public String findRoleMapping(String role) { return null; }
+ public String findRoleMapping(String role) {
+ return null;
+ }
+
@Override
- public void removeRoleMapping(String role) { /* NO-OP */ }
+ public void removeRoleMapping(String role) {
+ // NO-OP
+ }
@Override
- public void addSecurityRole(String role) { /* NO-OP */ }
+ public void addSecurityRole(String role) {
+ // NO-OP
+ }
+
@Override
- public boolean findSecurityRole(String role) { return false; }
+ public boolean findSecurityRole(String role) {
+ return false;
+ }
+
@Override
- public String[] findSecurityRoles() { return null; }
+ public String[] findSecurityRoles() {
+ return null;
+ }
+
@Override
- public void removeSecurityRole(String role) { /* NO-OP */ }
+ public void removeSecurityRole(String role) {
+ // NO-OP
+ }
@Override
- public void addServletMappingDecoded(String pattern, String name,
- boolean jspWildcard) { /* NO-OP */ }
+ public void addServletMappingDecoded(String pattern, String name, boolean jspWildcard) {
+ // NO-OP
+ }
+
@Override
- public String findServletMapping(String pattern) { return null; }
+ public String findServletMapping(String pattern) {
+ return null;
+ }
+
@Override
- public String[] findServletMappings() { return null; }
+ public String[] findServletMappings() {
+ return null;
+ }
+
@Override
- public void removeServletMapping(String pattern) { /* NO-OP */ }
+ public void removeServletMapping(String pattern) {
+ // NO-OP
+ }
@Override
- public void addWelcomeFile(String name) { /* NO-OP */ }
+ public void addWelcomeFile(String name) {
+ // NO-OP
+ }
+
@Override
- public boolean findWelcomeFile(String name) { return false; }
+ public boolean findWelcomeFile(String name) {
+ return false;
+ }
+
@Override
- public String[] findWelcomeFiles() { return null; }
+ public String[] findWelcomeFiles() {
+ return null;
+ }
+
@Override
- public void removeWelcomeFile(String name) { /* NO-OP */ }
+ public void removeWelcomeFile(String name) {
+ // NO-OP
+ }
@Override
- public void addWrapperLifecycle(String listener) { /* NO-OP */ }
+ public void addWrapperLifecycle(String listener) {
+ // NO-OP
+ }
+
@Override
- public String[] findWrapperLifecycles() { return null; }
+ public String[] findWrapperLifecycles() {
+ return null;
+ }
+
@Override
- public void removeWrapperLifecycle(String listener) { /* NO-OP */ }
+ public void removeWrapperLifecycle(String listener) {
+ // NO-OP
+ }
@Override
- public void addWrapperListener(String listener) { /* NO-OP */ }
+ public void addWrapperListener(String listener) {
+ // NO-OP
+ }
+
@Override
- public String[] findWrapperListeners() { return null; }
+ public String[] findWrapperListeners() {
+ return null;
+ }
+
@Override
- public void removeWrapperListener(String listener) { /* NO-OP */ }
+ public void removeWrapperListener(String listener) {
+ // NO-OP
+ }
@Override
- public InstanceManager createInstanceManager() { return null; }
+ public InstanceManager createInstanceManager() {
+ return null;
+ }
@Override
- public Wrapper createWrapper() { return null; }
+ public Wrapper createWrapper() {
+ return null;
+ }
@Override
- public boolean fireRequestInitEvent(ServletRequest request) { return false; }
+ public boolean fireRequestInitEvent(ServletRequest request) {
+ return false;
+ }
+
@Override
- public boolean fireRequestDestroyEvent(ServletRequest request) { return false; }
+ public boolean fireRequestDestroyEvent(ServletRequest request) {
+ return false;
+ }
@Override
- public void reload() { /* NO-OP */ }
+ public void reload() {
+ // NO-OP
+ }
@Override
- public String getRealPath(String path) { return null; }
+ public String getRealPath(String path) {
+ return null;
+ }
@Override
- public int getEffectiveMajorVersion() { return 0; }
+ public int getEffectiveMajorVersion() {
+ return 0;
+ }
+
@Override
- public void setEffectiveMajorVersion(int major) { /* NO-OP */ }
+ public void setEffectiveMajorVersion(int major) {
+ // NO-OP
+ }
@Override
- public int getEffectiveMinorVersion() { return 0; }
+ public int getEffectiveMinorVersion() {
+ return 0;
+ }
+
@Override
- public void setEffectiveMinorVersion(int minor) { /* NO-OP */ }
+ public void setEffectiveMinorVersion(int minor) {
+ // NO-OP
+ }
@Override
- public JspConfigDescriptor getJspConfigDescriptor() { return null; }
+ public JspConfigDescriptor getJspConfigDescriptor() {
+ return null;
+ }
@Override
- public void setJspConfigDescriptor(JspConfigDescriptor descriptor) { /* NO-OP */ }
+ public void setJspConfigDescriptor(JspConfigDescriptor descriptor) {
+ // NO-OP
+ }
@Override
- public void addServletContainerInitializer(ServletContainerInitializer sci,
- Set<Class<?>> classes) { /* NO-OP */ }
+ public void addServletContainerInitializer(ServletContainerInitializer sci, Set<Class<?>> classes) {
+ // NO-OP
+ }
@Override
- public boolean getPaused() { return false; }
+ public boolean getPaused() {
+ return false;
+ }
@Override
- public boolean isServlet22() { return false; }
+ public boolean isServlet22() {
+ return false;
+ }
@Override
- public Set<String> addServletSecurity(
- ServletRegistration.Dynamic registration,
- ServletSecurityElement servletSecurityElement) { return null; }
+ public Set<String> addServletSecurity(ServletRegistration.Dynamic registration,
+ ServletSecurityElement servletSecurityElement) {
+ return null;
+ }
@Override
- public void setResourceOnlyServlets(String resourceOnlyServlets) { /* NO-OP */ }
+ public void setResourceOnlyServlets(String resourceOnlyServlets) {
+ // NO-OP
+ }
+
@Override
- public String getResourceOnlyServlets() { return null; }
+ public String getResourceOnlyServlets() {
+ return null;
+ }
+
@Override
- public boolean isResourceOnlyServlet(String servletName) { return false; }
+ public boolean isResourceOnlyServlet(String servletName) {
+ return false;
+ }
@Override
- public String getBaseName() { return null; }
+ public String getBaseName() {
+ return null;
+ }
@Override
- public void setFireRequestListenersOnForwards(boolean enable) { /* NO-OP */ }
+ public void setFireRequestListenersOnForwards(boolean enable) {
+ // NO-OP
+ }
+
@Override
- public boolean getFireRequestListenersOnForwards() { return false; }
+ public boolean getFireRequestListenersOnForwards() {
+ return false;
+ }
@Override
- public void setPreemptiveAuthentication(boolean enable) { /* NO-OP */ }
+ public void setPreemptiveAuthentication(boolean enable) {
+ // NO-OP
+ }
+
@Override
- public boolean getPreemptiveAuthentication() { return false; }
+ public boolean getPreemptiveAuthentication() {
+ return false;
+ }
@Override
- public void setSendRedirectBody(boolean enable) { /* NO-OP */ }
+ public void setSendRedirectBody(boolean enable) {
+ // NO-OP
+ }
+
@Override
- public boolean getSendRedirectBody() { return false; }
+ public boolean getSendRedirectBody() {
+ return false;
+ }
@SuppressWarnings("unused")
- public synchronized void addValve(Valve valve) { /* NO-OP */ }
+ public synchronized void addValve(Valve valve) {
+ // NO-OP
+ }
@Override
- public File getCatalinaBase() { return null; }
+ public File getCatalinaBase() {
+ return null;
+ }
@Override
- public File getCatalinaHome() { return null; }
+ public File getCatalinaHome() {
+ return null;
+ }
@Override
public void setAddWebinfClassesResources(boolean addWebinfClassesResources) {
// NO-OP
}
+
@Override
- public boolean getAddWebinfClassesResources() { return false; }
+ public boolean getAddWebinfClassesResources() {
+ return false;
+ }
@Override
- public void addPostConstructMethod(String clazz, String method) { /* NO-OP */ }
+ public void addPostConstructMethod(String clazz, String method) {
+ // NO-OP
+ }
@Override
- public void addPreDestroyMethod(String clazz, String method) { /* NO-OP */ }
+ public void addPreDestroyMethod(String clazz, String method) {
+ // NO-OP
+ }
@Override
- public void removePostConstructMethod(String clazz) { /* NO-OP */ }
+ public void removePostConstructMethod(String clazz) {
+ // NO-OP
+ }
@Override
- public void removePreDestroyMethod(String clazz) { /* NO-OP */ }
+ public void removePreDestroyMethod(String clazz) {
+ // NO-OP
+ }
@Override
- public String findPostConstructMethod(String clazz) { return null; }
+ public String findPostConstructMethod(String clazz) {
+ return null;
+ }
@Override
- public String findPreDestroyMethod(String clazz) { return null; }
+ public String findPreDestroyMethod(String clazz) {
+ return null;
+ }
@Override
- public Map<String, String> findPostConstructMethods() { return null; }
+ public Map<String,String> findPostConstructMethods() {
+ return null;
+ }
@Override
- public Map<String, String> findPreDestroyMethods() { return null; }
+ public Map<String,String> findPreDestroyMethods() {
+ return null;
+ }
@Override
- public InstanceManager getInstanceManager() { return null; }
+ public InstanceManager getInstanceManager() {
+ return null;
+ }
@Override
- public void setInstanceManager(InstanceManager instanceManager) { /* NO-OP */ }
+ public void setInstanceManager(InstanceManager instanceManager) {
+ // NO-OP
+ }
@Override
- public void setContainerSciFilter(String containerSciFilter) { /* NO-OP */ }
+ public void setContainerSciFilter(String containerSciFilter) {
+ // NO-OP
+ }
@Override
- public String getContainerSciFilter() { return null; }
+ public String getContainerSciFilter() {
+ return null;
+ }
@Override
- public ThreadBindingListener getThreadBindingListener() { return null; }
+ public ThreadBindingListener getThreadBindingListener() {
+ return null;
+ }
@Override
public void setThreadBindingListener(ThreadBindingListener threadBindingListener) {
@@ -751,13 +1267,19 @@ public class FailedContext extends LifecycleMBeanBase implements Context {
}
@Override
- public Object getNamingToken() { return null; }
+ public Object getNamingToken() {
+ return null;
+ }
@Override
- public void setCookieProcessor(CookieProcessor cookieProcessor) { /* NO-OP */ }
+ public void setCookieProcessor(CookieProcessor cookieProcessor) {
+ // NO-OP
+ }
@Override
- public CookieProcessor getCookieProcessor() { return null; }
+ public CookieProcessor getCookieProcessor() {
+ return null;
+ }
@Override
public void setValidateClientProvidedNewSessionId(boolean validateClientProvidedNewSessionId) {
@@ -765,7 +1287,9 @@ public class FailedContext extends LifecycleMBeanBase implements Context {
}
@Override
- public boolean getValidateClientProvidedNewSessionId() { return false; }
+ public boolean getValidateClientProvidedNewSessionId() {
+ return false;
+ }
@Override
public void setMapperContextRootRedirectEnabled(boolean mapperContextRootRedirectEnabled) {
@@ -773,7 +1297,9 @@ public class FailedContext extends LifecycleMBeanBase implements Context {
}
@Override
- public boolean getMapperContextRootRedirectEnabled() { return false; }
+ public boolean getMapperContextRootRedirectEnabled() {
+ return false;
+ }
@Override
public void setMapperDirectoryRedirectEnabled(boolean mapperDirectoryRedirectEnabled) {
@@ -781,70 +1307,122 @@ public class FailedContext extends LifecycleMBeanBase implements Context {
}
@Override
- public boolean getMapperDirectoryRedirectEnabled() { return false; }
+ public boolean getMapperDirectoryRedirectEnabled() {
+ return false;
+ }
@Override
- public void setUseRelativeRedirects(boolean useRelativeRedirects) { /* NO-OP */ }
+ public void setUseRelativeRedirects(boolean useRelativeRedirects) {
+ // NO-OP
+ }
+
@Override
- public boolean getUseRelativeRedirects() { return true; }
+ public boolean getUseRelativeRedirects() {
+ return true;
+ }
@Override
- public void setDispatchersUseEncodedPaths(boolean dispatchersUseEncodedPaths) { /* NO-OP */ }
+ public void setDispatchersUseEncodedPaths(boolean dispatchersUseEncodedPaths) {
+ // NO-OP
+ }
+
@Override
- public boolean getDispatchersUseEncodedPaths() { return true; }
+ public boolean getDispatchersUseEncodedPaths() {
+ return true;
+ }
@Override
- public void setRequestCharacterEncoding(String encoding) { /* NO-OP */ }
+ public void setRequestCharacterEncoding(String encoding) {
+ // NO-OP
+ }
+
@Override
- public String getRequestCharacterEncoding() { return null; }
+ public String getRequestCharacterEncoding() {
+ return null;
+ }
@Override
- public void setResponseCharacterEncoding(String encoding) { /* NO-OP */ }
+ public void setResponseCharacterEncoding(String encoding) {
+ // NO-OP
+ }
+
@Override
- public String getResponseCharacterEncoding() { return null; }
+ public String getResponseCharacterEncoding() {
+ return null;
+ }
@Override
- public void setAllowMultipleLeadingForwardSlashInPath(
- boolean allowMultipleLeadingForwardSlashInPath) {
+ public void setAllowMultipleLeadingForwardSlashInPath(boolean allowMultipleLeadingForwardSlashInPath) {
// NO-OP
}
+
@Override
- public boolean getAllowMultipleLeadingForwardSlashInPath() { return false; }
+ public boolean getAllowMultipleLeadingForwardSlashInPath() {
+ return false;
+ }
@Override
- public void incrementInProgressAsyncCount() { /* NO-OP */ }
+ public void incrementInProgressAsyncCount() {
+ // NO-OP
+ }
+
@Override
- public void decrementInProgressAsyncCount() { /* NO-OP */ }
+ public void decrementInProgressAsyncCount() {
+ // NO-OP
+ }
@Override
- public void setCreateUploadTargets(boolean createUploadTargets) { /* NO-OP */}
+ public void setCreateUploadTargets(boolean createUploadTargets) {
+ /* NO-OP */}
+
@Override
- public boolean getCreateUploadTargets() { return false; }
+ public boolean getCreateUploadTargets() {
+ return false;
+ }
@Override
- public boolean getAlwaysAccessSession() { return false; }
+ public boolean getAlwaysAccessSession() {
+ return false;
+ }
+
@Override
- public void setAlwaysAccessSession(boolean alwaysAccessSession) {}
+ public void setAlwaysAccessSession(boolean alwaysAccessSession) {
+ }
@Override
- public boolean getContextGetResourceRequiresSlash() { return false; }
+ public boolean getContextGetResourceRequiresSlash() {
+ return false;
+ }
+
@Override
- public void setContextGetResourceRequiresSlash(boolean contextGetResourceRequiresSlash) {}
+ public void setContextGetResourceRequiresSlash(boolean contextGetResourceRequiresSlash) {
+ }
@Override
- public boolean getDispatcherWrapsSameObject() { return false; }
+ public boolean getDispatcherWrapsSameObject() {
+ return false;
+ }
+
@Override
- public void setDispatcherWrapsSameObject(boolean dispatcherWrapsSameObject) {}
+ public void setDispatcherWrapsSameObject(boolean dispatcherWrapsSameObject) {
+ }
@Override
- public boolean getParallelAnnotationScanning() { return false; }
+ public boolean getParallelAnnotationScanning() {
+ return false;
+ }
+
@Override
- public void setParallelAnnotationScanning(boolean parallelAnnotationScanning) {}
+ public void setParallelAnnotationScanning(boolean parallelAnnotationScanning) {
+ }
@Override
- public boolean getUseBloomFilterForArchives() { return false; }
+ public boolean getUseBloomFilterForArchives() {
+ return false;
+ }
@Override
- public void setUseBloomFilterForArchives(boolean useBloomFilterForArchives) {}
+ public void setUseBloomFilterForArchives(boolean useBloomFilterForArchives) {
+ }
}
\ No newline at end of file
diff --git a/java/org/apache/catalina/startup/HomesUserDatabase.java b/java/org/apache/catalina/startup/HomesUserDatabase.java
index a0be2dbc5f..fd8caf78d7 100644
--- a/java/org/apache/catalina/startup/HomesUserDatabase.java
+++ b/java/org/apache/catalina/startup/HomesUserDatabase.java
@@ -23,9 +23,8 @@ import java.util.HashMap;
import java.util.Map;
/**
- * Concrete implementation of the <code>UserDatabase</code> interface
- * considers all directories in a directory whose pathname is specified
- * to our constructor to be "home" directories for those users.
+ * Concrete implementation of the <code>UserDatabase</code> interface considers all directories in a directory whose
+ * pathname is specified to our constructor to be "home" directories for those users.
*
* @author Craig R. McClanahan
*/
diff --git a/java/org/apache/catalina/startup/HostConfig.java b/java/org/apache/catalina/startup/HostConfig.java
index 43b8d46b25..504ae72ef8 100644
--- a/java/org/apache/catalina/startup/HostConfig.java
+++ b/java/org/apache/catalina/startup/HostConfig.java
@@ -75,8 +75,8 @@ import org.apache.tomcat.util.modeler.Registry;
import org.apache.tomcat.util.res.StringManager;
/**
- * Startup event listener for a <b>Host</b> that configures the properties
- * of that Host, and the associated defined contexts.
+ * Startup event listener for a <b>Host</b> that configures the properties of that Host, and the associated defined
+ * contexts.
*
* @author Craig R. McClanahan
* @author Remy Maucherat
@@ -117,23 +117,20 @@ public class HostConfig implements LifecycleListener {
/**
- * Should we deploy XML Context config files packaged with WAR files and
- * directories?
+ * Should we deploy XML Context config files packaged with WAR files and directories?
*/
protected boolean deployXML = false;
/**
- * Should XML files be copied to
- * $CATALINA_BASE/conf/<engine>/<host> by default when
- * a web application is deployed?
+ * Should XML files be copied to $CATALINA_BASE/conf/<engine>/<host> by default when a web application
+ * is deployed?
*/
protected boolean copyXML = false;
/**
- * Should we unpack WAR files when auto-deploying applications in the
- * <code>appBase</code> directory?
+ * Should we unpack WAR files when auto-deploying applications in the <code>appBase</code> directory?
*/
protected boolean unpackWARs = false;
@@ -141,13 +138,11 @@ public class HostConfig implements LifecycleListener {
/**
* Map of deployed applications.
*/
- protected final Map<String, DeployedApplication> deployed =
- new ConcurrentHashMap<>();
+ protected final Map<String,DeployedApplication> deployed = new ConcurrentHashMap<>();
/**
- * Set of applications which are being serviced, and shouldn't be
- * deployed/undeployed/redeployed at the moment.
+ * Set of applications which are being serviced, and shouldn't be deployed/undeployed/redeployed at the moment.
*/
private Set<String> servicedSet = ConcurrentHashMap.newKeySet();
@@ -158,8 +153,7 @@ public class HostConfig implements LifecycleListener {
private final Object digesterLock = new Object();
/**
- * The list of Wars in the appBase to be ignored because they are invalid
- * (e.g. contain /../ sequences).
+ * The list of Wars in the appBase to be ignored because they are invalid (e.g. contain /../ sequences).
*/
protected final Set<String> invalidWars = new HashSet<>();
@@ -252,7 +246,7 @@ public class HostConfig implements LifecycleListener {
*/
public void setCopyXML(boolean copyXML) {
- this.copyXML= copyXML;
+ this.copyXML = copyXML;
}
@@ -314,8 +308,7 @@ public class HostConfig implements LifecycleListener {
/**
- * Add a serviced application to the list and indicates if the application
- * was already present in the list.
+ * Add a serviced application to the list and indicates if the application was already present in the list.
*
* @param name the context name
*
@@ -331,6 +324,7 @@ public class HostConfig implements LifecycleListener {
/**
* Removed a serviced application from the list.
+ *
* @param name the context name
*/
public void removeServiced(String name) {
@@ -340,9 +334,10 @@ public class HostConfig implements LifecycleListener {
/**
* Get the instant where an application was deployed.
+ *
* @param name the context name
- * @return 0L if no application with that name is deployed, or the instant
- * on which the 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) {
synchronized (host) {
@@ -357,12 +352,12 @@ public class HostConfig implements LifecycleListener {
/**
- * Has the specified application been deployed? Note applications defined
- * in server.xml will not have been deployed.
+ * Has the specified application been deployed? Note applications defined in server.xml will not have been deployed.
+ *
* @param name the context name
- * @return <code>true</code> if the application has been deployed and
- * <code>false</code> if the application has not been deployed or does not
- * exist
+ *
+ * @return <code>true</code> if the application has been deployed and <code>false</code> if the application has not
+ * been deployed or does not exist
*/
public boolean isDeployed(String name) {
return deployed.containsKey(name);
@@ -374,8 +369,9 @@ public class HostConfig implements LifecycleListener {
/**
* Create the digester which will be used to parse context config files.
- * @param contextClassName The class which will be used to create the
- * context instance
+ *
+ * @param contextClassName The class which will be used to create the context instance
+ *
* @return the digester
*/
protected static Digester createDigester(String contextClassName) {
@@ -403,8 +399,8 @@ public class HostConfig implements LifecycleListener {
/**
- * Get the name of the configBase.
- * For use with JMX management.
+ * Get the name of the configBase. For use with JMX management.
+ *
* @return the config base
*/
public String getConfigBaseName() {
@@ -413,8 +409,7 @@ public class HostConfig implements LifecycleListener {
/**
- * Deploy applications for any directories or WAR files that are found
- * in our "application root" directory.
+ * Deploy applications for any directories or WAR files that are found in our "application root" directory.
*/
protected void deployApps() {
// Migrate legacy Java EE apps from legacyAppBase
@@ -432,12 +427,12 @@ public class HostConfig implements LifecycleListener {
/**
- * Filter the list of application file paths to remove those that match
- * the regular expression defined by {@link Host#getDeployIgnore()}.
+ * Filter the list of application file paths to remove those that match the regular expression defined by
+ * {@link Host#getDeployIgnore()}.
*
- * @param unfilteredAppPaths The list of application paths to filter
+ * @param unfilteredAppPaths The list of application paths to filter
*
- * @return The filtered list of application paths
+ * @return The filtered list of application paths
*/
protected String[] filterAppPaths(String[] unfilteredAppPaths) {
Pattern filter = host.getDeployIgnorePattern();
@@ -466,11 +461,9 @@ public class HostConfig implements LifecycleListener {
/**
- * Deploy applications for any directories or WAR files that are found
- * in our "application root" directory.
+ * Deploy applications for any directories or WAR files that are found in our "application root" directory.
* <p>
- * Note: It is expected that the caller has successfully added the app
- * to servicedSet before calling this method.
+ * Note: It is expected that the caller has successfully added the app to servicedSet before calling this method.
*
* @param name The context name which should be deployed
*/
@@ -507,8 +500,9 @@ public class HostConfig implements LifecycleListener {
/**
* Deploy XML context descriptors.
+ *
* @param configBase The config base
- * @param files The XML descriptors which should be deployed
+ * @param files The XML descriptors which should be deployed
*/
protected void deployDescriptors(File configBase, String[] files) {
@@ -556,10 +550,9 @@ public class HostConfig implements LifecycleListener {
/**
* Deploy specified context descriptor.
* <p>
- * Note: It is expected that the caller has successfully added the app
- * to servicedSet before calling this method.
+ * Note: It is expected that the caller has successfully added the app to servicedSet before calling this method.
*
- * @param cn The context name
+ * @param cn The context name
* @param contextXml The descriptor
*/
@SuppressWarnings("null") // context is not null
@@ -570,8 +563,8 @@ public class HostConfig implements LifecycleListener {
long startTime = 0;
// Assume this is a configuration descriptor and deploy it
if (log.isInfoEnabled()) {
- startTime = System.currentTimeMillis();
- log.info(sm.getString("hostConfig.deployDescriptor", contextXml.getAbsolutePath()));
+ startTime = System.currentTimeMillis();
+ log.info(sm.getString("hostConfig.deployDescriptor", contextXml.getAbsolutePath()));
}
Context context = null;
@@ -615,23 +608,22 @@ public class HostConfig implements LifecycleListener {
// If external docBase, register .xml as redeploy first
if (!docBase.getCanonicalFile().toPath().startsWith(host.getAppBaseFile().toPath())) {
isExternal = true;
- deployedApp.redeployResources.put(
- contextXml.getAbsolutePath(), Long.valueOf(contextXml.lastModified()));
- deployedApp.redeployResources.put(
- docBase.getAbsolutePath(), Long.valueOf(docBase.lastModified()));
+ deployedApp.redeployResources.put(contextXml.getAbsolutePath(),
+ Long.valueOf(contextXml.lastModified()));
+ deployedApp.redeployResources.put(docBase.getAbsolutePath(), Long.valueOf(docBase.lastModified()));
if (docBase.getAbsolutePath().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
isExternalWar = true;
}
// Check that a WAR or DIR in the appBase is not 'hidden'
File war = new File(host.getAppBaseFile(), cn.getBaseName() + ".war");
if (war.exists()) {
- log.warn(sm.getString("hostConfig.deployDescriptor.hiddenWar",
- contextXml.getAbsolutePath(), war.getAbsolutePath()));
+ log.warn(sm.getString("hostConfig.deployDescriptor.hiddenWar", contextXml.getAbsolutePath(),
+ war.getAbsolutePath()));
}
File dir = new File(host.getAppBaseFile(), cn.getBaseName());
if (dir.exists()) {
- log.warn(sm.getString("hostConfig.deployDescriptor.hiddenDir",
- contextXml.getAbsolutePath(), dir.getAbsolutePath()));
+ log.warn(sm.getString("hostConfig.deployDescriptor.hiddenDir", contextXml.getAbsolutePath(),
+ dir.getAbsolutePath()));
}
} else {
log.warn(sm.getString("hostConfig.deployDescriptor.localDocBaseSpecified", docBase));
@@ -667,8 +659,8 @@ public class HostConfig implements LifecycleListener {
// watched inside it
if (isExternalWar) {
if (unpackWAR) {
- deployedApp.redeployResources.put(
- expandedDocBase.getAbsolutePath(), Long.valueOf(expandedDocBase.lastModified()));
+ deployedApp.redeployResources.put(expandedDocBase.getAbsolutePath(),
+ Long.valueOf(expandedDocBase.lastModified()));
addWatchedResources(deployedApp, expandedDocBase.getAbsolutePath(), context);
} else {
addWatchedResources(deployedApp, null, context);
@@ -678,16 +670,16 @@ public class HostConfig implements LifecycleListener {
if (!isExternal) {
File warDocBase = new File(expandedDocBase.getAbsolutePath() + ".war");
if (warDocBase.exists()) {
- deployedApp.redeployResources.put(
- warDocBase.getAbsolutePath(), Long.valueOf(warDocBase.lastModified()));
+ deployedApp.redeployResources.put(warDocBase.getAbsolutePath(),
+ Long.valueOf(warDocBase.lastModified()));
} else {
// Trigger a redeploy if a WAR is added
deployedApp.redeployResources.put(warDocBase.getAbsolutePath(), Long.valueOf(0));
}
}
if (unpackWAR) {
- deployedApp.redeployResources.put(
- expandedDocBase.getAbsolutePath(), Long.valueOf(expandedDocBase.lastModified()));
+ deployedApp.redeployResources.put(expandedDocBase.getAbsolutePath(),
+ Long.valueOf(expandedDocBase.lastModified()));
addWatchedResources(deployedApp, expandedDocBase.getAbsolutePath(), context);
} else {
addWatchedResources(deployedApp, null, context);
@@ -695,8 +687,8 @@ public class HostConfig implements LifecycleListener {
if (!isExternal) {
// For external docBases, the context.xml will have been
// added above.
- deployedApp.redeployResources.put(
- contextXml.getAbsolutePath(), Long.valueOf(contextXml.lastModified()));
+ deployedApp.redeployResources.put(contextXml.getAbsolutePath(),
+ Long.valueOf(contextXml.lastModified()));
}
}
// Add the global redeploy resources (which are never deleted) at
@@ -709,16 +701,17 @@ public class HostConfig implements LifecycleListener {
}
if (log.isInfoEnabled()) {
- log.info(sm.getString("hostConfig.deployDescriptor.finished",
- contextXml.getAbsolutePath(), Long.valueOf(System.currentTimeMillis() - startTime)));
+ log.info(sm.getString("hostConfig.deployDescriptor.finished", contextXml.getAbsolutePath(),
+ Long.valueOf(System.currentTimeMillis() - startTime)));
}
}
/**
* Deploy WAR files.
+ *
* @param appBase The base path for applications
- * @param files The WARs to deploy
+ * @param files The WARs to deploy
*/
protected void deployWARs(File appBase, String[] files) {
@@ -754,8 +747,8 @@ public class HostConfig implements LifecycleListener {
File dir = new File(appBase, cn.getBaseName());
if (dir.exists()) {
if (!app.loggedDirWarning) {
- log.warn(sm.getString("hostConfig.deployWar.hiddenDir",
- dir.getAbsoluteFile(), war.getAbsoluteFile()));
+ log.warn(sm.getString("hostConfig.deployWar.hiddenDir", dir.getAbsoluteFile(),
+ war.getAbsoluteFile()));
app.loggedDirWarning = true;
}
} else {
@@ -832,10 +825,9 @@ public class HostConfig implements LifecycleListener {
/**
* Deploy packed WAR.
* <p>
- * Note: It is expected that the caller has successfully added the app
- * to servicedSet before calling this method.
+ * Note: It is expected that the caller has successfully added the app to servicedSet before calling this method.
*
- * @param cn The context name
+ * @param cn The context name
* @param war The WAR file
*/
protected void deployWAR(ContextName cn, File war) {
@@ -902,8 +894,8 @@ public class HostConfig implements LifecycleListener {
} else if (!deployThisXML && xmlInWar) {
// Block deployment as META-INF/context.xml may contain security
// configuration necessary for a secure deployment.
- log.error(sm.getString("hostConfig.deployDescriptor.blocked",
- cn.getPath(), Constants.ApplicationContextXml,
+ log.error(sm.getString("hostConfig.deployDescriptor.blocked", cn.getPath(),
+ Constants.ApplicationContextXml,
new File(host.getConfigBaseFile(), cn.getBaseName() + ".xml")));
} else {
context = (Context) Class.forName(contextClass).getConstructor().newInstance();
@@ -943,12 +935,12 @@ public class HostConfig implements LifecycleListener {
}
}
- DeployedApplication deployedApp = new DeployedApplication(
- cn.getName(), xml.exists() && deployThisXML && copyThisXml);
+ DeployedApplication deployedApp =
+ new DeployedApplication(cn.getName(), xml.exists() && deployThisXML && copyThisXml);
long startTime = 0;
// Deploy the application in this WAR file
- if(log.isInfoEnabled()) {
+ if (log.isInfoEnabled()) {
startTime = System.currentTimeMillis();
log.info(sm.getString("hostConfig.deployWar", war.getAbsolutePath()));
}
@@ -1005,16 +997,17 @@ public class HostConfig implements LifecycleListener {
deployed.put(cn.getName(), deployedApp);
if (log.isInfoEnabled()) {
- log.info(sm.getString("hostConfig.deployWar.finished",
- war.getAbsolutePath(), Long.valueOf(System.currentTimeMillis() - startTime)));
+ log.info(sm.getString("hostConfig.deployWar.finished", war.getAbsolutePath(),
+ Long.valueOf(System.currentTimeMillis() - startTime)));
}
}
/**
* Deploy exploded webapps.
+ *
* @param appBase The base path for applications
- * @param files The exploded webapps that should be deployed
+ * @param files The exploded webapps that should be deployed
*/
protected void deployDirectories(File appBase, String[] files) {
@@ -1068,17 +1061,16 @@ public class HostConfig implements LifecycleListener {
/**
* Deploy exploded webapp.
* <p>
- * Note: It is expected that the caller has successfully added the app
- * to servicedSet before calling this method.
+ * Note: It is expected that the caller has successfully added the app to servicedSet before calling this method.
*
- * @param cn The context name
+ * @param cn The context name
* @param dir The path to the root folder of the webapp
*/
protected void deployDirectory(ContextName cn, File dir) {
long startTime = 0;
// Deploy the application in this directory
- if( log.isInfoEnabled() ) {
+ if (log.isInfoEnabled()) {
startTime = System.currentTimeMillis();
log.info(sm.getString("hostConfig.deployDir", dir.getAbsolutePath()));
}
@@ -1171,9 +1163,9 @@ public class HostConfig implements LifecycleListener {
deployed.put(cn.getName(), deployedApp);
- if( log.isInfoEnabled() ) {
- log.info(sm.getString("hostConfig.deployDir.finished",
- dir.getAbsolutePath(), Long.valueOf(System.currentTimeMillis() - startTime)));
+ if (log.isInfoEnabled()) {
+ log.info(sm.getString("hostConfig.deployDir.finished", dir.getAbsolutePath(),
+ Long.valueOf(System.currentTimeMillis() - startTime)));
}
}
@@ -1272,6 +1264,7 @@ public class HostConfig implements LifecycleListener {
* Check if a webapp is already deployed in this host.
*
* @param contextName of the context which will be checked
+ *
* @return <code>true</code> if the specified deployment exists
*/
protected boolean deploymentExists(String contextName) {
@@ -1281,14 +1274,15 @@ public class HostConfig implements LifecycleListener {
/**
* Add watched resources to the specified Context.
- * @param app HostConfig deployed app
+ *
+ * @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
+ // 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);
@@ -1304,34 +1298,28 @@ public class HostConfig implements LifecycleListener {
resource = new File(docBaseFile, watchedResource);
} else {
if (log.isDebugEnabled()) {
- log.debug("Ignoring non-existent WatchedResource '" +
- resource.getAbsolutePath() + "'");
+ log.debug("Ignoring non-existent WatchedResource '" + resource.getAbsolutePath() + "'");
}
continue;
}
}
if (log.isDebugEnabled()) {
- log.debug("Watching WatchedResource '" +
- resource.getAbsolutePath() + "'");
+ log.debug("Watching WatchedResource '" + resource.getAbsolutePath() + "'");
}
- app.reloadResources.put(resource.getAbsolutePath(),
- Long.valueOf(resource.lastModified()));
+ app.reloadResources.put(resource.getAbsolutePath(), Long.valueOf(resource.lastModified()));
}
}
protected void addGlobalRedeployResources(DeployedApplication app) {
// Redeploy resources processing is hard-coded to never delete this file
- File hostContextXml =
- new File(getConfigBaseName(), Constants.HostContextXml);
+ File hostContextXml = new File(getConfigBaseName(), Constants.HostContextXml);
if (hostContextXml.isFile()) {
- app.redeployResources.put(hostContextXml.getAbsolutePath(),
- Long.valueOf(hostContextXml.lastModified()));
+ app.redeployResources.put(hostContextXml.getAbsolutePath(), Long.valueOf(hostContextXml.lastModified()));
}
// Redeploy resources in CATALINA_BASE/conf are never deleted
- File globalContextXml =
- returnCanonicalPath(Constants.DefaultContextXml);
+ File globalContextXml = returnCanonicalPath(Constants.DefaultContextXml);
if (globalContextXml.isFile()) {
app.redeployResources.put(globalContextXml.getAbsolutePath(),
Long.valueOf(globalContextXml.lastModified()));
@@ -1342,43 +1330,33 @@ public class HostConfig implements LifecycleListener {
/**
* Check resources for redeployment and reloading.
*
- * @param app The web application to check
- * @param skipFileModificationResolutionCheck
- * When checking files for modification should the check that
- * requires that any file modification must have occurred at
- * least as long ago as the resolution of the file time stamp
- * be skipped
+ * @param app The web application to check
+ * @param skipFileModificationResolutionCheck When checking files for modification should the check that requires
+ * that any file modification must have occurred at least as long ago
+ * as the resolution of the file time stamp be skipped
*/
- protected void checkResources(DeployedApplication app,
- boolean skipFileModificationResolutionCheck) {
- String[] resources =
- app.redeployResources.keySet().toArray(new String[0]);
+ protected void checkResources(DeployedApplication app, boolean skipFileModificationResolutionCheck) {
+ String[] resources = app.redeployResources.keySet().toArray(new String[0]);
// Offset the current time by the resolution of File.lastModified()
- long currentTimeWithResolutionOffset =
- System.currentTimeMillis() - FILE_MODIFICATION_RESOLUTION_MS;
+ long currentTimeWithResolutionOffset = System.currentTimeMillis() - FILE_MODIFICATION_RESOLUTION_MS;
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);
+ log.debug("Checking context[" + app.name + "] redeploy resource " + resource);
}
- long lastModified =
- app.redeployResources.get(resources[i]).longValue();
+ long lastModified = app.redeployResources.get(resources[i]).longValue();
if (resource.exists() || lastModified == 0) {
// File.lastModified() has a resolution of 1s (1000ms). The last
// modified time has to be more than 1000ms ago to ensure that
// modifications that take place in the same second are not
// missed. See Bug 57765.
- if (resource.lastModified() != lastModified && (!host.getAutoDeploy() ||
- resource.lastModified() < currentTimeWithResolutionOffset ||
- skipFileModificationResolutionCheck)) {
+ if (resource.lastModified() != lastModified &&
+ (!host.getAutoDeploy() || resource.lastModified() < currentTimeWithResolutionOffset ||
+ skipFileModificationResolutionCheck)) {
if (resource.isDirectory()) {
// No action required for modified directory
- app.redeployResources.put(resources[i],
- Long.valueOf(resource.lastModified()));
- } else if (app.hasDescriptor &&
- resource.getName().toLowerCase(
- Locale.ENGLISH).endsWith(".war")) {
+ app.redeployResources.put(resources[i], Long.valueOf(resource.lastModified()));
+ } else if (app.hasDescriptor && resource.getName().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
// Modified WAR triggers a reload if there is an XML
// file present
// The only resource that should be deleted is the
@@ -1389,16 +1367,14 @@ public class HostConfig implements LifecycleListener {
// This is an expanded directory
File docBaseFile = new File(docBase);
if (!docBaseFile.isAbsolute()) {
- docBaseFile = new File(host.getAppBaseFile(),
- docBase);
+ docBaseFile = new File(host.getAppBaseFile(), docBase);
}
reload(app, docBaseFile, resource.getAbsolutePath());
} else {
reload(app, null, null);
}
// Update times
- app.redeployResources.put(resources[i],
- Long.valueOf(resource.lastModified()));
+ app.redeployResources.put(resources[i], Long.valueOf(resource.lastModified()));
app.timestamp = System.currentTimeMillis();
boolean unpackWAR = unpackWARs;
if (unpackWAR && context instanceof StandardContext) {
@@ -1449,8 +1425,7 @@ public class HostConfig implements LifecycleListener {
// modifications that take place in the same second are not
// missed. See Bug 57765.
if ((resource.lastModified() != lastModified &&
- (!host.getAutoDeploy() ||
- resource.lastModified() < currentTimeWithResolutionOffset ||
+ (!host.getAutoDeploy() || resource.lastModified() < currentTimeWithResolutionOffset ||
skipFileModificationResolutionCheck)) ||
update) {
if (!update) {
@@ -1460,8 +1435,7 @@ public class HostConfig implements LifecycleListener {
}
// Update times. More than one file may have been updated. We
// don't want to trigger a series of reloads.
- app.reloadResources.put(s,
- Long.valueOf(resource.lastModified()));
+ app.reloadResources.put(s, Long.valueOf(resource.lastModified()));
}
app.timestamp = System.currentTimeMillis();
}
@@ -1469,18 +1443,16 @@ public class HostConfig implements LifecycleListener {
/*
- * Note: If either of fileToRemove and newDocBase are null, both will be
- * ignored.
+ * Note: If either of fileToRemove and newDocBase are null, both will be ignored.
*/
private void reload(DeployedApplication app, File fileToRemove, String newDocBase) {
- if(log.isInfoEnabled()) {
+ if (log.isInfoEnabled()) {
log.info(sm.getString("hostConfig.reload", app.name));
}
Context context = (Context) host.findChild(app.name);
if (context.getState().isAvailable()) {
if (fileToRemove != null && newDocBase != null) {
- context.addLifecycleListener(
- new ExpandedDirectoryRemovalListener(fileToRemove, newDocBase));
+ context.addLifecycleListener(new ExpandedDirectoryRemovalListener(fileToRemove, newDocBase));
}
// Reload catches and logs exceptions
context.reload();
@@ -1509,8 +1481,7 @@ public class HostConfig implements LifecycleListener {
host.removeChild(context);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
- log.warn(sm.getString
- ("hostConfig.context.remove", app.name), t);
+ log.warn(sm.getString("hostConfig.context.remove", app.name), t);
}
deployed.remove(app.name);
}
@@ -1559,15 +1530,17 @@ public class HostConfig implements LifecycleListener {
/*
- * Delete any resource that would trigger the automatic deployment code to
- * re-deploy the application. This means deleting:
+ * Delete any resource that would trigger the automatic deployment code to re-deploy the application. This means
+ * deleting:
+ *
* - any resource located in the appBase
+ *
* - any deployment descriptor located under the configBase
+ *
* - symlinks in the appBase or configBase for either of the above
*/
private boolean isDeletableResource(DeployedApplication app, File resource) {
- // The resource may be a file, a directory or a symlink to a file or
- // directory.
+ // The resource may be a file, a directory or a symlink to a file or directory.
// Check that the resource is absolute. This should always be the case.
if (!resource.isAbsolute()) {
@@ -1580,8 +1553,7 @@ public class HostConfig implements LifecycleListener {
try {
canonicalLocation = resource.getParentFile().getCanonicalPath();
} catch (IOException e) {
- log.warn(sm.getString(
- "hostConfig.canonicalizing", resource.getParentFile(), app.name), e);
+ log.warn(sm.getString("hostConfig.canonicalizing", resource.getParentFile(), app.name), e);
return false;
}
@@ -1589,8 +1561,7 @@ public class HostConfig implements LifecycleListener {
try {
canonicalAppBase = host.getAppBaseFile().getCanonicalPath();
} catch (IOException e) {
- log.warn(sm.getString(
- "hostConfig.canonicalizing", host.getAppBaseFile(), app.name), e);
+ log.warn(sm.getString("hostConfig.canonicalizing", host.getAppBaseFile(), app.name), e);
return false;
}
@@ -1603,13 +1574,11 @@ public class HostConfig implements LifecycleListener {
try {
canonicalConfigBase = host.getConfigBaseFile().getCanonicalPath();
} catch (IOException e) {
- log.warn(sm.getString(
- "hostConfig.canonicalizing", host.getConfigBaseFile(), app.name), e);
+ log.warn(sm.getString("hostConfig.canonicalizing", host.getConfigBaseFile(), app.name), e);
return false;
}
- if (canonicalLocation.equals(canonicalConfigBase) &&
- resource.getName().endsWith(".xml")) {
+ if (canonicalLocation.equals(canonicalConfigBase) && resource.getName().endsWith(".xml")) {
// Resource is an xml file in the configBase so it may be deleted
return true;
}
@@ -1621,7 +1590,7 @@ public class HostConfig implements LifecycleListener {
public void beforeStart() {
if (host.getCreateDirs()) {
- File[] dirs = new File[] {host.getAppBaseFile(),host.getConfigBaseFile()};
+ File[] dirs = new File[] { host.getAppBaseFile(), host.getConfigBaseFile() };
for (File dir : dirs) {
if (!dir.mkdirs() && !dir.isDirectory()) {
log.error(sm.getString("hostConfig.createDirs", dir));
@@ -1642,17 +1611,14 @@ public class HostConfig implements LifecycleListener {
try {
ObjectName hostON = host.getObjectName();
- oname = new ObjectName
- (hostON.getDomain() + ":type=Deployer,host=" + host.getName());
- Registry.getRegistry(null, null).registerComponent
- (this, oname, this.getClass().getName());
+ oname = new ObjectName(hostON.getDomain() + ":type=Deployer,host=" + host.getName());
+ Registry.getRegistry(null, null).registerComponent(this, oname, this.getClass().getName());
} catch (Exception e) {
log.warn(sm.getString("hostConfig.jmx.register", oname), e);
}
if (!host.getAppBaseFile().isDirectory()) {
- log.error(sm.getString("hostConfig.appBase", host.getName(),
- host.getAppBaseFile().getPath()));
+ log.error(sm.getString("hostConfig.appBase", host.getName(), host.getAppBaseFile().getPath()));
host.setDeployOnStartup(false);
host.setAutoDeploy(false);
}
@@ -1713,13 +1679,11 @@ public class HostConfig implements LifecycleListener {
/**
- * Check status of a specific web application and reload, redeploy or deploy
- * it as necessary. This method is for use with functionality such as
- * management web applications that upload new/updated web applications and
- * need to trigger the appropriate action to deploy them. This method
- * assumes that any uploading/updating has been completed before this method
- * is called. Any action taken as a result of the checks will complete
- * before this method returns.
+ * Check status of a specific web application and reload, redeploy or deploy it as necessary. This method is for use
+ * with functionality such as management web applications that upload new/updated web applications and need to
+ * trigger the appropriate action to deploy them. This method assumes that any uploading/updating has been completed
+ * before this method is called. Any action taken as a result of the checks will complete before this method
+ * returns.
*
* @param name The name of the web application to check
*/
@@ -1743,8 +1707,8 @@ public class HostConfig implements LifecycleListener {
}
/**
- * Check for old versions of applications using parallel deployment that are
- * now unused (have no active sessions) and undeploy any that are found.
+ * Check for old versions of applications using parallel deployment that are now unused (have no active sessions)
+ * and undeploy any that are found.
*/
public void checkUndeploy() {
synchronized (host) {
@@ -1766,8 +1730,7 @@ public class HostConfig implements LifecycleListener {
// be a later version
Context previousContext = (Context) host.findChild(previous.getName());
Context currentContext = (Context) host.findChild(current.getName());
- if (previousContext != null && currentContext != null &&
- currentContext.getState().isAvailable() &&
+ if (previousContext != null && currentContext != null && currentContext.getState().isAvailable() &&
tryAddServiced(previous.getName())) {
try {
Manager manager = previousContext.getManager();
@@ -1802,11 +1765,11 @@ public class HostConfig implements LifecycleListener {
}
/**
- * Add a new Context to be managed by us.
- * Entry point for the admin webapp, and other JMX Context controllers.
+ * Add a new Context to be managed by us. Entry point for the admin webapp, and other JMX Context controllers.
+ *
* @param context The context instance
*/
- public void manageApp(Context context) {
+ public void manageApp(Context context) {
String contextName = context.getName();
@@ -1814,8 +1777,7 @@ public class HostConfig implements LifecycleListener {
return;
}
- DeployedApplication deployedApp =
- new DeployedApplication(contextName, false);
+ DeployedApplication deployedApp = new DeployedApplication(contextName, false);
// Add the associated docBase to the redeployed list if it's a WAR
boolean isWar = false;
@@ -1824,8 +1786,7 @@ public class HostConfig implements LifecycleListener {
if (!docBase.isAbsolute()) {
docBase = new File(host.getAppBaseFile(), context.getDocBase());
}
- deployedApp.redeployResources.put(docBase.getAbsolutePath(),
- Long.valueOf(docBase.lastModified()));
+ deployedApp.redeployResources.put(docBase.getAbsolutePath(), Long.valueOf(docBase.lastModified()));
if (docBase.getAbsolutePath().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
isWar = true;
}
@@ -1839,8 +1800,7 @@ public class HostConfig implements LifecycleListener {
}
if (isWar && unpackWAR) {
File docBase = new File(host.getAppBaseFile(), context.getBaseName());
- deployedApp.redeployResources.put(docBase.getAbsolutePath(),
- Long.valueOf(docBase.lastModified()));
+ deployedApp.redeployResources.put(docBase.getAbsolutePath(), Long.valueOf(docBase.lastModified()));
addWatchedResources(deployedApp, docBase.getAbsolutePath(), context);
} else {
addWatchedResources(deployedApp, null, context);
@@ -1849,11 +1809,9 @@ public class HostConfig implements LifecycleListener {
}
/**
- * Remove a webapp from our control.
- * Entry point for the admin webapp, and other JMX Context controllers.
+ * Remove a webapp from our control. Entry point for the admin webapp, and other JMX Context controllers.
* <p>
- * Note: It is expected that the caller has successfully added the app
- * to servicedSet before calling this method.
+ * Note: It is expected that the caller has successfully added the app to servicedSet before calling this method.
*
* @param contextName The context name
*/
@@ -1866,8 +1824,7 @@ public class HostConfig implements LifecycleListener {
/**
- * This class represents the state of a deployed application, as well as
- * the monitored resources.
+ * This class represents the state of a deployed application, as well as the monitored resources.
*/
protected static class DeployedApplication {
public DeployedApplication(String name, boolean hasDescriptor) {
@@ -1876,35 +1833,28 @@ public class HostConfig implements LifecycleListener {
}
/**
- * Application context path. The assertion is that
- * (host.getChild(name) != null).
+ * Application context path. The assertion is that (host.getChild(name) != null).
*/
public final String name;
/**
- * Does this application have a context.xml descriptor file on the
- * host's configBase?
+ * Does this application have a context.xml descriptor file on the host's configBase?
*/
public final boolean hasDescriptor;
/**
- * 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.
+ * 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 final LinkedHashMap<String, Long> redeployResources =
- new LinkedHashMap<>();
+ public final LinkedHashMap<String,Long> redeployResources = new LinkedHashMap<>();
/**
- * 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.
+ * 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 final HashMap<String, Long> reloadResources = new HashMap<>();
+ public final HashMap<String,Long> reloadResources = new HashMap<>();
/**
* Instant where the application was last put in service.
@@ -1912,10 +1862,9 @@ public class HostConfig implements LifecycleListener {
public long timestamp = System.currentTimeMillis();
/**
- * In some circumstances, such as when unpackWARs is true, a directory
- * may be added to the appBase that is ignored. This flag indicates that
- * the user has been warned so that the warning is not logged on every
- * run of the auto deployer.
+ * In some circumstances, such as when unpackWARs is true, a directory may be added to the appBase that is
+ * ignored. This flag indicates that the user has been warned so that the warning is not logged on every run of
+ * the auto deployer.
*/
public boolean loggedDirWarning = false;
}
@@ -1926,11 +1875,10 @@ public class HostConfig implements LifecycleListener {
private ContextName cn;
private File descriptor;
- DeployDescriptor(HostConfig config, ContextName cn,
- File descriptor) {
+ DeployDescriptor(HostConfig config, ContextName cn, File descriptor) {
this.config = config;
this.cn = cn;
- this.descriptor= descriptor;
+ this.descriptor = descriptor;
}
@Override
@@ -2014,16 +1962,13 @@ public class HostConfig implements LifecycleListener {
/*
- * The purpose of this class is to provide a way for HostConfig to get
- * a Context to delete an expanded WAR after the Context stops. This is to
- * resolve this issue described in Bug 57772. The alternative solutions
- * require either duplicating a lot of the Context.reload() code in
- * HostConfig or adding a new reload(boolean) method to Context that allows
- * the caller to optionally delete any expanded WAR.
+ * The purpose of this class is to provide a way for HostConfig to get a Context to delete an expanded WAR after the
+ * Context stops. This is to resolve this issue described in Bug 57772. The alternative solutions require either
+ * duplicating a lot of the Context.reload() code in HostConfig or adding a new reload(boolean) method to Context
+ * that allows the caller to optionally delete any expanded WAR.
*
- * The LifecycleListener approach offers greater flexibility and enables the
- * behaviour to be changed / extended / removed in future without changing
- * the Context API.
+ * The LifecycleListener approach offers greater flexibility and enables the behaviour to be changed / extended /
+ * removed in future without changing the Context API.
*/
private static class ExpandedDirectoryRemovalListener implements LifecycleListener {
@@ -2031,11 +1976,9 @@ public class HostConfig implements LifecycleListener {
private final String newDocBase;
/**
- * Create a listener that will ensure that any expanded WAR is removed
- * and the docBase set to the specified WAR.
+ * Create a listener that will ensure that any expanded WAR is removed and the docBase set to the specified WAR.
*
- * @param toDelete The file (a directory representing an expanded WAR)
- * to be deleted
+ * @param toDelete The file (a directory representing an expanded WAR) to be deleted
* @param newDocBase The new docBase for the Context
*/
ExpandedDirectoryRemovalListener(File toDelete, String newDocBase) {
diff --git a/java/org/apache/catalina/startup/HostRuleSet.java b/java/org/apache/catalina/startup/HostRuleSet.java
index af7b6a182d..c40f5bc823 100644
--- a/java/org/apache/catalina/startup/HostRuleSet.java
+++ b/java/org/apache/catalina/startup/HostRuleSet.java
@@ -20,10 +20,8 @@ import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
/**
- * <strong>RuleSet</strong> for processing the contents of a
- * Host definition element. This <code>RuleSet</code> does NOT include
- * any rules for nested Context which should be added via instances of
- * <code>ContextRuleSet</code>.
+ * <strong>RuleSet</strong> for processing the contents of a Host definition element. This <code>RuleSet</code> does NOT
+ * include any rules for nested Context which should be added via instances of <code>ContextRuleSet</code>.
*
* @author Craig R. McClanahan
*/
@@ -40,8 +38,7 @@ public class HostRuleSet implements RuleSet {
// ------------------------------------------------------------ Constructor
/**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
+ * Construct an instance of this <code>RuleSet</code> with the default matching pattern prefix.
*/
public HostRuleSet() {
this("");
@@ -49,11 +46,9 @@ public class HostRuleSet implements RuleSet {
/**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern 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)
+ * @param prefix Prefix for matching pattern rules (including the trailing slash character)
*/
public HostRuleSet(String prefix) {
this.prefix = prefix;
@@ -63,60 +58,40 @@ public class HostRuleSet implements RuleSet {
// --------------------------------------------------------- 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>
+ * 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.
*
- * @param digester Digester instance to which the new Rule instances
- * should be added.
+ * @param digester Digester instance to which the new Rule instances should be added.
*/
@Override
public void addRuleInstances(Digester digester) {
- digester.addObjectCreate(prefix + "Host",
- "org.apache.catalina.core.StandardHost",
- "className");
+ 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 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");
+ 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.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.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.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");
+ digester.addSetNext(prefix + "Host/Valve", "addValve", "org.apache.catalina.Valve");
}
}
diff --git a/java/org/apache/catalina/startup/LifecycleListenerRule.java b/java/org/apache/catalina/startup/LifecycleListenerRule.java
index aa94fa9af4..023cf90d8e 100644
--- a/java/org/apache/catalina/startup/LifecycleListenerRule.java
+++ b/java/org/apache/catalina/startup/LifecycleListenerRule.java
@@ -25,17 +25,14 @@ import org.xml.sax.Attributes;
/**
- * Rule that creates a new {@link LifecycleListener} and associates it with the
- * top object on the stack which must implement {@link Container}. The
- * implementation class to be used is determined by:
+ * Rule that creates a new {@link LifecycleListener} and associates it with the top object on the stack which must
+ * implement {@link Container}. The implementation class to be used is determined by:
* <ol>
- * <li>Does the top element on the stack specify an implementation class using
- * the attribute specified when this rule was created?</li>
- * <li>Does the parent {@link Container} of the {@link Container} on the top of
- * the stack specify an implementation class using the attribute specified
- * when this rule was created?</li>
- * <li>Use the default implementation class specified when this rule was
- * created.</li>
+ * <li>Does the top element on the stack specify an implementation class using the attribute specified when this rule
+ * was created?</li>
+ * <li>Does the parent {@link Container} of the {@link Container} on the top of the stack specify an implementation
+ * class using the attribute specified when this rule was created?</li>
+ * <li>Use the default implementation class specified when this rule was created.</li>
* </ol>
*/
public class LifecycleListenerRule extends Rule {
@@ -47,10 +44,9 @@ public class LifecycleListenerRule extends Rule {
/**
* 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
+ * @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) {
@@ -64,8 +60,7 @@ public class LifecycleListenerRule extends Rule {
/**
- * The attribute name of an attribute that can override the
- * implementation class name.
+ * The attribute name of an attribute that can override the implementation class name.
*/
private final String attributeName;
@@ -87,8 +82,7 @@ public class LifecycleListenerRule extends Rule {
* @exception Exception if a processing error occurs
*/
@Override
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
+ public void begin(String namespace, String name, Attributes attributes) throws Exception {
Container c = (Container) digester.peek();
Container p = null;
@@ -109,8 +103,7 @@ public class LifecycleListenerRule extends Rule {
// Check the container's parent for the specified attribute
if (p != null && className == null) {
- String configClass =
- (String) IntrospectionUtils.getProperty(p, attributeName);
+ String configClass = (String) IntrospectionUtils.getProperty(p, attributeName);
if (configClass != null && configClass.length() > 0) {
className = configClass;
}
diff --git a/java/org/apache/catalina/startup/ListenerCreateRule.java b/java/org/apache/catalina/startup/ListenerCreateRule.java
index 0dd3c25fac..6cfb75ceae 100644
--- a/java/org/apache/catalina/startup/ListenerCreateRule.java
+++ b/java/org/apache/catalina/startup/ListenerCreateRule.java
@@ -42,8 +42,7 @@ public class ListenerCreateRule extends ObjectCreateRule {
}
@Override
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
+ public void begin(String namespace, String name, Attributes attributes) throws Exception {
if ("true".equals(attributes.getValue("optional"))) {
try {
super.begin(namespace, name, attributes);
@@ -60,7 +59,8 @@ public class ListenerCreateRule extends ObjectCreateRule {
if (code != null) {
code.append(OptionalListener.class.getName().replace('$', '.')).append(' ');
code.append(digester.toVariableName(instance)).append(" = new ");
- code.append(OptionalListener.class.getName().replace('$', '.')).append("(\"").append(className).append("\");");
+ code.append(OptionalListener.class.getName().replace('$', '.')).append("(\"").append(className)
+ .append("\");");
code.append(System.lineSeparator());
}
}
@@ -71,41 +71,50 @@ public class ListenerCreateRule extends ObjectCreateRule {
public static class OptionalListener implements LifecycleListener {
protected final String className;
- protected final HashMap<String, String> properties = new HashMap<>();
+ protected final HashMap<String,String> properties = new HashMap<>();
+
public OptionalListener(String className) {
this.className = className;
}
+
/**
* @return the className
*/
public String getClassName() {
return className;
}
+
@Override
public void lifecycleEvent(LifecycleEvent event) {
// Do nothing
}
+
/**
* Return a set of the property keys.
+ *
* @return the set
*/
public Set<String> getProperties() {
return properties.keySet();
}
+
/**
* Return a property from the protocol handler.
*
* @param name the property name
+ *
* @return the property value
*/
public Object getProperty(String name) {
return properties.get(name);
}
+
/**
* Set the given property.
*
- * @param name the property name
+ * @param name the property name
* @param value the property value
+ *
* @return <code>true</code>
*/
public boolean setProperty(String name, String value) {
diff --git a/java/org/apache/catalina/startup/NamingRuleSet.java b/java/org/apache/catalina/startup/NamingRuleSet.java
index 3125d886cb..2e6c87937d 100644
--- a/java/org/apache/catalina/startup/NamingRuleSet.java
+++ b/java/org/apache/catalina/startup/NamingRuleSet.java
@@ -20,8 +20,7 @@ import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
/**
- * <strong>RuleSet</strong> for processing the JNDI Enterprise Naming
- * Context resource declaration elements.
+ * <strong>RuleSet</strong> for processing the JNDI Enterprise Naming Context resource declaration elements.
*
* @author Craig R. McClanahan
* @author Remy Maucherat
@@ -39,8 +38,7 @@ public class NamingRuleSet implements RuleSet {
// ------------------------------------------------------------ Constructor
/**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
+ * Construct an instance of this <code>RuleSet</code> with the default matching pattern prefix.
*/
public NamingRuleSet() {
this("");
@@ -48,11 +46,9 @@ public class NamingRuleSet implements RuleSet {
/**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern 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)
+ * @param prefix Prefix for matching pattern rules (including the trailing slash character)
*/
public NamingRuleSet(String prefix) {
this.prefix = prefix;
@@ -62,64 +58,48 @@ public class NamingRuleSet implements RuleSet {
// --------------------------------------------------------- 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>
+ * 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.
*
- * @param digester Digester instance to which the new Rule instances
- * should be added.
+ * @param digester Digester instance to which the new Rule instances should be added.
*/
@Override
public void addRuleInstances(Digester digester) {
- digester.addObjectCreate(prefix + "Ejb",
- "org.apache.tomcat.util.descriptor.web.ContextEjb");
+ digester.addObjectCreate(prefix + "Ejb", "org.apache.tomcat.util.descriptor.web.ContextEjb");
digester.addSetProperties(prefix + "Ejb");
digester.addRule(prefix + "Ejb",
- new SetNextNamingRule("addEjb",
- "org.apache.tomcat.util.descriptor.web.ContextEjb"));
+ new SetNextNamingRule("addEjb", "org.apache.tomcat.util.descriptor.web.ContextEjb"));
- digester.addObjectCreate(prefix + "Environment",
- "org.apache.tomcat.util.descriptor.web.ContextEnvironment");
+ digester.addObjectCreate(prefix + "Environment", "org.apache.tomcat.util.descriptor.web.ContextEnvironment");
digester.addSetProperties(prefix + "Environment");
digester.addRule(prefix + "Environment",
- new SetNextNamingRule("addEnvironment",
- "org.apache.tomcat.util.descriptor.web.ContextEnvironment"));
+ new SetNextNamingRule("addEnvironment", "org.apache.tomcat.util.descriptor.web.ContextEnvironment"));
- digester.addObjectCreate(prefix + "LocalEjb",
- "org.apache.tomcat.util.descriptor.web.ContextLocalEjb");
+ digester.addObjectCreate(prefix + "LocalEjb", "org.apache.tomcat.util.descriptor.web.ContextLocalEjb");
digester.addSetProperties(prefix + "LocalEjb");
digester.addRule(prefix + "LocalEjb",
- new SetNextNamingRule("addLocalEjb",
- "org.apache.tomcat.util.descriptor.web.ContextLocalEjb"));
+ new SetNextNamingRule("addLocalEjb", "org.apache.tomcat.util.descriptor.web.ContextLocalEjb"));
- digester.addObjectCreate(prefix + "Resource",
- "org.apache.tomcat.util.descriptor.web.ContextResource");
+ digester.addObjectCreate(prefix + "Resource", "org.apache.tomcat.util.descriptor.web.ContextResource");
digester.addSetProperties(prefix + "Resource");
digester.addRule(prefix + "Resource",
- new SetNextNamingRule("addResource",
- "org.apache.tomcat.util.descriptor.web.ContextResource"));
+ new SetNextNamingRule("addResource", "org.apache.tomcat.util.descriptor.web.ContextResource"));
digester.addObjectCreate(prefix + "ResourceEnvRef",
- "org.apache.tomcat.util.descriptor.web.ContextResourceEnvRef");
+ "org.apache.tomcat.util.descriptor.web.ContextResourceEnvRef");
digester.addSetProperties(prefix + "ResourceEnvRef");
- digester.addRule(prefix + "ResourceEnvRef",
- new SetNextNamingRule("addResourceEnvRef",
- "org.apache.tomcat.util.descriptor.web.ContextResourceEnvRef"));
+ digester.addRule(prefix + "ResourceEnvRef", new SetNextNamingRule("addResourceEnvRef",
+ "org.apache.tomcat.util.descriptor.web.ContextResourceEnvRef"));
- digester.addObjectCreate(prefix + "ServiceRef",
- "org.apache.tomcat.util.descriptor.web.ContextService");
+ digester.addObjectCreate(prefix + "ServiceRef", "org.apache.tomcat.util.descriptor.web.ContextService");
digester.addSetProperties(prefix + "ServiceRef");
digester.addRule(prefix + "ServiceRef",
- new SetNextNamingRule("addService",
- "org.apache.tomcat.util.descriptor.web.ContextService"));
+ new SetNextNamingRule("addService", "org.apache.tomcat.util.descriptor.web.ContextService"));
- digester.addObjectCreate(prefix + "Transaction",
- "org.apache.tomcat.util.descriptor.web.ContextTransaction");
+ digester.addObjectCreate(prefix + "Transaction", "org.apache.tomcat.util.descriptor.web.ContextTransaction");
digester.addSetProperties(prefix + "Transaction");
digester.addRule(prefix + "Transaction",
- new SetNextNamingRule("setTransaction",
- "org.apache.tomcat.util.descriptor.web.ContextTransaction"));
+ new SetNextNamingRule("setTransaction", "org.apache.tomcat.util.descriptor.web.ContextTransaction"));
}
}
diff --git a/java/org/apache/catalina/startup/PasswdUserDatabase.java b/java/org/apache/catalina/startup/PasswdUserDatabase.java
index 3cfc9f7fd1..a63284bee3 100644
--- a/java/org/apache/catalina/startup/PasswdUserDatabase.java
+++ b/java/org/apache/catalina/startup/PasswdUserDatabase.java
@@ -28,8 +28,8 @@ import org.apache.juli.logging.LogFactory;
import org.apache.naming.StringManager;
/**
- * Concrete implementation of the <code>UserDatabase</code> interface
- * that processes the <code>/etc/passwd</code> file on a Unix system.
+ * Concrete implementation of the <code>UserDatabase</code> interface that processes the <code>/etc/passwd</code> file
+ * on a Unix system.
*
* @author Craig R. McClanahan
*/
diff --git a/java/org/apache/catalina/startup/RealmRuleSet.java b/java/org/apache/catalina/startup/RealmRuleSet.java
index 9ff7457d79..b7cd432ea0 100644
--- a/java/org/apache/catalina/startup/RealmRuleSet.java
+++ b/java/org/apache/catalina/startup/RealmRuleSet.java
@@ -20,15 +20,13 @@ import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
/**
- * <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.
+ * <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.
*/
public class RealmRuleSet implements RuleSet {
- private static final int MAX_NESTED_REALM_LEVELS = Integer.getInteger(
- "org.apache.catalina.startup.RealmRuleSet.MAX_NESTED_REALM_LEVELS",
- 3).intValue();
+ private static final int MAX_NESTED_REALM_LEVELS =
+ Integer.getInteger("org.apache.catalina.startup.RealmRuleSet.MAX_NESTED_REALM_LEVELS", 3).intValue();
// ----------------------------------------------------- Instance Variables
@@ -42,8 +40,7 @@ public class RealmRuleSet implements RuleSet {
// ------------------------------------------------------------ Constructor
/**
- * Construct an instance of this <code>RuleSet</code> with the default
- * matching pattern prefix.
+ * Construct an instance of this <code>RuleSet</code> with the default matching pattern prefix.
*/
public RealmRuleSet() {
this("");
@@ -51,11 +48,9 @@ public class RealmRuleSet implements RuleSet {
/**
- * Construct an instance of this <code>RuleSet</code> with the specified
- * matching pattern 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)
+ * @param prefix Prefix for matching pattern rules (including the trailing slash character)
*/
public RealmRuleSet(String prefix) {
this.prefix = prefix;
@@ -65,13 +60,10 @@ public class RealmRuleSet implements RuleSet {
// --------------------------------------------------------- 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>
+ * 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.
*
- * @param digester Digester instance to which the new Rule instances
- * should be added.
+ * @param digester Digester instance to which the new Rule instances should be added.
*/
@Override
public void addRuleInstances(Digester digester) {
@@ -86,8 +78,7 @@ public class RealmRuleSet implements RuleSet {
}
private void addRuleInstances(Digester digester, String pattern, String methodName) {
- digester.addObjectCreate(pattern, null /* MUST be specified in the element */,
- "className");
+ digester.addObjectCreate(pattern, null /* MUST be specified in the element */, "className");
digester.addSetProperties(pattern);
digester.addSetNext(pattern, methodName, "org.apache.catalina.Realm");
digester.addRuleSet(new CredentialHandlerRuleSet(pattern + "/"));
diff --git a/java/org/apache/catalina/startup/SafeForkJoinWorkerThreadFactory.java b/java/org/apache/catalina/startup/SafeForkJoinWorkerThreadFactory.java
index 5f16d91b46..719cfefa42 100644
--- a/java/org/apache/catalina/startup/SafeForkJoinWorkerThreadFactory.java
+++ b/java/org/apache/catalina/startup/SafeForkJoinWorkerThreadFactory.java
@@ -21,12 +21,10 @@ import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory;
import java.util.concurrent.ForkJoinWorkerThread;
/**
- * Provides a {@link ForkJoinWorkerThreadFactory} that provides {@link
- * ForkJoinWorkerThread}s that won't trigger memory leaks due to retained
- * references to web application class loaders.
+ * Provides a {@link ForkJoinWorkerThreadFactory} that provides {@link ForkJoinWorkerThread}s that won't trigger memory
+ * leaks due to retained references to web application class loaders.
* <p>
- * Note: This class must be available on the boot strap class path for it to be
- * visible to {@link ForkJoinPool}.
+ * Note: This class must be available on the boot strap class path for it to be visible to {@link ForkJoinPool}.
*/
public class SafeForkJoinWorkerThreadFactory implements ForkJoinWorkerThreadFactory {
diff --git a/java/org/apache/catalina/startup/SetNextNamingRule.java b/java/org/apache/catalina/startup/SetNextNamingRule.java
index 33d1a6b57a..0fce2ddc75 100644
--- a/java/org/apache/catalina/startup/SetNextNamingRule.java
+++ b/java/org/apache/catalina/startup/SetNextNamingRule.java
@@ -23,12 +23,10 @@ import org.apache.tomcat.util.digester.Rule;
/**
- * 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.
+ * 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>
- * This rule now supports more flexible method matching by default.
- * It is possible that this may break (some) code
+ * 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.
*/
@@ -42,13 +40,11 @@ public class SetNextNamingRule extends Rule {
* 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 corresponding
- * Java wrapper class instead, such as <code>java.lang.Boolean</code>
- * for a <code>boolean</code> parameter)
+ * @param paramType Java class of the parent method's argument (if you wish to use a primitive type, specify the
+ * corresponding Java wrapper class instead, such as <code>java.lang.Boolean</code> for a
+ * <code>boolean</code> parameter)
*/
- public SetNextNamingRule(String methodName,
- String paramType) {
+ public SetNextNamingRule(String methodName, String paramType) {
this.methodName = methodName;
this.paramType = paramType;
@@ -77,11 +73,9 @@ public class SetNextNamingRule extends Rule {
/**
* Process the end of this element.
*
- * @param namespace the namespace URI of the matching element, or an
- * empty string if the parser is not namespace aware or the element has
- * no namespace
- * @param name the local name if the parser is namespace aware, or just
- * the element name otherwise
+ * @param namespace the namespace URI of the matching element, or an empty string if the parser is not namespace
+ * aware or the element has no namespace
+ * @param name the local name if the parser is namespace aware, or just the element name otherwise
*/
@Override
public void end(String namespace, String name) throws Exception {
@@ -100,8 +94,7 @@ public class SetNextNamingRule extends Rule {
}
// Call the specified method
- IntrospectionUtils.callMethod1(namingResources, methodName,
- child, paramType, digester.getClassLoader());
+ IntrospectionUtils.callMethod1(namingResources, methodName, child, paramType, digester.getClassLoader());
StringBuilder code = digester.getGeneratedCode();
if (code != null) {
diff --git a/java/org/apache/catalina/startup/Tomcat.java b/java/org/apache/catalina/startup/Tomcat.java
index d39bb8d928..0932474c24 100644
--- a/java/org/apache/catalina/startup/Tomcat.java
+++ b/java/org/apache/catalina/startup/Tomcat.java
@@ -87,72 +87,51 @@ import org.apache.tomcat.util.res.StringManager;
/**
* Minimal tomcat starter for embedding/unit tests.
- *
* <p>
- * Tomcat supports multiple styles of configuration and
- * startup - the most common and stable is server.xml-based,
+ * Tomcat supports multiple styles of configuration and startup - the most common and stable is server.xml-based,
* implemented in org.apache.catalina.startup.Bootstrap.
- *
* <p>
* This class is for use in apps that embed tomcat.
- *
* <p>
* Requirements:
* <ul>
- * <li>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)</li>
- *
- * <li>we need one temporary directory for work files</li>
- *
- * <li>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.</li>
+ * <li>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)</li>
+ * <li>we need one temporary directory for work files</li>
+ * <li>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.</li>
* </ul>
- *
* <p>
- * There are a variety of 'add' methods to configure servlets and webapps. These
- * methods, by default, create a simple in-memory security realm and apply it.
- * If you need more complex security processing, you can define a subclass of
+ * There are a variety of 'add' methods to configure servlets and webapps. These methods, by default, create a simple
+ * in-memory security realm and apply it. If you need more complex security processing, you can define a subclass of
* this class.
- *
* <p>
- * This class provides a set of convenience methods for configuring web
- * application contexts; all overloads of the method <code>addWebapp()</code>.
- * These methods are equivalent to adding a web application to the Host's
- * appBase (normally the webapps directory). These methods create a Context,
- * configure it with the equivalent of the defaults provided by
- * <code>conf/web.xml</code> (see {@link #initWebappDefaults(String)} for
- * details) and add the Context to a Host. These methods do not use a global
- * default web.xml; rather, they add a {@link LifecycleListener} to configure
- * the defaults. Any WEB-INF/web.xml and META-INF/context.xml packaged with the
- * application will be processed normally. Normal web fragment and
- * {@link jakarta.servlet.ServletContainerInitializer} processing will be applied.
- *
+ * This class provides a set of convenience methods for configuring web application contexts; all overloads of the
+ * method <code>addWebapp()</code>. These methods are equivalent to adding a web application to the Host's appBase
+ * (normally the webapps directory). These methods create a Context, configure it with the equivalent of the defaults
+ * provided by <code>conf/web.xml</code> (see {@link #initWebappDefaults(String)} for details) and add the Context to a
+ * Host. These methods do not use a global default web.xml; rather, they add a {@link LifecycleListener} to configure
+ * the defaults. Any WEB-INF/web.xml and META-INF/context.xml packaged with the application will be processed normally.
+ * Normal web fragment and {@link jakarta.servlet.ServletContainerInitializer} processing will be applied.
* <p>
- * In complex cases, you may prefer to use the ordinary Tomcat API to create
- * webapp contexts; for example, you might need to install a custom Loader
- * before the call to {@link Host#addChild(Container)}. To replicate the basic
- * behavior of the <code>addWebapp</code> methods, you may want to call two
- * methods of this class: {@link #noDefaultWebXmlPath()} and
- * {@link #getDefaultWebXmlListener()}.
- *
+ * In complex cases, you may prefer to use the ordinary Tomcat API to create webapp contexts; for example, you might
+ * need to install a custom Loader before the call to {@link Host#addChild(Container)}. To replicate the basic behavior
+ * of the <code>addWebapp</code> methods, you may want to call two methods of this class: {@link #noDefaultWebXmlPath()}
+ * and {@link #getDefaultWebXmlListener()}.
* <p>
- * {@link #getDefaultWebXmlListener()} returns a {@link LifecycleListener} that
- * adds the standard DefaultServlet, JSP processing, and welcome files. If you
- * add this listener, you must prevent Tomcat from applying any standard global
+ * {@link #getDefaultWebXmlListener()} returns a {@link LifecycleListener} that adds the standard DefaultServlet, JSP
+ * processing, and welcome files. If you add this listener, you must prevent Tomcat from applying any standard global
* web.xml with ...
- *
* <p>
- * {@link #noDefaultWebXmlPath()} returns a dummy pathname to configure to
- * prevent {@link ContextConfig} from trying to apply a global web.xml file.
- *
+ * {@link #noDefaultWebXmlPath()} returns a dummy pathname to configure to prevent {@link ContextConfig} from trying to
+ * apply a global web.xml file.
* <p>
- * This class provides a main() and few simple CLI arguments,
- * see setters for doc. It can be used for simple tests and
+ * This class provides a main() and few simple CLI arguments, see setters for doc. It can be used for simple tests and
* demo.
*
- * @see <a href="https://gitbox.apache.org/repos/asf?p=tomcat.git;a=blob;f=test/org/apache/catalina/startup/TestTomcat.java">TestTomcat</a>
+ * @see <a href=
+ * "https://gitbox.apache.org/repos/asf?p=tomcat.git;a=blob;f=test/org/apache/catalina/startup/TestTomcat.java">TestTomcat</a>
+ *
* @author Costin Manolache
*/
public class Tomcat {
@@ -164,7 +143,7 @@ public class Tomcat {
// after Loggers are configured but before they are used. The purpose of
// this Map is to retain strong references to explicitly configured loggers
// so that configuration is not lost.
- private final Map<String, Logger> pinnedLoggers = new HashMap<>();
+ private final Map<String,Logger> pinnedLoggers = new HashMap<>();
protected Server server;
@@ -172,9 +151,9 @@ public class Tomcat {
protected String hostname = "localhost";
protected String basedir;
- private final Map<String, String> userPass = new HashMap<>();
- private final Map<String, List<String>> userRoles = new HashMap<>();
- private final Map<String, Principal> userPrincipals = new HashMap<>();
+ private final Map<String,String> userPass = new HashMap<>();
+ private final Map<String,List<String>> userRoles = new HashMap<>();
+ private final Map<String,Principal> userPrincipals = new HashMap<>();
private boolean addDefaultWebXmlToWebapp = true;
@@ -183,22 +162,17 @@ public class Tomcat {
}
/**
- * Tomcat requires that the base directory is set because the defaults for
- * a number of other locations, such as the work directory, are derived from
- * the base directory. This should be the first method called.
+ * Tomcat requires that the base directory is set because the defaults for a number of other locations, such as the
+ * work directory, are derived from the base directory. This should be the first method called.
* <p>
- * If this method is not called then Tomcat will attempt to use these
- * locations in the following order:
+ * If this method is not called then Tomcat will attempt to use these locations in the following order:
* <ol>
- * <li>if set, the catalina.base system property</li>
- * <li>if set, the catalina.home system property</li>
- * <li>The user.dir system property (the directory where Java was run from)
- * where a directory named tomcat.$PORT will be created. $PORT is the
- * value configured via {@link #setPort(int)} which defaults to 8080 if
- * not set</li>
+ * <li>if set, the catalina.base system property</li>
+ * <li>if set, the catalina.home system property</li>
+ * <li>The user.dir system property (the directory where Java was run from) where a directory named tomcat.$PORT
+ * will be created. $PORT is the value configured via {@link #setPort(int)} which defaults to 8080 if not set</li>
* </ol>
- * The user should ensure that the file permissions for the base directory
- * are appropriate.
+ * The user should ensure that the file permissions for the base directory are appropriate.
* <p>
* TODO: disable work dir if not needed ( no jsp, etc ).
*
@@ -209,8 +183,8 @@ public class Tomcat {
}
/**
- * Set the port for the default connector. The default connector will
- * only be created if getConnector is called.
+ * Set the port for the default connector. The default connector will only be created if getConnector is called.
+ *
* @param port The port number
*/
public void setPort(int port) {
@@ -218,8 +192,8 @@ public class Tomcat {
}
/**
- * The the hostname of the default host, default is
- * 'localhost'.
+ * The the hostname of the default host, default is 'localhost'.
+ *
* @param s The default host name
*/
public void setHostname(String s) {
@@ -228,19 +202,15 @@ public class Tomcat {
/**
- * This is equivalent to adding a web application to a Host's appBase
- * (usually Tomcat's webapps directory). By default, the equivalent of the
- * default web.xml will be applied to the web application (see
+ * This is equivalent to adding a web application to a Host's appBase (usually Tomcat's webapps directory). By
+ * default, the equivalent of the default web.xml will be applied to the web application (see
* {@link #initWebappDefaults(String)}). This may be prevented by calling
- * {@link #setAddDefaultWebXmlToWebapp(boolean)} with {@code false}. Any
- * <code>WEB-INF/web.xml</code> and <code>META-INF/context.xml</code>
- * packaged with the application will always be processed and normal web
- * fragment and {@link jakarta.servlet.ServletContainerInitializer}
- * processing will always be applied.
+ * {@link #setAddDefaultWebXmlToWebapp(boolean)} with {@code false}. Any <code>WEB-INF/web.xml</code> and
+ * <code>META-INF/context.xml</code> packaged with the application will always be processed and normal web fragment
+ * and {@link jakarta.servlet.ServletContainerInitializer} processing will always be applied.
*
* @param contextPath The context mapping to use, "" for root context.
- * @param docBase Base directory for the context, for static files. Must
- * exist and be an absolute path.
+ * @param docBase Base directory for the context, for static files. Must exist and be an absolute path.
*
* @return the deployed context
*/
@@ -250,19 +220,17 @@ public class Tomcat {
/**
- * Copy the specified WAR file to the Host's appBase and then call
- * {@link #addWebapp(String, String)} with the newly copied WAR. The WAR
- * will <b>NOT</b> be removed from the Host's appBase when the Tomcat
- * instance stops. Note that {@link ExpandWar} provides utility methods that
- * may be used to delete the WAR and/or expanded directory if required.
+ * Copy the specified WAR file to the Host's appBase and then call {@link #addWebapp(String, String)} with the newly
+ * copied WAR. The WAR will <b>NOT</b> be removed from the Host's appBase when the Tomcat instance stops. Note that
+ * {@link ExpandWar} provides utility methods that may be used to delete the WAR and/or expanded directory if
+ * required.
*
- * @param contextPath The context mapping to use, "" for root context.
- * @param source The location from which the WAR should be copied
+ * @param contextPath The context mapping to use, "" for root context.
+ * @param source The location from which the WAR should be copied
*
* @return The deployed Context
*
- * @throws IOException If an I/O error occurs while copying the WAR file
- * from the specified URL to the appBase
+ * @throws IOException If an I/O error occurs while copying the WAR file from the specified URL to the appBase
*/
public Context addWebapp(String contextPath, URL source) throws IOException {
@@ -271,8 +239,8 @@ public class Tomcat {
// Make sure a conflicting web application has not already been deployed
Host h = getHost();
if (h.findChild(cn.getName()) != null) {
- throw new IllegalArgumentException(sm.getString("tomcat.addWebapp.conflictChild",
- source, contextPath, cn.getName()));
+ throw new IllegalArgumentException(
+ sm.getString("tomcat.addWebapp.conflictChild", source, contextPath, cn.getName()));
}
// Make sure appBase does not contain a conflicting web application
@@ -280,19 +248,18 @@ public class Tomcat {
File targetDir = new File(h.getAppBaseFile(), cn.getBaseName());
if (targetWar.exists()) {
- throw new IllegalArgumentException(sm.getString("tomcat.addWebapp.conflictFile",
- source, contextPath, targetWar.getAbsolutePath()));
+ throw new IllegalArgumentException(
+ sm.getString("tomcat.addWebapp.conflictFile", source, contextPath, targetWar.getAbsolutePath()));
}
if (targetDir.exists()) {
- throw new IllegalArgumentException(sm.getString("tomcat.addWebapp.conflictFile",
- source, contextPath, targetDir.getAbsolutePath()));
+ throw new IllegalArgumentException(
+ sm.getString("tomcat.addWebapp.conflictFile", source, contextPath, targetDir.getAbsolutePath()));
}
// Should be good to copy the WAR now
URLConnection uConn = source.openConnection();
- try (InputStream is = uConn.getInputStream();
- OutputStream os = new FileOutputStream(targetWar)) {
+ try (InputStream is = uConn.getInputStream(); OutputStream os = new FileOutputStream(targetWar)) {
IOTools.flow(is, os);
}
@@ -301,45 +268,36 @@ public class Tomcat {
/**
- * Add a context - programmatic mode, no default web.xml used. This means
- * that there is no JSP support (no JSP servlet), no default servlet and
- * no web socket support unless explicitly enabled via the programmatic
- * interface. There is also no
- * {@link jakarta.servlet.ServletContainerInitializer} processing and no
- * annotation processing. If a
- * {@link jakarta.servlet.ServletContainerInitializer} is added
- * programmatically, there will still be no scanning for
- * {@link jakarta.servlet.annotation.HandlesTypes} matches.
- *
+ * Add a context - programmatic mode, no default web.xml used. This means that there is no JSP support (no JSP
+ * servlet), no default servlet and no web socket support unless explicitly enabled via the programmatic interface.
+ * There is also no {@link jakarta.servlet.ServletContainerInitializer} processing and no annotation processing. If
+ * a {@link jakarta.servlet.ServletContainerInitializer} is added programmatically, there will still be no scanning
+ * for {@link jakarta.servlet.annotation.HandlesTypes} matches.
* <p>
* API calls equivalent with web.xml:
*
* <pre>{@code
- * // context-param
- * ctx.addParameter("name", "value");
+ * // context-param
+ * ctx.addParameter("name", "value");
*
*
- * // error-page
- * ErrorPage ep = new ErrorPage();
- * ep.setErrorCode(500);
- * ep.setLocation("/error.html");
- * ctx.addErrorPage(ep);
+ * // error-page
+ * ErrorPage ep = new ErrorPage();
+ * ep.setErrorCode(500);
+ * ep.setLocation("/error.html");
+ * ctx.addErrorPage(ep);
*
- * ctx.addMimeMapping("ext", "type");
+ * ctx.addMimeMapping("ext", "type");
* }</pre>
- *
- *
* <p>
- * 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.
- *
+ * 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.
* <p>
* TODO: add the rest
*
* @param contextPath The context mapping to use, "" for root context.
- * @param docBase Base directory for the context, for static files.
- * Must exist, relative to the server home
+ * @param docBase Base directory for the context, for static files. Must exist, relative to the server home
+ *
* @return the deployed context
*/
public Context addContext(String contextPath, String docBase) {
@@ -348,40 +306,36 @@ public class Tomcat {
/**
* Equivalent to <servlet><servlet-name><servlet-class>.
- *
* <p>
- * 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 )
+ * 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:
+ *
+ * <pre>
+ * wrapper.addInitParameter("name", "value");
+ * </pre>
*
- * You can customize the returned servlet, ex:
- * <pre>
- * wrapper.addInitParameter("name", "value");
- * </pre>
+ * @param contextPath Context to add Servlet to
+ * @param servletName Servlet name (used in mappings)
+ * @param servletClass The class to be used for the Servlet
*
- * @param contextPath Context to add Servlet to
- * @param servletName Servlet name (used in mappings)
- * @param servletClass The class to be used for the Servlet
* @return The wrapper for the servlet
*/
- public Wrapper addServlet(String contextPath,
- String servletName,
- String servletClass) {
+ public Wrapper addServlet(String contextPath, String servletName, String servletClass) {
Container ctx = getHost().findChild(contextPath);
return addServlet((Context) ctx, servletName, servletClass);
}
/**
* Static version of {@link #addServlet(String, String, String)}
- * @param ctx Context to add Servlet to
- * @param servletName Servlet name (used in mappings)
- * @param servletClass The class to be used for the Servlet
+ *
+ * @param ctx Context to add Servlet to
+ * @param servletName Servlet name (used in mappings)
+ * @param servletClass The class to be used for the Servlet
+ *
* @return The wrapper for the servlet
*/
- public static Wrapper addServlet(Context ctx,
- String servletName,
- String servletClass) {
+ public static Wrapper addServlet(Context ctx, String servletName, String servletClass) {
// will do class for name and set init params
Wrapper sw = ctx.createWrapper();
if (sw == null) {
@@ -395,30 +349,29 @@ public class Tomcat {
}
/**
- * Add an existing Servlet to the context with no class.forName or
- * initialisation.
- * @param contextPath Context to add Servlet to
- * @param servletName Servlet name (used in mappings)
- * @param servlet The Servlet to add
+ * Add an existing Servlet to the context with no class.forName or initialisation.
+ *
+ * @param contextPath Context to add Servlet to
+ * @param servletName Servlet name (used in mappings)
+ * @param servlet The Servlet to add
+ *
* @return The wrapper for the servlet
*/
- public Wrapper addServlet(String contextPath,
- String servletName,
- Servlet servlet) {
+ public Wrapper addServlet(String contextPath, String servletName, Servlet servlet) {
Container ctx = getHost().findChild(contextPath);
return addServlet((Context) ctx, servletName, servlet);
}
/**
* Static version of {@link #addServlet(String, String, Servlet)}.
- * @param ctx Context to add Servlet to
- * @param servletName Servlet name (used in mappings)
- * @param servlet The Servlet to add
+ *
+ * @param ctx Context to add Servlet to
+ * @param servletName Servlet name (used in mappings)
+ * @param servlet The Servlet to add
+ *
* @return The wrapper for the servlet
*/
- public static Wrapper addServlet(Context ctx,
- String servletName,
- Servlet servlet) {
+ public static Wrapper addServlet(Context ctx, String servletName, Servlet servlet) {
// will do class for name and set init params
Wrapper sw = new ExistingStandardWrapper(servlet);
sw.setName(servletName);
@@ -429,12 +382,10 @@ public class Tomcat {
/**
- * Initialize the server given the specified configuration source.
- * The server will be loaded according to the Tomcat configuration
- * files contained in the source (server.xml, web.xml, context.xml,
- * SSL certificates, etc).
- * If no configuration source is specified, it will use the default
- * locations for these files.
+ * Initialize the server given the specified configuration source. The server will be loaded according to the Tomcat
+ * configuration files contained in the source (server.xml, web.xml, context.xml, SSL certificates, etc). If no
+ * configuration source is specified, it will use the default locations for these files.
+ *
* @param source The configuration source
*/
public void init(ConfigurationSource source) {
@@ -442,13 +393,11 @@ public class Tomcat {
}
/**
- * Initialize the server given the specified configuration source.
- * The server will be loaded according to the Tomcat configuration
- * files contained in the source (server.xml, web.xml, context.xml,
- * SSL certificates, etc).
- * If no configuration source is specified, it will use the default
- * locations for these files.
- * @param source The configuration source
+ * Initialize the server given the specified configuration source. The server will be loaded according to the Tomcat
+ * configuration files contained in the source (server.xml, web.xml, context.xml, SSL certificates, etc). If no
+ * configuration source is specified, it will use the default locations for these files.
+ *
+ * @param source The configuration source
* @param catalinaArguments The arguments that should be passed to Catalina
*/
public void init(ConfigurationSource source, String[] catalinaArguments) {
@@ -500,8 +449,7 @@ public class Tomcat {
/**
- * Destroy the server. This object cannot be used once this method has been
- * called.
+ * Destroy the server. This object cannot be used once this method has been called.
*
* @throws LifecycleException Destroy error
*/
@@ -512,8 +460,8 @@ public class Tomcat {
}
/**
- * Add a user for the in-memory realm. All created apps use this
- * by default, can be replaced using setRealm().
+ * Add a user for the in-memory realm. All created apps use this by default, can be replaced using setRealm().
+ *
* @param user The user name
* @param pass The password
*/
@@ -523,7 +471,9 @@ public class Tomcat {
/**
* Add a role to a user.
+ *
* @see #addUser(String, String)
+ *
* @param user The user name
* @param role The role name
*/
@@ -535,11 +485,9 @@ public class Tomcat {
// You can tune individual Tomcat objects, using internal APIs
/**
- * Get the default HTTP connector that is used by the embedded
- * Tomcat. It is first configured connector in the service.
- * If there's no connector defined, it will create and add a default
- * connector using the port and address specified in this Tomcat
- * instance, and return it for further customization.
+ * Get the default HTTP connector that is used by the embedded Tomcat. It is first configured connector in the
+ * service. If there's no connector defined, it will create and add a default connector using the port and address
+ * specified in this Tomcat instance, and return it for further customization.
*
* @return The connector object
*/
@@ -557,8 +505,8 @@ public class Tomcat {
}
/**
- * Set the specified connector in the service, if it is not already
- * present.
+ * Set the specified connector in the service, if it is not already present.
+ *
* @param connector The connector instance to add
*/
public void setConnector(Connector connector) {
@@ -576,8 +524,8 @@ public class Tomcat {
}
/**
- * Get the service object. Can be used to add more
- * connectors and few other global settings.
+ * Get the service object. Can be used to add more connectors and few other global settings.
+ *
* @return The service
*/
public Service getService() {
@@ -585,9 +533,8 @@ public class Tomcat {
}
/**
- * Sets the current host - all future webapps will
- * be added to this host. When tomcat starts, the
- * host will be the default host.
+ * 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 The current host
*/
@@ -619,6 +566,7 @@ public class Tomcat {
/**
* Access to the engine, for further customization.
+ *
* @return The engine
*/
public Engine getEngine() {
@@ -627,7 +575,7 @@ public class Tomcat {
return service.getContainer();
}
Engine engine = new StandardEngine();
- engine.setName( "Tomcat" );
+ engine.setName("Tomcat");
engine.setDefaultHost(hostname);
engine.setRealm(createDefaultRealm());
service.setContainer(engine);
@@ -635,8 +583,8 @@ public class Tomcat {
}
/**
- * Get the server object. You can add listeners and few more
- * customizations. JNDI is disabled by default.
+ * Get the server object. You can add listeners and few more customizations. JNDI is disabled by default.
+ *
* @return The Server
*/
public Server getServer() {
@@ -654,7 +602,7 @@ public class Tomcat {
// Set configuration source
ConfigFileLoader.setSource(new CatalinaBaseConfigurationSource(new File(basedir), null));
- server.setPort( -1 );
+ server.setPort(-1);
Service service = new StandardService();
service.setName("Tomcat");
@@ -663,11 +611,12 @@ public class Tomcat {
}
/**
- * @param host The host in which the context will be deployed
+ * @param host The host in which the context will be deployed
* @param contextPath The context mapping to use, "" for root context.
- * @param dir Base directory for the context, for static files.
- * Must exist, relative to the server home
+ * @param dir Base directory for the context, for static files. Must exist, relative to the server home
+ *
* @return the deployed context
+ *
* @see #addContext(String, String)
*/
public Context addContext(Host host, String contextPath, String dir) {
@@ -675,16 +624,16 @@ public class Tomcat {
}
/**
- * @param host The host in which the context will be deployed
+ * @param host The host in which the context will be deployed
* @param contextPath The context mapping to use, "" for root context.
* @param contextName The context name
- * @param dir Base directory for the context, for static files.
- * Must exist, relative to the server home
+ * @param dir Base directory for the context, for static files. Must exist, relative to the server home
+ *
* @return the deployed context
+ *
* @see #addContext(String, String)
*/
- public Context addContext(Host host, String contextPath, String contextName,
- String dir) {
+ public Context addContext(Host host, String contextPath, String contextName, String dir) {
silence(host, contextName);
Context ctx = createContext(host, contextPath);
ctx.setName(contextName);
@@ -702,20 +651,16 @@ public class Tomcat {
/**
- * This is equivalent to adding a web application to a Host's appBase
- * (usually Tomcat's webapps directory). By default, the equivalent of the
- * default web.xml will be applied to the web application (see
+ * This is equivalent to adding a web application to a Host's appBase (usually Tomcat's webapps directory). By
+ * default, the equivalent of the default web.xml will be applied to the web application (see
* {@link #initWebappDefaults(String)}). This may be prevented by calling
- * {@link #setAddDefaultWebXmlToWebapp(boolean)} with {@code false}. Any
- * <code>WEB-INF/web.xml</code> and <code>META-INF/context.xml</code>
- * packaged with the application will always be processed and normal web
- * fragment and {@link jakarta.servlet.ServletContainerInitializer} processing
- * will always be applied.
+ * {@link #setAddDefaultWebXmlToWebapp(boolean)} with {@code false}. Any <code>WEB-INF/web.xml</code> and
+ * <code>META-INF/context.xml</code> packaged with the application will always be processed and normal web fragment
+ * and {@link jakarta.servlet.ServletContainerInitializer} processing will always be applied.
*
* @param host The host in which the context will be deployed
* @param contextPath The context mapping to use, "" for root context.
- * @param docBase Base directory for the context, for static files. Must
- * exist and be an absolute path.
+ * @param docBase Base directory for the context, for static files. Must exist and be an absolute path.
*
* @return the deployed context
*/
@@ -735,28 +680,22 @@ public class Tomcat {
/**
- * This is equivalent to adding a web application to a Host's appBase
- * (usually Tomcat's webapps directory). By default, the equivalent of the
- * default web.xml will be applied to the web application (see
+ * This is equivalent to adding a web application to a Host's appBase (usually Tomcat's webapps directory). By
+ * default, the equivalent of the default web.xml will be applied to the web application (see
* {@link #initWebappDefaults(String)}). This may be prevented by calling
- * {@link #setAddDefaultWebXmlToWebapp(boolean)} with {@code false}. Any
- * <code>WEB-INF/web.xml</code> and <code>META-INF/context.xml</code>
- * packaged with the application will always be processed and normal web
- * fragment and {@link jakarta.servlet.ServletContainerInitializer} processing
- * will always be applied.
+ * {@link #setAddDefaultWebXmlToWebapp(boolean)} with {@code false}. Any <code>WEB-INF/web.xml</code> and
+ * <code>META-INF/context.xml</code> packaged with the application will always be processed and normal web fragment
+ * and {@link jakarta.servlet.ServletContainerInitializer} processing will always be applied.
*
* @param host The host in which the context will be deployed
* @param contextPath The context mapping to use, "" for root context.
- * @param docBase Base directory for the context, for static files. Must
- * exist and be an absolute path.
- * @param config Custom context configuration helper. Any configuration
- * will be in addition to equivalent of the default
- * web.xml configuration described above.
+ * @param docBase Base directory for the context, for static files. Must exist and be an absolute path.
+ * @param config Custom context configuration helper. Any configuration will be in addition to equivalent of
+ * the default web.xml configuration described above.
*
* @return the deployed context
*/
- public Context addWebapp(Host host, String contextPath, String docBase,
- LifecycleListener config) {
+ public Context addWebapp(Host host, String contextPath, String docBase, LifecycleListener config) {
silence(host, contextPath);
@@ -787,11 +726,10 @@ public class Tomcat {
}
/**
- * Return a listener that provides the required configuration items for JSP
- * processing. From the standard Tomcat global web.xml. Pass this to
- * {@link Context#addLifecycleListener(LifecycleListener)} and then pass the
- * result of {@link #noDefaultWebXmlPath()} to
- * {@link ContextConfig#setDefaultWebXml(String)}.
+ * Return a listener that provides the required configuration items for JSP processing. From the standard Tomcat
+ * global web.xml. Pass this to {@link Context#addLifecycleListener(LifecycleListener)} and then pass the result of
+ * {@link #noDefaultWebXmlPath()} to {@link ContextConfig#setDefaultWebXml(String)}.
+ *
* @return a listener object that configures default JSP processing.
*/
public LifecycleListener getDefaultWebXmlListener() {
@@ -799,9 +737,8 @@ public class Tomcat {
}
/**
- * @return a pathname to pass to
- * {@link ContextConfig#setDefaultWebXml(String)} when using
- * {@link #getDefaultWebXmlListener()}.
+ * @return a pathname to pass to {@link ContextConfig#setDefaultWebXml(String)} when using
+ * {@link #getDefaultWebXmlListener()}.
*/
public String noDefaultWebXmlPath() {
return Constants.NoDefaultWebXml;
@@ -810,10 +747,10 @@ public class Tomcat {
// ---------- Helper methods and classes -------------------
/**
- * Create an in-memory realm. You can replace it for contexts with a real
- * one. The Realm created here will be added to the Engine by default and
- * may be replaced at the Engine level or over-ridden (as per normal Tomcat
- * behaviour) at the Host or Context level.
+ * Create an in-memory realm. You can replace it for contexts with a real one. The Realm created here will be added
+ * to the Engine by default and may be replaced at the Engine level or over-ridden (as per normal Tomcat behaviour)
+ * at the Host or Context level.
+ *
* @return a realm instance
*/
protected Realm createDefaultRealm() {
@@ -834,8 +771,7 @@ public class Tomcat {
if (p == null) {
String pass = userPass.get(username);
if (pass != null) {
- p = new GenericPrincipal(username,
- userRoles.get(username));
+ p = new GenericPrincipal(username, userRoles.get(username));
userPrincipals.put(username, p);
}
}
@@ -868,11 +804,9 @@ public class Tomcat {
throw new IllegalStateException(sm.getString("tomcat.baseDirMakeFail", baseFile));
}
/*
- * If file permissions were going to be set on the newly created
- * directory, this is the place to do it. However, even simple
- * calls such as File.setReadable(boolean,boolean) behaves
- * differently on different platforms. Therefore, setBaseDir
- * documents that the user needs to do this.
+ * If file permissions were going to be set on the newly created directory, this is the place to do it.
+ * However, even simple calls such as File.setReadable(boolean,boolean) behaves differently on different
+ * platforms. Therefore, setBaseDir documents that the user needs to do this.
*/
}
try {
@@ -899,28 +833,22 @@ public class Tomcat {
}
server.setCatalinaHome(homeFile);
}
- System.setProperty(Globals.CATALINA_HOME_PROP,
- server.getCatalinaHome().getPath());
+ System.setProperty(Globals.CATALINA_HOME_PROP, server.getCatalinaHome().getPath());
}
- static final String[] silences = new String[] {
- "org.apache.coyote.http11.Http11NioProtocol",
- "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"
- };
+ static final String[] silences =
+ new String[] { "org.apache.coyote.http11.Http11NioProtocol", "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" };
private boolean silent = false;
/**
* Controls if the loggers will be silenced or not.
- * @param silent <code>true</code> sets the log level to WARN for the
- * loggers that log information on Tomcat start up. This
- * prevents the usual startup information being logged.
- * <code>false</code> sets the log level to the default
- * level of INFO.
+ *
+ * @param silent <code>true</code> sets the log level to WARN for the loggers that log information on Tomcat start
+ * up. This prevents the usual startup information being logged. <code>false</code> sets the log
+ * level to the default level of INFO.
*/
public void setSilent(boolean silent) {
this.silent = silent;
@@ -948,19 +876,18 @@ public class Tomcat {
/**
- * By default, when calling addWebapp() to create a Context, the settings from
- * from the default web.xml are added to the context. Calling this method with
- * a <code>false</code> value prior to calling addWebapp() allows to opt out of
- * the default settings. In that event you will need to add the configurations
- * yourself, either programmatically or by using web.xml deployment descriptors.
- * @param addDefaultWebXmlToWebapp <code>false</code> will prevent the class from
- * automatically adding the default settings when
- * calling addWebapp().
- * <code>true</code> will add the default settings
- * and is the default behavior.
+ * By default, when calling addWebapp() to create a Context, the settings from from the default web.xml are added to
+ * the context. Calling this method with a <code>false</code> value prior to calling addWebapp() allows to opt out
+ * of the default settings. In that event you will need to add the configurations yourself, either programmatically
+ * or by using web.xml deployment descriptors.
+ *
+ * @param addDefaultWebXmlToWebapp <code>false</code> will prevent the class from automatically adding the default
+ * settings when calling addWebapp(). <code>true</code> will add the default
+ * settings and is the default behavior.
+ *
* @see #addWebapp(Host, String, String, LifecycleListener)
*/
- public void setAddDefaultWebXmlToWebapp(boolean addDefaultWebXmlToWebapp){
+ public void setAddDefaultWebXmlToWebapp(boolean addDefaultWebXmlToWebapp) {
this.addDefaultWebXmlToWebapp = addDefaultWebXmlToWebapp;
}
@@ -994,15 +921,13 @@ public class Tomcat {
}
/**
- * Create the configured {@link Context} for the given <code>host</code>.
- * The default constructor of the class that was configured with
- * {@link StandardHost#setContextClass(String)} will be used
+ * Create the configured {@link Context} for the given <code>host</code>. The default constructor of the class that
+ * was configured with {@link StandardHost#setContextClass(String)} will be used
+ *
+ * @param host host for which the {@link Context} should be created, or <code>null</code> if default host should be
+ * used
+ * @param url path of the webapp which should get the {@link Context}
*
- * @param host
- * host for which the {@link Context} should be created, or
- * <code>null</code> if default host should be used
- * @param url
- * path of the webapp which should get the {@link Context}
* @return newly created {@link Context}
*/
private Context createContext(Host host, String url) {
@@ -1018,20 +943,17 @@ public class Tomcat {
if (defaultContextClass.equals(contextClass)) {
return new StandardContext();
} else {
- return (Context) Class.forName(contextClass).getConstructor()
- .newInstance();
+ return (Context) Class.forName(contextClass).getConstructor().newInstance();
}
- } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) {
+ } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) {
throw new IllegalArgumentException(sm.getString("tomcat.noContextClass", contextClass, host, url), e);
}
}
/**
- * Enables JNDI naming which is disabled by default. Server must implement
- * {@link Lifecycle} in order for the {@link NamingContextListener} to be
- * used.
- *
+ * Enables JNDI naming which is disabled by default. Server must implement {@link Lifecycle} in order for the
+ * {@link NamingContextListener} to be used.
*/
public void enableNaming() {
// Make sure getServer() has been called as that is where naming is
@@ -1042,8 +964,7 @@ public class Tomcat {
System.setProperty("catalina.useNaming", "true");
String value = "org.apache.naming";
- String oldValue =
- System.getProperty(javax.naming.Context.URL_PKG_PREFIXES);
+ String oldValue = System.getProperty(javax.naming.Context.URL_PKG_PREFIXES);
if (oldValue != null) {
if (oldValue.contains(value)) {
value = oldValue;
@@ -1053,20 +974,17 @@ public class Tomcat {
}
System.setProperty(javax.naming.Context.URL_PKG_PREFIXES, value);
- value = System.getProperty
- (javax.naming.Context.INITIAL_CONTEXT_FACTORY);
+ 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");
+ System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
+ "org.apache.naming.java.javaURLContextFactory");
}
}
/**
- * Provide default configuration for a context. This is broadly the
- * programmatic equivalent of the default web.xml and provides the following
- * features:
+ * Provide default configuration for a context. This is broadly the programmatic equivalent of the default web.xml
+ * and provides the following features:
* <ul>
* <li>Default servlet mapped to "/"</li>
* <li>JSP servlet mapped to "*.jsp" and ""*.jspx"</li>
@@ -1074,10 +992,9 @@ public class Tomcat {
* <li>MIME mappings (subset of those in conf/web.xml)</li>
* <li>Welcome files</li>
* </ul>
- * TODO: Align the MIME mappings with conf/web.xml - possibly via a common
- * file.
+ * TODO: Align the MIME mappings with conf/web.xml - possibly via a common file.
*
- * @param contextPath The path of the context to set the defaults for
+ * @param contextPath The path of the context to set the defaults for
*/
public void initWebappDefaults(String contextPath) {
Container ctx = getHost().findChild(contextPath);
@@ -1088,18 +1005,16 @@ public class Tomcat {
/**
* Static version of {@link #initWebappDefaults(String)}.
*
- * @param ctx The context to set the defaults for
+ * @param ctx The context to set the defaults for
*/
public static void initWebappDefaults(Context ctx) {
// Default servlet
- Wrapper servlet = addServlet(
- ctx, "default", "org.apache.catalina.servlets.DefaultServlet");
+ Wrapper servlet = addServlet(ctx, "default", "org.apache.catalina.servlets.DefaultServlet");
servlet.setLoadOnStartup(1);
servlet.setOverridable(true);
// JSP servlet (by class name - to avoid loading all deps)
- servlet = addServlet(
- ctx, "jsp", "org.apache.jasper.servlet.JspServlet");
+ servlet = addServlet(ctx, "jsp", "org.apache.jasper.servlet.JspServlet");
servlet.addInitParameter("fork", "false");
servlet.setLoadOnStartup(3);
servlet.setOverridable(true);
@@ -1125,14 +1040,13 @@ public class Tomcat {
/**
* Add the default MIME type mappings to the provide Context.
*
- * @param context The web application to which the default MIME type
- * mappings should be added.
+ * @param context The web application to which the default MIME type mappings should be added.
*/
public static void addDefaultMimeTypeMappings(Context context) {
Properties defaultMimeMappings = new Properties();
try (InputStream is = Tomcat.class.getResourceAsStream("MimeTypeMappings.properties")) {
defaultMimeMappings.load(is);
- for (Map.Entry<Object, Object> entry: defaultMimeMappings.entrySet()) {
+ for (Map.Entry<Object,Object> entry : defaultMimeMappings.entrySet()) {
context.addMimeMapping((String) entry.getKey(), (String) entry.getValue());
}
} catch (IOException e) {
@@ -1143,10 +1057,8 @@ public class Tomcat {
/**
* Fix startup sequence - required if you don't use web.xml.
- *
* <p>
- * The start() method in context will set 'configured' to false - and
- * expects a listener to set it back to true.
+ * 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 {
@@ -1174,9 +1086,8 @@ public class Tomcat {
/**
- * 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.
+ * 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.
*/
public static class DefaultWebXmlListener implements LifecycleListener {
@Override
@@ -1189,14 +1100,13 @@ public class Tomcat {
/**
- * 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.
+ * 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 final Servlet existing;
- public ExistingStandardWrapper( Servlet existing ) {
+ public ExistingStandardWrapper(Servlet existing) {
this.existing = existing;
this.asyncSupported = hasAsync(existing);
}
@@ -1219,18 +1129,22 @@ public class Tomcat {
}
return existing;
}
+
@Override
public long getAvailable() {
return 0;
}
+
@Override
public boolean isUnavailable() {
return false;
}
+
@Override
public Servlet getServlet() {
return existing;
}
+
@Override
public String getServletClass() {
return existing.getClass().getName();
@@ -1277,7 +1191,8 @@ public class Tomcat {
static {
// Graal native images don't load any configuration except the VM default
if (JreCompat.isGraalAvailable()) {
- try (InputStream is = new FileInputStream(new File(System.getProperty("java.util.logging.config.file", "conf/logging.properties")))) {
+ try (InputStream is = new FileInputStream(
+ new File(System.getProperty("java.util.logging.config.file", "conf/logging.properties")))) {
LogManager.getLogManager().readConfiguration(is);
} catch (SecurityException | IOException e) {
// Ignore, the VM default will be used
@@ -1287,7 +1202,9 @@ public class Tomcat {
/**
* Main executable method for use with a Maven packager.
+ *
* @param args the command line arguments
+ *
* @throws Exception if an error occurs
*/
public static void main(String[] args) throws Exception {
diff --git a/java/org/apache/catalina/startup/Tool.java b/java/org/apache/catalina/startup/Tool.java
index 3dd2e75aa3..68499c33c8 100644
--- a/java/org/apache/catalina/startup/Tool.java
+++ b/java/org/apache/catalina/startup/Tool.java
@@ -27,42 +27,38 @@ import org.apache.juli.logging.LogFactory;
/**
- * 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:
+ * 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:
* <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>
+ * <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:
+ *
* <pre>
* java -classpath $CLASSPATH org.apache.catalina.startup.Tool \
* ${options} ${classname} ${arguments}
* </pre>
- *
- * <p>with the following replacement contents:
+ * <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>
+ * <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
@@ -84,8 +80,7 @@ public final class Tool {
/**
* The pathname of our installation base directory.
*/
- private static final String catalinaHome =
- System.getProperty(Constants.CATALINA_HOME_PROP);
+ private static final String catalinaHome = System.getProperty(Constants.CATALINA_HOME_PROP);
/**
@@ -161,28 +156,19 @@ public final class Tool {
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"));
+ 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"));
+ 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"));
+ unpacked.add(new File(catalinaHome, "shared" + File.separator + "classes"));
+ packed.add(new File(catalinaHome, "shared" + File.separator + "lib"));
}
- classLoader =
- ClassLoaderFactory.createClassLoader
- (unpacked.toArray(new File[0]),
- packed.toArray(new File[0]),
- null);
+ classLoader = ClassLoaderFactory.createClassLoader(unpacked.toArray(new File[0]),
+ packed.toArray(new File[0]), null);
} catch (Throwable t) {
Bootstrap.handleThrowable(t);
log.error("Class loader creation threw exception", t);
diff --git a/java/org/apache/catalina/startup/UserConfig.java b/java/org/apache/catalina/startup/UserConfig.java
index c83fbaaf80..c8e5648c8d 100644
--- a/java/org/apache/catalina/startup/UserConfig.java
+++ b/java/org/apache/catalina/startup/UserConfig.java
@@ -36,16 +36,14 @@ import org.apache.tomcat.util.res.StringManager;
/**
- * Startup event listener for a <b>Host</b> that configures Contexts (web
- * applications) for all defined "users" who have a web application in a
- * directory with the specified name in their home directories. The context
- * path of each deployed application will be set to <code>~xxxxx</code>, where
- * xxxxx is the username of the owning user for that web application
+ * Startup event listener for a <b>Host</b> that configures Contexts (web applications) for all defined "users" who have
+ * a web application in a directory with the specified name in their home directories. The context path of each deployed
+ * application will be set to <code>~xxxxx</code>, where xxxxx is the username of the owning user for that web
+ * application
*
* @author Craig R. McClanahan
*/
-public final class UserConfig
- implements LifecycleListener {
+public final class UserConfig implements LifecycleListener {
private static final Log log = LogFactory.getLog(UserConfig.class);
@@ -87,15 +85,13 @@ public final class UserConfig
/**
* The string resources for this package.
*/
- private static final StringManager sm =
- StringManager.getManager(Constants.Package);
+ private static final StringManager sm = StringManager.getManager(Constants.Package);
/**
* The Java class name of the user database class we should use.
*/
- private String userClass =
- "org.apache.catalina.startup.PasswdUserDatabase";
+ private String userClass = "org.apache.catalina.startup.PasswdUserDatabase";
/**
* A regular expression defining user who deployment is allowed.
@@ -192,6 +188,7 @@ public final class UserConfig
/**
* Set the user database class name for this component.
+ *
* @param userClass The user database class name
*/
public void setUserClass(String userClass) {
@@ -280,8 +277,8 @@ public final class UserConfig
/**
- * Deploy a web application for any user who has a web application present
- * in a directory with a specified name within their home directory.
+ * Deploy a web application for any user who has a web application present in a directory with a specified name
+ * within their home directory.
*/
private void deploy() {
@@ -325,8 +322,8 @@ public final class UserConfig
/**
- * Deploy a web application for the specified user if they have such an
- * application in the defined directory within their home directory.
+ * Deploy a web application for the specified user if they have such an application in the defined directory within
+ * their home directory.
*
* @param user Username owning the application to be deployed
* @param home Home directory of this user
@@ -390,8 +387,7 @@ public final class UserConfig
/**
* Test allow and deny rules for the provided user.
*
- * @return <code>true</code> if this user is allowed to deploy,
- * <code>false</code> otherwise
+ * @return <code>true</code> if this user is allowed to deploy, <code>false</code> otherwise
*/
private boolean isDeployAllowed(String user) {
if (deny != null && deny.matcher(user).matches()) {
@@ -416,7 +412,7 @@ public final class UserConfig
DeployUserDirectory(UserConfig config, String user, String home) {
this.config = config;
this.user = user;
- this.home= home;
+ this.home = home;
}
@Override
diff --git a/java/org/apache/catalina/startup/UserDatabase.java b/java/org/apache/catalina/startup/UserDatabase.java
index 6ba238dafb..0b0d08e5f8 100644
--- a/java/org/apache/catalina/startup/UserDatabase.java
+++ b/java/org/apache/catalina/startup/UserDatabase.java
@@ -21,8 +21,7 @@ import java.util.Enumeration;
/**
- * Abstraction of the set of users defined by the operating system on the
- * current server platform.
+ * Abstraction of the set of users defined by the operating system on the current server platform.
*
* @author Craig R. McClanahan
*/
diff --git a/java/org/apache/catalina/startup/VersionLoggerListener.java b/java/org/apache/catalina/startup/VersionLoggerListener.java
index 9e92df0339..971baf3280 100644
--- a/java/org/apache/catalina/startup/VersionLoggerListener.java
+++ b/java/org/apache/catalina/startup/VersionLoggerListener.java
@@ -34,8 +34,7 @@ import org.apache.tomcat.util.res.StringManager;
/**
* Logs version information on startup.
* <p>
- * This listener must only be nested within {@link Server} elements and should
- * be the first listener defined.
+ * This listener must only be nested within {@link Server} elements and should be the first listener defined.
*/
public class VersionLoggerListener implements LifecycleListener {
@@ -85,8 +84,7 @@ public class VersionLoggerListener implements LifecycleListener {
public void lifecycleEvent(LifecycleEvent event) {
if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
if (!(event.getLifecycle() instanceof Server)) {
- log.warn(sm.getString("listener.notServer",
- event.getLifecycle().getClass().getSimpleName()));
+ log.warn(sm.getString("listener.notServer", event.getLifecycle().getClass().getSimpleName()));
}
log();
}
@@ -94,28 +92,17 @@ public class VersionLoggerListener implements LifecycleListener {
private void log() {
- log.info(sm.getString("versionLoggerListener.serverInfo.server.version",
- ServerInfo.getServerInfo()));
- log.info(sm.getString("versionLoggerListener.serverInfo.server.built",
- ServerInfo.getServerBuilt()));
- log.info(sm.getString("versionLoggerListener.serverInfo.server.number",
- ServerInfo.getServerNumber()));
- log.info(sm.getString("versionLoggerListener.os.name",
- System.getProperty("os.name")));
- log.info(sm.getString("versionLoggerListener.os.version",
- System.getProperty("os.version")));
- log.info(sm.getString("versionLoggerListener.os.arch",
- System.getProperty("os.arch")));
- log.info(sm.getString("versionLoggerListener.java.home",
- System.getProperty("java.home")));
- log.info(sm.getString("versionLoggerListener.vm.version",
- System.getProperty("java.runtime.version")));
- log.info(sm.getString("versionLoggerListener.vm.vendor",
- System.getProperty("java.vm.vendor")));
- log.info(sm.getString("versionLoggerListener.catalina.base",
- System.getProperty(Constants.CATALINA_BASE_PROP)));
- log.info(sm.getString("versionLoggerListener.catalina.home",
- System.getProperty(Constants.CATALINA_HOME_PROP)));
+ log.info(sm.getString("versionLoggerListener.serverInfo.server.version", ServerInfo.getServerInfo()));
+ log.info(sm.getString("versionLoggerListener.serverInfo.server.built", ServerInfo.getServerBuilt()));
+ log.info(sm.getString("versionLoggerListener.serverInfo.server.number", ServerInfo.getServerNumber()));
+ log.info(sm.getString("versionLoggerListener.os.name", System.getProperty("os.name")));
+ log.info(sm.getString("versionLoggerListener.os.version", System.getProperty("os.version")));
+ log.info(sm.getString("versionLoggerListener.os.arch", System.getProperty("os.arch")));
+ log.info(sm.getString("versionLoggerListener.java.home", System.getProperty("java.home")));
+ log.info(sm.getString("versionLoggerListener.vm.version", System.getProperty("java.runtime.version")));
+ log.info(sm.getString("versionLoggerListener.vm.vendor", System.getProperty("java.vm.vendor")));
+ log.info(sm.getString("versionLoggerListener.catalina.base", System.getProperty(Constants.CATALINA_BASE_PROP)));
+ log.info(sm.getString("versionLoggerListener.catalina.home", System.getProperty(Constants.CATALINA_HOME_PROP)));
if (logArgs) {
List<String> args = ManagementFactory.getRuntimeMXBean().getInputArguments();
@@ -125,18 +112,18 @@ public class VersionLoggerListener implements LifecycleListener {
}
if (logEnv) {
- SortedMap<String, String> sortedMap = new TreeMap<>(System.getenv());
- for (Map.Entry<String, String> e : sortedMap.entrySet()) {
+ SortedMap<String,String> sortedMap = new TreeMap<>(System.getenv());
+ for (Map.Entry<String,String> e : sortedMap.entrySet()) {
log.info(sm.getString("versionLoggerListener.env", e.getKey(), e.getValue()));
}
}
if (logProps) {
- SortedMap<String, String> sortedMap = new TreeMap<>();
- for (Map.Entry<Object, Object> e : System.getProperties().entrySet()) {
+ SortedMap<String,String> sortedMap = new TreeMap<>();
+ for (Map.Entry<Object,Object> e : System.getProperties().entrySet()) {
sortedMap.put(String.valueOf(e.getKey()), String.valueOf(e.getValue()));
}
- for (Map.Entry<String, String> e : sortedMap.entrySet()) {
+ for (Map.Entry<String,String> e : sortedMap.entrySet()) {
log.info(sm.getString("versionLoggerListener.prop", e.getKey(), e.getValue()));
}
}
diff --git a/java/org/apache/catalina/startup/WebAnnotationSet.java b/java/org/apache/catalina/startup/WebAnnotationSet.java
index 02273443de..abf6de8cc5 100644
--- a/java/org/apache/catalina/startup/WebAnnotationSet.java
+++ b/java/org/apache/catalina/startup/WebAnnotationSet.java
@@ -40,9 +40,8 @@ import org.apache.tomcat.util.descriptor.web.MessageDestinationRef;
import org.apache.tomcat.util.res.StringManager;
/**
- * <strong>AnnotationSet</strong> for processing the annotations of the web
- * application classes (<code>/WEB-INF/classes</code> and
- * <code>/WEB-INF/lib</code>).
+ * <strong>AnnotationSet</strong> for processing the annotations of the web application classes
+ * (<code>/WEB-INF/classes</code> and <code>/WEB-INF/lib</code>).
*/
public class WebAnnotationSet {
@@ -137,9 +136,9 @@ public class WebAnnotationSet {
loadFieldsAnnotation(context, clazz);
loadMethodsAnnotation(context, clazz);
- /* Process RunAs annotation which can be only on servlets.
- * Ref JSR 250, equivalent to the run-as element in
- * the deployment descriptor
+ /*
+ * Process RunAs annotation which can be only on servlets. Ref JSR 250, equivalent to the run-as element
+ * in the deployment descriptor
*/
RunAs runAs = clazz.getAnnotation(RunAs.class);
if (runAs != null) {
@@ -149,8 +148,7 @@ public class WebAnnotationSet {
// Process ServletSecurity annotation
ServletSecurity servletSecurity = clazz.getAnnotation(ServletSecurity.class);
if (servletSecurity != null) {
- context.addServletSecurity(
- new ApplicationServletRegistration(wrapper, context),
+ context.addServletSecurity(new ApplicationServletRegistration(wrapper, context),
new ServletSecurityElement(servletSecurity));
}
}
@@ -162,19 +160,18 @@ public class WebAnnotationSet {
* Process the annotations on a context for a given className.
*
* @param context The context which will have its annotations processed
- * @param clazz The class to examine for Servlet annotations
+ * @param clazz The class to examine for Servlet annotations
*/
- protected static void loadClassAnnotation(Context context,
- Class<?> clazz) {
- /* Process Resource annotation.
- * Ref JSR 250
+ protected static void loadClassAnnotation(Context context, Class<?> clazz) {
+ /*
+ * Process Resource annotation. Ref JSR 250
*/
Resource resourceAnnotation = clazz.getAnnotation(Resource.class);
if (resourceAnnotation != null) {
addResource(context, resourceAnnotation);
}
- /* Process Resources annotation.
- * Ref JSR 250
+ /*
+ * Process Resources annotation. Ref JSR 250
*/
Resources resourcesAnnotation = clazz.getAnnotation(Resources.class);
if (resourcesAnnotation != null && resourcesAnnotation.value() != null) {
@@ -182,9 +179,9 @@ public class WebAnnotationSet {
addResource(context, resource);
}
}
- /* Process DeclareRoles annotation.
- * Ref JSR 250, equivalent to the security-role element in
- * the deployment descriptor
+ /*
+ * Process DeclareRoles annotation. Ref JSR 250, equivalent to the security-role element in the deployment
+ * descriptor
*/
DeclareRoles declareRolesAnnotation = clazz.getAnnotation(DeclareRoles.class);
if (declareRolesAnnotation != null && declareRolesAnnotation.value() != null) {
@@ -219,12 +216,10 @@ public class WebAnnotationSet {
Resource annotation = method.getAnnotation(Resource.class);
if (annotation != null) {
if (!Introspection.isValidSetter(method)) {
- throw new IllegalArgumentException(sm.getString(
- "webAnnotationSet.invalidInjection"));
+ throw new IllegalArgumentException(sm.getString("webAnnotationSet.invalidInjection"));
}
- String defaultName = clazz.getName() + SEPARATOR +
- Introspection.getPropertyName(method);
+ String defaultName = clazz.getName() + SEPARATOR + Introspection.getPropertyName(method);
Class<?> defaultType = (method.getParameterTypes()[0]);
addResource(context, annotation, defaultName, defaultType);
@@ -235,11 +230,10 @@ public class WebAnnotationSet {
/**
- * 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.
- * @param context The context which will have its annotations processed
+ * 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.
+ *
+ * @param context The context which will have its annotations processed
* @param annotation The annotation that was found
*/
protected static void addResource(Context context, Resource annotation) {
@@ -247,20 +241,13 @@ public class WebAnnotationSet {
}
- protected static void addResource(Context context, Resource annotation, String defaultName,
- Class<?> defaultType) {
+ protected static void addResource(Context context, Resource annotation, String defaultName, Class<?> defaultType) {
String name = getName(annotation, defaultName);
String type = getType(annotation, defaultType);
- if (type.equals("java.lang.String") ||
- type.equals("java.lang.Character") ||
- type.equals("java.lang.Integer") ||
- type.equals("java.lang.Boolean") ||
- type.equals("java.lang.Double") ||
- type.equals("java.lang.Byte") ||
- type.equals("java.lang.Short") ||
- type.equals("java.lang.Long") ||
- type.equals("java.lang.Float")) {
+ if (type.equals("java.lang.String") || type.equals("java.lang.Character") || type.equals("java.lang.Integer") ||
+ type.equals("java.lang.Boolean") || type.equals("java.lang.Double") || type.equals("java.lang.Byte") ||
+ type.equals("java.lang.Short") || type.equals("java.lang.Long") || type.equals("java.lang.Float")) {
// env-entry element
ContextEnvironment resource = new ContextEnvironment();
@@ -286,14 +273,10 @@ public class WebAnnotationSet {
context.getNamingResources().addService(service);
- } else if (type.equals("javax.sql.DataSource") ||
- type.equals("javax.jms.ConnectionFactory") ||
- type.equals("javax.jms.QueueConnectionFactory") ||
- type.equals("javax.jms.TopicConnectionFactory") ||
- type.equals("jakarta.mail.Session") ||
- type.equals("java.net.URL") ||
- type.equals("javax.resource.cci.ConnectionFactory") ||
- type.equals("org.omg.CORBA_2_3.ORB") ||
+ } else if (type.equals("javax.sql.DataSource") || type.equals("javax.jms.ConnectionFactory") ||
+ type.equals("javax.jms.QueueConnectionFactory") || type.equals("javax.jms.TopicConnectionFactory") ||
+ type.equals("jakarta.mail.Session") || type.equals("java.net.URL") ||
+ type.equals("javax.resource.cci.ConnectionFactory") || type.equals("org.omg.CORBA_2_3.ORB") ||
type.endsWith("ConnectionFactory")) {
// resource-ref element
@@ -315,8 +298,7 @@ public class WebAnnotationSet {
context.getNamingResources().addResource(resource);
- } else if (type.equals("javax.jms.Queue") ||
- type.equals("javax.jms.Topic")) {
+ } else if (type.equals("javax.jms.Queue") || type.equals("javax.jms.Topic")) {
// message-destination-ref
MessageDestinationRef resource = new MessageDestinationRef();
@@ -331,9 +313,7 @@ public class WebAnnotationSet {
} else {
/*
- * General case. Also used for:
- * - javax.resource.cci.InteractionSpec
- * - jakarta.transaction.UserTransaction
+ * General case. Also used for: - javax.resource.cci.InteractionSpec - jakarta.transaction.UserTransaction
*/
// resource-env-ref
diff --git a/java/org/apache/catalina/startup/WebappServiceLoader.java b/java/org/apache/catalina/startup/WebappServiceLoader.java
index 02c36147bc..c58c42bb21 100644
--- a/java/org/apache/catalina/startup/WebappServiceLoader.java
+++ b/java/org/apache/catalina/startup/WebappServiceLoader.java
@@ -40,18 +40,14 @@ import org.apache.catalina.Context;
import org.apache.tomcat.util.scan.JarFactory;
/**
- * A variation of Java's JAR ServiceLoader that respects exclusion rules for
- * web applications.
+ * A variation of Java's JAR ServiceLoader that respects exclusion rules for web applications.
* <p>
- * Primarily intended for use loading ServletContainerInitializers as defined
- * by Servlet 8.2.4. This implementation does not attempt lazy loading as the
- * container is required to introspect all implementations discovered.
+ * Primarily intended for use loading ServletContainerInitializers as defined by Servlet 8.2.4. This implementation does
+ * not attempt lazy loading as the container is required to introspect all implementations discovered.
* <p>
- * If the ServletContext defines ORDERED_LIBS, then only JARs in WEB-INF/lib
- * that are named in that set will be included in the search for
- * provider configuration files; if ORDERED_LIBS is not defined then
- * all JARs will be searched for provider configuration files. Providers
- * defined by resources in the parent ClassLoader will always be returned.
+ * If the ServletContext defines ORDERED_LIBS, then only JARs in WEB-INF/lib that are named in that set will be included
+ * in the search for provider configuration files; if ORDERED_LIBS is not defined then all JARs will be searched for
+ * provider configuration files. Providers defined by resources in the parent ClassLoader will always be returned.
* <p>
* Provider classes will be loaded using the context's ClassLoader.
*
@@ -88,15 +84,15 @@ public class WebappServiceLoader<T> {
/**
- * Load the providers for a service type. Container defined services will be
- * loaded before application defined services in case the application
- * depends on a Container provided service. Note that services are always
- * loaded via the Context (web application) class loader so it is possible
- * for an application to provide an alternative implementation of what would
- * normally be a Container provided service.
+ * Load the providers for a service type. Container defined services will be loaded before application defined
+ * services in case the application depends on a Container provided service. Note that services are always loaded
+ * via the Context (web application) class loader so it is possible for an application to provide an alternative
+ * implementation of what would normally be a Container provided service.
*
* @param serviceType the type of service to load
+ *
* @return an unmodifiable collection of service providers
+ *
* @throws IOException if there was a problem loading any service
*/
public List<T> load(Class<T> serviceType) throws IOException {
@@ -131,13 +127,13 @@ public class WebappServiceLoader<T> {
// Obtaining the application provided configuration files is a little
// more difficult for two reasons:
// - The web application may employ a custom class loader. Ideally, we
- // would use ClassLoader.findResources() but that method is protected.
- // We could force custom class loaders to override that method and
- // make it public but that would be a new requirement and break
- // backwards compatibility for what is an often customised component.
+ // would use ClassLoader.findResources() but that method is protected.
+ // We could force custom class loaders to override that method and
+ // make it public but that would be a new requirement and break
+ // backwards compatibility for what is an often customised component.
// - If the application web.xml file has defined an order for fragments
- // then only those JAR files represented by fragments in that order
- // (and arguably WEB-INF/classes) should be scanned for services.
+ // then only those JAR files represented by fragments in that order
+ // (and arguably WEB-INF/classes) should be scanned for services.
LinkedHashSet<String> applicationServiceClassNames = new LinkedHashSet<>();
// Check to see if the ServletContext has ORDERED_LIBS defined
@@ -209,8 +205,8 @@ public class WebappServiceLoader<T> {
void parseConfigFile(LinkedHashSet<String> servicesFound, URL url) throws IOException {
try (InputStream is = url.openStream();
- InputStreamReader in = new InputStreamReader(is, StandardCharsets.UTF_8);
- BufferedReader reader = new BufferedReader(in)) {
+ InputStreamReader in = new InputStreamReader(is, StandardCharsets.UTF_8);
+ BufferedReader reader = new BufferedReader(in)) {
String line;
while ((line = reader.readLine()) != null) {
int i = line.indexOf('#');
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 04/04: Align with 11.0.x
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit ee7012fd35e6f651dba1b1d133bca81968f267a2
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sun Feb 4 16:37:39 2024 +0000
Align with 11.0.x
---
java/org/apache/catalina/startup/HostConfig.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/java/org/apache/catalina/startup/HostConfig.java b/java/org/apache/catalina/startup/HostConfig.java
index 504ae72ef8..c543abb445 100644
--- a/java/org/apache/catalina/startup/HostConfig.java
+++ b/java/org/apache/catalina/startup/HostConfig.java
@@ -1397,10 +1397,12 @@ public class HostConfig implements LifecycleListener {
} else {
// There is a chance the the resource was only missing
// temporarily eg renamed during a text editor save
- try {
- Thread.sleep(500);
- } catch (InterruptedException e1) {
- // Ignore
+ if (resource.exists() || !resource.getName().toLowerCase(Locale.ENGLISH).endsWith(".war")) {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e1) {
+ // Ignore
+ }
}
// Recheck the resource to see if it was really deleted
if (resource.exists()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
(tomcat) 01/04: Format clean-ups
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit c43c667944919055567544edaefff51fe57dd493
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Sun Feb 4 16:07:44 2024 +0000
Format clean-ups
---
java/org/apache/catalina/startup/ContextConfig.java | 8 +++++++-
java/org/apache/catalina/startup/ContextRuleSet.java | 4 ++--
java/org/apache/catalina/startup/CopyParentClassLoaderRule.java | 4 ++--
java/org/apache/catalina/startup/CredentialHandlerRuleSet.java | 4 ++--
java/org/apache/catalina/startup/EngineRuleSet.java | 4 ++--
java/org/apache/catalina/startup/HostRuleSet.java | 4 ++--
java/org/apache/catalina/startup/NamingRuleSet.java | 4 ++--
java/org/apache/catalina/startup/RealmRuleSet.java | 4 ++--
java/org/apache/catalina/startup/SetNextNamingRule.java | 9 ++++-----
java/org/apache/catalina/startup/Tool.java | 8 ++++----
10 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/java/org/apache/catalina/startup/ContextConfig.java b/java/org/apache/catalina/startup/ContextConfig.java
index fe51d82a25..4e6cad771d 100644
--- a/java/org/apache/catalina/startup/ContextConfig.java
+++ b/java/org/apache/catalina/startup/ContextConfig.java
@@ -1233,9 +1233,11 @@ public class ContextConfig implements LifecycleListener {
protected void webConfig() {
/*
* Anything and everything can override the global and host defaults.
- * This is implemented in two parts
+ * This is implemented in two parts:
+ *
* - Handle as a web fragment that gets added after everything else so
* everything else takes priority
+ *
* - Mark Servlets as overridable so SCI configuration can replace
* configuration from the defaults
*/
@@ -1243,15 +1245,19 @@ public class ContextConfig implements LifecycleListener {
/*
* The rules for annotation scanning are not as clear-cut as one might
* think. Tomcat implements the following process:
+ *
* - As per SRV.1.6.2, Tomcat will scan for annotations regardless of
* which Servlet spec version is declared in web.xml. The EG has
* confirmed this is the expected behaviour.
+ *
* - As per http://java.net/jira/browse/SERVLET_SPEC-36, if the main
* web.xml is marked as metadata-complete, JARs are still processed
* for SCIs.
+ *
* - If metadata-complete=true and an absolute ordering is specified,
* JARs excluded from the ordering are also excluded from the SCI
* processing.
+ *
* - If an SCI has a @HandlesType annotation then all classes (except
* those in JARs excluded from an absolute ordering) need to be
* scanned to check if they match.
diff --git a/java/org/apache/catalina/startup/ContextRuleSet.java b/java/org/apache/catalina/startup/ContextRuleSet.java
index 4aa081e083..fb054df88b 100644
--- a/java/org/apache/catalina/startup/ContextRuleSet.java
+++ b/java/org/apache/catalina/startup/ContextRuleSet.java
@@ -20,8 +20,8 @@ import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
/**
- * <p><strong>RuleSet</strong> for processing the contents of a
- * Context definition element.</p>
+ * <strong>RuleSet</strong> for processing the contents of a
+ * Context definition element.
*
* @author Craig R. McClanahan
*/
diff --git a/java/org/apache/catalina/startup/CopyParentClassLoaderRule.java b/java/org/apache/catalina/startup/CopyParentClassLoaderRule.java
index cefc579aaf..a7f4998ef2 100644
--- a/java/org/apache/catalina/startup/CopyParentClassLoaderRule.java
+++ b/java/org/apache/catalina/startup/CopyParentClassLoaderRule.java
@@ -25,10 +25,10 @@ import org.xml.sax.Attributes;
/**
- * <p>Rule that copies the <code>parentClassLoader</code> property from the
+ * 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>
+ * <code>Container</code>).
*
* @author Craig R. McClanahan
*/
diff --git a/java/org/apache/catalina/startup/CredentialHandlerRuleSet.java b/java/org/apache/catalina/startup/CredentialHandlerRuleSet.java
index 5742178ea2..68404e718c 100644
--- a/java/org/apache/catalina/startup/CredentialHandlerRuleSet.java
+++ b/java/org/apache/catalina/startup/CredentialHandlerRuleSet.java
@@ -20,10 +20,10 @@ import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
/**
- * <p><strong>RuleSet</strong> for processing the contents of a
+ * <strong>RuleSet</strong> for processing the contents of a
* CredentialHandler definition element. This <code>RuleSet</code> supports
* CredentialHandler such as the <code>NestedCredentialHandler</code> that used
- * nested CredentialHandlers.</p>
+ * nested CredentialHandlers.
*/
public class CredentialHandlerRuleSet implements RuleSet {
diff --git a/java/org/apache/catalina/startup/EngineRuleSet.java b/java/org/apache/catalina/startup/EngineRuleSet.java
index f98e285a86..30601f8752 100644
--- a/java/org/apache/catalina/startup/EngineRuleSet.java
+++ b/java/org/apache/catalina/startup/EngineRuleSet.java
@@ -20,10 +20,10 @@ import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
/**
- * <p><strong>RuleSet</strong> for processing the contents of a
+ * <strong>RuleSet</strong> for processing the contents of a
* Engine definition element. This <code>RuleSet</code> does NOT include
* any rules for nested Host elements, which should be added via instances of
- * <code>HostRuleSet</code>.</p>
+ * <code>HostRuleSet</code>.
*
* @author Craig R. McClanahan
*/
diff --git a/java/org/apache/catalina/startup/HostRuleSet.java b/java/org/apache/catalina/startup/HostRuleSet.java
index 3114cc1f9a..af7b6a182d 100644
--- a/java/org/apache/catalina/startup/HostRuleSet.java
+++ b/java/org/apache/catalina/startup/HostRuleSet.java
@@ -20,10 +20,10 @@ import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
/**
- * <p><strong>RuleSet</strong> for processing the contents of a
+ * <strong>RuleSet</strong> for processing the contents of a
* Host definition element. This <code>RuleSet</code> does NOT include
* any rules for nested Context which should be added via instances of
- * <code>ContextRuleSet</code>.</p>
+ * <code>ContextRuleSet</code>.
*
* @author Craig R. McClanahan
*/
diff --git a/java/org/apache/catalina/startup/NamingRuleSet.java b/java/org/apache/catalina/startup/NamingRuleSet.java
index b2a3baa570..3125d886cb 100644
--- a/java/org/apache/catalina/startup/NamingRuleSet.java
+++ b/java/org/apache/catalina/startup/NamingRuleSet.java
@@ -20,8 +20,8 @@ import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
/**
- * <p><strong>RuleSet</strong> for processing the JNDI Enterprise Naming
- * Context resource declaration elements.</p>
+ * <strong>RuleSet</strong> for processing the JNDI Enterprise Naming
+ * Context resource declaration elements.
*
* @author Craig R. McClanahan
* @author Remy Maucherat
diff --git a/java/org/apache/catalina/startup/RealmRuleSet.java b/java/org/apache/catalina/startup/RealmRuleSet.java
index eb6cfa6521..9ff7457d79 100644
--- a/java/org/apache/catalina/startup/RealmRuleSet.java
+++ b/java/org/apache/catalina/startup/RealmRuleSet.java
@@ -20,9 +20,9 @@ import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.digester.RuleSet;
/**
- * <p><strong>RuleSet</strong> for processing the contents of a Realm definition
+ * <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>
+ * <code>CombinedRealm</code> that used nested Realms.
*/
public class RealmRuleSet implements RuleSet {
diff --git a/java/org/apache/catalina/startup/SetNextNamingRule.java b/java/org/apache/catalina/startup/SetNextNamingRule.java
index 3b51a2940f..33d1a6b57a 100644
--- a/java/org/apache/catalina/startup/SetNextNamingRule.java
+++ b/java/org/apache/catalina/startup/SetNextNamingRule.java
@@ -23,14 +23,13 @@ import org.apache.tomcat.util.digester.Rule;
/**
- * <p>Rule implementation that calls a method on the (top-1) (parent)
+ * 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.
+ * commonly used to establish parent-child relationships.
+ * <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 {
diff --git a/java/org/apache/catalina/startup/Tool.java b/java/org/apache/catalina/startup/Tool.java
index cd9fdd6e4c..3dd2e75aa3 100644
--- a/java/org/apache/catalina/startup/Tool.java
+++ b/java/org/apache/catalina/startup/Tool.java
@@ -27,18 +27,18 @@ import org.apache.juli.logging.LogFactory;
/**
- * <p>General purpose wrapper for command line tools that should execute in an
+ * 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>
+ * the following requirements:
* <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>
+ * <p>
+ * The command line to execute the tool looks like:
* <pre>
* java -classpath $CLASSPATH org.apache.catalina.startup.Tool \
* ${options} ${classname} ${arguments}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org