java.beans.beancontext

Interface BeanContextServiceProvider

public interface BeanContextServiceProvider

An actual factory for services.

It is the BeanContextServiceProvider's responsibility to register itself with whatever BeanContextServices object it wishes to provide services through using the addService() method.

If for some reason it can no longer provide services for a particular class, this class must invoke BeanContextServices.revokeService(serviceClass,this,true) for all the places it has registered the service.

Since: JDK1.2

Method Summary
IteratorgetCurrentServiceSelectors(BeanContextServices services, Class serviceClass)
Get a list of valid service selectors for the specified service class.
ObjectgetService(BeanContextServices services, Object requestor, Class serviceClass, Object serviceSelector)
Get a service.
voidreleaseService(BeanContextServices services, Object requestor, Object service)
Release the service.

Method Detail

getCurrentServiceSelectors

public Iterator getCurrentServiceSelectors(BeanContextServices services, Class serviceClass)
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.

Parameters: services 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: getCurrentServiceSelectors

getService

public Object getService(BeanContextServices services, Object requestor, Class serviceClass, Object serviceSelector)
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.

Parameters: services 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: getService

releaseService

public void releaseService(BeanContextServices services, Object requestor, Object service)
Release the service.

Called by BeanContextServices.releaseService().

Most BeanContextServiceProviders won't have to do anything here.

Parameters: services 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: releaseService