static Configuration overwriteCacheManagerIfConfigured(final Configuration configuration, final Map properties) { if (properties != null) { final String cacheManagerName = (String) properties.get( EHCACHE_CONFIGURATION_CACHE_MANAGER_NAME ); if (cacheManagerName != null) { configuration.setName( cacheManagerName ); } } return configuration; }
/** * Build an EhCache {@link CacheManager} from the given configuration resource. * @param name the desired name of the cache manager * @param configLocation the location of the configuration file (as a Spring resource) * @return the new EhCache CacheManager * @throws CacheException in case of configuration parsing failure */ public static CacheManager buildCacheManager(String name, Resource configLocation) throws CacheException { Configuration configuration = parseConfiguration(configLocation); configuration.setName(name); return new CacheManager(configuration); }
/** * Build an EhCache {@link CacheManager} from the default configuration. * <p>The CacheManager will be configured from "ehcache.xml" in the root of the class path * (that is, default EhCache initialization - as defined in the EhCache docs - will apply). * If no configuration file can be found, a fail-safe fallback configuration will be used. * @param name the desired name of the cache manager * @return the new EhCache CacheManager * @throws CacheException in case of configuration parsing failure */ public static CacheManager buildCacheManager(String name) throws CacheException { Configuration configuration = ConfigurationFactory.parseConfiguration(); configuration.setName(name); return new CacheManager(configuration); }
static void setCacheManagerNameIfNeeded(SessionFactoryOptions settings, Configuration configuration, Map properties) { overwriteCacheManagerIfConfigured( configuration, properties ); if (configuration.getName() == null) { String sessionFactoryName = settings.getSessionFactoryName(); if (sessionFactoryName != null) { configuration.setName( sessionFactoryName ); } else { configuration.setName( "Hibernate " + settings.getUuid() ); } } }
/** * Build an EhCache {@link CacheManager} from the given configuration resource. * @param name the desired name of the cache manager * @param configLocation the location of the configuration file (as a Spring resource) * @return the new EhCache CacheManager * @throws CacheException in case of configuration parsing failure */ public static CacheManager buildCacheManager(String name, Resource configLocation) throws CacheException { Configuration configuration = parseConfiguration(configLocation); configuration.setName(name); return new CacheManager(configuration); }
/** * Build an EhCache {@link CacheManager} from the default configuration. * <p>The CacheManager will be configured from "ehcache.xml" in the root of the class path * (that is, default EhCache initialization - as defined in the EhCache docs - will apply). * If no configuration file can be found, a fail-safe fallback configuration will be used. * @param name the desired name of the cache manager * @return the new EhCache CacheManager * @throws CacheException in case of configuration parsing failure */ public static CacheManager buildCacheManager(String name) throws CacheException { Configuration configuration = ConfigurationFactory.parseConfiguration(); configuration.setName(name); return new CacheManager(configuration); }
EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration()); if (this.cacheManagerName != null) { configuration.setName(this.cacheManagerName);
EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration()); if (this.cacheManagerName != null) { configuration.setName(this.cacheManagerName);
/** * Builder to set the cache manager name. * <p> * Cache manager names have constraints on the characters they can use: * <ul> * <li>cache managers that are registered as MBeans must obey the {@link javax.management.ObjectName} rules for unquoted value. * This means the following characters are illegal: ',', '=', ':', '"', '*' and '?'.</li> * </ul> * Note that a clustered cache manager is by default registered as MBean. * * @see #setName(String) * @param name * the name to set * @return this configuration instance */ public final Configuration name(String name) { setName(name); return this; }
/** * Will overwrite the CacheManager name from the passed in configuration with the value of * net.sf.ehcache.hibernate.AbstractEhcacheRegionFactory#NET_SF_EHCACHE_CACHE_MANAGER_NAME of the passed in Properties * @param configuration the configuration * @param properties the properties passed in from Hibernate * @return the configuration object passed in, only for convenience */ static Configuration overwriteCacheManagerIfConfigured(final Configuration configuration, final Properties properties) { final String cacheManagerName = properties.getProperty(AbstractEhcacheRegionFactory.NET_SF_EHCACHE_CACHE_MANAGER_NAME); if (cacheManagerName != null) { configuration.setName(cacheManagerName); } return configuration; } }
private String convertConfigurationToXMLString(net.sf.ehcache.config.Configuration configuration, String cacheManagerName, boolean stripCacheConfigs) { net.sf.ehcache.config.Configuration targetConfiguration = cloneConfiguration(configuration); targetConfiguration.setName(cacheManagerName); if (stripCacheConfigs) { targetConfiguration.getCacheConfigurations().clear(); } return ConfigurationUtil.generateCacheManagerConfigurationText(targetConfiguration); }
/** * Builder to set the cache manager name. * * @see #setName(String) * @param name * the name to set * @return this configuration instance */ public final Configuration name(String name) { setName(name); return this; }
/** * Builder to set the cache manager name. * * @see #setName(String) * @param name * the name to set * @return this configuration instance */ public final Configuration name(String name) { setName(name); return this; }
static Configuration overwriteCacheManagerIfConfigured(final Configuration configuration, final Map properties) { if (properties != null) { final String cacheManagerName = (String) properties.get( EHCACHE_CONFIGURATION_CACHE_MANAGER_NAME ); if (cacheManagerName != null) { configuration.setName( cacheManagerName ); } } return configuration; }
/** * Will overwrite the CacheManager name from the passed in configuration with the value of * net.sf.ehcache.hibernate.AbstractEhcacheRegionFactory#NET_SF_EHCACHE_CACHE_MANAGER_NAME of the passed in Properties * @param configuration the configuration * @param properties the properties passed in from Hibernate * @return the configuration object passed in, only for convenience */ static Configuration overwriteCacheManagerIfConfigured(final Configuration configuration, final Properties properties) { final String cacheManagerName = properties.getProperty(AbstractEhcacheRegionFactory.NET_SF_EHCACHE_CACHE_MANAGER_NAME); if (cacheManagerName != null) { configuration.setName(cacheManagerName); } return configuration; } }
static void setCacheManagerNameIfNeeded(SessionFactoryOptions settings, Configuration configuration, Map properties) { overwriteCacheManagerIfConfigured( configuration, properties ); if (configuration.getName() == null) { String sessionFactoryName = settings.getSessionFactoryName(); if (sessionFactoryName != null) { configuration.setName( sessionFactoryName ); } else { configuration.setName( "Hibernate " + settings.getUuid() ); } } }
/** * Default no-args constructor. Creates the {@code scopeManager} by calling the factory method * {@link net.sf.ehcache.CacheManager#newInstance(net.sf.ehcache.config.Configuration)}, because we want a * separate {@code CacheManager}, not the singleton one, since we don't want to the tick() method of a cache * implementation to be called on a CacheManager that doesn't have {@link CacheItem}s. */ public EhCacheStoreAdapter() { Configuration scopeManagerConfig = ConfigurationFactory.parseConfiguration(); scopeManagerConfig.setName(SCOPE_MANAGER_NAME); scopeManager = CacheManager.newInstance(scopeManagerConfig); }
/** * Build an EhCache {@link CacheManager} from the given configuration resource. * @param name the desired name of the cache manager * @param configLocation the location of the configuration file (as a Spring resource) * @return the new EhCache CacheManager * @throws CacheException in case of configuration parsing failure */ public static CacheManager buildCacheManager(String name, Resource configLocation) throws CacheException { Configuration configuration = parseConfiguration(configLocation); configuration.setName(name); return new CacheManager(configuration); }
@Override public void afterPropertiesSet() throws IOException, CacheException { InputStream is = XmlMerger.merge(OA_XML_CONFIG_FILE, PROJECT_XML_CONFIG_FILE, servletContext); Configuration configuration = ConfigurationFactory.parseConfiguration(is); String path = System.getProperty("java.io.tmpdir") + servletContext.getContextPath() + "/ehcache"; configuration.addDiskStore(new DiskStoreConfiguration().path(path)); configuration.setName(configuration.getName() + servletContext.getContextPath() + UUID.randomUUID()); cacheManager = new CacheManager(configuration); createMBean(); }
private static CacheManager findDefaultCacheManager(String confName, URL configFileURL) { try { Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL); conf.setName(confName); if ("java.io.tmpdir".equals(conf.getDiskStoreConfiguration().getOriginalPath())) { String path = conf.getDiskStoreConfiguration().getPath() + File.separator + confName; conf.getDiskStoreConfiguration().setPath(path); } return createCacheManager(conf); } catch (Throwable t) { return null; } }