public static Class tryToLoadClassForName(String name) { try { return loadClassForName(name); } catch (ClassNotFoundException e) { return null; } }
/** * Gets the {@link Class} from the {@link TagAttribute}. * * @param attribute The {@link TagAttribute}. * @param ctx The {@link FaceletContext}. * @return The {@link Class}. */ protected Class<?> getClassFromAttribute(TagAttribute attribute, FaceletContext ctx) { String type = attribute.getValue(ctx); try { return LangUtils.loadClassForName(type); } catch (ClassNotFoundException e) { throw new FacesException("Class " + type + " not found.", e); } }
/** * Lazy init cacheProvider. Not required if no cache component is used in the application. */ protected synchronized void initCacheProvider() { if (cacheProvider == null) { String cacheProviderConfigValue = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(Constants.ContextParams.CACHE_PROVIDER); if (cacheProviderConfigValue == null) { cacheProvider = new DefaultCacheProvider(); } else { try { cacheProvider = (CacheProvider) LangUtils.loadClassForName(cacheProviderConfigValue).newInstance(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { throw new FacesException(ex); } } } }
/** * Gets the {@link Class} from the {@link TagAttribute}. * * @param attribute The {@link TagAttribute}. * @param ctx The {@link FaceletContext}. * @return The {@link Class}. */ protected Class<?> getClassFromAttribute(TagAttribute attribute, FaceletContext ctx) { String type = attribute.getValue(ctx); try { return LangUtils.loadClassForName(type); } catch (ClassNotFoundException e) { throw new FacesException("Class " + type + " not found.", e); } }