<include name="org/apache/catalina/security/SecurityClassLoad.class" />
<include name="org/apache/naming/JndiPermission.class" />
<include name="org/apache/tomcat/util/compat/*" />
+ <include name="org/apache/catalina/loader/NamedClassLoader.class" />
<!-- Javadoc and i18n exclusions -->
<exclude name="**/package.html" />
<exclude name="**/LocalStrings_*" />
<exclude name="org/apache/catalina/launcher/**" />
<exclude name="org/apache/catalina/storeconfig/**" />
<exclude name="org/apache/naming/factory/webservices/**" />
+ <exclude name="org/apache/catalina/loader/NamedClassLoader.class" />
</fileset>
</jar>
--- /dev/null
+/*\r
+ * Licensed to the Apache Software Foundation (ASF) under one or more\r
+ * contributor license agreements. See the NOTICE file distributed with\r
+ * this work for additional information regarding copyright ownership.\r
+ * The ASF licenses this file to You under the Apache License, Version 2.0\r
+ * (the "License"); you may not use this file except in compliance with\r
+ * the License. You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.apache.catalina.loader;\r
+/**\r
+ * \r
+ * An interface to be able to able to have named classloader.\r
+ * Useful when distributing data through AOP or byte code injection\r
+ * To be able to map loaders between two instances to make sure the data\r
+ * gets loaded through the correct loader on the other node.\r
+ * @author Filip Hanik\r
+ * \r
+ */\r
+public interface NamedClassLoader {\r
+ \r
+ /**\r
+ * returns the name of this class loader\r
+ * @return String\r
+ */\r
+ public String getName();\r
+ \r
+ /**\r
+ * Sets the name of this class loader\r
+ * @param name String\r
+ */\r
+ public void setName(String name);\r
+ \r
+}
\ No newline at end of file
import java.net.URL;
import java.net.URLClassLoader;
+
/**
* Subclass implementation of <b>java.net.URLClassLoader</b>. There are no
* functional differences between this class and <b>java.net.URLClassLoader</b>.
public class StandardClassLoader
extends URLClassLoader
- implements StandardClassLoaderMBean {
+ implements StandardClassLoaderMBean, NamedClassLoader {
+
+ protected String name;
public StandardClassLoader(URL repositories[]) {
super(repositories);
public StandardClassLoader(URL repositories[], ClassLoader parent) {
super(repositories, parent);
}
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+
}
import org.apache.naming.resources.ResourceAttributes;
import org.apache.tomcat.util.IntrospectionUtils;
+
/**
* Specialized web application class loader.
* <p>
*/
public class WebappClassLoader
extends URLClassLoader
- implements Reloader, Lifecycle
+ implements Reloader, Lifecycle, NamedClassLoader
{
protected static org.apache.juli.logging.Log log=
*/
protected Permission allPermission = new java.security.AllPermission();
+ /**
+ * The name of this classloader
+ * typically a concatenated string of Engine/Host/Context names
+ */
+ protected String name = null;
// ------------------------------------------------------------- Properties
protected void setParentClassLoader(ClassLoader pcl) {
parent = pcl;
}
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
// ------------------------------------------------------- Reloader Methods
import org.apache.naming.resources.DirContextURLStreamHandlerFactory;
import org.apache.naming.resources.Resource;
import org.apache.tomcat.util.modeler.Registry;
+import org.apache.catalina.Host;
/**
((ClassLoader) classLoader, this.container.getResources());
StandardContext ctx=(StandardContext)container;
- Engine eng=(Engine)ctx.getParent().getParent();
+ Host host = (Host)ctx.getParent();
+ Engine eng=(Engine)host.getParent();
String path = ctx.getPath();
if (path.equals("")) {
path = "/";
+ path + ",host=" + ctx.getParent().getName());
Registry.getRegistry(null, null)
.registerComponent(classLoader, cloname, null);
-
+
+ //set the name of the webapp classloader
+ String clName = eng.getName()+"#"+host.getName()+"#"+ctx.getName();
+ classLoader.setName(clName);
} catch (Throwable t) {
log.error( "LifecycleException ", t );
throw new LifecycleException("start: ", t);
}
-
}
+
/**
import org.apache.catalina.security.SecurityClassLoad;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
+import org.apache.catalina.loader.NamedClassLoader;
/**
ClassLoader classLoader = ClassLoaderFactory.createClassLoader
(locations, types, parent);
+
+ if ( classLoader instanceof NamedClassLoader ) {
+ ((NamedClassLoader)classLoader).setName(name);
+ }
// Retrieving MBean server
MBeanServer mBeanServer = null;