org.rhq.enterprise.server.plugin.pc
Class RootServerPluginClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.rhq.enterprise.server.plugin.pc.RootServerPluginClassLoader

public class RootServerPluginClassLoader
extends java.net.URLClassLoader

This is the classloader that will be the parent to all plugin classloaders. It will be created such that it essentially hides a set of excluded classes which typically means this this root classloader (and its children plugin classloaders) will allow the following to be loaded:

Author:
John Mazzitelli

Constructor Summary
RootServerPluginClassLoader(java.net.URL[] urls, java.lang.ClassLoader parent, java.lang.String... classesToHideRegexStr)
          Creates this classloader.
 
Method Summary
 java.net.URL getResource(java.lang.String name)
           
protected  java.lang.Class<?> loadClass(java.lang.String name, boolean resolve)
           
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findClass, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RootServerPluginClassLoader

public RootServerPluginClassLoader(java.net.URL[] urls,
                                   java.lang.ClassLoader parent,
                                   java.lang.String... classesToHideRegexStr)
Creates this classloader. classesToHideRegexStr is a regular expression to use to match against names of classes to hide (i.e. not load). If a class that is to be loaded doesn't match the regex, it will be loaded using parent-first semantics (i.e. it will first be searched in the parent classloader, and only if it isn't found there will this classloader be checked for it). Otherwise, the class will be loaded using this classloader only - the parent classloader will not be consulted so if this classloader does not have the class to be loaded, a ClassCastException will be thrown.

Parameters:
urls - URLs to jar files where classes can be loaded by this classloader
parent - the parent to this classloader, used when loading classes via parent-first semantics
classesToHideRegexStr - regular expression(s) to use to match against names of classes to load. if null or empty, no classes will be hidden, the parent will always be consulted first to load the classes.
Throws:
java.util.regex.PatternSyntaxException - if the given regex is invalid (see Pattern.compile(String))
Method Detail

loadClass

protected java.lang.Class<?> loadClass(java.lang.String name,
                                       boolean resolve)
                                throws java.lang.ClassNotFoundException
Overrides:
loadClass in class java.lang.ClassLoader
Throws:
java.lang.ClassNotFoundException

getResource

public java.net.URL getResource(java.lang.String name)
Overrides:
getResource in class java.lang.ClassLoader


Copyright © 2008-2009 Red Hat, Inc.. All Rights Reserved.