// Indicates if the classLoad should be overridden for the passed className. // Returns true in case the class should NOT be loaded by parent classLoader. protected boolean shouldOverrideLoadClass(String name) { if (shouldOverrideLoadClassForCollectionMembers) { // Override classLoad if the name is in collection return (classNames != null) && classNames.contains(name); } else { // Directly opposite: Override classLoad if the name is NOT in collection. // Forced to check for java. and javax. packages here, because even if the class // has been loaded by parent loader we would load it again // (see comment in loadClass) return !name.startsWith("java.") && !name.startsWith("javax.") && ((classNames == null) || !classNames.contains(name)); } }
/** * INTERNAL: Create a list of java.lang.Class that contains the classes of all the entities that * we will be deploying */ protected Set loadEntityClasses(Collection entityNames, ClassLoader classLoader) { Set entityClasses = new HashSet(); // Load the classes using the loader passed in AbstractSessionLog.getLog() .log(SessionLog.FINER, "cmp_loading_entities_using_loader", classLoader); for (Iterator iter = entityNames.iterator(); iter.hasNext(); ) { String entityClassName = (String) iter.next(); try { entityClasses.add(classLoader.loadClass(entityClassName)); } catch (ClassNotFoundException cnfEx) { throw ValidationException.entityClassNotFound(entityClassName, classLoader, cnfEx); } } return entityClasses; }