当前位置: 首页>>代码示例>>Java>>正文


Java EhCacheFactoryBean.getObject方法代码示例

本文整理汇总了Java中org.springframework.cache.ehcache.EhCacheFactoryBean.getObject方法的典型用法代码示例。如果您正苦于以下问题:Java EhCacheFactoryBean.getObject方法的具体用法?Java EhCacheFactoryBean.getObject怎么用?Java EhCacheFactoryBean.getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.cache.ehcache.EhCacheFactoryBean的用法示例。


在下文中一共展示了EhCacheFactoryBean.getObject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    this.blockingDhtCache = new BlockingDhtCache();

    EhCacheFactoryBean ehCacheFactoryBean = new EhCacheFactoryBean();
    ehCacheFactoryBean.setCacheName("unittest");
    ehCacheFactoryBean.afterPropertiesSet();
    this.cache = (Cache) ehCacheFactoryBean.getObject();
    this.blockingDhtCache.setCache(this.cache);
    this.dhtClientFactory = mock(DhtClientFactory.class);
    this.blockingDhtCache.setDhtClientFactory(this.dhtClientFactory);
    this.id = mock(PId.class);
    when(this.id.toStringFull()).thenReturn("" + System.currentTimeMillis());
    this.piEntity = mock(PiEntity.class);
    this.blockingReader = mock(BlockingDhtReader.class);
    when(this.dhtClientFactory.createBlockingReader()).thenReturn(this.blockingReader);
    this.blockingWriter = mock(BlockingDhtWriter.class);
    when(this.dhtClientFactory.createBlockingWriter()).thenReturn(this.blockingWriter);
}
 
开发者ID:barnyard,项目名称:pi,代码行数:20,代码来源:BlockingDhtCacheTest.java

示例2: testThatCacheDoesExpire

import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入方法依赖的package包/类
@Ignore("because this is just testing ehcache which hopefully works anyhow")
@Test
public void testThatCacheDoesExpire() throws Exception {
    // setup
    int ttl = 2;
    EhCacheFactoryBean ehCacheFactoryBean = new EhCacheFactoryBean();
    ehCacheFactoryBean.setCacheName("unittest1");
    ehCacheFactoryBean.setTimeToIdle(ttl);
    ehCacheFactoryBean.setTimeToLive(ttl);
    ehCacheFactoryBean.afterPropertiesSet();
    this.cache = (Cache) ehCacheFactoryBean.getObject();
    this.blockingDhtCache.setCache(this.cache);

    when(this.blockingReader.get(id)).thenReturn(piEntity);

    // act
    PiEntity result = this.blockingDhtCache.get(id);
    assertEquals(this.piEntity, result);
    Thread.sleep(ttl * 2 * 1000);

    result = this.blockingDhtCache.get(id);
    assertEquals(this.piEntity, result);

    // assert
    verify(this.blockingReader, times(2)).get(id);
}
 
开发者ID:barnyard,项目名称:pi,代码行数:27,代码来源:BlockingDhtCacheTest.java

示例3: ehcache

import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入方法依赖的package包/类
@Bean
public Ehcache ehcache(){
    EhCacheFactoryBean cacheFactoryBean = new EhCacheFactoryBean();
    cacheFactoryBean.setCacheManager(cacheManager());
    cacheFactoryBean.setCacheName("aclCache");
    cacheFactoryBean.setMaxBytesLocalHeap("1M");
    cacheFactoryBean.setMaxEntriesLocalHeap(0L);
    cacheFactoryBean.afterPropertiesSet();
    return cacheFactoryBean.getObject();
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:11,代码来源:AclConfig.java

示例4: aclCache

import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入方法依赖的package包/类
@Bean
EhCacheBasedAclCache aclCache() {
    EhCacheFactoryBean factoryBean = new EhCacheFactoryBean();
    EhCacheManagerFactoryBean cacheManager = new   EhCacheManagerFactoryBean();
    cacheManager.setAcceptExisting(true);
    cacheManager.setCacheManagerName(CacheManager.class.getName());
    cacheManager.afterPropertiesSet();

    factoryBean.setCacheName("aclCache");
    factoryBean.setCacheManager(cacheManager.getObject());
    //factoryBean.setMaxBytesLocalHeap("16M");
    //factoryBean.setMaxEntriesLocalHeap(0L);
    factoryBean.afterPropertiesSet();
    return new EhCacheBasedAclCache(factoryBean.getObject());
}
 
开发者ID:abixen,项目名称:abixen-platform,代码行数:16,代码来源:PlatformAclConfiguration.java

示例5: before

import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void before() throws Exception {
    EhCacheFactoryBean ehCacheFactoryBean = new EhCacheFactoryBean();
    ehCacheFactoryBean.setCacheName("unittest");
    ehCacheFactoryBean.afterPropertiesSet();
    this.cache = (Cache) ehCacheFactoryBean.getObject();

    id = mock(PId.class);

    continuation = new TestContinuation<PiEntity>();

    when(dhtClientFactory.createReader()).thenReturn(dhtReader);
    when(dhtClientFactory.createWriter()).thenReturn(dhtWriter);

    dhtPiEntityReadAnswer = new GenericContinuationAnswer<PiEntity>(dhtPiEntity);
    doAnswer(dhtPiEntityReadAnswer).when(dhtReader).getAsync(eq(id), isA(Continuation.class));

    dhtPiEntityUpdateAnswer = new UpdateResolvingContinuationAnswer(dhtPiEntity);
    doAnswer(dhtPiEntityUpdateAnswer).when(dhtWriter).update(eq(id), (PiEntity) any(), isA(UpdateResolvingPiContinuation.class));

    when(updateResolvingContinuation.update(isA(PiEntity.class), isA(PiEntity.class))).thenReturn(dhtPiEntity);

    dhtCache = new DhtCache();
    dhtCache.setCache(this.cache);
    dhtCache.setDhtClientFactory(dhtClientFactory);
}
 
开发者ID:barnyard,项目名称:pi,代码行数:28,代码来源:DhtCacheTest.java

示例6: GoCache

import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入方法依赖的package包/类
public GoCache(EhCacheFactoryBean ehCacheFactoryBean, TransactionSynchronizationManager transactionSynchronizationManager) {
    this((Cache) ehCacheFactoryBean.getObject(), transactionSynchronizationManager);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:4,代码来源:GoCache.java

示例7: setUp

import org.springframework.cache.ehcache.EhCacheFactoryBean; //导入方法依赖的package包/类
public void setUp(boolean isMockFile) throws Exception {
    if (isMockFile) {
        mockFile = mock(File.class);
        when(mockFile.exists()).thenReturn(true);
        when(mockFile.getFreeSpace()).thenReturn(1024 * 1024 * 1024L);
        systemResourceState = new SystemResourceState() {
            @Override
            protected File getFile(String instancePath) {
                return mockFile;
            }
        };
    } else
        systemResourceState = new SystemResourceState();

    libvirtManager = mock(LibvirtManager.class);
    systemResourceState.setLibvirtManager(libvirtManager);

    xenConfigurationParser = mock(XenConfigurationParser.class);
    systemResourceState.setXenConfigurationParser(xenConfigurationParser);

    mockNodeInfo = new NodeInfo();
    mockNodeInfo.cpus = 10;
    mockNodeInfo.memory = 2048 * 1024;

    domainInfo1 = new DomainInfo();
    domainInfo1.nrVirtCpu = 4;

    domainInfo2 = new DomainInfo();
    domainInfo2.nrVirtCpu = 2;

    mockDomain = mock(Domain.class);
    when(mockDomain.getInfo()).thenReturn(domainInfo1).thenReturn(domainInfo2);
    when(mockDomain.getMaxMemory()).thenReturn(768 * 1024L).thenReturn(256 * 1024L);

    setupLibvirtManagerExpectations(Arrays.asList(new Domain[] { mockDomain, mockDomain }));

    EhCacheFactoryBean ehCacheFactoryBean = new EhCacheFactoryBean();
    ehCacheFactoryBean.setCacheName("unittest");
    ehCacheFactoryBean.setTimeToIdle(cacheTTLSeconds);
    ehCacheFactoryBean.setTimeToLive(cacheTTLSeconds);
    ehCacheFactoryBean.afterPropertiesSet();
    this.cache = (Cache) ehCacheFactoryBean.getObject();

    systemResourceState.setCache(cache);
}
 
开发者ID:barnyard,项目名称:pi,代码行数:46,代码来源:SystemResourceStateTest.java


注:本文中的org.springframework.cache.ehcache.EhCacheFactoryBean.getObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。