org.sonar.core.classloaders
Class ClassLoadersCollection

java.lang.Object
  extended by org.sonar.core.classloaders.ClassLoadersCollection

public class ClassLoadersCollection
extends Object

Encapsulates manipulations with ClassLoaders, such as creation and establishing dependencies. Current implementation based on ClassWorld.

IMPORTANT

If we have pluginA , then all classes and resources from package and subpackages of org.sonar.plugins.pluginA.api will be visible for all other plugins even if they located in dependent library.

Search order for ClassRealm :

Since:
2.4

Constructor Summary
ClassLoadersCollection(ClassLoader baseClassLoader)
           
 
Method Summary
 ClassLoader createClassLoader(String key, Collection<URL> urls, boolean childFirst)
          Generates URLClassLoader with specified delegation model.
 void done()
          Establishes dependencies among ClassLoaders.
 void extend(String baseKey, String key, Collection<URL> urls)
           
 ClassLoader get(String key)
          Note that this method should be called only after creation of all ClassLoaders - see done().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassLoadersCollection

public ClassLoadersCollection(ClassLoader baseClassLoader)
Method Detail

createClassLoader

public ClassLoader createClassLoader(String key,
                                     Collection<URL> urls,
                                     boolean childFirst)
Generates URLClassLoader with specified delegation model.

Parameters:
key - plugin key
urls - libraries
childFirst - true, if child-first delegation model required instead of parent-first
Returns:
created ClassLoader, but actually this method shouldn't return anything, because dependencies must be established - see done().

extend

public void extend(String baseKey,
                   String key,
                   Collection<URL> urls)

done

public void done()
Establishes dependencies among ClassLoaders.


get

public ClassLoader get(String key)
Note that this method should be called only after creation of all ClassLoaders - see done().



Copyright © 2009-2011 SonarSource. All Rights Reserved.