1 package org.jboss.ejb3.entity; 2 3 import java.util.Properties ; 4 5 import javax.management.ObjectName ; 6 7 import org.hibernate.cache.Cache; 8 import org.hibernate.cache.CacheException; 9 import org.jboss.cache.jmx.CacheJmxWrapperMBean; 10 import org.jboss.ejb3.tx.TxUtil; 11 import org.jboss.mx.util.MBeanProxyExt; 12 import org.jboss.mx.util.MBeanServerLocator; 13 14 class JBCCacheFactory extends TransactionalCacheFactory 15 { 16 private org.jboss.cache.Cache cache; 17 private boolean optimistic; 18 19 JBCCacheFactory() 20 { 21 22 } 23 24 protected void configure(Properties hibernateConfig) 25 { 26 try 27 { 28 ObjectName mbeanObjectName = new ObjectName ((String ) hibernateConfig.get("hibernate.treecache.mbean.object_name")); 29 CacheJmxWrapperMBean mbean = (CacheJmxWrapperMBean) MBeanProxyExt.create(CacheJmxWrapperMBean.class, mbeanObjectName, MBeanServerLocator.locateJBoss()); 30 cache = mbean.getCache(); 31 optimistic = cache.getConfiguration().isNodeLockingOptimistic(); 32 } 33 catch (Exception e) 34 { 35 throw new CacheException(e); 36 } 37 } 38 39 public Cache buildCache(String regionName, Properties properties) throws CacheException 40 { 41 return new JBCCache(cache, regionName, TxUtil.getTransactionManager()); 48 } 50 51 } 52 | Popular Tags |