1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.camel.spring.spi; |
18 |
|
|
19 |
|
import org.apache.camel.spi.Injector; |
20 |
|
import org.apache.commons.logging.Log; |
21 |
|
import org.apache.commons.logging.LogFactory; |
22 |
|
|
23 |
|
import org.springframework.beans.factory.config.AutowireCapableBeanFactory; |
24 |
|
import org.springframework.context.support.AbstractRefreshableApplicationContext; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
public class SpringInjector implements Injector { |
32 |
1 |
private static final transient Log LOG = LogFactory.getLog(SpringInjector.class); |
33 |
|
private final AbstractRefreshableApplicationContext applicationContext; |
34 |
56 |
private int autowireMode = AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR; |
35 |
|
private boolean dependencyCheck; |
36 |
|
|
37 |
56 |
public SpringInjector(AbstractRefreshableApplicationContext applicationContext) { |
38 |
56 |
this.applicationContext = applicationContext; |
39 |
56 |
} |
40 |
|
|
41 |
|
public <T> T newInstance(Class<T> type) { |
42 |
|
|
43 |
119 |
Object value = applicationContext.getBeanFactory().createBean(type, autowireMode, dependencyCheck); |
44 |
119 |
return type.cast(value); |
45 |
|
} |
46 |
|
|
47 |
|
public int getAutowireMode() { |
48 |
0 |
return autowireMode; |
49 |
|
} |
50 |
|
|
51 |
|
public void setAutowireMode(int autowireMode) { |
52 |
0 |
this.autowireMode = autowireMode; |
53 |
0 |
} |
54 |
|
|
55 |
|
public boolean isDependencyCheck() { |
56 |
0 |
return dependencyCheck; |
57 |
|
} |
58 |
|
|
59 |
|
public void setDependencyCheck(boolean dependencyCheck) { |
60 |
0 |
this.dependencyCheck = dependencyCheck; |
61 |
0 |
} |
62 |
|
} |