Showing the changes to java/pkg/java/beans/beancontext/BeanContextServices.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,159 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved. | ||
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| 4 | * | ||
| 5 | * This code is free software; you can redistribute it and/or modify it | ||
| 6 | * under the terms of the GNU General Public License version 2 only, as | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 10 | * | ||
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 14 | * version 2 for more details (a copy is included in the LICENSE file that | ||
| 15 | * accompanied this code). | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License version | ||
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, | ||
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 20 | * | ||
| 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| 22 | * or visit www.oracle.com if you need additional information or have any | ||
| 23 | * questions. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package java.beans.beancontext; | ||
| 27 | |||
| 28 | import java.util.Iterator; | ||
| 29 | |||
| 30 | import java.util.TooManyListenersException; | ||
| 31 | |||
| 32 | import java.beans.beancontext.BeanContext; | ||
| 33 | |||
| 34 | import java.beans.beancontext.BeanContextServiceProvider; | ||
| 35 | |||
| 36 | import java.beans.beancontext.BeanContextServicesListener; | ||
| 37 | |||
| 38 | |||
| 39 | /** | ||
| 40 | * <p> | ||
| 41 | * The BeanContextServices interface provides a mechanism for a BeanContext | ||
| 42 | * to expose generic "services" to the BeanContextChild objects within. | ||
| 43 | * </p> | ||
| 44 | */ | ||
| 45 | public interface BeanContextServices extends BeanContext, BeanContextServicesListener { | ||
| 46 | |||
| 47 | /** | ||
| 48 | * Adds a service to this BeanContext. | ||
| 49 | * <code>BeanContextServiceProvider</code>s call this method | ||
| 50 | * to register a particular service with this context. | ||
| 51 | * If the service has not previously been added, the | ||
| 52 | * <code>BeanContextServices</code> associates | ||
| 53 | * the service with the <code>BeanContextServiceProvider</code> and | ||
| 54 | * fires a <code>BeanContextServiceAvailableEvent</code> to all | ||
| 55 | * currently registered <code>BeanContextServicesListeners</code>. | ||
| 56 | * The method then returns <code>true</code>, indicating that | ||
| 57 | * the addition of the service was successful. | ||
| 58 | * If the given service has already been added, this method | ||
| 59 | * simply returns <code>false</code>. | ||
| 60 | * @param serviceClass the service to add | ||
| 61 | * @param serviceProvider the <code>BeanContextServiceProvider</code> | ||
| 62 | * associated with the service | ||
| 63 | */ | ||
| 64 | boolean addService(Class serviceClass, BeanContextServiceProvider serviceProvider); | ||
| 65 | |||
| 66 | /** | ||
| 67 | * BeanContextServiceProviders wishing to remove | ||
| 68 | * a currently registered service from this context | ||
| 69 | * may do so via invocation of this method. Upon revocation of | ||
| 70 | * the service, the <code>BeanContextServices</code> fires a | ||
| 71 | * <code>BeanContextServiceRevokedEvent</code> to its | ||
| 72 | * list of currently registered | ||
| 73 | * <code>BeanContextServiceRevokedListeners</code> and | ||
| 74 | * <code>BeanContextServicesListeners</code>. | ||
| 75 | * @param serviceClass the service to revoke from this BeanContextServices | ||
| 76 | * @param serviceProvider the BeanContextServiceProvider associated with | ||
| 77 | * this particular service that is being revoked | ||
| 78 | * @param revokeCurrentServicesNow a value of <code>true</code> | ||
| 79 | * indicates an exceptional circumstance where the | ||
| 80 | * <code>BeanContextServiceProvider</code> or | ||
| 81 | * <code>BeanContextServices</code> wishes to immediately | ||
| 82 | * terminate service to all currently outstanding references | ||
| 83 | * to the specified service. | ||
| 84 | */ | ||
| 85 | void revokeService(Class serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow); | ||
| 86 | |||
| 87 | /** | ||
| 88 | * Reports whether or not a given service is | ||
| 89 | * currently available from this context. | ||
| 90 | * @param serviceClass the service in question | ||
| 91 | * @return true if the service is available | ||
| 92 | */ | ||
| 93 | boolean hasService(Class serviceClass); | ||
| 94 | |||
| 95 | /** | ||
| 96 | * A <code>BeanContextChild</code>, or any arbitrary object | ||
| 97 | * associated with a <code>BeanContextChild</code>, may obtain | ||
| 98 | * a reference to a currently registered service from its | ||
| 99 | * nesting <code>BeanContextServices</code> | ||
| 100 | * via invocation of this method. When invoked, this method | ||
| 101 | * gets the service by calling the getService() method on the | ||
| 102 | * underlying <code>BeanContextServiceProvider</code>. | ||
| 103 | * @param child the <code>BeanContextChild</code> | ||
| 104 | * associated with this request | ||
| 105 | * @param requestor the object requesting the service | ||
| 106 | * @param serviceClass class of the requested service | ||
| 107 | * @param serviceSelector the service dependent parameter | ||
| 108 | * @param bcsrl the | ||
| 109 | * <code>BeanContextServiceRevokedListener</code> to notify | ||
| 110 | * if the service should later become revoked | ||
| 111 | * @throws TooManyListenersException | ||
| 112 | * @return a reference to this context's named | ||
| 113 | * Service as requested or <code>null</code> | ||
| 114 | */ | ||
| 115 | Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException; | ||
| 116 | |||
| 117 | /** | ||
| 118 | * Releases a <code>BeanContextChild</code>'s | ||
| 119 | * (or any arbitrary object associated with a BeanContextChild) | ||
| 120 | * reference to the specified service by calling releaseService() | ||
| 121 | * on the underlying <code>BeanContextServiceProvider</code>. | ||
| 122 | * @param child the <code>BeanContextChild</code> | ||
| 123 | * @param requestor the requestor | ||
| 124 | * @param service the service | ||
| 125 | */ | ||
| 126 | void releaseService(BeanContextChild child, Object requestor, Object service); | ||
| 127 | |||
| 128 | /** | ||
| 129 | * Gets the currently available services for this context. | ||
| 130 | * @return an <code>Iterator</code> consisting of the | ||
| 131 | * currently available services | ||
| 132 | */ | ||
| 133 | Iterator getCurrentServiceClasses(); | ||
| 134 | |||
| 135 | /** | ||
| 136 | * Gets the list of service dependent service parameters | ||
| 137 | * (Service Selectors) for the specified service, by | ||
| 138 | * calling getCurrentServiceSelectors() on the | ||
| 139 | * underlying BeanContextServiceProvider. | ||
| 140 | * @param serviceClass the specified service | ||
| 141 | * @return the currently available service selectors | ||
| 142 | * for the named serviceClass | ||
| 143 | */ | ||
| 144 | Iterator getCurrentServiceSelectors(Class serviceClass); | ||
| 145 | |||
| 146 | /** | ||
| 147 | * Adds a <code>BeanContextServicesListener</code> to this BeanContext | ||
| 148 | * @param bcsl the <code>BeanContextServicesListener</code> to add | ||
| 149 | */ | ||
| 150 | void addBeanContextServicesListener(BeanContextServicesListener bcsl); | ||
| 151 | |||
| 152 | /** | ||
| 153 | * Removes a <code>BeanContextServicesListener</code> | ||
| 154 | * from this <code>BeanContext</code> | ||
| 155 | * @param bcsl the <code>BeanContextServicesListener</code> | ||
| 156 | * to remove from this context | ||
| 157 | */ | ||
| 158 | void removeBeanContextServicesListener(BeanContextServicesListener bcsl); | ||
| 159 | } | ||