use of jakarta.faces.view.facelets.FaceletCache in project mojarra by eclipse-ee4j.
the class DefaultFaceletFactory method init.
public final void init(FacesContext facesContext, Compiler compiler, DefaultResourceResolver resolver, long refreshPeriod, FaceletCache cache) {
notNull("compiler", compiler);
notNull("resolver", resolver);
ExternalContext externalContext = facesContext.getExternalContext();
WebConfiguration config = WebConfiguration.getInstance(externalContext);
this.compiler = compiler;
cachePerContract = new ConcurrentHashMap<>();
this.resolver = resolver;
baseUrl = resolver.resolveUrl("/");
this.idMappers = config.isOptionEnabled(UseFaceletsID) ? null : new Cache<>(new IdMapperFactory());
refreshPeriod = refreshPeriod >= 0 ? refreshPeriod * 1000 : -1;
this.refreshPeriod = refreshPeriod;
if (log.isLoggable(Level.FINE)) {
log.log(Level.FINE, "Using ResourceResolver: {0}", resolver);
log.log(Level.FINE, "Using Refresh Period: {0}", refreshPeriod);
}
// We can cast to the FaceletCache<DefaultFacelet> here because we know
// that the Generics information is only used at compile time, and all cache
// implementations will be using instance factories provided by us and returning DefaultFacelet
this.cache = initCache(cache);
}
use of jakarta.faces.view.facelets.FaceletCache in project mojarra by eclipse-ee4j.
the class DefaultFaceletFactory method initCache.
// ---------------------------------------------------------- Private Methods
private FaceletCache<DefaultFacelet> initCache(FaceletCache<DefaultFacelet> cache) {
if (cache == null) {
FaceletCacheFactory cacheFactory = (FaceletCacheFactory) FactoryFinder.getFactory(FactoryFinder.FACELET_CACHE_FACTORY);
cache = cacheFactory.getFaceletCache();
}
// Create instance factories for the cache, so that the cache can
// create Facelets and Metadata Facelets
FaceletCache.MemberFactory<DefaultFacelet> faceletFactory = key -> createFacelet(key);
FaceletCache.MemberFactory<DefaultFacelet> metadataFaceletFactory = key -> createMetadataFacelet(key);
cache.setCacheFactories(faceletFactory, metadataFaceletFactory);
return cache;
}
Aggregations