001 // Copyright 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.hivemind.annotations; 016 017 import org.apache.hivemind.service.Autowiring; 018 019 /** 020 * Specialized interface for the {@link org.apache.hivemind.Registry} access from annotated modules. 021 * Implements typed access to services and configurations by use of Generics. 022 * 023 * @author Achim Huegen 024 */ 025 public interface TypedRegistry 026 { 027 /** 028 * Returns a service from the registry. 029 * 030 * @see org.apache.hivemind.Registry#getService(String, Class) 031 */ 032 public <T> T getService(String serviceId, Class<T> serviceInterface); 033 034 /** 035 * Finds a service that implements the provided interface. 036 * Exactly one such service may exist or an exception is thrown. 037 * 038 * @see org.apache.hivemind.Registry#getService(Class) 039 */ 040 public <T> T getService(Class<T> serviceInterface); 041 042 /** 043 * Returns the specified configuration from the registry. 044 * 045 * @see org.apache.hivemind.Registry#getConfiguration(String) 046 */ 047 public <T> T getConfiguration(String configurationId, Class<T> configurationType); 048 049 /** 050 * Finds a configuration by its type. 051 * Exactly one such configuration may exist or an exception is thrown. 052 * 053 * @see org.apache.hivemind.Registry#getConfiguration(String) 054 */ 055 public <T> T getConfiguration(Class<T> configurationType); 056 057 058 /** 059 * Returns a reference to the {@link Autowiring} service. 060 */ 061 public Autowiring getAutowiring(); 062 063 /** 064 * @see org.apache.hivemind.Registry#shutdown() 065 */ 066 public void shutdown(); 067 }