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