Path: blob/master/src/java.desktop/share/classes/java/beans/beancontext/BeanContextServiceProvider.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;2829/**30* <p>31* One of the primary functions of a BeanContext is to act a as rendezvous32* between JavaBeans, and BeanContextServiceProviders.33* </p>34* <p>35* A JavaBean nested within a BeanContext, may ask that BeanContext to36* provide an instance of a "service", based upon a reference to a Java37* Class object that represents that service.38* </p>39* <p>40* If such a service has been registered with the context, or one of its41* nesting context's, in the case where a context delegate to its context42* to satisfy a service request, then the BeanContextServiceProvider associated with43* the service is asked to provide an instance of that service.44* </p>45* <p>46* The ServcieProvider may always return the same instance, or it may47* construct a new instance for each request.48* </p>49*/5051public interface BeanContextServiceProvider {5253/**54* Invoked by {@code BeanContextServices}, this method55* requests an instance of a56* service from this {@code BeanContextServiceProvider}.57*58* @param bcs The {@code BeanContextServices} associated with this59* particular request. This parameter enables the60* {@code BeanContextServiceProvider} to distinguish service61* requests from multiple sources.62*63* @param requestor The object requesting the service64*65* @param serviceClass The service requested66*67* @param serviceSelector the service dependent parameter68* for a particular service, or {@code null} if not applicable.69*70* @return a reference to the requested service71*/72Object getService(BeanContextServices bcs, Object requestor, Class<?> serviceClass, Object serviceSelector);7374/**75* Invoked by {@code BeanContextServices},76* this method releases a nested {@code BeanContextChild}'s77* (or any arbitrary object associated with a78* {@code BeanContextChild}) reference to the specified service.79*80* @param bcs the {@code BeanContextServices} associated with this81* particular release request82*83* @param requestor the object requesting the service to be released84*85* @param service the service that is to be released86*/87public void releaseService(BeanContextServices bcs, Object requestor, Object service);8889/**90* Invoked by {@code BeanContextServices}, this method91* gets the current service selectors for the specified service.92* A service selector is a service specific parameter,93* typical examples of which could include: a94* parameter to a constructor for the service implementation class,95* a value for a particular service's property, or a key into a96* map of existing implementations.97*98* @param bcs the {@code BeanContextServices} for this request99* @param serviceClass the specified service100* @return the current service selectors for the specified serviceClass101*/102Iterator<?> getCurrentServiceSelectors(BeanContextServices bcs, Class<?> serviceClass);103}104105106