Package net.sf.ehcache.config

Examples of net.sf.ehcache.config.Configuration


    protected static CacheManager CACHE_MANAGER;

    @BeforeClass
    public static void setUpGlobal() {
        final Configuration config = new Configuration();
        config.addDefaultCache(
                new CacheConfiguration("default", Integer.MAX_VALUE)
                    .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU)
                    .overflowToDisk(false));
        CACHE_MANAGER = CacheManager.create(config);
    }
View Full Code Here


    protected static CacheManager CACHE_MANAGER;

    @BeforeClass
    public static void setUpGlobal() {
        Configuration config = new Configuration();
        config.addDefaultCache(
                new CacheConfiguration("default", Integer.MAX_VALUE)
                    .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU)
                    .overflowToDisk(false));
        CACHE_MANAGER = CacheManager.create(config);
    }
View Full Code Here

    this.cacheManagerName = cacheManagerName;
  }

  public void afterPropertiesSet() throws IOException, CacheException {
    log.info("Initializing EHCache CacheManager");
    Configuration config = null;
    if (this.configLocation != null) {
      config = ConfigurationFactory
          .parseConfiguration(this.configLocation.getInputStream());
      if (this.diskStoreLocation != null) {
        DiskStoreConfiguration dc = new DiskStoreConfiguration();
        dc.setPath(this.diskStoreLocation.getFile().getAbsolutePath());
        try {
          config.addDiskStore(dc);
        } catch (ObjectExistsException e) {
          log.warn("if you want to config distStore in spring,"
              + " please remove diskStore in config file!", e);
        }
      }
View Full Code Here

          + " between repeated calls to buildSessionFactory. Using previously created EhCacheProvider."
          + " If this behaviour is required, consider using SingletonEhCacheProvider.";
      log.warn(s);
      return;
    }
    Configuration config = null;
    try {
      if (configLocation != null) {
        config = ConfigurationFactory.parseConfiguration(configLocation
            .getInputStream());
        if (this.diskStoreLocation != null) {
          DiskStoreConfiguration dc = new DiskStoreConfiguration();
          dc.setPath(this.diskStoreLocation.getFile()
              .getAbsolutePath());
          try {
            config.addDiskStore(dc);
          } catch (ObjectExistsException e) {
            String s = "if you want to config distStore in spring,"
                + " please remove diskStore in config file!";
            log.warn(s, e);
          }
View Full Code Here

      logger.warn("No configuration found; using defaults");
      return new CacheManager();
    }

    logger.info("Loading configuration from: {}", url);
    Configuration configuration = ConfigurationFactory.parseConfiguration(url);
    configuration.setUpdateCheck(false);
    return new CacheManager(configuration);
  }
View Full Code Here

      }
    }
    else {
      url = this.getClass().getResource( "/org/hibernate/ogm/datastore/ehcache/default-ehcache.xml" );
    }
    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

    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

  @SuppressWarnings("rawtypes")
  @Override
  public EhCacheCacheManager dynamicCacheManager() {
    EhCacheCacheManager cacheManager = new EhCacheCacheManager();
    Configuration cacheManagerConfig;
    InputStream inputStream = null;
    try {

      CoreLogger.LOGGER.info("In cluster mode.");
      inputStream = new ClassPathResource("ehcache-dist.xml").getInputStream();
      cacheManagerConfig = ConfigurationFactory.parseConfiguration(inputStream);
      FactoryConfiguration peerProviderConfig = new FactoryConfiguration();
      peerProviderConfig.setClass(RMICacheManagerPeerProviderFactory.class.getName());
      List<String> replicatedCacheNames = getReplicatedCacheNames(cacheManagerConfig);
      Pair<NetworkUtils.IPPortPair, String> properties = createManualDiscoveryCacheProperties(replicatedCacheNames);
      NetworkUtils.IPPortPair currentListener = properties.getFirst();
      String peerProperty = properties.getSecond();
      peerProviderConfig.setProperties(peerProperty);
      cacheManagerConfig.addCacheManagerPeerProviderFactory(peerProviderConfig);
      System.setProperty("java.rmi.server.hostname", currentListener.getFormattedIP());
      FactoryConfiguration peerListenerConfig = new FactoryConfiguration();
      peerListenerConfig.setClass(RMICacheManagerPeerListenerFactory.class.getName());
      String peerListenerProperty = String.format("hostName=%s, port=%d, socketTimeoutMillis=1000",
          currentListener.getFormattedIP(), currentListener.getPort());
      peerListenerConfig.setProperties(peerListenerProperty);
      cacheManagerConfig.addCacheManagerPeerListenerFactory(peerListenerConfig);
      CoreLogger.LOGGER.info("clusterURLs:{}", peerListenerProperty);
      cacheManagerConfig.setName("TestCluster");
      CacheManager mgr = CacheManager.create(cacheManagerConfig);
      cacheManager.setCacheManager(mgr);
    } catch (IOException e) {
      CoreLogger.LOGGER.error("Error while setting up cache", e);
    } finally {
View Full Code Here

   */
  @SuppressWarnings("rawtypes")
  @Bean(name = "cacheManager")
  public EhCacheCacheManager dynamicCacheManager() {
    EhCacheCacheManager cacheManager = new EhCacheCacheManager();
    Configuration cacheManagerConfig;
    InputStream inputStream = null;
    try {
      if (!isClustered()) {
        inputStream = new ClassPathResource("ehcache.xml").getInputStream();
        cacheManagerConfig = ConfigurationFactory.parseConfiguration(inputStream);
      } else {
        CoreLogger.LOGGER.info("In cluster mode.");
        inputStream = new ClassPathResource("ehcache-dist.xml").getInputStream();
        cacheManagerConfig = ConfigurationFactory.parseConfiguration(inputStream);
        Pair<FactoryConfiguration, NetworkUtils.IPPortPair> result =
            createRMICacheManagerPeerProviderFactory(cacheManagerConfig);
        cacheManagerConfig.addCacheManagerPeerProviderFactory(result.getFirst());
        cacheManagerConfig.addCacheManagerPeerListenerFactory(
            createPearListenerFactory(result.getSecond().getIP(), result.getSecond().getPort()));
      }
      cacheManagerConfig.setName(getCacheName());
      CacheManager mgr = CacheManager.create(cacheManagerConfig);
      cacheManager.setCacheManager(mgr);

    } catch (IOException e) {
      CoreLogger.LOGGER.error("Error while setting up cache", e);
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 CacheManager.create(conf);
        } catch (Throwable t) {
            return null;
        }
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.