|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.tapestry.enhance; |
|
16 |
| |
|
17 |
| import java.lang.reflect.Constructor; |
|
18 |
| |
|
19 |
| import org.apache.hivemind.ApplicationRuntimeException; |
|
20 |
| import org.apache.hivemind.Location; |
|
21 |
| import org.apache.hivemind.util.Defense; |
|
22 |
| import org.apache.tapestry.services.ComponentConstructor; |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| public class ComponentConstructorImpl implements ComponentConstructor |
|
29 |
| { |
|
30 |
| private Location _location; |
|
31 |
| |
|
32 |
| private Constructor _constructor; |
|
33 |
| |
|
34 |
| private Object[] _parameters; |
|
35 |
| |
|
36 |
| private String _classFabString; |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
1746
| public ComponentConstructorImpl(Constructor constructor, Object[] parameters,
|
|
53 |
| String classFabString, Location location) |
|
54 |
| { |
|
55 |
1746
| Defense.notNull(constructor, "constructor");
|
|
56 |
1746
| _constructor = constructor;
|
|
57 |
1746
| _parameters = parameters;
|
|
58 |
1746
| _classFabString = classFabString;
|
|
59 |
1746
| _location = location;
|
|
60 |
| } |
|
61 |
| |
|
62 |
1167
| public Class getComponentClass()
|
|
63 |
| { |
|
64 |
1167
| return _constructor.getDeclaringClass();
|
|
65 |
| } |
|
66 |
| |
|
67 |
3591
| public Object newInstance()
|
|
68 |
| { |
|
69 |
3591
| try
|
|
70 |
| { |
|
71 |
3591
| Object result = _constructor.newInstance(_parameters);
|
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
3588
| _classFabString = null;
|
|
77 |
| |
|
78 |
3588
| return result;
|
|
79 |
| } |
|
80 |
| catch (Throwable ex) |
|
81 |
| { |
|
82 |
3
| throw new ApplicationRuntimeException(EnhanceMessages.instantiationFailure(
|
|
83 |
| _constructor, |
|
84 |
| _parameters, |
|
85 |
| _classFabString, |
|
86 |
| ex), null, _location, ex); |
|
87 |
| } |
|
88 |
| } |
|
89 |
| |
|
90 |
| } |