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 |
|
import java.lang.reflect.Method; |
19 |
|
|
20 |
|
import javassist.CtClass; |
21 |
|
import javassist.CtMethod; |
22 |
|
|
23 |
|
import org.apache.hivemind.Location; |
24 |
|
import org.apache.hivemind.impl.MessageFormatter; |
25 |
|
import org.apache.hivemind.service.ClassFabUtils; |
26 |
|
import org.apache.hivemind.service.MethodSignature; |
27 |
|
import org.apache.tapestry.Tapestry; |
28 |
|
import org.apache.tapestry.spec.IComponentSpecification; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
final class EnhanceMessages |
37 |
|
{ |
38 |
2 |
private static final MessageFormatter _formatter = new MessageFormatter(EnhanceMessages.class); |
39 |
|
|
40 |
|
|
41 |
0 |
private EnhanceMessages() { } |
42 |
|
|
43 |
|
static String noImplForAbstractMethod(Method method, Class declareClass, Class baseClass, |
44 |
|
Class enhancedClass) |
45 |
|
{ |
46 |
1 |
return _formatter.format("no-impl-for-abstract-method", new Object[] |
47 |
|
{ method, declareClass.getName(), baseClass.getName(), enhancedClass.getName() }); |
48 |
|
} |
49 |
|
|
50 |
|
static String unimplementedInterfaceMethod(Method method, Class baseClass, Class enhancedClass) |
51 |
|
{ |
52 |
1 |
return _formatter.format( |
53 |
|
"unimplemented-interface-method", |
54 |
|
method, |
55 |
|
baseClass.getName(), |
56 |
|
enhancedClass.getName()); |
57 |
|
} |
58 |
|
|
59 |
|
static String unabelToIntrospectClass(Class targetClass, Throwable cause) |
60 |
|
{ |
61 |
0 |
return _formatter.format("unable-to-introspect-class", targetClass.getName(), cause); |
62 |
|
} |
63 |
|
|
64 |
|
static String propertyTypeMismatch(Class componentClass, String propertyName, |
65 |
|
Class actualPropertyType, Class expectedPropertyType) |
66 |
|
{ |
67 |
2 |
return _formatter.format("property-type-mismatch", new Object[] |
68 |
|
{ componentClass.getName(), propertyName, |
69 |
|
ClassFabUtils.getJavaClassName(actualPropertyType), |
70 |
|
ClassFabUtils.getJavaClassName(expectedPropertyType) }); |
71 |
|
} |
72 |
|
|
73 |
|
static String errorAddingProperty(String propertyName, Class componentClass, Throwable cause) |
74 |
|
{ |
75 |
17 |
return _formatter.format( |
76 |
|
"error-adding-property", |
77 |
|
propertyName, |
78 |
|
componentClass.getName(), |
79 |
|
cause); |
80 |
|
} |
81 |
|
|
82 |
|
static String claimedProperty(String propertyName) |
83 |
|
{ |
84 |
10 |
return _formatter.format("claimed-property", propertyName); |
85 |
|
} |
86 |
|
|
87 |
|
static String instantiationFailure(Constructor c, Object[] parameters, String classFab, |
88 |
|
Throwable cause) |
89 |
|
{ |
90 |
1 |
int count = Tapestry.size(parameters); |
91 |
1 |
StringBuffer buffer = new StringBuffer("["); |
92 |
2 |
for (int i = 0; i < count; i++) |
93 |
|
{ |
94 |
1 |
if (i > 0) |
95 |
0 |
buffer.append(", "); |
96 |
1 |
buffer.append(parameters[i]); |
97 |
|
} |
98 |
|
|
99 |
1 |
buffer.append("]"); |
100 |
|
|
101 |
1 |
return _formatter.format("instantiation-failure", new Object[] |
102 |
|
{ c.getDeclaringClass().getName(), c, buffer.toString(), classFab, cause }); |
103 |
|
} |
104 |
|
|
105 |
|
static String locatedValueIsNull(String objectReference) |
106 |
|
{ |
107 |
1 |
return _formatter.format("located-value-is-null", objectReference); |
108 |
|
} |
109 |
|
|
110 |
|
static String incompatibleInjectType(String locator, Object value, Class propertyType) |
111 |
|
{ |
112 |
1 |
return _formatter.format("incompatible-inject-type", locator, value, ClassFabUtils |
113 |
|
.getJavaClassName(propertyType)); |
114 |
|
} |
115 |
|
|
116 |
|
static String initialValueForProperty(String propertyName) |
117 |
|
{ |
118 |
2 |
return _formatter.format("initial-value-for-property", propertyName); |
119 |
|
} |
120 |
|
|
121 |
|
static String unknownInjectType(String propertyName, String injectType) |
122 |
|
{ |
123 |
2 |
return _formatter.format("unknown-inject-type", propertyName, injectType); |
124 |
|
} |
125 |
|
|
126 |
|
static String wrongTypeForProperty(String propertyName, Class propertyType, Class requiredType) |
127 |
|
{ |
128 |
1 |
return _formatter.format("wrong-type-for-property", propertyName, ClassFabUtils |
129 |
|
.getJavaClassName(propertyType), ClassFabUtils.getJavaClassName(requiredType)); |
130 |
|
} |
131 |
|
|
132 |
|
static String wrongTypeForPageInjection(String propertyName, Class propertyType) |
133 |
|
{ |
134 |
1 |
return _formatter.format("wrong-type-for-page-injection", propertyName, ClassFabUtils |
135 |
|
.getJavaClassName(propertyType)); |
136 |
|
} |
137 |
|
|
138 |
|
static String incompatiblePropertyType(String propertyName, Class propertyType, |
139 |
|
Class expectedType) |
140 |
|
{ |
141 |
1 |
return _formatter.format("incompatible-property-type", propertyName, ClassFabUtils |
142 |
|
.getJavaClassName(propertyType), ClassFabUtils.getJavaClassName(expectedType)); |
143 |
|
} |
144 |
|
|
145 |
|
static String classEnhancementFailure(Class baseClass, Throwable cause) |
146 |
|
{ |
147 |
1 |
return _formatter.format("class-enhancement-failure", ClassFabUtils |
148 |
|
.getJavaClassName(baseClass), cause); |
149 |
|
} |
150 |
|
|
151 |
|
static String methodConflict(MethodSignature sig, Location existing) |
152 |
|
{ |
153 |
1 |
return _formatter.format("method-conflict", sig, existing); |
154 |
|
} |
155 |
|
|
156 |
|
static String readonlyProperty(String propertyName, Method writeMethod) |
157 |
|
{ |
158 |
1 |
return _formatter.format("readonly-property", propertyName, writeMethod); |
159 |
|
} |
160 |
|
|
161 |
|
static String mustBeBoolean(String propertyName) |
162 |
|
{ |
163 |
1 |
return _formatter.format("must-be-boolean", propertyName); |
164 |
|
} |
165 |
|
|
166 |
|
static String autowiring( String propertyName, IComponentSpecification spec, Object proxy ) |
167 |
|
{ |
168 |
2 |
return _formatter.format( "autowiring", propertyName, spec.getDescription(), proxy ); |
169 |
|
} |
170 |
|
|
171 |
|
static String unableToCreateClass(String name, Class superClass, Throwable cause) |
172 |
|
{ |
173 |
0 |
return _formatter.format("unable-to-create-class", name, superClass.getName(), cause); |
174 |
|
} |
175 |
|
|
176 |
|
static String unableToCreateInterface(String name, Exception cause) |
177 |
|
{ |
178 |
0 |
return _formatter.format("unable-to-create-interface", name, cause); |
179 |
|
} |
180 |
|
|
181 |
|
static String unableToAddField(String fieldName, CtClass ctClass, Throwable cause) |
182 |
|
{ |
183 |
0 |
return _formatter.format("unable-to-add-field", fieldName, ctClass.getName(), cause); |
184 |
|
} |
185 |
|
|
186 |
|
static String unableToLookupClass(String name, Throwable cause) |
187 |
|
{ |
188 |
0 |
return _formatter.format("unable-to-lookup", name, cause); |
189 |
|
} |
190 |
|
|
191 |
|
static String unableToWriteClass(CtClass ctClass, Throwable cause) |
192 |
|
{ |
193 |
0 |
return _formatter.format("unable-to-write-class", ctClass.getName(), cause); |
194 |
|
} |
195 |
|
|
196 |
|
static String duplicateMethodInClass(MethodSignature ms, ClassFabImpl cf) |
197 |
|
{ |
198 |
0 |
return _formatter.format("duplicate-method-in-class", ms, cf.getName()); |
199 |
|
} |
200 |
|
|
201 |
|
static String unableToAddMethod(MethodSignature methodSignature, CtClass ctClass, |
202 |
|
Throwable cause) |
203 |
|
{ |
204 |
0 |
return _formatter.format("unable-to-add-method", methodSignature, ctClass.getName(), cause); |
205 |
|
} |
206 |
|
|
207 |
|
static String unableToAddConstructor(CtClass ctClass, Throwable cause) |
208 |
|
{ |
209 |
0 |
return _formatter.format("unable-to-add-constructor", ctClass.getName(), cause); |
210 |
|
} |
211 |
|
|
212 |
|
static String unableToAddCatch(Class exceptionClass, CtMethod method, Throwable cause) |
213 |
|
{ |
214 |
0 |
return _formatter.format("unable-to-add-catch", exceptionClass.getName(), method |
215 |
|
.getDeclaringClass().getName(), cause); |
216 |
|
} |
217 |
|
|
218 |
|
static String unableToExtendMethod(MethodSignature ms, String className, Throwable cause) |
219 |
|
{ |
220 |
0 |
return _formatter.format("unable-to-extend-method", ms, className, cause); |
221 |
|
} |
222 |
|
} |