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