001: // Copyright 2006, 2007 The Apache Software Foundation
002: //
003: // Licensed under the Apache License, Version 2.0 (the "License");
004: // you may not use this file except in compliance with the License.
005: // You may obtain a copy of the License at
006: //
007: // http://www.apache.org/licenses/LICENSE-2.0
008: //
009: // Unless required by applicable law or agreed to in writing, software
010: // distributed under the License is distributed on an "AS IS" BASIS,
011: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: // See the License for the specific language governing permissions and
013: // limitations under the License.
014:
015: package org.apache.tapestry.internal.services;
016:
017: import java.net.URL;
018: import java.util.Collection;
019: import java.util.List;
020:
021: import javassist.CtClass;
022:
023: import org.apache.tapestry.ioc.Location;
024: import org.apache.tapestry.ioc.Messages;
025: import org.apache.tapestry.ioc.Resource;
026: import org.apache.tapestry.ioc.internal.util.CollectionFactory;
027: import org.apache.tapestry.ioc.internal.util.InternalUtils;
028: import org.apache.tapestry.ioc.internal.util.MessagesImpl;
029: import org.apache.tapestry.ioc.services.ClassFabUtils;
030: import org.apache.tapestry.runtime.Component;
031: import org.apache.tapestry.runtime.RenderCommand;
032: import org.apache.tapestry.services.MethodSignature;
033:
034: class ServicesMessages {
035: private static final Messages MESSAGES = MessagesImpl
036: .forClass(ServicesMessages.class);
037:
038: static final String duplicateContribution(Object conflict,
039: Class contributionType, Object existing) {
040: return MESSAGES.format("duplicate-contribution", conflict,
041: contributionType.getName(), existing);
042: }
043:
044: static final String markupWriterNoCurrentElement() {
045: return MESSAGES.get("markup-writer-no-current-element");
046: }
047:
048: static String noConstructorFound(Class instanceClass) {
049: return MESSAGES.format("no-constructor-found", instanceClass
050: .getName());
051: }
052:
053: static String missingDeclaredField(CtClass ctClass, String fieldName) {
054: return MESSAGES.format("missing-declared-field", ctClass
055: .getName(), fieldName);
056: }
057:
058: static String errorAddingMethod(CtClass ctClass, String methodName,
059: Throwable cause) {
060: return MESSAGES.format("error-adding-method",
061: ctClass.getName(), methodName, cause);
062: }
063:
064: static String fieldAlreadyClaimed(String fieldName,
065: CtClass ctClass, Object existingTag, Object newTag) {
066: return MESSAGES.format("field-already-claimed", new Object[] {
067: fieldName, ctClass.getName(), existingTag, newTag });
068: }
069:
070: static String noDeclaredMethod(CtClass ctClass,
071: MethodSignature methodSignature) {
072: return MESSAGES.format("no-declared-method", ctClass.getName(),
073: methodSignature);
074: }
075:
076: static String incorrectClassForInstantiator(String className,
077: Class componentClass) {
078: return MESSAGES.format("incorrect-class-for-instantiator",
079: className, componentClass.getName());
080: }
081:
082: static String classNotTransformed(String className) {
083: return MESSAGES.format("class-not-transformed", className);
084: }
085:
086: static String newParserError(Resource resource, Throwable cause) {
087: return MESSAGES.format("new-parser-error", resource, cause);
088: }
089:
090: static String missingTemplateResource(Resource resource) {
091: return MESSAGES.format("missing-template-resource", resource);
092: }
093:
094: static String templateParseError(Resource resource, Throwable cause) {
095: return MESSAGES.format("template-parse-error", resource, cause);
096: }
097:
098: static String contentInsideBodyNotAllowed(Location location) {
099: return MESSAGES.format("content-inside-body-not-allowed",
100: location);
101: }
102:
103: static String mayNotNestElementsInsideBody(String elementName) {
104: return MESSAGES.format("may-not-nest-elements-inside-body",
105: elementName);
106: }
107:
108: static String methodCompileError(MethodSignature signature,
109: String methodBody, Throwable cause) {
110: return MESSAGES.format("method-compile-error", signature,
111: methodBody, cause);
112: }
113:
114: static String renderQueueError(RenderCommand command,
115: Throwable cause) {
116: return MESSAGES.format("render-queue-error", command, cause);
117: }
118:
119: static String readOnlyField(String className, String fieldName) {
120: return MESSAGES.format("read-only-field", className, fieldName);
121: }
122:
123: static String nonPrivateFields(String className, List<String> names) {
124: return MESSAGES.format("non-private-fields", className,
125: InternalUtils.joinSorted(names));
126: }
127:
128: static String compTypeConflict(String embeddedId,
129: String templateType, String modelType) {
130: return MESSAGES.format("comp-type-conflict", embeddedId,
131: templateType, modelType);
132: }
133:
134: static String noTypeForEmbeddedComponent(String embeddedId,
135: String componentClassName) {
136: return MESSAGES.format("no-type-for-embedded-component",
137: embeddedId, componentClassName);
138: }
139:
140: static String embeddedComponentsNotInTemplate(
141: Collection<String> ids, String componentClassName) {
142: return MESSAGES.format("embedded-components-not-in-template",
143: InternalUtils.joinSorted(ids), componentClassName);
144: }
145:
146: static String bindingSourceFailure(String expression,
147: Throwable cause) {
148: return MESSAGES.format("binding-source-failure", expression,
149: cause);
150: }
151:
152: static String contextIndexOutOfRange(String methodDescription) {
153: return MESSAGES.format("context-index-out-of-range",
154: methodDescription);
155: }
156:
157: static String pageNameUnresolved(String pageClassName) {
158: return MESSAGES.format("page-name-unresolved", pageClassName);
159: }
160:
161: static String exceptionInMethodParameter(String methodDescription,
162: int index, Throwable cause) {
163: return MESSAGES.format("exception-in-method-parameter",
164: methodDescription, index + 1, cause);
165: }
166:
167: static String componentEventIsAborted(String methodDescription) {
168: return MESSAGES.format("component-event-is-aborted",
169: methodDescription);
170: }
171:
172: static String unknownPersistentFieldStrategy(String stategyName,
173: Collection<String> strategyNames) {
174: return MESSAGES.format("unknown-persistent-field-strategy",
175: stategyName, InternalUtils.joinSorted(strategyNames));
176: }
177:
178: static String couldNotResolvePageName(String pageName,
179: Collection<String> pageNames) {
180: return MESSAGES.format("could-not-resolve-page-name", pageName,
181: InternalUtils.joinSorted(pageNames));
182: }
183:
184: static String couldNotCanonicalizePageName(String pageName,
185: Collection<String> pageNames) {
186: return MESSAGES.format("could-not-canonicalize-page-name",
187: pageName, InternalUtils.joinSorted(pageNames));
188: }
189:
190: static String couldNotResolveComponentType(String componentType,
191: Collection<String> componentTypes) {
192: return MESSAGES
193: .format("could-not-resolve-component-type",
194: componentType, InternalUtils
195: .joinSorted(componentTypes));
196: }
197:
198: static String couldNotResolveMixinType(String mixinType,
199: Collection<String> mixinTypes) {
200: return MESSAGES.format("could-not-resolve-mixin-type",
201: mixinType, InternalUtils.joinSorted(mixinTypes));
202: }
203:
204: static String parameterNameMustBeUnique(String parameterName,
205: String parameterValue) {
206: return MESSAGES.format("parameter-name-must-be-unique",
207: parameterName, parameterValue);
208: }
209:
210: static String pageIsDirty(Object page) {
211: return MESSAGES.format("page-is-dirty", page);
212: }
213:
214: static String componentInstanceIsNotAPage(String methodDescription,
215: Component component, Component result) {
216: return MESSAGES.format("component-instance-is-not-a-page",
217: methodDescription, component.getComponentResources()
218: .getCompleteId(), result
219: .getComponentResources().getCompleteId());
220: }
221:
222: static String failureReadingMessages(URL url, Throwable cause) {
223: return MESSAGES.format("failure-reading-messages", url, cause);
224: }
225:
226: static String unknownAssetPrefix(String path) {
227: return MESSAGES.format("unknown-asset-prefix", path);
228: }
229:
230: static String assetDoesNotExist(Resource resource) {
231: return MESSAGES.format("asset-does-not-exist", resource);
232: }
233:
234: static String wrongAssetDigest(Resource resource) {
235: return MESSAGES
236: .format("wrong-asset-digest", resource.getPath());
237: }
238:
239: static String componentNotAssignableToField(Component component,
240: String fieldName, String fieldType) {
241: return MESSAGES.format("component-not-assignable-to-field",
242: component.getComponentResources().getCompleteId(),
243: fieldName, fieldType);
244: }
245:
246: static String unknownValidatorType(String validatorType,
247: List<String> knownValidatorTypes) {
248: return MESSAGES.format("unknown-validator-type", validatorType,
249: InternalUtils.join(knownValidatorTypes));
250: }
251:
252: static String unknownTranslatorType(String translatorType,
253: List<String> knownTranslatorTypes) {
254: return MESSAGES.format("unknown-translator-type",
255: translatorType, InternalUtils
256: .join(knownTranslatorTypes));
257: }
258:
259: static String validatorSpecificationParseError(int cursor,
260: String specification) {
261: return MESSAGES
262: .format("validator-specification-parse-error",
263: specification.charAt(cursor), cursor + 1,
264: specification);
265: }
266:
267: static String mixinsInvalidWithoutIdOrType(String elementName) {
268: return MESSAGES.format("mixins-invalid-without-id-or-type",
269: elementName);
270: }
271:
272: static String missingFromEnvironment(Class type,
273: Collection<Class> availableTypes) {
274: List<String> types = CollectionFactory.newList();
275:
276: for (Class c : availableTypes)
277: types.add(c.getName());
278:
279: return MESSAGES.format("missing-from-environment", type
280: .getName(), InternalUtils.joinSorted(types));
281:
282: }
283:
284: static String invalidComponentEventResult(Component component,
285: Object result, String methodDescription,
286: Collection<Class> configuredResultTypes) {
287: List<String> classNames = CollectionFactory.newList();
288:
289: for (Class c : configuredResultTypes)
290: classNames.add(c.getName());
291:
292: return MESSAGES.format("invalid-component-event-result",
293: component.getComponentResources().getCompleteId(),
294: result, methodDescription, ClassFabUtils
295: .toJavaClassName(result.getClass()),
296: InternalUtils.joinSorted(classNames));
297: }
298:
299: static String undefinedTapestryAttribute(String elementName,
300: String attributeName, String allowedAttributeName) {
301: return MESSAGES.format("undefined-tapestry-attribute",
302: elementName, attributeName, allowedAttributeName);
303: }
304:
305: static String parameterElementNameRequired() {
306: return MESSAGES.get("parameter-element-name-required");
307: }
308:
309: static String missingApplicationStatePersistenceStrategy(
310: String name, Collection<String> availableNames) {
311: return MESSAGES.format(
312: "missing-application-state-persistence-strategy", name,
313: InternalUtils.joinSorted(availableNames));
314: }
315:
316: static String methodIsVoid(String methodName, Class inClass,
317: String propertyExpression) {
318: return MESSAGES.format("method-is-void", methodName, inClass
319: .getName(), propertyExpression);
320: }
321:
322: static String methodNotFound(String methodName, Class inClass,
323: String propertyExpression) {
324: return MESSAGES.format("method-not-found", methodName, inClass
325: .getName(), propertyExpression);
326: }
327:
328: static String noSuchProperty(Class targetClass,
329: String propertyName, String propertyExpression) {
330: return MESSAGES.format("no-such-property", targetClass
331: .getName(), propertyName, propertyExpression);
332: }
333:
334: static String writeOnlyProperty(String propertyName, Class clazz,
335: String propertyExpression) {
336: return MESSAGES.format("write-only-property", propertyName,
337: clazz.getName(), propertyExpression);
338: }
339:
340: static String requestException(Throwable cause) {
341: return MESSAGES.format("request-exception", cause);
342: }
343:
344: static String componentRecursion(String componentClassName) {
345: return MESSAGES.format("component-recursion",
346: componentClassName);
347: }
348:
349: static String fieldInjectionError(String className,
350: String fieldName, Throwable cause) {
351: return MESSAGES.format("field-injection-error", className,
352: fieldName, cause);
353: }
354:
355: static String clientStateMustBeSerializable(Object newValue) {
356: return MESSAGES.format("client-state-must-be-serializable",
357: newValue);
358: }
359:
360: static String corruptClientState() {
361: return MESSAGES.get("corrupt-client-state");
362: }
363:
364: static String unclosedAttributeExpression(String expression) {
365: return MESSAGES.format("unclosed-attribute-expression",
366: expression);
367: }
368:
369: static String noDisplayForDataType(String datatype) {
370: return MESSAGES.format("no-display-for-data-type", datatype);
371: }
372:
373: static String noEditForDataType(String datatype) {
374: return MESSAGES.format("no-edit-for-data-type", datatype);
375: }
376:
377: static String missingValidatorConstraint(String validatorType,
378: Class type) {
379: return MESSAGES.format("missing-validator-constraint",
380: validatorType, type.getName());
381: }
382: }
|