1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.config.spring.factories; |
12 | |
|
13 | |
import org.mule.api.component.Component; |
14 | |
import org.mule.api.endpoint.EndpointBuilder; |
15 | |
import org.mule.api.processor.MessageProcessor; |
16 | |
import org.mule.api.transformer.Transformer; |
17 | |
import org.mule.config.spring.util.SpringBeanLookup; |
18 | |
import org.mule.construct.SimpleService; |
19 | |
import org.mule.construct.SimpleService.Type; |
20 | |
import org.mule.construct.builder.AbstractFlowConstructBuilder; |
21 | |
import org.mule.construct.builder.SimpleServiceBuilder; |
22 | |
import org.springframework.beans.BeansException; |
23 | |
import org.springframework.context.ApplicationContext; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | 0 | public class SimpleServiceFactoryBean extends AbstractFlowConstructFactoryBean |
29 | |
{ |
30 | 0 | final SimpleServiceBuilder simpleServiceBuilder = new SimpleServiceBuilder(); |
31 | |
|
32 | |
private SpringBeanLookup springBeanLookup; |
33 | |
|
34 | |
public Class<?> getObjectType() |
35 | |
{ |
36 | 0 | return SimpleService.class; |
37 | |
} |
38 | |
|
39 | |
@Override |
40 | |
protected AbstractFlowConstructBuilder<SimpleServiceBuilder, SimpleService> getFlowConstructBuilder() |
41 | |
{ |
42 | 0 | return simpleServiceBuilder; |
43 | |
} |
44 | |
|
45 | |
@Override |
46 | |
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException |
47 | |
{ |
48 | 0 | super.setApplicationContext(applicationContext); |
49 | |
|
50 | 0 | if (springBeanLookup != null) |
51 | |
{ |
52 | 0 | springBeanLookup.setApplicationContext(applicationContext); |
53 | |
} |
54 | 0 | } |
55 | |
|
56 | |
public void setEndpointBuilder(EndpointBuilder endpointBuilder) |
57 | |
{ |
58 | 0 | simpleServiceBuilder.inboundEndpoint(endpointBuilder); |
59 | 0 | } |
60 | |
|
61 | |
public void setAddress(String address) |
62 | |
{ |
63 | 0 | simpleServiceBuilder.inboundAddress(address); |
64 | 0 | } |
65 | |
|
66 | |
public void setTransformers(Transformer... transformers) |
67 | |
{ |
68 | 0 | simpleServiceBuilder.inboundTransformers(transformers); |
69 | 0 | } |
70 | |
|
71 | |
public void setResponseTransformers(Transformer... responseTransformers) |
72 | |
{ |
73 | 0 | simpleServiceBuilder.inboundResponseTransformers(responseTransformers); |
74 | 0 | } |
75 | |
|
76 | |
public void setComponentClass(Class<?> componentClass) |
77 | |
{ |
78 | 0 | simpleServiceBuilder.component(componentClass); |
79 | 0 | } |
80 | |
|
81 | |
public void setComponentBeanName(String componentBeanName) |
82 | |
{ |
83 | 0 | springBeanLookup = new SpringBeanLookup(); |
84 | 0 | springBeanLookup.setBean(componentBeanName); |
85 | 0 | simpleServiceBuilder.component(springBeanLookup); |
86 | 0 | } |
87 | |
|
88 | |
public void setType(Type type) { |
89 | 0 | simpleServiceBuilder.type(type); |
90 | 0 | } |
91 | |
|
92 | |
public void setMessageProcessor(MessageProcessor component) |
93 | |
{ |
94 | 0 | if (component instanceof Component) |
95 | |
{ |
96 | 0 | simpleServiceBuilder.component((Component) component); |
97 | |
} |
98 | |
else |
99 | |
{ |
100 | 0 | throw new IllegalArgumentException("Single Component message processor is required"); |
101 | |
} |
102 | 0 | } |
103 | |
} |