1 15 package org.apache.hivemind.impl; 16 17 import java.net.URL ; 18 import java.util.Collection ; 19 import java.util.Iterator ; 20 import java.util.List ; 21 22 import org.apache.hivemind.ClassResolver; 23 import org.apache.hivemind.Location; 24 import org.apache.hivemind.Resource; 25 import org.apache.hivemind.definition.InterceptorDefinition; 26 import org.apache.hivemind.definition.ServicePointDefinition; 27 import org.apache.hivemind.events.RegistryShutdownListener; 28 import org.apache.hivemind.internal.ConfigurationPoint; 29 import org.apache.hivemind.internal.Module; 30 import org.apache.hivemind.internal.ServicePoint; 31 32 37 class ImplMessages 38 { 39 private static final MessageFormatter _formatter = new MessageFormatter(ImplMessages.class, 40 "ImplStrings"); 41 42 static String recursiveServiceBuild(ServicePoint point) 43 { 44 return _formatter.format("recursive-service-build", point.getExtensionPointId()); 45 } 46 47 static String recursiveConfiguration(String pointId) 48 { 49 return _formatter.format("recursive-configuration", pointId); 50 } 51 52 static String unableToConstructConfiguration(String pointId, Throwable exception) 53 { 54 return _formatter.format("unable-to-construct-configuration", pointId, exception 55 .getMessage()); 56 } 57 58 static String unknownServiceModel(String name) 59 { 60 return _formatter.format("unknown-service-model", name); 61 } 62 63 static String unqualifiedServicePoint( String serviceId, String matchingIds ) 64 { 65 return _formatter.format( "unqualified-service-point", serviceId, matchingIds ); 66 } 67 68 static String noSuchServicePoint(String serviceId) 69 { 70 return _formatter.format("no-such-service-point", serviceId); 71 } 72 73 static String unableToLoadClass(String name, ClassLoader loader, Throwable cause) 74 { 75 return _formatter.format("unable-to-load-class", name, loader, cause); 76 } 77 78 static String nullInterceptor(InterceptorDefinition interceptor, 79 ServicePoint point) 80 { 81 return _formatter.format("null-interceptor", interceptor.getName(), point 82 .getExtensionPointId()); 83 } 84 85 static String interceptorDoesNotImplementInterface(Object interceptor, 86 InterceptorDefinition interceptorDefinition, ServicePoint point, Class serviceInterface) 87 { 88 return _formatter.format("interceptor-does-not-implement-interface", new Object [] 89 { interceptor, interceptorDefinition.getName(), point.getExtensionPointId(), 90 serviceInterface.getName() }); 91 } 92 93 static String unableToReadMessages(URL url) 94 { 95 return _formatter.format("unable-to-read-messages", url); 96 } 97 98 static String unableToParse(Resource resource, Throwable cause) 99 { 100 return _formatter.format("unable-to-parse", resource, cause); 101 } 102 103 static String unableToFindProviders(ClassResolver resolver, Throwable cause) 104 { 105 return _formatter.format("unable-to-find-providers", resolver, cause); 106 } 107 108 static String unableToReadManifest(URL url, Throwable cause) 109 { 110 return _formatter.format("unable-to-read-manifest", url.toString(), cause); 111 } 112 113 static String duplicateModuleId(String moduleId, Location locationOfExisting, 114 Location locationOfDuplicate) 115 { 116 return _formatter.format( 117 "duplicate-module-id", 118 moduleId, 119 locationOfExisting.getResource(), 120 locationOfDuplicate.getResource()); 121 } 122 123 static String missingService(ServicePoint point) 124 { 125 return _formatter.format("missing-service", point.getExtensionPointId()); 126 } 127 128 static String duplicateFactory(Module sourceModule, String pointId, 129 ServicePointImpl existing) 130 { 131 return _formatter.format("duplicate-factory", sourceModule.getModuleId(), pointId, existing 132 .getImplementationDefinition().getModuleId()); 133 } 134 135 static String noSuchConfiguration(String pointId) 136 { 137 return _formatter.format("no-such-configuration", pointId); 138 } 139 140 static String badInterface(String interfaceName, String pointId) 141 { 142 return _formatter.format("bad-interface", interfaceName, pointId); 143 } 144 145 static String serviceWrongInterface(ServicePoint servicePoint, Class requestedInterface) 146 { 147 return _formatter.format( 148 "service-wrong-interface", 149 servicePoint.getExtensionPointId(), 150 requestedInterface.getName(), 151 servicePoint.getServiceInterface().getName()); 152 } 153 154 static String shutdownCoordinatorFailure(RegistryShutdownListener listener, 155 Throwable cause) 156 { 157 return _formatter.format("shutdown-coordinator-failure", listener, cause); 158 } 159 160 static String unlocatedError(String message) 161 { 162 return _formatter.format("unlocated-error", message); 163 } 164 165 static String locatedError(Location location, String message) 166 { 167 return _formatter.format("located-error", location, message); 168 } 169 170 static String interceptorContribution() 171 { 172 return _formatter.getMessage("interceptor-contribution"); 173 } 174 175 static String registryAlreadyStarted() 176 { 177 return _formatter.getMessage("registry-already-started"); 178 } 179 180 static String noServicePointForInterface(Class interfaceClass) 181 { 182 return _formatter.format("no-service-point-for-interface", interfaceClass.getName()); 183 } 184 185 static String noConfigurationPointForType(Class configurationType) 186 { 187 return _formatter.format("no-configuration-point-for-type", configurationType.getName()); 188 } 189 190 static String multipleServicePointsForInterface(Class interfaceClass, 191 Collection matchingPoints) 192 { 193 StringBuffer buffer = new StringBuffer ("{"); 194 195 boolean following = false; 196 197 Iterator i = matchingPoints.iterator(); 198 while (i.hasNext()) 199 { 200 if (following) 201 buffer.append(", "); 202 203 ServicePoint p = (ServicePoint) i.next(); 204 205 buffer.append(p.getExtensionPointId()); 206 207 following = true; 208 } 209 210 buffer.append("}"); 211 212 return _formatter.format( 213 "multiple-service-points-for-interface", 214 interfaceClass.getName(), 215 buffer); 216 } 217 218 static String multipleConfigurationPointsForType(Class configurationType, List configurationPoints) 219 { 220 StringBuffer buffer = new StringBuffer ("{"); 221 222 boolean following = false; 223 224 Iterator i = configurationPoints.iterator(); 225 while (i.hasNext()) 226 { 227 if (following) 228 buffer.append(", "); 229 230 ServicePoint p = (ServicePoint) i.next(); 231 232 buffer.append(p.getExtensionPointId()); 233 234 following = true; 235 } 236 237 buffer.append("}"); 238 239 return _formatter.format( 240 "multiple-configuration-points-for-type", 241 configurationType.getName(), 242 buffer); 243 } 244 245 private static String convertModule(Module module) 246 { 247 if (module == null) 248 return _formatter.getMessage("null-module"); 249 250 return _formatter.format("module", module.getModuleId()); 251 } 252 253 static String serviceNotVisible(String serviceId, Module module) 254 { 255 return _formatter.format("service-not-visible", serviceId, convertModule(module)); 256 } 257 258 static String configurationNotVisible(String configurationId, Module module) 259 { 260 return _formatter.format( 261 "configuration-not-visible", 262 configurationId, 263 convertModule(module)); 264 } 265 266 static String unableToMapConfiguration(ConfigurationPoint point) 267 { 268 return _formatter.format("unable-to-map-configuration", point.getExtensionPointId()); 269 } 270 271 static String unableToConvertType(String type, String packageName) 272 { 273 return _formatter.format("unable-to-convert-type", type, packageName); 274 } 275 276 public static String unableToCreateProvider(String providerClassName, Exception cause) 277 { 278 return _formatter.format("unable-to-create-provider", providerClassName, cause); 279 } 280 281 public static String providerWrongType(String providerClassName, Class requiredInterface) 282 { 283 return _formatter.format("provider-wrong-type", providerClassName, requiredInterface.getName()); 284 } 285 286 public static String servicePointDefinitionWithoutImplementation(ServicePointDefinition sd) 287 { 288 return _formatter.format("servicepointdefinition-without-implementation", sd.getQualifiedId()); 289 } 290 291 292 } | Popular Tags |