コード例 #1
0
 @Test
 public void testParentChildAnnotationConfigurationFromAnotherPackage() {
   AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
   child.register(org.springframework.integration.configuration2.ChildConfiguration.class);
   child.setParent(this.context);
   child.refresh();
   AbstractMessageChannel foo = child.getBean("foo", AbstractMessageChannel.class);
   ChannelInterceptor baz = child.getBean("baz", ChannelInterceptor.class);
   assertTrue(foo.getChannelInterceptors().contains(baz));
   assertFalse(this.output.getChannelInterceptors().contains(baz));
   child.close();
 }
コード例 #2
0
 @Override
 public void onInit() throws Exception {
   if (this.initialized) {
     return;
   }
   super.onInit();
   if (this.maxSubscribers == null) {
     Integer maxSubscribers =
         getIntegrationProperty(
             IntegrationProperties.CHANNELS_MAX_BROADCAST_SUBSCRIBERS, Integer.class);
     this.setMaxSubscribers(maxSubscribers);
   }
   if (this.messageConverter == null) {
     this.messageConverter = new SimpleMessageConverter();
   }
   if (this.messageConverter instanceof BeanFactoryAware) {
     ((BeanFactoryAware) this.messageConverter).setBeanFactory(this.getBeanFactory());
   }
   this.container.setConnectionFactory(this.connectionFactory);
   if (!(this.taskExecutor instanceof ErrorHandlingTaskExecutor)) {
     ErrorHandler errorHandler =
         new MessagePublishingErrorHandler(new BeanFactoryChannelResolver(this.getBeanFactory()));
     this.taskExecutor = new ErrorHandlingTaskExecutor(this.taskExecutor, errorHandler);
   }
   this.container.setTaskExecutor(this.taskExecutor);
   MessageListenerAdapter adapter = new MessageListenerAdapter(new MessageListenerDelegate());
   adapter.setSerializer(this.serializer);
   adapter.afterPropertiesSet();
   this.container.addMessageListener(adapter, new ChannelTopic(this.topicName));
   this.container.afterPropertiesSet();
   this.dispatcher.setBeanFactory(this.getBeanFactory());
   this.initialized = true;
 }