1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
package org.mule.config.dsl; |
11 | |
|
12 | |
import org.mule.api.MuleContext; |
13 | |
import org.mule.api.component.Component; |
14 | |
import org.mule.api.object.ObjectFactory; |
15 | |
import org.mule.component.DefaultJavaComponent; |
16 | |
import org.mule.component.PooledJavaComponent; |
17 | |
import org.mule.object.AbstractObjectFactory; |
18 | |
import org.mule.object.PrototypeObjectFactory; |
19 | |
import org.mule.object.SingletonObjectFactory; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
public class ComponentBuilder |
25 | |
{ |
26 | 0 | public enum Scope |
27 | |
{ |
28 | 0 | Prototype, |
29 | 0 | Pooled, |
30 | 0 | Singleton; |
31 | |
} |
32 | |
|
33 | |
private Component component; |
34 | |
private MuleContext muleContext; |
35 | |
|
36 | |
ComponentBuilder(Scope scope, Class clazz, MuleContext muleContext) |
37 | 0 | { |
38 | 0 | this.muleContext = muleContext; |
39 | |
AbstractObjectFactory factory; |
40 | 0 | if (scope == Scope.Singleton) |
41 | |
{ |
42 | 0 | factory = new SingletonObjectFactory(clazz); |
43 | |
} |
44 | |
else |
45 | |
{ |
46 | 0 | factory = new PrototypeObjectFactory(clazz); |
47 | |
} |
48 | |
|
49 | 0 | if (scope == Scope.Pooled) |
50 | |
{ |
51 | 0 | component = new PooledJavaComponent(factory); |
52 | |
} |
53 | |
else |
54 | |
{ |
55 | 0 | component = new DefaultJavaComponent(factory); |
56 | |
} |
57 | 0 | } |
58 | |
|
59 | |
ComponentBuilder(Object instance, MuleContext muleContext) |
60 | 0 | { |
61 | 0 | this.muleContext = muleContext; |
62 | 0 | ObjectFactory factory = new SingletonObjectFactory(instance); |
63 | 0 | component = new DefaultJavaComponent(factory); |
64 | 0 | } |
65 | |
|
66 | |
Component create() |
67 | |
{ |
68 | 0 | return component; |
69 | |
} |
70 | |
|
71 | |
public OutRouteBuilder to(String uri) |
72 | |
{ |
73 | 0 | return null; |
74 | |
} |
75 | |
} |