/** * Create a <code>transaction-listener</code> using the declarable interface * and set the transaction manager with the newly instantiated listener. */ private void endTransactionListener() { Declarable d = createDeclarable(); if (!(d instanceof TransactionListener)) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_CACHELISTENER.toLocalizedString(d.getClass().getName())); } CacheTransactionManagerCreation txMgrCreation = (CacheTransactionManagerCreation) stack .peek(); txMgrCreation.addListener((TransactionListener) d); }
/** * Create a <code>transaction-listener</code> using the declarable interface * and set the transaction manager with the newly instantiated listener. */ private void endTransactionListener() { Declarable d = createDeclarable(); if (!(d instanceof TransactionListener)) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_CACHELISTENER.toLocalizedString(d.getClass().getName())); } CacheTransactionManagerCreation txMgrCreation = (CacheTransactionManagerCreation) stack .peek(); txMgrCreation.addListener((TransactionListener) d); }
TransactionListener l1 = new MyTestTransactionListener(); TransactionListener l2 = new MySecondTestTransactionListener(); txMgrCreation.addListener(l1); txMgrCreation.addListener(l2); cache.addCacheTransactionManagerCreation(txMgrCreation); testXml(cache);
public void testTXManagerOnClientCache() { ClientCacheCreation cc = new ClientCacheCreation(); //CacheCreation cc = new CacheCreation(); CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation(); txMgrCreation.addListener(new TestTXListener()); cc.addCacheTransactionManagerCreation(txMgrCreation); testXml(cc); Cache c = getCache(); assertTrue(c instanceof ClientCache); c.loadCacheXml(generate(cc)); ClientCache clientC = (ClientCache) c; CacheTransactionManager mgr = clientC.getCacheTransactionManager(); assertNotNull(mgr); assertTrue(mgr.getListeners()[0] instanceof TestTXListener); }