org.mule.module.launcher.application
Class CompositeApplicationClassLoader
java.lang.Object
java.lang.ClassLoader
org.mule.module.launcher.application.CompositeApplicationClassLoader
- All Implemented Interfaces:
- Closeable, ApplicationClassLoader, ArtifactClassLoader
public class CompositeApplicationClassLoader
- extends ClassLoader
- implements ApplicationClassLoader, Closeable
Defines a classloader that delegates classes and resources resolution to
a list of classloaders.
Methods inherited from class java.lang.ClassLoader |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLoadedClass, findResources, findSystemClass, getPackage, getPackages, getParent, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
protected static final Log logger
CompositeApplicationClassLoader
public CompositeApplicationClassLoader(String appName,
List<ClassLoader> classLoaders)
getAppName
public String getAppName()
- Specified by:
getAppName
in interface ApplicationClassLoader
loadClass
public Class<?> loadClass(String name)
throws ClassNotFoundException
- Overrides:
loadClass
in class ClassLoader
- Throws:
ClassNotFoundException
loadClass
protected Class<?> loadClass(String name,
boolean resolve)
throws ClassNotFoundException
- Overrides:
loadClass
in class ClassLoader
- Throws:
ClassNotFoundException
loadClass
protected Class<?> loadClass(ClassLoader classLoader,
String name,
boolean resolve)
throws ClassNotFoundException
- Throws:
ClassNotFoundException
getResource
public URL getResource(String name)
- Overrides:
getResource
in class ClassLoader
getResourceAsStream
public InputStream getResourceAsStream(String name)
- Overrides:
getResourceAsStream
in class ClassLoader
findLibrary
protected String findLibrary(String libname)
- Overrides:
findLibrary
in class ClassLoader
findLibrary
protected String findLibrary(String libname,
ClassLoader classLoader)
getResources
public Enumeration<URL> getResources(String name)
throws IOException
- Overrides:
getResources
in class ClassLoader
- Throws:
IOException
getArtifactName
public String getArtifactName()
- Specified by:
getArtifactName
in interface ArtifactClassLoader
- Returns:
- the artifact unique identifier
findResource
public URL findResource(String name)
- Specified by:
findResource
in interface ApplicationClassLoader
- Specified by:
findResource
in interface ArtifactClassLoader
- Overrides:
findResource
in class ClassLoader
- Parameters:
name
- name of the resource to find.
- Returns:
- the resource URL, null if it doesn't exists.
getClassLoader
public ClassLoader getClassLoader()
- Description copied from interface:
ArtifactClassLoader
- ClassLoader is an abstract class. Not an interface.
There are parts of the code that requires a ClassLoader and others that requires an ArtifactClassLoader.
Ideally I would make ArtifactClassLoader implement ClassLoader interface but there's no such interface.
So if I have a method that requires a ClassLoader instance and an ArtifactClassLoader I would have to down cast and assume that it can be down casted or send two parameters, one for the ClassLoader and one for the ArtifactClassLoader:
public void doSomething(ArtifactClassLoader acl)
{
doSomething2(acl); //this requires an ArtifactClassLoader
doSomething3((ClassLoader)acl); //this requires a ClassLoader
}
public void doSomething(ArtifactClassLoader acl, ClassLoader cl)
{
doSomething2(acl); //this requires an ArtifactClassLoader
doSomething3(cl); //this requires a ClassLoader
}
To overcome that problem seems much better to have a method in ArtifactClassLoader that can actually return a ClassLoader instance:
public void doSomething(ArtifactClassLoader acl)
{
doSomething2(acl); //this requires an ArtifactClassLoader
doSomething3(acl.getDomainClassLoader()); //this requires a ClassLoader
}
- Specified by:
getClassLoader
in interface ArtifactClassLoader
- Returns:
- class loader to use for this artifact.
dispose
public void dispose()
- Description copied from interface:
ArtifactClassLoader
- Gets rid of the class loader resources.
- Specified by:
dispose
in interface ArtifactClassLoader
close
public void close()
- Specified by:
close
in interface Closeable
Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.