01: // Copyright 2006, 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // 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.tapestry.ioc.internal;
16:
17: import org.apache.tapestry.ioc.AnnotationProvider;
18: import org.apache.tapestry.ioc.ObjectLocator;
19:
20: /**
21: * Base service locator class used when only the module is known (i.e., when instantiating a module
22: * builder class).
23: */
24: public class ObjectLocatorImpl implements ObjectLocator {
25: private final InternalRegistry _registry;
26:
27: private final Module _module;
28:
29: public ObjectLocatorImpl(InternalRegistry registry, Module module) {
30: _registry = registry;
31: _module = module;
32: }
33:
34: public <T> T getService(String serviceId, Class<T> serviceInterface) {
35: String expandedServiceId = _registry.expandSymbols(serviceId);
36:
37: return _registry
38: .getService(expandedServiceId, serviceInterface);
39: }
40:
41: public <T> T getService(Class<T> serviceInterface) {
42: return _registry.getService(serviceInterface);
43: }
44:
45: public <T> T getObject(Class<T> objectType,
46: AnnotationProvider annotationProvider) {
47: return _registry.getObject(objectType, annotationProvider);
48: }
49:
50: protected InternalRegistry getRegistry() {
51: return _registry;
52: }
53:
54: protected Module getModule() {
55: return _module;
56: }
57:
58: public <T> T autobuild(Class<T> clazz) {
59: return _registry.autobuild(clazz);
60: }
61:
62: }
|