public static ClassLoader getCurrentClassLoader(Class clazz) { ClassLoader cl = getContextClassLoader(); if (cl == null && clazz != null) { cl = clazz.getClassLoader(); } return cl; }
public static Class loadClassForName(String name) throws ClassNotFoundException { try { return Class.forName(name, false, LangUtils.class.getClassLoader()); } catch (ClassNotFoundException e) { try { return Class.forName(name, false, getContextClassLoader()); } catch (ClassNotFoundException e2) { throw e2; } } }
Enumeration<URL> webFragments = LangUtils.getContextClassLoader().getResources("META-INF/web-fragment.xml");
public PrimeApplicationContext(FacesContext context) { this.environment = new PrimeEnvironment(context); this.config = new PrimeConfiguration(context, environment); if (this.config.isBeanValidationEnabled()) { this.validatorFactory = Validation.buildDefaultValidatorFactory(); this.validator = validatorFactory.getValidator(); } enumCacheMap = new ConcurrentHashMap<>(); constantsCacheMap = new ConcurrentHashMap<>(); if (environment.isPortlet()) { //the method is new in Porlets3.x, so we can't use it now //applicationClassLoader = ((PortletContext) context.getExternalContext().getContext()).getClassLoader(); applicationClassLoader = LangUtils.getContextClassLoader(); } else if (context.getExternalContext().getContext() instanceof ServletContext) { applicationClassLoader = ((ServletContext) context.getExternalContext().getContext()).getClassLoader(); } }