/** * Tests a cache listener with no parameters * * @since 4.0 */ public void testTransactionListener() { CacheCreation cache = new CacheCreation(); CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation(); txMgrCreation.setListener(new MyTestTransactionListener()); cache.addCacheTransactionManagerCreation(txMgrCreation); testXml(cache); }
/** * 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-writer</code> using the declarable interface * and set the transaction manager with the newly instantiated writer. */ private void endTransactionWriter() { Declarable d = createDeclarable(); if (!(d instanceof TransactionWriter)) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_TRANSACTION_WRITER.toLocalizedString(d.getClass().getName())); } CacheTransactionManagerCreation txMgrCreation = (CacheTransactionManagerCreation) stack .peek(); txMgrCreation.setWriter((TransactionWriter) d); }
public void testNoTXWriterOnClient() { //test writer is not created ClientCacheCreation cc = new ClientCacheCreation(); CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation(); txMgrCreation.setWriter(new TestTransactionWriter()); cc.addCacheTransactionManagerCreation(txMgrCreation); try { testXml(cc); fail("expected exception not thrown"); } catch (IllegalStateException e) { } }
CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation(); TransactionListener l1 = new MyTestTransactionListener(); TransactionListener l2 = new MySecondTestTransactionListener(); txMgrCreation.addListener(l1); txMgrCreation.addListener(l2); cache.addCacheTransactionManagerCreation(txMgrCreation); testXml(cache);
this.txMgrCreation.getListeners().length > 0 && cache.getCacheTransactionManager()!=null) { cache.getCacheTransactionManager().initListeners(this.txMgrCreation.getListeners()); cache.getCacheTransactionManager()!=null && this.txMgrCreation.getWriter() != null) { throw new IllegalStateException(LocalizedStrings.TXManager_NO_WRITER_ON_CLIENT.toLocalizedString());
/** * When a <code>cache-transaction-manager</code> element is found, create a * container for the potential <code>transaction-listener</code> and push it * on the stack */ private void startCacheTransactionManager() { stack.push(new CacheTransactionManagerCreation()); }
public TransactionListener setListener(TransactionListener newListener) { TransactionListener result = getListener(); this.txListeners.clear(); if (newListener != null) { this.txListeners.add(newListener); } return result; } public void initListeners(TransactionListener[] newListeners) {
/** * Tests that a region created with a named attributes set programmatically * for delta propogation has the correct attributes. * */ public void testTransactionWriter() throws CacheException { CacheCreation creation = new CacheCreation(); CacheTransactionManagerCreation ctmc = new CacheTransactionManagerCreation(); ctmc.setWriter(new TestTransactionWriter()); creation.addCacheTransactionManagerCreation(ctmc); testXml(creation); Cache c = getCache(); assertTrue(c instanceof GemFireCacheImpl); c.loadCacheXml(generate(creation)); TransactionWriter tw = c.getCacheTransactionManager().getWriter(); assertTrue("tw should be TransactionWriter, but it is:"+tw,tw instanceof TestTransactionWriter); }
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); }
this.txMgrCreation.getListeners().length > 0 && cache.getCacheTransactionManager()!=null) { cache.getCacheTransactionManager().initListeners(this.txMgrCreation.getListeners()); cache.getCacheTransactionManager()!=null && this.txMgrCreation.getWriter() != null) { throw new IllegalStateException(LocalizedStrings.TXManager_NO_WRITER_ON_CLIENT.toLocalizedString());
/** * When a <code>cache-transaction-manager</code> element is found, create a * container for the potential <code>transaction-listener</code> and push it * on the stack */ private void startCacheTransactionManager() { stack.push(new CacheTransactionManagerCreation()); }
public TransactionListener setListener(TransactionListener newListener) { TransactionListener result = getListener(); this.txListeners.clear(); if (newListener != null) { this.txListeners.add(newListener); } return result; } public void initListeners(TransactionListener[] newListeners) {
this.txMgrCreation.getListeners().length > 0 && cache.getCacheTransactionManager()!=null) { cache.getCacheTransactionManager().initListeners(this.txMgrCreation.getListeners()); cache.getCacheTransactionManager().setWriter(this.txMgrCreation.getWriter());
/** * Tests transaction manager with no listener * * @since 4.0 */ public void testCacheTransactionManager() { CacheCreation cache = new CacheCreation(); CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation(); cache.addCacheTransactionManagerCreation(txMgrCreation); testXml(cache); }
/** * Create a <code>transaction-writer</code> using the declarable interface * and set the transaction manager with the newly instantiated writer. */ private void endTransactionWriter() { Declarable d = createDeclarable(); if (!(d instanceof TransactionWriter)) { throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_TRANSACTION_WRITER.toLocalizedString(d.getClass().getName())); } CacheTransactionManagerCreation txMgrCreation = (CacheTransactionManagerCreation) stack .peek(); txMgrCreation.setWriter((TransactionWriter) 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); }
this.txMgrCreation.getListeners().length > 0 && cache.getCacheTransactionManager()!=null) { cache.getCacheTransactionManager().initListeners(this.txMgrCreation.getListeners()); cache.getCacheTransactionManager().setWriter(this.txMgrCreation.getWriter());