private ServletContainerInitializer loadSci( ClassLoader classLoader, VirtualFile sci, String jar, boolean error) throws DeploymentUnitProcessingException { ServletContainerInitializer service = null; InputStream is = null; try { // Get the ServletContainerInitializer class name is = sci.openStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String servletContainerInitializerClassName = reader.readLine(); int pos = servletContainerInitializerClassName.indexOf('#'); if (pos > 0) { servletContainerInitializerClassName = servletContainerInitializerClassName.substring(0, pos); } servletContainerInitializerClassName = servletContainerInitializerClassName.trim(); // Instantiate the ServletContainerInitializer service = (ServletContainerInitializer) classLoader.loadClass(servletContainerInitializerClassName).newInstance(); } catch (Exception e) { if (error) { throw MESSAGES.errorProcessingSCI(jar, e); } else { UndertowLogger.ROOT_LOGGER.skippedSCI(jar, e); } } finally { try { if (is != null) is.close(); } catch (IOException e) { // Ignore } } return service; }
private Set<Class<?>> loadClassInfoSet(Set<ClassInfo> classInfos, ClassLoader classLoader) throws DeploymentUnitProcessingException { Set<Class<?>> classes = new HashSet<Class<?>>(); for (ClassInfo classInfo : classInfos) { Class<?> type; try { type = classLoader.loadClass(classInfo.name().toString()); classes.add(type); } catch (Exception e) { UndertowLogger.ROOT_LOGGER.cannotLoadDesignatedHandleTypes(classInfo, e); } } return classes; }