FileDocCategorySizeDatePackage
ServiceRegistry.javaAPI DocAndroid 1.5 API16844Wed May 06 22:41:54 BST 2009javax.imageio.spi

ServiceRegistry

public class ServiceRegistry extends Object
The ServiceRegistry class provides ability to register, deregister, look up and obtain service provider instances (SPIs). A service means a set of interfaces and classes, and a service provider is an implementation of a service. Service providers can be associated with one or more categories. Each category is defined by a class or interface. Only a single instance of a each class is allowed to be registered as a category.
since
Android 1.0

Fields Summary
CategoriesMap
categories
The categories.
Constructors Summary
public ServiceRegistry(Iterator categoriesIterator)
Instantiates a new ServiceRegistry with the specified categories.

param
categoriesIterator an Iterator of Class objects for defining of categories.


                                        
       
        if (null == categoriesIterator) {
            throw new IllegalArgumentException("categories iterator should not be NULL");
        }
        while (categoriesIterator.hasNext()) {
            Class<?> c = categoriesIterator.next();
            categories.addCategory(c);
        }
    
Methods Summary
public booleancontains(java.lang.Object provider)
Checks whether the specified provider has been already registered.

param
provider the provider to be checked.
return
true, if the specified provider has been already registered, false otherwise.

        throw new UnsupportedOperationException("Not supported yet");
    
public voidderegisterAll(java.lang.Class category)
Deregisters all providers from the specified category.

param
category the specified category.

        throw new UnsupportedOperationException("Not supported yet");
    
public voidderegisterAll()
Deregister all providers from all categories.

        throw new UnsupportedOperationException("Not supported yet");
    
public booleanderegisterServiceProvider(T provider, java.lang.Class category)
Deregisters the specifies service provider from the specified category.

param
provider the service provider to be deregistered.
param
category the specified category.
return
true, if the provider was already registered in the specified category, false otherwise.

        throw new UnsupportedOperationException("Not supported yet");
    
public voidderegisterServiceProvider(java.lang.Object provider)
Deregisters the specified service provider from all categories.

param
provider the specified service provider.

        throw new UnsupportedOperationException("Not supported yet");
    
public voidfinalize()
Finalizes this object.

throws
Throwable if an error occurs during finalization.

        // TODO uncomment when deregisterAll is implemented
        // deregisterAll();
    
public java.util.IteratorgetCategories()
Gets an iterator of Class objects representing the current categories.

return
the Iterator of Class objects.

        return categories.list();
    
public TgetServiceProviderByClass(java.lang.Class providerClass)
Gets the registered service provider object that has the specified class type.

param
providerClass the specified provider class.
return
the service provider object.

        throw new UnsupportedOperationException("Not supported yet");
    
public java.util.IteratorgetServiceProviders(java.lang.Class category, boolean useOrdering)
Gets an Iterator of all registered service providers in the specified category. The useOrdering parameter indicates whether the iterator will return all of the server provider objects in a set order.

param
category the specified category.
param
useOrdering the flag indicating that providers are ordered in the returned Iterator.
return
the Iterator of service providers.

        return (Iterator<T>)categories.getProviders(category, useOrdering);
    
public java.util.IteratorgetServiceProviders(java.lang.Class category, javax.imageio.spi.ServiceRegistry$Filter filter, boolean useOrdering)
Gets an Iterator of registered service providers in the specified category which satisfy the specified Filter. The useOrdering parameter indicates whether the iterator will return all of the server provider objects in a set order.

param
category the specified category.
param
filter the specified filter.
param
useOrdering the flag indicating that providers are ordered in the returned Iterator.
return
the iterator of registered service providers.

        return new FilteredIterator<T>(filter, (Iterator<T>)categories.getProviders(category,
                useOrdering));
    
public static java.util.IteratorlookupProviders(java.lang.Class providerClass, java.lang.ClassLoader loader)
Looks up and instantiates the available providers of this service using the specified class loader.

param
providerClass the Class object of the provider to be looked up.
param
loader the class loader to be used.
return
the iterator of providers objects for this service.

        throw new UnsupportedOperationException("Not supported yet");
    
public static java.util.IteratorlookupProviders(java.lang.Class providerClass)
Looks up and instantiates the available providers of this service using the context class loader.

param
providerClass the Class object of the provider to be looked up.
return
the iterator of providers objects for this service.

        return lookupProviders(providerClass, Thread.currentThread().getContextClassLoader());
    
public booleanregisterServiceProvider(T provider, java.lang.Class category)
Registers the specified service provider object in the specified categories.

param
provider the specified provider to be registered.
param
category the category.
return
true, if no provider of the same class is registered in this category, false otherwise.

        return categories.addProvider(provider, category);
    
public voidregisterServiceProvider(java.lang.Object provider)
Registers the specified service provider object in all categories.

param
provider the service provider.

        categories.addProvider(provider, null);
    
public voidregisterServiceProviders(java.util.Iterator providers)
Registers a list of service providers.

param
providers the list of service providers.

        for (Iterator<?> iterator = providers; iterator.hasNext();) {
            categories.addProvider(iterator.next(), null);
        }
    
public booleansetOrdering(java.lang.Class category, T firstProvider, T secondProvider)
Sets an ordering between two service provider objects within the specified category.

param
category the specified category.
param
firstProvider the first provider.
param
secondProvider the second provider.
return
true, if a previously unset order was set.

        throw new UnsupportedOperationException("Not supported yet");
    
public booleanunsetOrdering(java.lang.Class category, T firstProvider, T secondProvider)
Unsets an ordering between two service provider objects within the specified category.

param
category the specified category.
param
firstProvider the first provider.
param
secondProvider the second provider.
return
true, if a previously unset order was removed.

        throw new UnsupportedOperationException("Not supported yet");