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.ioc.internal.services;
016:
017: import javassist.CtClass;
018:
019: import org.apache.tapestry.ioc.Messages;
020: import org.apache.tapestry.ioc.internal.util.MessagesImpl;
021: import org.apache.tapestry.ioc.services.ClassFabUtils;
022: import org.apache.tapestry.ioc.services.Coercion;
023: import org.apache.tapestry.ioc.services.MethodSignature;
024: import org.apache.tapestry.ioc.services.ThreadCleanupListener;
025:
026: final class ServiceMessages {
027: private final static Messages MESSAGES = MessagesImpl
028: .forClass(ServiceMessages.class);
029:
030: private ServiceMessages() {
031: }
032:
033: static String unableToAddMethod(MethodSignature signature,
034: CtClass ctClass, Throwable cause) {
035: return MESSAGES.format("unable-to-add-method", signature,
036: ctClass.getName(), cause);
037: }
038:
039: static String unableToAddConstructor(CtClass ctClass,
040: Throwable cause) {
041: return MESSAGES.format("unable-to-add-constructor", ctClass
042: .getName(), cause);
043: }
044:
045: static String unableToAddField(String fieldName, CtClass ctClass,
046: Throwable cause) {
047: return MESSAGES.format("unable-to-add-field", fieldName,
048: ctClass.getName(), cause);
049: }
050:
051: static String unableToCreateClass(String className,
052: Class super Class, Throwable cause) {
053: return MESSAGES.format("unable-to-create-class", className,
054: super Class.getName(), cause);
055: }
056:
057: static String unableToLookupClass(String className, Throwable cause) {
058: return MESSAGES.format("unable-to-lookup-class", className,
059: cause);
060: }
061:
062: static String unableToWriteClass(CtClass ctClass, Throwable cause) {
063: return MESSAGES.format("unable-to-write-class", ctClass
064: .getName(), cause);
065: }
066:
067: static String duplicateMethodInClass(MethodSignature ms,
068: ClassFabImpl fab) {
069: return MESSAGES.format("duplicate-method-in-class", ms, fab
070: .getName());
071: }
072:
073: static String loggingInterceptor(String serviceId,
074: Class serviceInterface) {
075: return MESSAGES.format("logging-interceptor", serviceId,
076: serviceInterface.getName());
077: }
078:
079: static String threadCleanupError(ThreadCleanupListener listener,
080: Throwable cause) {
081: return MESSAGES.format("thread-cleanup-error", listener, cause);
082: }
083:
084: static String noSuchProperty(Class clazz, String propertyName) {
085: return MESSAGES.format("no-such-property", clazz.getName(),
086: propertyName);
087: }
088:
089: static String readNotSupported(Object instance, String propertyName) {
090: return MESSAGES.format("read-not-supported", instance
091: .getClass().getName(), propertyName);
092: }
093:
094: static String writeNotSupported(Object instance, String propertyName) {
095: return MESSAGES.format("write-not-supported", instance
096: .getClass().getName(), propertyName);
097: }
098:
099: static String readFailure(String propertyName, Object instance,
100: Throwable cause) {
101: return MESSAGES.format("read-failure", propertyName, instance,
102: cause);
103: }
104:
105: static String writeFailure(String propertyName, Object instance,
106: Throwable cause) {
107: return MESSAGES.format("write-failure", propertyName, instance,
108: cause);
109: }
110:
111: static String propertyTypeMismatch(String propertyName,
112: Class sourceClass, Class propertyType, Class expectedType) {
113: return MESSAGES.format("property-type-mismatch", propertyName,
114: sourceClass.getName(), propertyType.getName(),
115: expectedType.getName());
116: }
117:
118: static String extraFilterMethod(MethodSignature sig,
119: Class filterInterface, Class serviceInterface) {
120: return MESSAGES.format("extra-filter-method", sig,
121: filterInterface.getName(), serviceInterface.getName());
122: }
123:
124: static String unmatchedServiceMethod(MethodSignature sig,
125: Class filterInterface) {
126: return MESSAGES.format("unmatched-service-method", sig,
127: filterInterface.getName());
128: }
129:
130: static String unknownObjectProvider(String prefix, String reference) {
131: return MESSAGES.format("unknown-object-provider", prefix,
132: reference);
133: }
134:
135: static String shutdownListenerError(Object listener, Throwable cause) {
136: return MESSAGES.format("shutdown-listener-error", listener,
137: cause);
138: }
139:
140: static String noCoercionFound(Class sourceType, Class targetType,
141: String coercions) {
142: return MESSAGES.format("no-coercion-found", sourceType
143: .getName(), targetType.getName(), coercions);
144: }
145:
146: static String recursiveSymbol(String symbolName, String path) {
147: return MESSAGES.format("recursive-symbol", symbolName, path);
148: }
149:
150: static String symbolUndefined(String symbolName) {
151: return MESSAGES.format("symbol-undefined", symbolName);
152: }
153:
154: static String symbolUndefinedInPath(String symbolName, String path) {
155: return MESSAGES.format("symbol-undefined-in-path", symbolName,
156: path);
157: }
158:
159: static String missingSymbolCloseBrace(String input) {
160: return MESSAGES.format("missing-symbol-close-brace", input);
161: }
162:
163: static String missingSymbolCloseBraceInPath(String input,
164: String path) {
165: return MESSAGES.format("missing-symbol-close-brace-in-path",
166: input, path);
167: }
168:
169: static String failedCoercion(Object input, Class targetType,
170: Coercion coercion, Throwable cause) {
171: return MESSAGES.format("failed-coercion",
172: String.valueOf(input), ClassFabUtils
173: .toJavaClassName(targetType), coercion, cause);
174: }
175:
176: static String registryShutdown(String serviceId) {
177: return MESSAGES.format("registry-shutdown", serviceId);
178: }
179:
180: static String serviceBuildFailure(String serviceId, Throwable cause) {
181: return MESSAGES.format("service-build-failure", serviceId,
182: cause);
183: }
184: }
|