1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
package org.apache.camel.spring.remoting; |
19 |
|
|
20 |
|
import org.apache.camel.CamelContext; |
21 |
|
import org.apache.camel.component.pojo.PojoComponent; |
22 |
|
import org.springframework.beans.factory.DisposableBean; |
23 |
|
import org.springframework.beans.factory.InitializingBean; |
24 |
|
import org.springframework.remoting.support.RemoteExporter; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
1 |
public class CamelServiceExporter extends RemoteExporter implements InitializingBean, DisposableBean { |
32 |
|
|
33 |
|
CamelContext camelContext; |
34 |
|
PojoComponent pojoComponent; |
35 |
|
String serviceName; |
36 |
|
|
37 |
|
public void afterPropertiesSet() throws Exception { |
38 |
1 |
if( serviceName == null ) { |
39 |
0 |
throw new IllegalArgumentException("The serviceName must be configured."); |
40 |
|
} |
41 |
1 |
if( pojoComponent == null ) { |
42 |
1 |
if( camelContext == null ) { |
43 |
0 |
throw new IllegalArgumentException("A pojoComponent or camelContext must be configured."); |
44 |
|
} |
45 |
1 |
pojoComponent = (PojoComponent) camelContext.getComponent("pojo"); |
46 |
1 |
if( pojoComponent == null ) { |
47 |
0 |
throw new IllegalArgumentException("The pojoComponent could not be found."); |
48 |
|
} |
49 |
|
} |
50 |
1 |
pojoComponent.addService(serviceName, getProxyForService()); |
51 |
1 |
} |
52 |
|
|
53 |
|
public void destroy() throws Exception { |
54 |
1 |
if( serviceName!=null ) { |
55 |
1 |
pojoComponent.removeService(serviceName); |
56 |
|
} |
57 |
1 |
} |
58 |
|
|
59 |
|
|
60 |
|
public PojoComponent getPojoComponent() { |
61 |
0 |
return pojoComponent; |
62 |
|
} |
63 |
|
public void setPojoComponent(PojoComponent pojoComponent) { |
64 |
0 |
this.pojoComponent = pojoComponent; |
65 |
0 |
} |
66 |
|
|
67 |
|
public CamelContext getCamelContext() { |
68 |
0 |
return camelContext; |
69 |
|
} |
70 |
|
public void setCamelContext(CamelContext camelContext) { |
71 |
1 |
this.camelContext = camelContext; |
72 |
1 |
} |
73 |
|
|
74 |
|
public String getServiceName() { |
75 |
0 |
return serviceName; |
76 |
|
} |
77 |
|
public void setServiceName(String serviceName) { |
78 |
1 |
this.serviceName = serviceName; |
79 |
1 |
} |
80 |
|
|
81 |
|
} |