Package net.sf.ehcache.config

Examples of net.sf.ehcache.config.Configuration


            // ignore
        }
        if (configFileURL == null) {
            cacheManager = CacheManager.create();
        } else {
            Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
           
            if (bus != null) {
                conf.setName(bus.getId());
                DiskStoreConfiguration dsc = conf.getDiskStoreConfiguration();
                if (dsc != null && "java.io.tmpdir".equals(dsc.getOriginalPath())) {
                    String path = conf.getDiskStoreConfiguration().getPath() + File.separator
                        + bus.getId();
                    conf.getDiskStoreConfiguration().setPath(path);
                }
            }
           
            cacheManager = CacheManager.create(conf);
        }
View Full Code Here


   
    private void createCache(String key, URL configFileURL) {
        if (configFileURL == null) {
            cacheManager = CacheManager.create();
        } else {
            Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
            cacheManager = CacheManager.create(conf);
        }
       
        CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(key, cacheManager);
       
View Full Code Here

     * Create a cache manager configuration from the supplied url, correcting it for Hibernate compatibility.
     * <p/>
     * Currently correcting for Hibernate compatibility means simply switching any identity based value modes to serialization.
     */
    public static Configuration loadAndCorrectConfiguration(URL url) {
        Configuration config = ConfigurationFactory.parseConfiguration( url );
       
        // EHC-875 / HHH-6576
     if ( config == null ) {
       return null;
     }
       
     if ( config.getDefaultCacheConfiguration() != null
        && 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

      }
    }
    else {
      url = this.getClass().getResource( Environment.DEFAULT_CONFIG );
    }
    final Configuration configuration = ConfigurationFactory.parseConfiguration( url );
    if ( jtaPlatform != null ) {
      OgmTransactionManagerLookupDelegate.transactionManager = jtaPlatform.retrieveTransactionManager();
      final FactoryConfiguration transactionManagerLookupParameter = new FactoryConfiguration();
      transactionManagerLookupParameter.setClass( OgmTransactionManagerLookupDelegate.class.getName() );
      configuration.addTransactionManagerLookup( transactionManagerLookupParameter );
    }
    cacheManager = CacheManager.create( url );
  }
View Full Code Here

            }
        } catch (IOException e) {
            // Do nothing
        }
        try {
            Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
            /*
            String perBus = (String)bus.getProperty("ws-security.cachemanager.per.bus");
            if (perBus == null) {
                perBus = "true";
            }
            if (Boolean.parseBoolean(perBus)) {
            */
            conf.setName(busId);
            if ("java.io.tmpdir".equals(conf.getDiskStoreConfiguration().getOriginalPath())) {
                String path = conf.getDiskStoreConfiguration().getPath() + File.separator
                    + busId;
                conf.getDiskStoreConfiguration().setPath(path);
            }
            return createCacheManager(conf);
        } catch (Throwable t) {
            return null;
        }
View Full Code Here

   
    private void createCache(String key, URL configFileURL) {
        if (configFileURL == null) {
            cacheManager = CacheManager.create();
        } else {
            Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
            cacheManager = CacheManager.create(conf);
        }
       
        CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(key, cacheManager);
       
View Full Code Here

    // log.debug("Appcontext: " + applicationContext.toString());
    try {
      // instance the manager
      CacheManager cm = CacheManager.getInstance();
      // Use the Configuration to create our caches
      Configuration configuration = new Configuration();
      //set initial default cache name
      String defaultCacheName = Cache.DEFAULT_CACHE_NAME;
      //add the configs to a configuration
      for (CacheConfiguration conf : configs) {
        //set disk expiry
        conf.setDiskExpiryThreadIntervalSeconds(diskExpiryThreadIntervalSeconds);
        //set eviction policy
        conf.setMemoryStoreEvictionPolicy(memoryStoreEvictionPolicy);
        if (null == cache) {
          //get first cache name and use as default
          defaultCacheName = conf.getName();
          configuration.addDefaultCache(conf);
        } else {
          configuration.addCache(conf);
        }
      }
      //instance the helper
      ConfigurationHelper helper = new ConfigurationHelper(cm, configuration);
      //create the default cache
View Full Code Here

            }
        } catch (IOException e) {
            // Do nothing
        }
        try {
            Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
            /*
            String perBus = (String)bus.getProperty("ws-security.cachemanager.per.bus");
            if (perBus == null) {
                perBus = "true";
            }
            if (Boolean.parseBoolean(perBus)) {
            */
            conf.setName(bus.getId());
            if ("java.io.tmpdir".equals(conf.getDiskStoreConfiguration().getOriginalPath())) {
                String path = conf.getDiskStoreConfiguration().getPath() + File.separator
                    + bus.getId();
                conf.getDiskStoreConfiguration().setPath(path);
            }
            return createCacheManager(conf);
        } catch (Throwable t) {
            return null;
        }
View Full Code Here

    try {
      CacheManager cacheManager = CacheManager.create(resource.getInputStream());
     
      cache = cacheManager.getCache(CACHE_NAME);
      if (cache == null) {
        Configuration configuration = ConfigurationFactory.parseConfiguration(resource.getInputStream());
       
        cache = new Cache(configuration.getCacheConfigurations().get(CACHE_NAME));
        if (cache == null) {
          cache = cacheManager.getCache(Cache.DEFAULT_CACHE_NAME);
        } else {
          cacheManager.addCache(cache);
        }
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.