use of com.tangosol.net.NamedCache in project radargun by radargun.
the class Coherence3Service method stop.
@Override
public synchronized void stop() {
for (NamedCache nc : caches.values()) {
releaseCache(nc);
}
caches.clear();
CacheFactory.shutdown();
try {
Field ssField = MultiProviderSelectionService.class.getDeclaredField("m_mapServices");
ssField.setAccessible(true);
ConcurrentMap<SelectorProvider, SelectionService> selectionServices = (ConcurrentMap<SelectorProvider, SelectionService>) ssField.get(SelectionServices.getDefaultService());
for (SelectionService ss : selectionServices.values()) {
ss.shutdown();
}
} catch (Exception e) {
log.error("Failed to shutdown selection services", e);
}
started = false;
synchronized (this) {
membershipHistory.add(Membership.empty());
}
log.info("Cache factory was shut down.");
}
use of com.tangosol.net.NamedCache in project coherence-spring by coherence-community.
the class CoherenceNamedCacheConfigurationTests method shouldInjectSuperTypeCacheMap.
@Test
void shouldInjectSuperTypeCacheMap() {
SuperTypesBean bean = this.ctx.getBean(SuperTypesBean.class);
CacheMap map = bean.getCacheMap();
NamedCache cache = bean.getNamedCache();
assertThat(map, is(notNullValue()));
assertThat(cache, is(notNullValue()));
assertThat(map, is(sameInstance(cache)));
}
use of com.tangosol.net.NamedCache in project coherence-spring by coherence-community.
the class CoherenceGenericConverterTests method testContinuousQueryCacheConversion.
@Test
public void testContinuousQueryCacheConversion() {
final Map map = this.conversionService.convert(this.mockedContinuousQueryCache, Map.class);
assertThat(map).isSameAs(this.mockedContinuousQueryCache);
final ContinuousQueryCache continuousQueryCache = this.conversionService.convert(this.mockedContinuousQueryCache, ContinuousQueryCache.class);
assertThat(continuousQueryCache).isSameAs(this.mockedContinuousQueryCache);
final AbstractKeySetBasedMap abstractKeySetBasedMap = this.conversionService.convert(this.mockedContinuousQueryCache, AbstractKeySetBasedMap.class);
assertThat(abstractKeySetBasedMap).isSameAs(this.mockedContinuousQueryCache);
final AbstractKeyBasedMap abstractKeyBasedMap = this.conversionService.convert(this.mockedContinuousQueryCache, AbstractKeyBasedMap.class);
assertThat(abstractKeyBasedMap).isSameAs(this.mockedContinuousQueryCache);
final NamedCache namedCache = this.conversionService.convert(this.mockedContinuousQueryCache, NamedCache.class);
assertThat(namedCache).isSameAs(this.mockedContinuousQueryCache);
final NamedMap namedMap = this.conversionService.convert(this.mockedContinuousQueryCache, NamedMap.class);
assertThat(namedMap).isSameAs(this.mockedContinuousQueryCache);
final CacheMap cacheMap = this.conversionService.convert(this.mockedContinuousQueryCache, CacheMap.class);
assertThat(cacheMap).isSameAs(this.mockedContinuousQueryCache);
final NamedCollection namedCollection = this.conversionService.convert(this.mockedContinuousQueryCache, NamedCollection.class);
assertThat(namedCollection).isSameAs(this.mockedContinuousQueryCache);
final ObservableMap observableMap = this.conversionService.convert(this.mockedContinuousQueryCache, ObservableMap.class);
assertThat(observableMap).isSameAs(this.mockedContinuousQueryCache);
final ConcurrentMap concurrentMap = this.conversionService.convert(this.mockedContinuousQueryCache, ConcurrentMap.class);
assertThat(concurrentMap).isSameAs(this.mockedContinuousQueryCache);
final QueryMap queryMap = this.conversionService.convert(this.mockedContinuousQueryCache, QueryMap.class);
assertThat(queryMap).isSameAs(this.mockedContinuousQueryCache);
final InvocableMap invocableMap = this.conversionService.convert(this.mockedContinuousQueryCache, InvocableMap.class);
assertThat(invocableMap).isSameAs(this.mockedContinuousQueryCache);
final Releasable releasable = this.conversionService.convert(this.mockedContinuousQueryCache, Releasable.class);
assertThat(releasable).isSameAs(this.mockedContinuousQueryCache);
}
use of com.tangosol.net.NamedCache in project coherence-spring by coherence-community.
the class SpringApplicationTests method testBackingMapManagerContextInjection.
/**
* Test the injection of a backing map manager context via
* the {manager-context} macro.
*/
@Test
public void testBackingMapManagerContextInjection() {
String[] asCacheNames = new String[] { "CacheBML", "CacheBMLPull" };
String[] asBeanNames = new String[] { "bml", "bmlPull" };
for (int i = 0; i < asCacheNames.length; ++i) {
NamedCache cache = this.session.getCache(asCacheNames[i]);
BeanFactory beanFactory = this.session.getResourceRegistry().getResource(BeanFactory.class);
StubBackingMapListener bml = beanFactory.getBean(asBeanNames[i], StubBackingMapListener.class);
assertThat(bml.isContextConfigured()).isFalse();
cache.put("key", "value");
assertThat(bml.isContextConfigured()).isTrue();
}
}
use of com.tangosol.net.NamedCache in project coherence-spring by coherence-community.
the class SpringNamespaceHandlerTests method testCacheStore.
/**
* Test the use of Spring to inject a CacheStore.
*/
@Test
public void testCacheStore() {
String[] asCacheNames = new String[] { "CacheStore", "CacheStorePull" };
for (String sCacheName : asCacheNames) {
NamedCache cache = getFactory().ensureCache(sCacheName, null);
// the CacheStore provided by Spring is an instance of MapCacheStore
// which has an internal map that contains the entry <"key", "value">
assertThat("value").isEqualTo(cache.get("key"));
// this asserts that the {cache-name} macro succeeded in injecting
// the cache name to the cache store (see StubNamedCacheStore)
assertThat(sCacheName).isEqualTo(cache.get(StubNamedCacheStore.CACHE_NAME_KEY));
}
BeanFactory beanFactory = getFactory().getResourceRegistry().getResource(BeanFactory.class);
StubNamedCacheStore cs = beanFactory.getBean("mapCacheStorePull", StubNamedCacheStore.class);
assertThat(cs.getSpelValue()).isEqualTo("Prosper");
}
Aggregations