Path: blob/master/src/java.desktop/share/classes/java/beans/beancontext/BeanContextServices.java
41159 views
/*1* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.beans.beancontext;2627import java.util.Iterator;2829import java.util.TooManyListenersException;3031import java.beans.beancontext.BeanContext;3233import java.beans.beancontext.BeanContextServiceProvider;3435import java.beans.beancontext.BeanContextServicesListener;363738/**39* <p>40* The BeanContextServices interface provides a mechanism for a BeanContext41* to expose generic "services" to the BeanContextChild objects within.42* </p>43*/44public interface BeanContextServices extends BeanContext, BeanContextServicesListener {4546/**47* Adds a service to this BeanContext.48* {@code BeanContextServiceProvider}s call this method49* to register a particular service with this context.50* If the service has not previously been added, the51* {@code BeanContextServices} associates52* the service with the {@code BeanContextServiceProvider} and53* fires a {@code BeanContextServiceAvailableEvent} to all54* currently registered {@code BeanContextServicesListeners}.55* The method then returns {@code true}, indicating that56* the addition of the service was successful.57* If the given service has already been added, this method58* simply returns {@code false}.59* @param serviceClass the service to add60* @param serviceProvider the {@code BeanContextServiceProvider}61* associated with the service62* @return true if the service was successful added, false otherwise63*/64boolean addService(Class<?> serviceClass, BeanContextServiceProvider serviceProvider);6566/**67* BeanContextServiceProviders wishing to remove68* a currently registered service from this context69* may do so via invocation of this method. Upon revocation of70* the service, the {@code BeanContextServices} fires a71* {@code BeanContextServiceRevokedEvent} to its72* list of currently registered73* {@code BeanContextServiceRevokedListeners} and74* {@code BeanContextServicesListeners}.75* @param serviceClass the service to revoke from this BeanContextServices76* @param serviceProvider the BeanContextServiceProvider associated with77* this particular service that is being revoked78* @param revokeCurrentServicesNow a value of {@code true}79* indicates an exceptional circumstance where the80* {@code BeanContextServiceProvider} or81* {@code BeanContextServices} wishes to immediately82* terminate service to all currently outstanding references83* to the specified service.84*/85void revokeService(Class<?> serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow);8687/**88* Reports whether or not a given service is89* currently available from this context.90* @param serviceClass the service in question91* @return true if the service is available92*/93boolean hasService(Class<?> serviceClass);9495/**96* A {@code BeanContextChild}, or any arbitrary object97* associated with a {@code BeanContextChild}, may obtain98* a reference to a currently registered service from its99* nesting {@code BeanContextServices}100* via invocation of this method. When invoked, this method101* gets the service by calling the getService() method on the102* underlying {@code BeanContextServiceProvider}.103* @param child the {@code BeanContextChild}104* associated with this request105* @param requestor the object requesting the service106* @param serviceClass class of the requested service107* @param serviceSelector the service dependent parameter108* @param bcsrl the109* {@code BeanContextServiceRevokedListener} to notify110* if the service should later become revoked111* @throws TooManyListenersException if there are too many listeners112* @return a reference to this context's named113* Service as requested or {@code null}114*/115Object getService(BeanContextChild child, Object requestor, Class<?> serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException;116117/**118* Releases a {@code BeanContextChild}'s119* (or any arbitrary object associated with a BeanContextChild)120* reference to the specified service by calling releaseService()121* on the underlying {@code BeanContextServiceProvider}.122* @param child the {@code BeanContextChild}123* @param requestor the requestor124* @param service the service125*/126void releaseService(BeanContextChild child, Object requestor, Object service);127128/**129* Gets the currently available services for this context.130* @return an {@code Iterator} consisting of the131* currently available services132*/133Iterator<?> getCurrentServiceClasses();134135/**136* Gets the list of service dependent service parameters137* (Service Selectors) for the specified service, by138* calling getCurrentServiceSelectors() on the139* underlying BeanContextServiceProvider.140* @param serviceClass the specified service141* @return the currently available service selectors142* for the named serviceClass143*/144Iterator<?> getCurrentServiceSelectors(Class<?> serviceClass);145146/**147* Adds a {@code BeanContextServicesListener} to this BeanContext148* @param bcsl the {@code BeanContextServicesListener} to add149*/150void addBeanContextServicesListener(BeanContextServicesListener bcsl);151152/**153* Removes a {@code BeanContextServicesListener}154* from this {@code BeanContext}155* @param bcsl the {@code BeanContextServicesListener}156* to remove from this context157*/158void removeBeanContextServicesListener(BeanContextServicesListener bcsl);159}160161162