Problem: create cache programmatically in jboss AS 6
yangju Apr 26, 2011 12:02 PMJboss AS 6 Final'a all profile comes with infinispan 4.2.0.FINAL. We are using it with no problem with predefined named cache. However, when I use the following code to look for a cache name which does not exist, the created cache name is always _defaultCache.
Let's say the passed in newcache name is called "newCacheName"
public Cache<?, ?> findCacheByName(String cacheName) {
Cache<?, ?> cache = null;
if (!cacheExists(cacheName)) {
Configuration c = cacheManager.getDefaultConfiguration().clone();
// c.setCacheMode(CacheMode.DIST_SYNC);
// c.setOtherAttributeToOverrideDefault
cacheManager.defineConfiguration(cacheName, c);
cache = cacheManager.getCache(cacheName);
} else {
cache = cacheManager.getCache(cacheName);
}
return cache;
}
The cacheManager is lookedup through jndi:
EmbeddedCacheManager ecm = (EmbeddedCacheManager) jndi
.jndiLookup("MyCacheManager);
But intestingly, the newly createdly cache ("_defaultCache")'s cache manager now becomes MyCacheManager/newCacheName)
Here is my infinispan xml (Note this is part of the infinispan config that is part of the jboss cluster deployer)
<infinispan-config name="epen_application" jndi-name="java:MyCacheManager">
<infinispan xmlns="urn:infinispan:config:4.2">
<global>
<transport clusterName="${jboss.partition.name:DefaultPartition}-myApp"
distributedSyncTimeout="17500">
<properties>
<property name="stack" value="${jboss.default.jgroups.stack:udp}" />
</properties>
</transport>
<globalJmxStatistics enabled="true" />
<shutdown hookBehavior="DONT_REGISTER" />
</global>
<default>
<jmxStatistics enabled="true" />
<invocationBatching enabled="true" />
<locking isolationLevel="READ_COMMITTED"
lockAcquisitionTimeout="20000" writeSkewCheck="false"
concurrencyLevel="5000" useLockStriping="false" />
<transaction
transactionManagerLookupClass="org.infinispan.transaction.lookup.GenericTransactionManagerLookup"
syncRollbackPhase="false" syncCommitPhase="false" useEagerLocking="true"
eagerLockSingleNode="true" />
<clustering mode="distribution">
<l1 enabled="false" lifespan="60000" />
<hash numOwners="1" rehashRpcTimeout="120000" />
<sync />
</clustering>
</default>
</infinispan>
</infinispan-config>
Can anybody tell me why it always creates _defaultCache instead of the cache name that I want?
Is this a defect in 4.2.0.Fianl?