javax.imageio.spi
Class ServiceRegistry
A registry for service providers.
ServiceRegistry(Iterator> categories) - Constructs a
ServiceRegistry for the specified
service categories.
|
| Iterator getServiceProviders(Class category, boolean useOrdering) - Retrieves all providers that have been registered for the
specified service category.
|
| Iterator getServiceProviders(Class category, ServiceRegistry.Filter filter, boolean useOrdering) - Retrieves all providers that have been registered for the
specified service category and that satisfy the criteria
of a custom filter.
|
static | Iterator lookupProviders(Class spi) - Finds service providers that are implementing the specified
Service Provider Interface, using the context class loader
for loading providers.
|
static | Iterator lookupProviders(Class spi, ClassLoader loader) - Finds service providers that are implementing the specified
Service Provider Interface.
|
| T getServiceProviderByClass(Class providerClass) - Returns one of the service providers that is a subclass of the
specified class.
|
| boolean deregisterServiceProvider(T provider, Class category) - De-registers a provider for the specified service category.
|
| boolean registerServiceProvider(T provider, Class category) - Registers a provider for the specified service category.
|
| boolean setOrdering(Class category, T firstProvider, T secondProvider) - Adds an ordering constraint on service providers.
|
| boolean unsetOrdering(Class category, T firstProvider, T secondProvider) - Removes an ordering constraint on service providers.
|
boolean | contains(Object provider) - Determines whether a provider has been registered with this
registry.
|
void | deregisterAll() - De-registers all service providers.
|
void | deregisterAll(Class> category) - De-registers all providers which have been registered for the
specified service category.
|
void | deregisterServiceProvider(Object provider) - De-registers a provider from all service categories it
implements.
|
void | finalize() - Called by the Virtual Machine when it detects that this
ServiceRegistry has become garbage.
|
Iterator> | getCategories() - Returns an iterator over all service categories.
|
void | registerServiceProvider(Object provider) - Registers a provider under all service categories it
implements.
|
void | registerServiceProviders(Iterator> providers) - Registers a number of providers under all service categories they
implement.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
ServiceRegistry
public ServiceRegistry(Iterator> categories)
Constructs a ServiceRegistry
for the specified
service categories.
categories
- the categories to support
Iterator getServiceProviders
public Iterator getServiceProviders(Class category,
boolean useOrdering)
Retrieves all providers that have been registered for the
specified service category.
category
- the service category whose providers are
to be retrieved.useOrdering
- true
in order to retrieve the
providers in an order imposed by the ordering constraints; false
in order to retrieve
the providers in any order.
getServiceProviders(Class, Filter, boolean)
Iterator getServiceProviders
public Iterator getServiceProviders(Class category,
ServiceRegistry.Filter filter,
boolean useOrdering)
Retrieves all providers that have been registered for the
specified service category and that satisfy the criteria
of a custom filter.
category
- the service category whose providers are
to be retrieved.filter
- a custom filter, or null
to
retrieve all registered providers for the specified
category.useOrdering
- true
in order to retrieve the
providers in an order imposed by the ordering constraints; false
in order to retrieve
the providers in any order.
Iterator lookupProviders
public static Iterator lookupProviders(Class spi)
Finds service providers that are implementing the specified
Service Provider Interface, using the context class loader
for loading providers.
spi
- the service provider interface which must be
implemented by any loaded service providers.
- an iterator over instances of
spi
.
lookupProviders(Class, ClassLoader)
Iterator lookupProviders
public static Iterator lookupProviders(Class spi,
ClassLoader loader)
Finds service providers that are implementing the specified
Service Provider Interface.
On-demand loading: Loading and initializing service
providers is delayed as much as possible. The rationale is that
typical clients will iterate through the set of installed service
providers until one is found that matches some criteria (like
supported formats, or quality of service). In such scenarios, it
might make sense to install only the frequently needed service
providers on the local machine. More exotic providers can be put
onto a server; the server will only be contacted when no suitable
service could be found locally.
Security considerations: Any loaded service providers
are loaded through the specified ClassLoader, or the system
ClassLoader if
classLoader
is
null
. When
lookupProviders
is called,
the current
AccessControlContext
gets
recorded. This captured security context will determine the
permissions when services get loaded via the
next()
method of the returned
Iterator
.
spi
- the service provider interface which must be
implemented by any loaded service providers.loader
- the class loader that will be used to load the
service providers, or null
for the system class
loader. For using the context class loader, see lookupProviders(Class)
.
- an iterator over instances of
spi
.
T getServiceProviderByClass
public T getServiceProviderByClass(Class providerClass)
Returns one of the service providers that is a subclass of the
specified class.
providerClass
- a class to search for.
boolean deregisterServiceProvider
public boolean deregisterServiceProvider(T provider,
Class category)
De-registers a provider for the specified service category.
If
provider
implements the
RegisterableService
interface, its
onDeregistration
method is
invoked in order to inform the provider about the removal from
this registry.
provider
- the service provider to be de-registered.category
- the service category from which
provider
shall be de-registered.
true
if provider
was previously
registered for the specified service category; false
if if the provider had not been registered.
boolean registerServiceProvider
public boolean registerServiceProvider(T provider,
Class category)
Registers a provider for the specified service category.
If
provider
implements the
RegisterableService
interface, its
onRegistration
method is
invoked in order to inform the provider about the addition to
this registry.
provider
- the service provider to be registered.category
- the service category under which
provider
shall be registered.
true
if provider
is the first
provider that gets registered for the specified service category;
false
if other providers have already been
registered for the same servide category.
boolean setOrdering
public boolean setOrdering(Class category,
T firstProvider,
T secondProvider)
Adds an ordering constraint on service providers.
category
- the service category to which an ordering
constraint is to be added.firstProvider
- the provider which is supposed to come before
second
.secondProvider
- the provider which is supposed to come after
first
.
ServiceRegistry
, getServiceProviders(Class, Filter, boolean)
boolean unsetOrdering
public boolean unsetOrdering(Class category,
T firstProvider,
T secondProvider)
Removes an ordering constraint on service providers.
category
- the service category from which an ordering
constraint is to be removed.firstProvider
- the provider which is supposed to come before
second
.secondProvider
- the provider which is supposed to come after
first
.
contains
public boolean contains(Object provider)
Determines whether a provider has been registered with this
registry.
true
if provider
has been
registered under any service category; false
if
it is not registered.
deregisterAll
public void deregisterAll()
De-registers all service providers.
If a provider implements the
RegisterableService
interface, its
onDeregistration
method is invoked in order to inform the
provider about the removal from this registry. If the provider
implements several service categories,
onDeregistration
gets called multiple times.
deregisterAll
public void deregisterAll(Class> category)
De-registers all providers which have been registered for the
specified service category.
If a provider implements the
RegisterableService
interface, its
onDeregistration
method is invoked in order to inform the
provider about the removal from this registry. If the provider
implements several service categories,
onDeregistration
gets called multiple times.
category
- the category whose registered providers will be
de-registered.
deregisterServiceProvider
public void deregisterServiceProvider(Object provider)
De-registers a provider from all service categories it
implements.
If
provider
implements the
RegisterableService
interface, its
onDeregistration
method is
invoked in order to inform the provider about the removal from
this registry. If
provider
implements several
service categories,
onDeregistration
gets called
multiple times.
provider
- the service provider to be de-registered.
IllegalArgumentException
- if provider
is
null
, or if provider
does not implement
any of the service categories passed to the constructor of this
ServiceRegistry
.
getCategories
public Iterator> getCategories()
Returns an iterator over all service categories.
registerServiceProvider
public void registerServiceProvider(Object provider)
Registers a provider under all service categories it
implements.
If
provider
implements the
RegisterableService
interface, its
onRegistration
method is
invoked in order to inform the provider about the addition to
this registry. If
provider
implements several
service categories,
onRegistration
gets called
multiple times.
provider
- the service provider to be registered.
IllegalArgumentException
- if provider
is
null
, or if provider
does not implement
any of the service categories passed to the constructor of this ServiceRegistry.
registerServiceProviders
public void registerServiceProviders(Iterator> providers)
Registers a number of providers under all service categories they
implement.
If a provider implements the
RegisterableService
interface, its
onRegistration
method is invoked in order to inform the provider
about the addition to this registry. If
provider
implements several service categories,
onRegistration
gets called multiple times.
IllegalArgumentException
- if providers
is
null
, if any iterated provider is null
,
or if some iterated provider does not implement any of the
service categories passed to the constructor of this
ServiceRegistry
.
ServiceRegistry.java -- A simple registry for service providers.
Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.