001// Copyright 2007, 2010, 2011 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
015package org.apache.tapestry5.ioc.internal;
016
017import org.apache.tapestry5.commons.AnnotationProvider;
018import org.apache.tapestry5.commons.ObjectLocator;
019import org.apache.tapestry5.ioc.Registry;
020
021import java.lang.annotation.Annotation;
022
023/**
024 * A wrapper around {@link InternalRegistry} that exists to expand symbols in a service id before
025 * invoking {@link ObjectLocator#getService(String, Class)}.
026 */
027public class RegistryWrapper implements Registry
028{
029    private final InternalRegistry registry;
030
031    public RegistryWrapper(final InternalRegistry registry)
032    {
033        this.registry = registry;
034    }
035
036    @Override
037    public void cleanupThread()
038    {
039        registry.cleanupThread();
040    }
041
042    @Override
043    public void shutdown()
044    {
045        registry.shutdown();
046    }
047
048    @Override
049    public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider)
050    {
051        return registry.getObject(objectType, annotationProvider);
052    }
053
054    @Override
055    public <T> T getService(String serviceId, Class<T> serviceInterface)
056    {
057        String expandedServiceId = registry.expandSymbols(serviceId);
058
059        return registry.getService(expandedServiceId, serviceInterface);
060    }
061
062    @Override
063    public <T> T getService(Class<T> serviceInterface)
064    {
065        return registry.getService(serviceInterface);
066    }
067
068    @Override
069    public <T> T getService(Class<T> serviceInterface, Class<? extends Annotation>... markerTypes)
070    {
071        return registry.getService(serviceInterface, markerTypes);
072    }
073
074    @Override
075    public <T> T autobuild(Class<T> clazz)
076    {
077        return registry.autobuild(clazz);
078    }
079
080    @Override
081    public <T> T autobuild(String description, Class<T> clazz)
082    {
083        return registry.autobuild(description, clazz);
084    }
085
086    @Override
087    public void performRegistryStartup()
088    {
089        registry.performRegistryStartup();
090    }
091
092    @Override
093    public <T> T proxy(Class<T> interfaceClass, Class<? extends T> implementationClass)
094    {
095        return registry.proxy(interfaceClass, implementationClass);
096    }
097
098}