GNU Classpath (0.95) | |
Frames | No Frames |
1: /* java.beans.beancontext.BeanContextServiceProvider 2: Copyright (C) 1999 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: package java.beans.beancontext; 40: 41: import java.util.Iterator; 42: 43: /** 44: * An actual factory for services. 45: * <P> 46: * 47: * It is the <code>BeanContextServiceProvider</code>'s responsibility to 48: * register itself with whatever <code>BeanContextServices</code> object 49: * it wishes to provide services through using the 50: * <code>addService()</code> method. 51: * <P> 52: * 53: * If for some reason it can no longer provide services for a particular 54: * class, this class must invoke 55: * <code>BeanContextServices.revokeService(serviceClass,this,true)</code> 56: * for all the places it has registered the service. 57: * 58: * @author John Keiser 59: * @since JDK1.2 60: */ 61: 62: public interface BeanContextServiceProvider { 63: /** 64: * Get a service. 65: * Called from <code>BeanContextServices.getService()</code>. 66: * 67: * <p>If the requested service class is not available, or if this 68: * <code>BeanContextServiceProvider</code> chooses not honor the 69: * request for some reason, then this method will return 70: * <code>null</code>.</p> 71: * 72: * This method may throw unchecked exceptions, so watch out. 73: * 74: * @param services the <code>BeanContextServices</code> that wants 75: * to get the service. Only weak references to this will 76: * be retained, and it will never be changed, only queried 77: * in a read-only manner. 78: * @param requestor the actual requestor of the service. Only 79: * weak references to this will be retained, and it will 80: * never be changed, only queried in a read-only manner. 81: * @param serviceClass the <code>Class</code> of the service being 82: * requested. 83: * @param serviceSelector a parameter to customize the service 84: * returned with. 85: * @return an instance of <code>serviceClass</code> (such that 86: * <code>instanceof</code> serviceClass is true), or 87: * <code>null</code>. 88: * @see java.beans.beancontext.BeanContextServices#getService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Class,java.lang.Object,java.beans.beancontext.BeanContextServiceRevokedListener) 89: */ 90: Object getService(BeanContextServices services, Object requestor, Class serviceClass, Object serviceSelector); 91: 92: /** 93: * Release the service. 94: * <P> 95: * 96: * Called by <code>BeanContextServices.releaseService()</code>. 97: * <P> 98: * 99: * Most <code>BeanContextServiceProvider</code>s won't have to do 100: * anything here. 101: * 102: * @param services the <code>BeanContextServices</code> that wants 103: * to release the service. Only weak references to this will 104: * be retained, and it will never be changed, only queried 105: * in a read-only manner. 106: * @param requestor the original requestor of the service. 107: * @param service the service to relinquish 108: * @see java.beans.beancontext.BeanContextServices#releaseService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Object) 109: */ 110: void releaseService(BeanContextServices services, Object requestor, Object service); 111: 112: /** 113: * Get a list of valid service selectors for the specified service class. 114: * This method is called from 115: * <code>BeanContextServices.getCurrentServiceSelectors()</code>. 116: * <P> 117: * 118: * If the specified service class does not have a finite number of 119: * valid service selectors, it should return <code>null</code>. 120: * If it takes a general <code>Integer</code> parameter, for 121: * example, you may as well return <code>null</code> or the poor 122: * soul who called this method will be iterating all day. 123: * <P> 124: * 125: * If it has no valid service selectors, it should still return an empty 126: * <code>Iterator</code>. 127: * 128: * @param services the <code>BeanContextServices</code> that wants 129: * to get the service selectors. Only weak references to this will 130: * be retained, and it will never be changed, only queried 131: * in a read-only manner. 132: * @param serviceClass the service class to get selectors for. 133: * @return a list of valid service selectors for the service 134: * class, or <code>null</code>. 135: * @see java.beans.beancontext.BeanContextServices#getCurrentServiceSelectors(java.lang.Class) 136: */ 137: Iterator getCurrentServiceSelectors(BeanContextServices services, Class serviceClass); 138: }
GNU Classpath (0.95) |