001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.geronimo.osgi.registry.api;
018
019 import java.util.List;
020
021 /**
022 * The implementation of the factory registry used to store
023 * the bundle registrations.
024 */
025 public interface ProviderRegistry {
026 /**
027 * Locate a class by its factory id indicator. .
028 *
029 * @param factoryId The factory id (generally, a fully qualified class name).
030 *
031 * @return The Class corresponding to this factory id. Returns null
032 * if this is not registered or the indicated class can't be
033 * loaded.
034 */
035 public Class<?> locate(String factoryId);
036
037 /**
038 * Locate all class files that match a given factory id.
039 *
040 * @param factoryId The target factory identifier.
041 *
042 * @return A List containing the class objects corresponding to the
043 * factory identifier. Returns an empty list if no
044 * matching classes can be located.
045 */
046 public List<Class<?>> locateAll(String factoryId);
047
048
049 /**
050 * Locate and instantiate an instance of a service provider
051 * defined in the META-INF/services directory of tracked bundles.
052 *
053 * @param providerId The name of the target interface class.
054 *
055 * @return The service instance. Returns null if no service defintions
056 * can be located.
057 * @exception Exception Any classloading or other exceptions thrown during
058 * the process of creating this service instance.
059 */
060 public Object getService(String providerId) throws Exception;
061
062 /**
063 * Locate all services that match a given provider id and create instances.
064 *
065 * @param providerId The target provider identifier.
066 *
067 * @return A List containing the instances corresponding to the
068 * provider identifier. Returns an empty list if no
069 * matching classes can be located or created
070 */
071 public List<Object> getServices(String providerId);
072
073
074 /**
075 * Locate and return the class for a service provider
076 * defined in the META-INF/services directory of tracked bundles.
077 *
078 * @param providerId The name of the target interface class.
079 *
080 * @return The provider class. Returns null if no service defintions
081 * can be located.
082 * @exception Exception Any classloading or other exceptions thrown during
083 * the process of loading this service provider class.
084 */
085 public Class<?> getServiceClass(String providerId) throws ClassNotFoundException;
086
087
088 /**
089 * Locate all services that match a given provider id and return the implementation
090 * classes
091 *
092 * @param providerId The target provider identifier.
093 *
094 * @return A List containing the classes corresponding to the
095 * provider identifier. Returns an empty list if no
096 * matching classes can be located.
097 */
098 public List<Class<?>> getServiceClasses(String providerId);
099 }