Package net.sf.ehcache.config

Examples of net.sf.ehcache.config.Configuration


            // 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


*/
public class EHCacheUtilTest extends Assert {

    @Test
    public void testCreateCacheManager() {
        Configuration conf =
            ConfigurationFactory.parseConfiguration(EHCacheUtil.class.getResource("/cxf-test-ehcache.xml"));
           
        assertNotNull(conf);
        conf.setName("testCache");
       
        CacheManager manager1 = EHCacheUtil.createCacheManager(conf);
        assertNotNull(manager1);
        CacheManager manager2 = EHCacheUtil.createCacheManager();
        assertNotNull(manager2);
View Full Code Here

    }

    @Test
    public void factory() {
        assertEquals(3, new EhCacheGaugeFactory().gauges().length);
        new CacheManager(new Configuration().name("other"));
        assertEquals(6, new EhCacheGaugeFactory().gauges().length);
    }
View Full Code Here

*/
public class EHCacheManagerHolderTest extends Assert {

    @Test
    public void testCreateCacheManager() {
        Configuration conf =
            ConfigurationFactory.parseConfiguration(EHCacheManagerHolder.class.getResource("/cxf-test-ehcache.xml"));
           
        assertNotNull(conf);
        conf.setName("testCache");
       
        CacheManager manager1 = EHCacheManagerHolder.createCacheManager(conf);
        assertNotNull(manager1);
        CacheManager manager2 = EHCacheManagerHolder.createCacheManager();
        assertNotNull(manager2);
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

        CacheManagerFactory factory = new DefaultCacheManagerFactory();
        CacheManager manager = factory.getInstance();
        assertEquals(Status.STATUS_ALIVE, manager.getStatus());
       
        // create another unrelated cache manager
        Configuration conf =
            ConfigurationFactory.parseConfiguration(DefaultCacheManagerFactory.class.getResource("/test-ehcache.xml"));
        assertNotNull(conf);
        conf.setName("otherCache");
        CacheManager other = CacheManager.create(conf);
        assertEquals(Status.STATUS_ALIVE, other.getStatus());
       
        // shutdown this unrelated cache manager
        other.shutdown();
View Full Code Here

       
        // inputstream
        assertNotNull("create with inputstream", EHCacheUtil.createCacheManager(configURL.openStream()));
       
        // config
        Configuration conf = ConfigurationFactory.parseConfiguration(configURL);
        assertNotNull(conf);
        assertNotNull("create with configuration", EHCacheUtil.createCacheManager(conf));
    }
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().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 ) {
        final Configuration configuration = ConfigurationFactory.parseConfiguration();
        manager = new CacheManager( configuration );
      }
      else {
        final URL url = loadResource( configurationResourceName );
        final Configuration configuration = HibernateEhcacheUtils.loadAndCorrectConfiguration( url );
        manager = new CacheManager( configuration );
      }
      mbeanRegistrationHelper.registerMBean( manager, properties );
    }
    catch (net.sf.ehcache.CacheException 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 createCacheManager(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.