@Test public void pollerWithAdviceChain() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "pollerWithAdviceChain.xml", PollerParserTests.class); Object poller = context.getBean("poller"); assertNotNull(poller); PollerMetadata metadata = (PollerMetadata) poller; assertNotNull(metadata.getAdviceChain()); assertEquals(4, metadata.getAdviceChain().size()); assertSame(context.getBean("adviceBean1"), metadata.getAdviceChain().get(0)); assertEquals(TestAdviceBean.class, metadata.getAdviceChain().get(1).getClass()); assertEquals(2, ((TestAdviceBean) metadata.getAdviceChain().get(1)).getId()); assertSame(context.getBean("adviceBean3"), metadata.getAdviceChain().get(2)); Advice txAdvice = metadata.getAdviceChain().get(3); assertEquals(TransactionInterceptor.class, txAdvice.getClass()); TransactionAttributeSource transactionAttributeSource = ((TransactionInterceptor) txAdvice).getTransactionAttributeSource(); assertEquals(NameMatchTransactionAttributeSource.class, transactionAttributeSource.getClass()); @SuppressWarnings("rawtypes") HashMap nameMap = TestUtils.getPropertyValue(transactionAttributeSource, "nameMap", HashMap.class); assertEquals(1, nameMap.size()); assertEquals("{*=PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT,readOnly}", nameMap.toString()); context.close(); }
pollingEndpoint.setAdviceChain(pollerMetadata.getAdviceChain()); pollingEndpoint.setMaxMessagesPerPoll(pollerMetadata.getMaxMessagesPerPoll()); pollingEndpoint.setErrorHandler(pollerMetadata.getErrorHandler());
pollingConsumer.setAdviceChain(this.pollerMetadata.getAdviceChain()); pollingConsumer.setMaxMessagesPerPoll(this.pollerMetadata.getMaxMessagesPerPoll());
spca.setAdviceChain(this.pollerMetadata.getAdviceChain()); spca.setTrigger(this.pollerMetadata.getTrigger()); spca.setErrorHandler(this.pollerMetadata.getErrorHandler());
pollingEndpoint.setAdviceChain(pollerMetadata.getAdviceChain()); pollingEndpoint.setMaxMessagesPerPoll(pollerMetadata.getMaxMessagesPerPoll()); pollingEndpoint.setErrorHandler(pollerMetadata.getErrorHandler());
private void initializeAdapter() { synchronized (this.initializationMonitor) { if (this.initialized) { return; } Assert.notNull(this.source, "source is required"); Assert.notNull(this.outputChannel, "outputChannel is required"); SourcePollingChannelAdapter spca = new SourcePollingChannelAdapter(); spca.setSource(this.source); spca.setOutputChannel(this.outputChannel); if (this.pollerMetadata == null) { this.pollerMetadata = IntegrationContextUtils.getDefaultPollerMetadata(this.beanFactory); Assert.notNull(this.pollerMetadata, "No poller has been defined for channel-adapter '" + this.beanName + "', and no default poller is available within the context."); } spca.setTrigger(this.pollerMetadata.getTrigger()); spca.setMaxMessagesPerPoll(this.pollerMetadata.getMaxMessagesPerPoll()); spca.setTaskExecutor(this.pollerMetadata.getTaskExecutor()); spca.setTransactionManager(this.pollerMetadata.getTransactionManager()); spca.setTransactionDefinition(this.pollerMetadata.getTransactionDefinition()); spca.setAdviceChain(this.pollerMetadata.getAdviceChain()); spca.setAutoStartup(this.autoStartup); spca.setBeanName(this.beanName); spca.setBeanFactory(this.beanFactory); spca.setBeanClassLoader(this.beanClassLoader); spca.afterPropertiesSet(); this.adapter = spca; this.initialized = true; } }
pollingConsumer.setTransactionManager(this.pollerMetadata.getTransactionManager()); pollingConsumer.setTransactionDefinition(this.pollerMetadata.getTransactionDefinition()); pollingConsumer.setAdviceChain(this.pollerMetadata.getAdviceChain()); this.endpoint = pollingConsumer;
pollingConsumer.setAdviceChain(this.pollerMetadata.getAdviceChain()); pollingConsumer.setMaxMessagesPerPoll(this.pollerMetadata.getMaxMessagesPerPoll());
spca.setAdviceChain(this.pollerMetadata.getAdviceChain()); spca.setTrigger(this.pollerMetadata.getTrigger()); spca.setErrorHandler(this.pollerMetadata.getErrorHandler());