java.beans.beancontext
Class BeanContextServicesSupport.BCSSProxyServiceProvider

java.lang.Object
  extended by java.beans.beancontext.BeanContextServicesSupport.BCSSProxyServiceProvider
All Implemented Interfaces:
BeanContextServiceProvider, BeanContextServiceRevokedListener, EventListener
Enclosing class:
BeanContextServicesSupport

protected class BeanContextServicesSupport.BCSSProxyServiceProvider
extends Object
implements BeanContextServiceProvider, BeanContextServiceRevokedListener


Method Summary
 Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass)
          Get a list of valid service selectors for the specified service class.
 Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector)
          Get a service.
 void releaseService(BeanContextServices bcs, Object requestor, Object service)
          Release the service.
 void serviceRevoked(BeanContextServiceRevokedEvent bcsre)
          Called by BeanContextServices.revokeService() to indicate that a service has been revoked.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCurrentServiceSelectors

public Iterator getCurrentServiceSelectors(BeanContextServices bcs,
                                           Class serviceClass)
Description copied from interface: BeanContextServiceProvider
Get a list of valid service selectors for the specified service class. This method is called from BeanContextServices.getCurrentServiceSelectors().

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.

Specified by:
getCurrentServiceSelectors in interface BeanContextServiceProvider
Parameters:
bcs - the BeanContextServices that wants to get the service selectors. Only weak references to this will be retained, and it will never be changed, only queried in a read-only manner.
serviceClass - the service class to get selectors for.
Returns:
a list of valid service selectors for the service class, or null.
See Also:
BeanContextServices.getCurrentServiceSelectors(java.lang.Class)

getService

public Object getService(BeanContextServices bcs,
                         Object requestor,
                         Class serviceClass,
                         Object serviceSelector)
Description copied from interface: BeanContextServiceProvider
Get a service. Called from BeanContextServices.getService().

If the requested service class is not available, or if this BeanContextServiceProvider chooses not honor the request for some reason, then this method will return null.

This method may throw unchecked exceptions, so watch out.

Specified by:
getService in interface BeanContextServiceProvider
Parameters:
bcs - the BeanContextServices that wants to get the service. 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.
Returns:
an instance of serviceClass (such that instanceof serviceClass is true), or null.
See Also:
BeanContextServices.getService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Class,java.lang.Object,java.beans.beancontext.BeanContextServiceRevokedListener)

releaseService

public void releaseService(BeanContextServices bcs,
                           Object requestor,
                           Object service)
Description copied from interface: BeanContextServiceProvider
Release the service.

Called by BeanContextServices.releaseService().

Most BeanContextServiceProviders won't have to do anything here.

Specified by:
releaseService in interface BeanContextServiceProvider
Parameters:
bcs - the BeanContextServices that wants to release the service. Only weak references to this will be retained, and it will never be changed, only queried in a read-only manner.
requestor - the original requestor of the service.
service - the service to relinquish
See Also:
BeanContextServices.releaseService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Object)

serviceRevoked

public void serviceRevoked(BeanContextServiceRevokedEvent bcsre)
Description copied from interface: BeanContextServiceRevokedListener
Called by BeanContextServices.revokeService() to indicate that a service has been revoked. If you have a reference to such a service, it should be discarded and may no longer function properly. getService() will no longer work on the specified service class after this event has been fired.

Specified by:
serviceRevoked in interface BeanContextServiceRevokedListener
Parameters:
bcsre - the service revoked event.
See Also:
BeanContextServices.revokeService(java.lang.Class,java.beans.beancontext.BeanContextServiceProvider,boolean)