Package net.sf.ehcache.config

Examples of net.sf.ehcache.config.Configuration


    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<SerializableEntityKey>( cacheManager.getCache( CacheNames.ENTITY_CACHE ) );
    associationCache = new Cache<SerializableAssociationKey>( cacheManager.getCache( CacheNames.ASSOCIATION_CACHE ) );
View Full Code Here


            LOG.warn( "cache service was already initialized and is alive" );
            initialized = true;
            return;
        }

        Configuration cc;
        String cachePath = null;

        if ( layout != null )
        {
            File configFile = new File( layout.getConfDirectory(), DIRECTORY_CACHESERVICE_XML );

            if ( !configFile.exists() )
            {
                LOG.info( "no custom cache configuration was set, loading the default cache configuration" );
                cc = ConfigurationFactory.parseConfiguration( getClass().getClassLoader().getResource(
                    DIRECTORY_CACHESERVICE_XML ) );
            }
            else
            {
                LOG.info( "loading cache configuration from the file {}", configFile );

                cc = ConfigurationFactory.parseConfiguration( configFile );
            }

            cachePath = layout.getCacheDirectory().getAbsolutePath();
        }
        else
        {
            LOG.info( "no custom cache configuration was set, loading the default cache configuration" );
            cc = ConfigurationFactory.parseConfiguration( getClass().getClassLoader().getResource(
                DIRECTORY_CACHESERVICE_XML ) );

            cachePath = FileUtils.getTempDirectoryPath();
        }

        cc.getDiskStoreConfiguration().setPath( cachePath );
        cacheManager = new CacheManager( cc );

        initialized = true;
    }
View Full Code Here

                cacheManager = CacheManager.getCacheManager( getName() );
            }
        }
        else
        {
            this.cacheManager = new CacheManager( new Configuration().name( getName() ).diskStore(
                new DiskStoreConfiguration().path( getDiskStorePath() ) ) );
        }

        boolean cacheExists = cacheManager.cacheExists( getName() );
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

            // ignore
        }
        if (configFileURL == null) {
            cacheManager = EHCacheUtil.createCacheManager();
        } else {
            Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL);
           
            if (cxfBus != null) {
                conf.setName(cxfBus.getId());
                DiskStoreConfiguration dsc = conf.getDiskStoreConfiguration();
                if (dsc != null && "java.io.tmpdir".equals(dsc.getOriginalPath())) {
                    String path = conf.getDiskStoreConfiguration().getPath() + File.separator
                        + cxfBus.getId();
                    conf.getDiskStoreConfiguration().setPath(path);
                }
            }
           
            cacheManager = EHCacheUtil.createCacheManager(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

                                configurationResourceName
                        );
                    }
                    url = loadResource( configurationResourceName );
                }
                Configuration configuration = HibernateUtil.loadAndCorrectConfiguration( url );
                manager = CacheManager.create( configuration );
                REFERENCE_COUNT.incrementAndGet();
            }
            mbeanRegistrationHelper.registerMBean( manager, properties );
        }
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 );
        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

            String configurationResourceName = null;
            if ( properties != null ) {
                configurationResourceName = (String) properties.get( NET_SF_EHCACHE_CONFIGURATION_RESOURCE_NAME );
            }
            if ( configurationResourceName == null || configurationResourceName.length() == 0 ) {
                Configuration configuration = ConfigurationFactory.parseConfiguration();
                manager = new CacheManager( configuration );
            }
            else {
                URL url;
                try {
                    url = new URL( configurationResourceName );
                }
                catch ( MalformedURLException e ) {
                    url = loadResource( configurationResourceName );
                }
                Configuration configuration = HibernateUtil.loadAndCorrectConfiguration( url );
                manager = new CacheManager( configuration );
            }
            mbeanRegistrationHelper.registerMBean( manager, properties );
        }
        catch ( net.sf.ehcache.CacheException e ) {
View Full Code Here

            // ignore
        }
        if (configFileURL == null) {
            cacheManager = EHCacheUtil.createCacheManager();
        } 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 = EHCacheUtil.createCacheManager(conf);
        }
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.