0N/A/*
2362N/A * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.beans.beancontext;
0N/A
0N/Aimport java.util.Iterator;
0N/A
0N/Aimport java.util.TooManyListenersException;
0N/A
0N/Aimport java.beans.beancontext.BeanContext;
0N/A
0N/Aimport java.beans.beancontext.BeanContextServiceProvider;
0N/A
0N/Aimport java.beans.beancontext.BeanContextServicesListener;
0N/A
0N/A
0N/A/**
0N/A * <p>
0N/A * The BeanContextServices interface provides a mechanism for a BeanContext
0N/A * to expose generic "services" to the BeanContextChild objects within.
0N/A * </p>
0N/A */
0N/Apublic interface BeanContextServices extends BeanContext, BeanContextServicesListener {
0N/A
0N/A /**
0N/A * Adds a service to this BeanContext.
0N/A * <code>BeanContextServiceProvider</code>s call this method
0N/A * to register a particular service with this context.
0N/A * If the service has not previously been added, the
0N/A * <code>BeanContextServices</code> associates
0N/A * the service with the <code>BeanContextServiceProvider</code> and
0N/A * fires a <code>BeanContextServiceAvailableEvent</code> to all
0N/A * currently registered <code>BeanContextServicesListeners</code>.
0N/A * The method then returns <code>true</code>, indicating that
0N/A * the addition of the service was successful.
0N/A * If the given service has already been added, this method
0N/A * simply returns <code>false</code>.
0N/A * @param serviceClass the service to add
0N/A * @param serviceProvider the <code>BeanContextServiceProvider</code>
0N/A * associated with the service
0N/A */
0N/A boolean addService(Class serviceClass, BeanContextServiceProvider serviceProvider);
0N/A
0N/A /**
0N/A * BeanContextServiceProviders wishing to remove
0N/A * a currently registered service from this context
0N/A * may do so via invocation of this method. Upon revocation of
0N/A * the service, the <code>BeanContextServices</code> fires a
0N/A * <code>BeanContextServiceRevokedEvent</code> to its
0N/A * list of currently registered
0N/A * <code>BeanContextServiceRevokedListeners</code> and
0N/A * <code>BeanContextServicesListeners</code>.
0N/A * @param serviceClass the service to revoke from this BeanContextServices
0N/A * @param serviceProvider the BeanContextServiceProvider associated with
0N/A * this particular service that is being revoked
0N/A * @param revokeCurrentServicesNow a value of <code>true</code>
0N/A * indicates an exceptional circumstance where the
0N/A * <code>BeanContextServiceProvider</code> or
0N/A * <code>BeanContextServices</code> wishes to immediately
0N/A * terminate service to all currently outstanding references
0N/A * to the specified service.
0N/A */
0N/A void revokeService(Class serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow);
0N/A
0N/A /**
0N/A * Reports whether or not a given service is
0N/A * currently available from this context.
0N/A * @param serviceClass the service in question
0N/A * @return true if the service is available
0N/A */
0N/A boolean hasService(Class serviceClass);
0N/A
0N/A /**
0N/A * A <code>BeanContextChild</code>, or any arbitrary object
0N/A * associated with a <code>BeanContextChild</code>, may obtain
0N/A * a reference to a currently registered service from its
0N/A * nesting <code>BeanContextServices</code>
0N/A * via invocation of this method. When invoked, this method
0N/A * gets the service by calling the getService() method on the
0N/A * underlying <code>BeanContextServiceProvider</code>.
0N/A * @param child the <code>BeanContextChild</code>
0N/A * associated with this request
0N/A * @param requestor the object requesting the service
0N/A * @param serviceClass class of the requested service
0N/A * @param serviceSelector the service dependent parameter
0N/A * @param bcsrl the
0N/A * <code>BeanContextServiceRevokedListener</code> to notify
0N/A * if the service should later become revoked
0N/A * @throws TooManyListenersException
0N/A * @return a reference to this context's named
0N/A * Service as requested or <code>null</code>
0N/A */
0N/A Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException;
0N/A
0N/A /**
0N/A * Releases a <code>BeanContextChild</code>'s
0N/A * (or any arbitrary object associated with a BeanContextChild)
0N/A * reference to the specified service by calling releaseService()
0N/A * on the underlying <code>BeanContextServiceProvider</code>.
0N/A * @param child the <code>BeanContextChild</code>
0N/A * @param requestor the requestor
0N/A * @param service the service
0N/A */
0N/A void releaseService(BeanContextChild child, Object requestor, Object service);
0N/A
0N/A /**
0N/A * Gets the currently available services for this context.
0N/A * @return an <code>Iterator</code> consisting of the
0N/A * currently available services
0N/A */
0N/A Iterator getCurrentServiceClasses();
0N/A
0N/A /**
0N/A * Gets the list of service dependent service parameters
0N/A * (Service Selectors) for the specified service, by
0N/A * calling getCurrentServiceSelectors() on the
0N/A * underlying BeanContextServiceProvider.
0N/A * @param serviceClass the specified service
0N/A * @return the currently available service selectors
0N/A * for the named serviceClass
0N/A */
0N/A Iterator getCurrentServiceSelectors(Class serviceClass);
0N/A
0N/A /**
0N/A * Adds a <code>BeanContextServicesListener</code> to this BeanContext
0N/A * @param bcsl the <code>BeanContextServicesListener</code> to add
0N/A */
0N/A void addBeanContextServicesListener(BeanContextServicesListener bcsl);
0N/A
0N/A /**
0N/A * Removes a <code>BeanContextServicesListener</code>
0N/A * from this <code>BeanContext</code>
0N/A * @param bcsl the <code>BeanContextServicesListener</code>
0N/A * to remove from this context
0N/A */
0N/A void removeBeanContextServicesListener(BeanContextServicesListener bcsl);
0N/A}