View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.config.spring.factories;
8   
9   import org.mule.api.processor.MessageProcessor;
10  import org.mule.api.source.CompositeMessageSource;
11  import org.mule.api.source.MessageSource;
12  import org.mule.source.StartableCompositeMessageSource;
13  
14  import java.util.Collections;
15  import java.util.List;
16  
17  import org.springframework.beans.factory.FactoryBean;
18  
19  public class CompositeMessageSourceFactoryBean implements FactoryBean
20  {
21  
22      protected List<MessageSource> sources = Collections.<MessageSource> emptyList();
23  
24      public Class getObjectType()
25      {
26          return MessageProcessor.class;
27      }
28  
29      public void setMessageSources(List<MessageSource> sources)
30      {
31          this.sources = sources;
32      }
33  
34      public Object getObject() throws Exception
35      {
36          CompositeMessageSource composite = new StartableCompositeMessageSource();
37          for (MessageSource source : sources)
38          {
39              composite.addSource(source);
40          }
41          return composite;
42      }
43  
44      public boolean isSingleton()
45      {
46          return false;
47      }
48  
49  }