java.beans.beancontext
Interface BeanContextServices
- BeanContext, BeanContextChild, BeanContextServiceRevokedListener, BeanContextServicesListener, Collection<E>, DesignMode, EventListener, Iterable<E>, Visibility
- BeanContextServicesSupport
Allows a BeanContext
to provide services to its children.
T[] toArray , add , addAll , clear , contains , containsAll , equals , hashCode , isEmpty , iterator , remove , removeAll , retainAll , size , toArray |
addService
public boolean addService(Class<T> serviceClass,
BeanContextServiceProvider provider)
Register a service to make it available to others.
This class may refuse to add the service based on whatever
information it can gather, including whether the service
provider is trusted.
serviceClass
- the service class.provider
- the factory that will actually provide the service.
- whether the service was added or not.
getCurrentServiceClasses
public Iterator<E> getCurrentServiceClasses()
Get a list of all service classes supported.
This method must synchronize on
BeanContext.globalHierarchyLock
.
- a list of all service classes supported.
getCurrentServiceSelectors
public Iterator<E> getCurrentServiceSelectors(Class<T> serviceClass)
Get a list of valid service selectors for the specified service class.
If the specified service class does not have a finite number of
valid service selectors, it should return
null
.
If it takes a general
Integer
parameter, for
example, you may as well return
null
or the poor
soul who called this method will be iterating all day.
If it has no valid service selectors, it should still return an empty
Iterator
.
serviceClass
- the service class to get selectors for.
- a list of valid service selectors for the service
class, or
null
.
getService
public Object getService(BeanContextChild requestorChild,
Object requestor,
Class<T> serviceClass,
Object serviceSelector,
BeanContextServiceRevokedListener listener)
throws TooManyListenersException
Get a service from this
BeanContextServices
.
The specified listener will be registered to receive a
revocation notice for the specified serviceClass. One
notification per service class per requestor object will be
sent.
The listener will be unregistered when all services that were
obtained by that requestor for that service class are released.
If the requested service class is not available, or if this
BeanContextServices
object chooses not honor the
request because the service class has been revoked or for some
other reason, then this method will return
null
.
This method may throw unchecked exceptions, so watch out.
requestorChild
- the BeanContextChild
associated with the requestor. Typically this will be
the same as the requestor itself, but since any
Object
, even one outside the hierarchy, may
make a request, this parameter is necessary. Only weak
references to this will be retained, and it will never
be changed, only queried in a read-only manner.requestor
- the actual requestor of the service. Only
weak references to this will be retained, and it will
never be changed, only queried in a read-only manner.serviceClass
- the Class
of the service being
requested.serviceSelector
- a parameter to customize the service
returned with.listener
- a listener that will be notified if the service
being requested is revoked.
- an instance of
serviceClass
(such that
instanceof
serviceClass is true), or
null
.
hasService
public boolean hasService(Class<T> serviceClass)
Tell whether the specified service class is available.
Iff getService() could return a non-null value for the
specified service, this method will return true
.
serviceClass
- the service class to check on.
- whether the specified service class is available.
releaseService
public void releaseService(BeanContextChild requestorChild,
Object requestor,
Object service)
Release your copy of this service.
If all copies of the service's class have been relinquished by
the requestor, the
BeanContextServiceRevokedListener
previously registered by
getService()
will be
unregistered.
requestorChild
- the original BeanContextChild
requesting the service.requestor
- the original requestor of the service.service
- the service to relinquish
revokeService
public void revokeService(Class<T> serviceClass,
BeanContextServiceProvider provider,
boolean revokeNow)
Make it so that no one else can use this service.
If
revokeNow
is
false
, the only
effect of this method is to make all subsequent calls to
getService()
on this service class fail.
If it is
true
, a message is also sent out to all
listeners on the service and all references to it are released.
serviceClass
- the service class to revoke.provider
- the service provider providing the service class.revokeNow
- whether to release all current references to
the service.
java.beans.beancontext.BeanContextServices
Copyright (C) 1999 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.