KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > impl > ImplMessages


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.hivemind.impl;
16
17 import java.net.URL JavaDoc;
18 import java.util.Collection JavaDoc;
19 import java.util.Iterator JavaDoc;
20 import java.util.List JavaDoc;
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 /**
33  * Used to format messages used in errors and log output for classes within the impl package.
34  *
35  * @author Howard Lewis Ship
36  */

37 class ImplMessages
38 {
39     private static final MessageFormatter _formatter = new MessageFormatter(ImplMessages.class,
40             "ImplStrings");
41
42     static String JavaDoc recursiveServiceBuild(ServicePoint point)
43     {
44         return _formatter.format("recursive-service-build", point.getExtensionPointId());
45     }
46
47     static String JavaDoc recursiveConfiguration(String JavaDoc pointId)
48     {
49         return _formatter.format("recursive-configuration", pointId);
50     }
51
52     static String JavaDoc unableToConstructConfiguration(String JavaDoc pointId, Throwable JavaDoc exception)
53     {
54         return _formatter.format("unable-to-construct-configuration", pointId, exception
55                 .getMessage());
56     }
57
58     static String JavaDoc unknownServiceModel(String JavaDoc name)
59     {
60         return _formatter.format("unknown-service-model", name);
61     }
62
63     static String JavaDoc unqualifiedServicePoint( String JavaDoc serviceId, String JavaDoc matchingIds )
64     {
65         return _formatter.format( "unqualified-service-point", serviceId, matchingIds );
66     }
67     
68     static String JavaDoc noSuchServicePoint(String JavaDoc serviceId)
69     {
70         return _formatter.format("no-such-service-point", serviceId);
71     }
72
73     static String JavaDoc unableToLoadClass(String JavaDoc name, ClassLoader JavaDoc loader, Throwable JavaDoc cause)
74     {
75         return _formatter.format("unable-to-load-class", name, loader, cause);
76     }
77
78     static String JavaDoc nullInterceptor(InterceptorDefinition interceptor,
79             ServicePoint point)
80     {
81         return _formatter.format("null-interceptor", interceptor.getName(), point
82                 .getExtensionPointId());
83     }
84
85     static String JavaDoc interceptorDoesNotImplementInterface(Object JavaDoc interceptor,
86             InterceptorDefinition interceptorDefinition, ServicePoint point, Class JavaDoc serviceInterface)
87     {
88         return _formatter.format("interceptor-does-not-implement-interface", new Object JavaDoc[]
89         { interceptor, interceptorDefinition.getName(), point.getExtensionPointId(),
90                 serviceInterface.getName() });
91     }
92
93     static String JavaDoc unableToReadMessages(URL JavaDoc url)
94     {
95         return _formatter.format("unable-to-read-messages", url);
96     }
97
98     static String JavaDoc unableToParse(Resource resource, Throwable JavaDoc cause)
99     {
100         return _formatter.format("unable-to-parse", resource, cause);
101     }
102
103     static String JavaDoc unableToFindProviders(ClassResolver resolver, Throwable JavaDoc cause)
104     {
105         return _formatter.format("unable-to-find-providers", resolver, cause);
106     }
107     
108     static String JavaDoc unableToReadManifest(URL JavaDoc url, Throwable JavaDoc cause)
109     {
110         return _formatter.format("unable-to-read-manifest", url.toString(), cause);
111     }
112
113     static String JavaDoc duplicateModuleId(String JavaDoc 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 JavaDoc missingService(ServicePoint point)
124     {
125         return _formatter.format("missing-service", point.getExtensionPointId());
126     }
127
128     static String JavaDoc duplicateFactory(Module sourceModule, String JavaDoc pointId,
129             ServicePointImpl existing)
130     {
131         return _formatter.format("duplicate-factory", sourceModule.getModuleId(), pointId, existing
132                 .getImplementationDefinition().getModuleId());
133     }
134
135     static String JavaDoc noSuchConfiguration(String JavaDoc pointId)
136     {
137         return _formatter.format("no-such-configuration", pointId);
138     }
139
140     static String JavaDoc badInterface(String JavaDoc interfaceName, String JavaDoc pointId)
141     {
142         return _formatter.format("bad-interface", interfaceName, pointId);
143     }
144
145     static String JavaDoc serviceWrongInterface(ServicePoint servicePoint, Class JavaDoc 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 JavaDoc shutdownCoordinatorFailure(RegistryShutdownListener listener,
155             Throwable JavaDoc cause)
156     {
157         return _formatter.format("shutdown-coordinator-failure", listener, cause);
158     }
159
160     static String JavaDoc unlocatedError(String JavaDoc message)
161     {
162         return _formatter.format("unlocated-error", message);
163     }
164
165     static String JavaDoc locatedError(Location location, String JavaDoc message)
166     {
167         return _formatter.format("located-error", location, message);
168     }
169
170     static String JavaDoc interceptorContribution()
171     {
172         return _formatter.getMessage("interceptor-contribution");
173     }
174
175     static String JavaDoc registryAlreadyStarted()
176     {
177         return _formatter.getMessage("registry-already-started");
178     }
179
180     static String JavaDoc noServicePointForInterface(Class JavaDoc interfaceClass)
181     {
182         return _formatter.format("no-service-point-for-interface", interfaceClass.getName());
183     }
184
185     static String JavaDoc noConfigurationPointForType(Class JavaDoc configurationType)
186     {
187         return _formatter.format("no-configuration-point-for-type", configurationType.getName());
188     }
189
190     static String JavaDoc multipleServicePointsForInterface(Class JavaDoc interfaceClass,
191             Collection JavaDoc matchingPoints)
192     {
193         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("{");
194
195         boolean following = false;
196
197         Iterator JavaDoc 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 JavaDoc multipleConfigurationPointsForType(Class JavaDoc configurationType, List JavaDoc configurationPoints)
219     {
220         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc("{");
221
222         boolean following = false;
223
224         Iterator JavaDoc 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 JavaDoc 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 JavaDoc serviceNotVisible(String JavaDoc serviceId, Module module)
254     {
255         return _formatter.format("service-not-visible", serviceId, convertModule(module));
256     }
257
258     static String JavaDoc configurationNotVisible(String JavaDoc configurationId, Module module)
259     {
260         return _formatter.format(
261                 "configuration-not-visible",
262                 configurationId,
263                 convertModule(module));
264     }
265
266     static String JavaDoc unableToMapConfiguration(ConfigurationPoint point)
267     {
268         return _formatter.format("unable-to-map-configuration", point.getExtensionPointId());
269     }
270
271     static String JavaDoc unableToConvertType(String JavaDoc type, String JavaDoc packageName)
272     {
273         return _formatter.format("unable-to-convert-type", type, packageName);
274     }
275
276     public static String JavaDoc unableToCreateProvider(String JavaDoc providerClassName, Exception JavaDoc cause)
277     {
278         return _formatter.format("unable-to-create-provider", providerClassName, cause);
279     }
280
281     public static String JavaDoc providerWrongType(String JavaDoc providerClassName, Class JavaDoc requiredInterface)
282     {
283         return _formatter.format("provider-wrong-type", providerClassName, requiredInterface.getName());
284     }
285
286     public static String JavaDoc servicePointDefinitionWithoutImplementation(ServicePointDefinition sd)
287     {
288         return _formatter.format("servicepointdefinition-without-implementation", sd.getQualifiedId());
289     }
290
291
292 }
Popular Tags