1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
package org.apache.camel.spring.xml; |
19 |
|
|
20 |
|
import static org.apache.camel.util.ObjectHelper.notNull; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
|
24 |
|
import org.apache.camel.CamelContext; |
25 |
|
import org.springframework.beans.BeansException; |
26 |
|
import org.springframework.beans.factory.BeanFactory; |
27 |
|
import org.springframework.beans.factory.BeanFactoryAware; |
28 |
|
import org.springframework.beans.factory.FactoryBean; |
29 |
|
import org.springframework.beans.factory.InitializingBean; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
27 |
public class RouteBuilderFactoryBean implements FactoryBean, BeanFactoryAware, InitializingBean { |
39 |
|
private ArrayList<BuilderStatement> routes; |
40 |
|
private BeanFactory beanFactory; |
41 |
|
private CamelContext context; |
42 |
27 |
private StatementRouteBuilder builder = new StatementRouteBuilder(); |
43 |
|
|
44 |
|
public Object getObject() throws Exception { |
45 |
1 |
return builder; |
46 |
|
} |
47 |
|
|
48 |
|
public Class getObjectType() { |
49 |
32 |
return StatementRouteBuilder.class; |
50 |
|
} |
51 |
|
|
52 |
|
public boolean isSingleton() { |
53 |
12 |
return true; |
54 |
|
} |
55 |
|
|
56 |
|
public ArrayList<BuilderStatement> getRoutes() { |
57 |
0 |
return routes; |
58 |
|
} |
59 |
|
public void setRoutes(ArrayList<BuilderStatement> routes) { |
60 |
27 |
this.routes = routes; |
61 |
27 |
} |
62 |
|
|
63 |
|
public void setBeanFactory(BeanFactory beanFactory) throws BeansException { |
64 |
27 |
this.beanFactory = beanFactory; |
65 |
27 |
} |
66 |
|
|
67 |
|
public CamelContext getContext() { |
68 |
0 |
return context; |
69 |
|
} |
70 |
|
|
71 |
|
public void setContext(CamelContext context) { |
72 |
27 |
this.context = context; |
73 |
27 |
} |
74 |
|
|
75 |
|
public void afterPropertiesSet() throws Exception { |
76 |
27 |
notNull(context, "context"); |
77 |
27 |
notNull(routes, "routes"); |
78 |
27 |
builder.setBeanFactory(beanFactory); |
79 |
27 |
builder.setRoutes(routes); |
80 |
|
|
81 |
|
|
82 |
27 |
context.addRoutes(builder); |
83 |
27 |
} |
84 |
|
} |