protected FaceletFactory createFaceletFactory(Compiler c, WebConfiguration webConfig) { // refresh period String refreshPeriod = webConfig.getOptionValue(FaceletsDefaultRefreshPeriod); long period = Long.parseLong(refreshPeriod); // resource resolver ResourceResolver resolver = new DefaultResourceResolver(); String resolverName = webConfig.getOptionValue(FaceletsResourceResolver); if (resolverName != null && resolverName.length() > 0) { resolver = (ResourceResolver) ReflectionUtil.decorateInstance(resolverName, ResourceResolver.class, resolver); } FaceletCache cache = null; String faceletCacheName = webConfig.getOptionValue(FaceletCache); if (faceletCacheName != null && faceletCacheName.length() > 0) { try { com.sun.faces.facelets.FaceletCache privateApiCache = (com.sun.faces.facelets.FaceletCache) ReflectionUtil.forName(faceletCacheName).newInstance(); cache = new PrivateApiFaceletCacheAdapter(privateApiCache); } catch (Exception e) { if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.log(Level.SEVERE, "Error Loading Facelet cache: " + faceletCacheName, e); } } } if (null == cache) { FaceletCacheFactory cacheFactory = (FaceletCacheFactory) FactoryFinder.getFactory(FactoryFinder.FACELET_CACHE_FACTORY); cache = cacheFactory.getFaceletCache(); } // Resource.getResourceUrl(ctx,"/") FaceletFactory factory = new DefaultFaceletFactory(c, resolver, period, cache); // Check to see if a custom Factory has been defined String factoryClass = webConfig.getOptionValue(FaceletFactory); if (factoryClass != null && factoryClass.length() > 0) { factory = (FaceletFactory) ReflectionUtil.decorateInstance(factoryClass, FaceletFactory.class, factory); } return factory; }
@Override public Class getPropertyType(String name) { PropertyDescriptor compDescriptor = findDescriptor(name); if (compDescriptor != null) { // composite:attribute declaration... ValueExpression typeVE = (ValueExpression) compDescriptor.getValue("type"); if (typeVE == null) { return Object.class; } else { String className = (String) typeVE.getValue(FacesContext.getCurrentInstance().getELContext()); if (className != null) { className = prefix(className); try { return ReflectionUtil.forName(className); } catch (ClassNotFoundException cnfe) { throw new FacesException(cnfe); } } else { return Object.class; } } } else { // defer to the default processing which will inspect the // PropertyDescriptor of the UIComponent type return super.getPropertyType(name); } }
@Override public Object getValue(String attributeName) { Object result = super.getValue(attributeName); if ("type".equals(attributeName)) { if ((null != result) && !(result instanceof Class)) { FacesContext context = FacesContext.getCurrentInstance(); ELContext elContext = context.getELContext(); String classStr = (String) ((ValueExpression) result).getValue(elContext); if (null != classStr) { try { result = ReflectionUtil.forName(classStr); this.setValue(attributeName, result); } catch (ClassNotFoundException ex) { classStr = "java.lang." + classStr; boolean throwException = false; try { result = ReflectionUtil.forName(classStr); this.setValue(attributeName, result); } catch (ClassNotFoundException ex2) { throwException = true; } if (throwException) { String message = "Unable to obtain class for " + classStr; if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, message, ex); } throw new TagAttributeException(tag, name, message, ex); } } } } } return result; }
protected Compiler createCompiler(WebConfiguration webConfig) { Compiler c = new SAXCompiler(); // load decorators String decParam = webConfig.getOptionValue(FaceletsDecorators); if (decParam != null) { decParam = decParam.trim(); String[] decs = Util.split(decParam, ";"); TagDecorator decObj; for (String decorator : decs) { try { decObj = (TagDecorator) ReflectionUtil.forName(decorator).newInstance(); c.addTagDecorator(decObj); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Successfully Loaded Decorator: {0}", decorator); } } catch (Exception e) { if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.log(Level.SEVERE, "Error Loading Decorator: " + decorator, e); } } } } // skip params? c.setTrimmingComments( webConfig.isOptionEnabled(BooleanWebContextInitParameter.FaceletsSkipComments)); c.addTagLibrary(new CoreLibrary()); c.addTagLibrary(new HtmlLibrary()); c.addTagLibrary(new UILibrary()); c.addTagLibrary(new JstlCoreLibrary()); c.addTagLibrary( new FunctionLibrary(JstlFunction.class, "http://java.sun.com/jsp/jstl/functions")); if (isDevModeEnabled()) { c.addTagLibrary( new FunctionLibrary(DevTools.class, "http://java.sun.com/mojarra/private/functions")); } c.addTagLibrary(new CompositeLibrary()); c.addTagLibrary(new XmlLibrary()); return c; }
protected Compiler createCompiler(WebConfiguration webConfig) { Compiler c = new SAXCompiler(); // load decorators String decParam = webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.FaceletsDecorators); if (decParam != null) { decParam = decParam.trim(); String[] decs = Util.split(decParam, ";"); TagDecorator decObj; for (int i = 0; i < decs.length; i++) { try { decObj = (TagDecorator) ReflectionUtil.forName(decs[i]).newInstance(); c.addTagDecorator(decObj); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Successfully Loaded Decorator: {0}", decs[i]); } } catch (Exception e) { if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.log(Level.SEVERE, "Error Loading Decorator: " + decs[i], e); } } } } // skip params? c.setTrimmingComments( webConfig.isOptionEnabled(BooleanWebContextInitParameter.FaceletsSkipComments)); c.addTagLibrary(new CoreLibrary()); c.addTagLibrary(new HtmlLibrary()); c.addTagLibrary(new UILibrary()); c.addTagLibrary(new JstlCoreLibrary()); c.addTagLibrary(new JstlFnLibrary()); c.addTagLibrary(new CompositeLibrary()); return c; }
protected FaceletFactory createFaceletFactory(Compiler c, WebConfiguration webConfig) { // refresh period String refreshPeriod = webConfig.getOptionValue( WebConfiguration.WebContextInitParameter.FaceletsDefaultRefreshPeriod); long period = Long.parseLong(refreshPeriod); // resource resolver ResourceResolver resolver = new DefaultResourceResolver(); String resolverName = webConfig.getOptionValue(WebConfiguration.WebContextInitParameter.FaceletsResourceResolver); if (resolverName != null && resolverName.length() > 0) { try { resolver = (ResourceResolver) ReflectionUtil.forName(resolverName).newInstance(); } catch (Exception e) { throw new FacesException("Error Initializing ResourceResolver[" + resolverName + "]", e); } } // Resource.getResourceUrl(ctx,"/") return new DefaultFaceletFactory(c, resolver, period); }