Package org.apache.geronimo.kernel.config

Examples of org.apache.geronimo.kernel.config.MultiParentClassLoader


     * ClassLoader.  This should load the parent's copy when
     * contextPriorityClassLoader is set to false (as here) and the child's
     * copy when the contextPriorityClassLoader is set to true.
     */
    public void xtestFalseExistantNonJavaxClass() {
        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), classLoadingRules);
        try {
            Class cls = cl.loadClass("mx4j.MBeanDescription");
            assertTrue("Should not have overriden parent CL definition of class mx4j.MBeanDescription", cls.getDeclaredMethods().length > 0);
        } catch(ClassNotFoundException e) {
            fail("Problem with test; expecting to have mx4j.* on the ClassPath");
View Full Code Here


     * contextPriorityClassLoader is set to false and the child's copy when
     * the contextPriorityClassLoader is set to true (as here).
     */
    public void xtestTrueExistantNonJavaxClass() {
        classLoadingRules.setInverseClassLoading(true);
        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), classLoadingRules);
        try {
            Class cls = cl.loadClass("mx4j.MBeanDescription");
            assertTrue("Should be able to override a class that is not in java.*, javax.*, etc.", cls.getDeclaredMethods().length == 0);
        } catch(ClassNotFoundException e) {
            fail("Problem with test; expecting to have mx4j.* on the ClassPath");
View Full Code Here

    /**
     * Tries to load a javax.* class that's not available from the
     * parent ClassLoader.  This should work.
     */
    public void testFalseNonexistantJavaxResource() {
        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), classLoadingRules);
        URL url = cl.getResource("javax/foo/Foo.class");
        if(url == null) {
            fail("Should be able to load a javax.* class that is not defined by my parent CL");
        }
        assertEquals(url.getProtocol(), "file");
View Full Code Here

     * Tries to load a javax.* class that's not available from the
     * parent ClassLoader.  This should work.
     */
    public void testTrueNonexistantJavaxResource() {
        classLoadingRules.setInverseClassLoading(true);
        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), classLoadingRules);
        URL url = cl.getResource("javax/foo/Foo.class");
        if(url == null) {
            fail("Should be able to load a javax.* class that is not defined by my parent CL");
        }
        assertEquals(url.getProtocol(), "file");
View Full Code Here

     * Tries to load a javax.* class that is avialable from the parent ClassLoader,
     * when there's a different definition available from this ClassLoader too.
     * This should always load the parent's copy.
     */
    public void testFalseExistantJavaxResource() {
        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), classLoadingRules);
        URL url = cl.getResource("javax/servlet/Servlet.class");
        if(url == null) {
            fail("Problem with test; expecting to have javax.servlet.* on the ClassPath");
        }
        assertEquals("Loaded wrong class first; expected to find parent CL's copy of javax.servlet.Servlet", url.getProtocol(), "jar");
View Full Code Here

     * when there's a different definition available from this ClassLoader too.
     * This should always load the parent's copy.
     */
    public void testTrueExistantJavaxResource() {
        classLoadingRules.setInverseClassLoading(true);
        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), classLoadingRules);
        URL url = cl.getResource("javax/servlet/Servlet.class");
        if(url == null) {
            fail("Problem with test; expecting to have javax.servlet.* on the ClassPath");
        }
        assertEquals("Loaded wrong class first; expected to find parent CL's copy of javax.servlet.Servlet",url.getProtocol(),"jar");
View Full Code Here

     * ClassLoader.  This should load the parent's copy when
     * contextPriorityClassLoader is set to false (as here) and the child's
     * copy when the contextPriorityClassLoader is set to true.
     */
    public void xtestFalseExistantNonJavaxResource() {
        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), classLoadingRules);
        URL url = cl.getResource("mx4j/MBeanDescription.class");
        if(url == null) {
            fail("Problem with test; expecting to have mx4j.* on the ClassPath");
        }
        assertEquals("Should not have overriden parent CL definition of class mx4j.MBeanDescription", url.getProtocol(), "jar");
View Full Code Here

     * the contextPriorityClassLoader is set to true (as here).
     */
    public void testTrueExistantNonJavaxResource() {
        classLoadingRules.setInverseClassLoading(true);
        classLoadingRules.getHiddenRule().setClassPrefixes(Collections.EMPTY_SET);
        cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), classLoadingRules);
        URL url = cl.getResource("mx4j/MBeanDescription.class");
        if(url == null) {
            fail("Problem with test; expecting to have mx4j.* on the ClassPath");
        }
        assertEquals("Should be able to override a class that is not in java.*, javax.*, etc.", url.getProtocol(), "file");
View Full Code Here

   
    public static void getClassLoaderClasspath(ClassLoader loader, LinkedHashSet<URL> classpath) {
        if (loader == null || loader == ClassLoader.getSystemClassLoader()) {
            return;
        } else if (loader instanceof MultiParentClassLoader) {
            MultiParentClassLoader cl = (MultiParentClassLoader)loader;
            for (ClassLoader parent : cl.getParents()) {  
                getClassLoaderClasspath(parent, classpath);
            }
            for (URL u : cl.getURLs()) {
                classpath.add(u);
            }
        } else if (loader instanceof URLClassLoader) {
            URLClassLoader cl = (URLClassLoader)loader;
            getClassLoaderClasspath(cl.getParent(), classpath);
            for (URL u : cl.getURLs()) {
                classpath.add(u);
            }
        } else {
            getClassLoaderClasspath(loader.getParent(), classpath);
        }
View Full Code Here

        if (module instanceof WebModule) {
            try {
                ClassLoader classLoader = module.getEarContext().getClassLoader();
                UrlSet urlSet = new UrlSet(classLoader);
                if (classLoader instanceof MultiParentClassLoader) {
                    MultiParentClassLoader multiParentClassLoader = (MultiParentClassLoader) classLoader;
                    for (ClassLoader parent : multiParentClassLoader.getParents()) {
                        if (parent != null) {
                            urlSet = urlSet.exclude(parent);
                        }
                    }
                } else {
View Full Code Here

TOP

Related Classes of org.apache.geronimo.kernel.config.MultiParentClassLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.