Methods Summary |
---|
public boolean | contains(java.lang.Object provider)Returns true if provider is currently
registered.
if (provider == null) {
throw new IllegalArgumentException("provider == null!");
}
Iterator regs = getSubRegistries(provider);
while (regs.hasNext()) {
SubRegistry reg = (SubRegistry)regs.next();
if (reg.contains(provider)) {
return true;
}
}
return false;
|
public void | deregisterAll(java.lang.Class category)Deregisters all service provider object currently registered
under the given category.
SubRegistry reg = (SubRegistry)categoryMap.get(category);
if (reg == null) {
throw new IllegalArgumentException("category unknown!");
}
reg.clear();
|
public void | deregisterAll()Deregisters all currently registered service providers from all
categories.
Iterator iter = categoryMap.values().iterator();
while (iter.hasNext()) {
SubRegistry reg = (SubRegistry)iter.next();
reg.clear();
}
|
public void | deregisterServiceProvider(java.lang.Object provider)Removes a service provider object from all categories that
contain it.
if (provider == null) {
throw new IllegalArgumentException("provider == null!");
}
Iterator regs = getSubRegistries(provider);
while (regs.hasNext()) {
SubRegistry reg = (SubRegistry)regs.next();
reg.deregisterServiceProvider(provider);
}
|
public boolean | deregisterServiceProvider(T provider, java.lang.Class category)Removes a service provider object from the given category. If
the provider was not previously registered, nothing happens and
false is returned. Otherwise, true
is returned. If an object of the same class as
provider but not equal (using == ) to
provider is registered, it will not be
deregistered.
If provider implements the
RegisterableService interface, its
onDeregistration method will be called.
if (provider == null) {
throw new IllegalArgumentException("provider == null!");
}
SubRegistry reg = (SubRegistry)categoryMap.get(category);
if (reg == null) {
throw new IllegalArgumentException("category unknown!");
}
if (!category.isAssignableFrom(provider.getClass())) {
throw new ClassCastException();
}
return reg.deregisterServiceProvider(provider);
|
public void | finalize()Finalizes this object prior to garbage collection. The
deregisterAll method is called to deregister all
currently registered service providers. This method should not
be called from application code.
deregisterAll();
super.finalize();
|
public java.util.Iterator | getCategories()Returns an Iterator of Class objects
indicating the current set of categories. The iterator will be
empty if no categories exist.
Set keySet = categoryMap.keySet();
return keySet.iterator();
|
public T | getServiceProviderByClass(java.lang.Class providerClass)Returns the currently registered service provider object that
is of the given class type. At most one object of a given
class is allowed to be registered at any given time. If no
registered object has the desired class type, null
is returned.
if (providerClass == null) {
throw new IllegalArgumentException("providerClass == null!");
}
Iterator iter = categoryMap.keySet().iterator();
while (iter.hasNext()) {
Class c = (Class)iter.next();
if (c.isAssignableFrom(providerClass)) {
SubRegistry reg = (SubRegistry)categoryMap.get(c);
T provider = reg.getServiceProviderByClass(providerClass);
if (provider != null) {
return provider;
}
}
}
return null;
|
public java.util.Iterator | getServiceProviders(java.lang.Class category, boolean useOrdering)Returns an Iterator containing all registered
service providers in the given category. If
useOrdering is false , the iterator
will return all of the server provider objects in an arbitrary
order. Otherwise, the ordering will respect any pairwise
orderings that have been set. If the graph of pairwise
orderings contains cycles, any providers that belong to a cycle
will not be returned.
SubRegistry reg = (SubRegistry)categoryMap.get(category);
if (reg == null) {
throw new IllegalArgumentException("category unknown!");
}
return reg.getServiceProviders(useOrdering);
|
public java.util.Iterator | getServiceProviders(java.lang.Class category, javax.imageio.spi.ServiceRegistry$Filter filter, boolean useOrdering)Returns an Iterator containing service provider
objects within a given category that satisfy a criterion
imposed by the supplied ServiceRegistry.Filter
object's filter method.
The useOrdering argument controls the
ordering of the results using the same rules as
getServiceProviders(Class, boolean) .
SubRegistry reg = (SubRegistry)categoryMap.get(category);
if (reg == null) {
throw new IllegalArgumentException("category unknown!");
}
Iterator iter = getServiceProviders(category, useOrdering);
return new FilterIterator(iter, filter);
|
private java.util.Iterator | getSubRegistries(java.lang.Object provider)Returns an Iterator containing the subregistries to which the
provider belongs.
List l = new ArrayList();
Iterator iter = categoryMap.keySet().iterator();
while (iter.hasNext()) {
Class c = (Class)iter.next();
if (c.isAssignableFrom(provider.getClass())) {
l.add((SubRegistry)categoryMap.get(c));
}
}
return l.iterator();
|
public static java.util.Iterator | lookupProviders(java.lang.Class providerClass, java.lang.ClassLoader loader)Searches for implementations of a particular service class
using the given class loader.
This method transforms the name of the given service class
into a provider-configuration filename as described in the
class comment and then uses the getResources
method of the given class loader to find all available files
with that name. These files are then read and parsed to
produce a list of provider-class names. The iterator that is
returned uses the given class loader to look up and then
instantiate each element of the list.
Because it is possible for extensions to be installed into
a running Java virtual machine, this method may return
different results each time it is invoked.
if (providerClass == null) {
throw new IllegalArgumentException("providerClass == null!");
}
return Service.providers(providerClass, loader);
|
public static java.util.Iterator | lookupProviders(java.lang.Class providerClass)Locates and incrementally instantiates the available providers
of a given service using the context class loader. This
convenience method is equivalent to:
ClassLoader cl = Thread.currentThread().getContextClassLoader();
return Service.providers(service, cl);
if (providerClass == null) {
throw new IllegalArgumentException("providerClass == null!");
}
return Service.providers(providerClass);
|
public boolean | registerServiceProvider(T provider, java.lang.Class category)Adds a service provider object to the registry. The provider
is associated with the given category.
If provider implements the
RegisterableService interface, its
onRegistration method will be called. Its
onDeregistration method will be called each time
it is deregistered from a category, for example if a
category is removed or the registry is garbage collected.
if (provider == null) {
throw new IllegalArgumentException("provider == null!");
}
SubRegistry reg = (SubRegistry)categoryMap.get(category);
if (reg == null) {
throw new IllegalArgumentException("category unknown!");
}
if (!category.isAssignableFrom(provider.getClass())) {
throw new ClassCastException();
}
return reg.registerServiceProvider(provider);
|
public void | registerServiceProvider(java.lang.Object provider)Adds a service provider object to the registry. The provider
is associated within each category present in the registry
whose Class it implements.
If provider implements the
RegisterableService interface, its
onRegistration method will be called once for each
category it is registered under. Its
onDeregistration method will be called each time
it is deregistered from a category or when the registry is
finalized.
if (provider == null) {
throw new IllegalArgumentException("provider == null!");
}
Iterator regs = getSubRegistries(provider);
while (regs.hasNext()) {
SubRegistry reg = (SubRegistry)regs.next();
reg.registerServiceProvider(provider);
}
|
public void | registerServiceProviders(java.util.Iterator providers)Adds a set of service provider objects, taken from an
Iterator to the registry. Each provider is
associated within each category present in the registry whose
Class it implements.
For each entry of providers that implements
the RegisterableService interface, its
onRegistration method will be called once for each
category it is registered under. Its
onDeregistration method will be called each time
it is deregistered from a category or when the registry is
finalized.
if (providers == null) {
throw new IllegalArgumentException("provider == null!");
}
while (providers.hasNext()) {
registerServiceProvider(providers.next());
}
|
public boolean | setOrdering(java.lang.Class category, T firstProvider, T secondProvider)Sets a pairwise ordering between two service provider objects
within a given category. If one or both objects are not
currently registered within the given category, or if the
desired ordering is already set, nothing happens and
false is returned. If the providers previously
were ordered in the reverse direction, that ordering is
removed.
The ordering will be used by the
getServiceProviders methods when their
useOrdering argument is true .
if (firstProvider == null || secondProvider == null) {
throw new IllegalArgumentException("provider is null!");
}
if (firstProvider == secondProvider) {
throw new IllegalArgumentException("providers are the same!");
}
SubRegistry reg = (SubRegistry)categoryMap.get(category);
if (reg == null) {
throw new IllegalArgumentException("category unknown!");
}
if (reg.contains(firstProvider) &&
reg.contains(secondProvider)) {
return reg.setOrdering(firstProvider, secondProvider);
}
return false;
|
public boolean | unsetOrdering(java.lang.Class category, T firstProvider, T secondProvider)Sets a pairwise ordering between two service provider objects
within a given category. If one or both objects are not
currently registered within the given category, or if no
ordering is currently set between them, nothing happens
and false is returned.
The ordering will be used by the
getServiceProviders methods when their
useOrdering argument is true .
if (firstProvider == null || secondProvider == null) {
throw new IllegalArgumentException("provider is null!");
}
if (firstProvider == secondProvider) {
throw new IllegalArgumentException("providers are the same!");
}
SubRegistry reg = (SubRegistry)categoryMap.get(category);
if (reg == null) {
throw new IllegalArgumentException("category unknown!");
}
if (reg.contains(firstProvider) &&
reg.contains(secondProvider)) {
return reg.unsetOrdering(firstProvider, secondProvider);
}
return false;
|