public ClassLoader getClassLoader() { return (this.classLoader != null ? this.classLoader : Classes.getClassLoader()); }
/** * Returns the (initialized) class represented by {@code className} using the given class's loader. * * <p/> * * returns {@code null} if the class is not found */ public static Class<?> tryForName(Class<?> loaderClass,String className) { return tryForName(getClassLoader(loaderClass),className); }
protected static ClassLoader getClassLoader() { ClassLoader current = Classes.getClassLoader(AppContextInitializer.class); return null == classLoaderGetter ? current : classLoaderGetter.getClassLoader(current); }
/** * Returns the (initialized) class represented by {@code className} using the current thread's context class loader. * * @throws NestedClassNotFoundException if the class is not found */ public static Class<?> forName(String className) throws NestedClassNotFoundException { return forName(getClassLoader(),className,true); }
/** * Returns the (initialized) class represented by {@code className} using the given class's loader. * * @throws NestedClassNotFoundException if the class is not found */ public static Class<?> forName(Class<?> loaderClass,String className) throws NestedClassNotFoundException { return forName(getClassLoader(loaderClass),className); }
/** * Returns the (initialized) class represented by {@code className} using the current thread's context class loader. * * <p/> * * returns {@code null} if the class is not found */ public static Class<?> tryForName(String className) { try { return forName(getClassLoader(),className,true); } catch (NestedClassNotFoundException e) { return null; } }
/** * Create a new ClassPathResource for ClassLoader usage. * A leading slash will be removed, as the ClassLoader * resource access methods will not accept it. * @param path the absolute path within the classpath * @param classLoader the class loader to load the resource with, * or <code>null</code> for the thread context class loader * @see java.lang.ClassLoader#getResourceAsStream(String) */ public ClassPathResource(String path, ClassLoader classLoader) { Args.notNull(path, "path"); String pathToUse = Paths.normalize(path); if (pathToUse.startsWith("/")) { pathToUse = pathToUse.substring(1); } this.path = pathToUse; this.classLoader = (classLoader != null ? classLoader : Classes.getClassLoader()); }
context.setClassLoader(Classes.getClassLoader()); context.setParentLoaderPriority(true); context.setServer(server);
className = internalClassName.replace('/','.'); classes.add(Class.forName(className, false, Classes.getClassLoader())); }catch(IOException e) { throw new NestedIOException("Error loading .class file " + resource.getDescription() + "' : " + e.getMessage(), e);