1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.config.spring.factories; |
12 | |
|
13 | |
import java.util.Collection; |
14 | |
|
15 | |
import org.mule.api.processor.MessageProcessor; |
16 | |
import org.mule.routing.AbstractSelectiveRouter; |
17 | |
import org.mule.routing.MessageProcessorFilterPair; |
18 | |
import org.springframework.beans.factory.FactoryBean; |
19 | |
|
20 | |
public abstract class AbstractSelectiveRouterFactoryBean implements FactoryBean |
21 | |
{ |
22 | |
private MessageProcessor defaultProcessor; |
23 | |
private Collection<MessageProcessorFilterPair> conditionalMessageProcessors; |
24 | |
|
25 | |
public AbstractSelectiveRouterFactoryBean() |
26 | |
{ |
27 | 0 | super(); |
28 | 0 | } |
29 | |
|
30 | |
public void setDefaultRoute(MessageProcessorFilterPair conditionalProcessor) |
31 | |
{ |
32 | 0 | defaultProcessor = conditionalProcessor.getMessageProcessor(); |
33 | 0 | } |
34 | |
|
35 | |
public void setRoutes(Collection<MessageProcessorFilterPair> conditionalMessageProcessors) |
36 | |
{ |
37 | 0 | this.conditionalMessageProcessors = conditionalMessageProcessors; |
38 | 0 | } |
39 | |
|
40 | |
public Object getObject() throws Exception |
41 | |
{ |
42 | 0 | final AbstractSelectiveRouter router = newAbstractSelectiveRouter(); |
43 | 0 | router.setDefaultRoute(defaultProcessor); |
44 | |
|
45 | 0 | for (final MessageProcessorFilterPair mpfp : conditionalMessageProcessors) |
46 | |
{ |
47 | 0 | router.addRoute(mpfp.getMessageProcessor(), mpfp.getFilter()); |
48 | |
} |
49 | |
|
50 | 0 | return router; |
51 | |
} |
52 | |
|
53 | |
protected abstract AbstractSelectiveRouter newAbstractSelectiveRouter(); |
54 | |
|
55 | |
public boolean isSingleton() |
56 | |
{ |
57 | 0 | return true; |
58 | |
} |
59 | |
|
60 | |
} |