public EhCacheCacheFactory() { super(); URL configUrl = null; ClassLoader ccl = Thread.currentThread().getContextClassLoader(); if (ccl != null) { configUrl = ccl.getResource("ehcache.xml"); } if (configUrl != null) { LOG.info(MessageFormat.format("Using cache configuration: {0}", configUrl.toExternalForm())); } else { configUrl = EhCacheCacheFactory.class.getResource("ehcache-failsafe-richfaces.xml"); LOG.info(MessageFormat.format("Using default cache configuration: {0}", configUrl.toExternalForm())); } cacheManager = CacheManager.create(configUrl); }
public Cache createCache(FacesContext facesContext, String cacheName, Map<?, ?> env) { // TODO - handle cache name LOG.info("Creating LRUMap cache instance using parameters: " + env); Integer cacheSize = getIntConfigurationValue(facesContext, CoreConfiguration.Items.lruMapCacheSize); if (cacheSize == null) { cacheSize = getIntConfigurationValue(facesContext, CoreConfiguration.Items.resourcesCacheSize); } LOG.info("Creating LRUMap cache instance of " + cacheSize + " items capacity"); return new LRUMapCache(cacheSize); }
LOG.info(MessageFormat.format("Configured to use [{0}] cache factory", configuredFactoryName)); factories = new String[] { configuredFactoryName }; } else { Class<?> spiClass = Class.forName(factoryName, true, loader); cacheFactory = CacheFactory.class.cast(spiClass.newInstance()); LOG.info(MessageFormat.format("Selected [{0}]", factoryName)); break; } catch (LinkageError iae) { LOG.info("Selected fallback cache factory");
/** * Initializes {@link org.richfaces.application.push.PushContext} on startup as it is a time when {@link FacesContext} is available */ private void initializePushContext() { try { LOGGER.info("Startup initialization of PushContext"); ServiceTracker.getService(PushContextFactory.class).getPushContext(); } catch (Exception e) { LOGGER.error(MessageFormat.format("There were problems initializing PushContext on startup: {0}", e.getMessage())); } }
private static void registerServlet(ServletContext context) { Dynamic dynamicRegistration = context.addServlet("AutoRegisteredResourceServlet", ResourceServlet.class); dynamicRegistration.addMapping(RICHFACES_RESOURCES_DEFAULT_MAPPING); if (LOGGER.isInfoEnabled()) { LOGGER.info("Auto-registered servlet " + ResourceServlet.class.getSimpleName() + " with mapping '" + RICHFACES_RESOURCES_DEFAULT_MAPPING + "'"); } } }
public Cache createCache(FacesContext facesContext, String cacheName, Map<?, ?> env) { // TODO - handle cache name Properties cacheProperties = new Properties(); try { cacheProperties.putAll(loadProperties()); } catch (IOException e) { throw new FacesException(e.getMessage(), e); } try { cacheProperties.putAll(loadProperties()); } catch (IOException e) { throw new FacesException(e.getMessage(), e); } cacheProperties.putAll(env); LOG.info("Creating OSCache cache instance using parameters: " + cacheProperties); String property = cacheProperties.getProperty(AbstractCacheAdministrator.CACHE_CAPACITY_KEY); if (property == null) { int maxCacheSize = getIntConfigurationValue(facesContext, CoreConfiguration.Items.resourcesCacheSize); LOG.info(MessageFormat.format("Maximum cache size hasn''t been set, resetting to {0} max items", maxCacheSize)); cacheProperties.put(AbstractCacheAdministrator.CACHE_CAPACITY_KEY, Integer.toString(maxCacheSize)); } GeneralCacheAdministrator cacheAdministrator = new GeneralCacheAdministrator(cacheProperties); cacheAdministrators.add(cacheAdministrator); return new OSCacheCache(cacheAdministrator.getCache()); }
/** * Uses dynamic servlet registartaion for registering PushServlet automatically */ private static void registerPushServlet(ServletContext context) { Dynamic dynamicRegistration = context.addServlet("AutoRegisteredPushServlet", PushServlet.class); dynamicRegistration.addMapping(PUSH_CONTEXT_DEFAULT_MAPPING); dynamicRegistration.setAsyncSupported(true); if (LOGGER.isInfoEnabled()) { LOGGER.info("Auto-registered servlet " + PushServlet.class.getSimpleName() + " with mapping '" + PUSH_CONTEXT_DEFAULT_MAPPING + "'"); } }
private void logResourceProblem(FacesContext context, Throwable throwable, String messagePattern, Object... arguments) { boolean isProductionStage = context.isProjectStage(ProjectStage.Production); if (LOGGER.isWarnEnabled() || (!isProductionStage && LOGGER.isInfoEnabled())) { String formattedMessage = MessageFormat.format(messagePattern, arguments); if (throwable != null) { LOGGER.warn(formattedMessage, throwable); } else { if (isProductionStage) { LOGGER.info(formattedMessage); } else { LOGGER.warn(formattedMessage); } } } }
public Cache createCache(FacesContext facesContext, String cacheName, Map<?, ?> env) { LOG.info("Creating EhCache cache instance"); int maxCacheSize = getIntConfigurationValue(facesContext, CoreConfiguration.Items.resourcesCacheSize); boolean preconfiguredCache = false; Ehcache ehcache = cacheManager.getEhcache(cacheName); if (ehcache == null) { ehcache = new net.sf.ehcache.Cache(cacheName, maxCacheSize, false, true, 0, 0); } else { preconfiguredCache = true; if (ehcache.getCacheConfiguration().getMaxElementsInMemory() <=0) { LOG.info(MessageFormat.format("Maximum cache size hasn''t been set, resetting to {0} max items", maxCacheSize)); ehcache.getCacheConfiguration().setMaxElementsInMemory(maxCacheSize); } } ehcache.setCacheManager(cacheManager); return new EhCacheCache(ehcache, preconfiguredCache); }
private void setupMaxSizeEviction(FacesContext facesContext, Cache<String, Object> cache) { EvictionConfig evictionConfig = cache.getConfiguration().getEvictionConfig(); EvictionAlgorithmConfig evictionAlgorithmConfig = evictionConfig.getDefaultEvictionRegionConfig() .getEvictionAlgorithmConfig(); if (evictionAlgorithmConfig instanceof EvictionAlgorithmConfigBase) { EvictionAlgorithmConfigBase baseEvicitonConfig = (EvictionAlgorithmConfigBase) evictionAlgorithmConfig; if (baseEvicitonConfig.getMaxNodes() <= 0) { int maxCacheSize = getIntConfigurationValue(facesContext, CoreConfiguration.Items.resourcesCacheSize); LOG.info(MessageFormat.format("Maximum cache size hasn''t been set, resetting to {0} max items", maxCacheSize)); baseEvicitonConfig.setMaxNodes(maxCacheSize); } } }
} else { if (!ctx.isProjectStage(ProjectStage.Production)) { LOGGER.info(MessageFormat.format(NULL_STYLESHEET, getLibraryName(), getResourceName()));
log.info(MessageFormat.format("Skipping {0} because it contains EL-expressions", resourceKey)); return;
/** * Called on application startup */ protected void onStart() { JsfVersionInspector enforcer = new JsfVersionInspector(); if (!enforcer.verifyJsfImplVersion()) { throw new RuntimeException(String.format("The JSF implementation %s does not support the RichFaces ExtendedPartialViewContext. Please upgrade to at least Mojarra 2.1.28 or 2.2.6", enforcer.getVersionString())); } createFactory(); if (LOGGER.isInfoEnabled()) { String versionString = VersionBean.VERSION.toString(); if (versionString != null && versionString.length() != 0) { LOGGER.info(versionString); } } if (getConfiguration(executeAWTInitializer)) { initializeAWT(); } boolean jmsEnabled = getConfiguration(pushJMSEnabled) != null && getConfiguration(pushJMSEnabled); if (jmsEnabled || getConfiguration(pushInitializePushContextOnStartup)) { initializePushContext(); } if (getConfiguration(pushJMSEnabled) == null) { logWarningWhenConnectionFactoryPresent(); } }