Package net.sf.ehcache.config

Examples of net.sf.ehcache.config.Configuration


    /**
     * initialises the CacheManager
     */
    protected void init(Configuration configuration, String configurationFileName, URL configurationURL,
                        InputStream configurationInputStream) {
        Configuration localConfiguration = configuration;
        if (configuration == null) {
            localConfiguration = parseConfiguration(configurationFileName, configurationURL, configurationInputStream);
        } else {
            localConfiguration.setSource("Programmatically configured.");
        }

        ConfigurationHelper configurationHelper = new ConfigurationHelper(this, localConfiguration);
        configure(configurationHelper);
        status = Status.STATUS_ALIVE;
View Full Code Here


     * @throws CacheException if the configuration cannot be parsed
     */
    private synchronized Configuration parseConfiguration(String configurationFileName, URL configurationURL,
                                                          InputStream configurationInputStream) throws CacheException {
        reinitialisationCheck();
        Configuration configuration;
        String configurationSource;
        if (configurationFileName != null) {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.log(Level.FINE, "Configuring CacheManager from " + configurationFileName);
            }
            configuration = ConfigurationFactory.parseConfiguration(new File(configurationFileName));
            configurationSource = "file located at " + configurationFileName;
        } else if (configurationURL != null) {
            configuration = ConfigurationFactory.parseConfiguration(configurationURL);
            configurationSource = "URL of " + configurationURL;
        } else if (configurationInputStream != null) {
            configuration = ConfigurationFactory.parseConfiguration(configurationInputStream);
            configurationSource = "InputStream " + configurationInputStream;
        } else {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.log(Level.FINE, "Configuring ehcache from classpath.");
            }
            configuration = ConfigurationFactory.parseConfiguration();
            configurationSource = "classpath";
        }
        configuration.setSource(configurationSource);
        return configuration;

    }
View Full Code Here

   * @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);
  }
View Full Code Here

   * @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);
  }
View Full Code Here


  @Override
  public void afterPropertiesSet() throws CacheException {
    logger.info("Initializing EhCache CacheManager");
    Configuration configuration = (this.configLocation != null ?
        EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration());
    if (this.cacheManagerName != null) {
      configuration.setName(this.cacheManagerName);
    }
    if (this.shared) {
      // Old-school EhCache singleton sharing...
      // No way to find out whether we actually created a new CacheManager
      // or just received an existing singleton reference.
View Full Code Here

  private Ehcache nativeCache;
  private EhCacheCache cache;

  @Before
  public void setUp() {
    cacheManager = new CacheManager(new Configuration().name("EhCacheCacheTests")
        .defaultCache(new CacheConfiguration("default", 100)));
    nativeCache = new net.sf.ehcache.Cache(new CacheConfiguration(CACHE_NAME, 100));
    cacheManager.addCache(nativeCache);

    cache = new EhCacheCache(nativeCache);
View Full Code Here

  private EhCacheCacheManager cacheManager;
  private EhCacheCacheManager transactionalCacheManager;

  @Before
  public void setup() {
    nativeCacheManager = new CacheManager(new Configuration().name("EhCacheCacheManagerTests")
        .defaultCache(new CacheConfiguration("default", 100)));
    addNativeCache(CACHE_NAME);

    cacheManager = new EhCacheCacheManager(nativeCacheManager);
    cacheManager.setTransactionAware(false);
View Full Code Here

          // No CacheManager.create(Configuration) method available before EhCache 2.1;
          // can only set CacheManager name after creation.
          this.cacheManager = (is != null ? CacheManager.create(is) : CacheManager.create());
          this.cacheManager.setName(this.cacheManagerName);
        } else {
          Configuration configuration = (is != null ? ConfigurationFactory.parseConfiguration(is) :
              ConfigurationFactory.parseConfiguration());
          configuration.setName(this.cacheManagerName);
          if (this.shared) {
            this.cacheManager = (CacheManager) ReflectionUtils.invokeMethod(createWithConfiguration, null, configuration);
          } else {
            this.cacheManager = new CacheManager(configuration);
          }
View Full Code Here

   * @param url The url to load the config from
   *
   * @return The Ehcache Configuration object
   */
  public static Configuration loadAndCorrectConfiguration(URL url) {
    final Configuration config = ConfigurationFactory.parseConfiguration( url );
    if ( config.getDefaultCacheConfiguration().isTerracottaClustered() ) {
      if ( ValueMode.IDENTITY
          .equals( config.getDefaultCacheConfiguration().getTerracottaConfiguration().getValueMode() ) ) {
        LOG.incompatibleCacheValueMode();
        config.getDefaultCacheConfiguration()
            .getTerracottaConfiguration()
            .setValueMode( ValueMode.SERIALIZATION.name() );
      }
      setupHibernateTimeoutBehavior(
          config.getDefaultCacheConfiguration()
              .getTerracottaConfiguration()
              .getNonstopConfiguration()
      );
    }

    for ( CacheConfiguration cacheConfig : config.getCacheConfigurations().values() ) {
      if ( cacheConfig.isTerracottaClustered() ) {
        if ( ValueMode.IDENTITY.equals( cacheConfig.getTerracottaConfiguration().getValueMode() ) ) {
          LOG.incompatibleCacheValueModePerCache( cacheConfig.getName() );
          cacheConfig.getTerracottaConfiguration().setValueMode( ValueMode.SERIALIZATION.name() );
        }
View Full Code Here

    this.jtaPlatform = serviceRegistryImplementor.getService( JtaPlatform.class );
  }

  @Override
  public void start() {
    final Configuration configuration = ConfigurationFactory.parseConfiguration( config.getUrl() );
    if ( jtaPlatform != null ) {
      OgmTransactionManagerLookupDelegate.transactionManager = jtaPlatform.retrieveTransactionManager();
      final FactoryConfiguration transactionManagerLookupParameter = new FactoryConfiguration();
      transactionManagerLookupParameter.setClass( OgmTransactionManagerLookupDelegate.class.getName() );
      configuration.addTransactionManagerLookup( transactionManagerLookupParameter );
    }
    cacheManager = CacheManager.create( config.getUrl() );

    entityCache = new Cache<SerializableKey>( cacheManager.getCache( DefaultDatastoreNames.ENTITY_STORE ) );
    associationCache = new Cache<SerializableKey>( cacheManager.getCache( DefaultDatastoreNames.ASSOCIATION_STORE ) );
View Full Code Here

TOP

Related Classes of net.sf.ehcache.config.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.