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