View Javadoc

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