001 /* java.beans.beancontext.BeanContextServiceProvider
002 Copyright (C) 1999 Free Software Foundation, Inc.
003
004 This file is part of GNU Classpath.
005
006 GNU Classpath is free software; you can redistribute it and/or modify
007 it under the terms of the GNU General Public License as published by
008 the Free Software Foundation; either version 2, or (at your option)
009 any later version.
010
011 GNU Classpath is distributed in the hope that it will be useful, but
012 WITHOUT ANY WARRANTY; without even the implied warranty of
013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 General Public License for more details.
015
016 You should have received a copy of the GNU General Public License
017 along with GNU Classpath; see the file COPYING. If not, write to the
018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019 02110-1301 USA.
020
021 Linking this library statically or dynamically with other modules is
022 making a combined work based on this library. Thus, the terms and
023 conditions of the GNU General Public License cover the whole
024 combination.
025
026 As a special exception, the copyright holders of this library give you
027 permission to link this library with independent modules to produce an
028 executable, regardless of the license terms of these independent
029 modules, and to copy and distribute the resulting executable under
030 terms of your choice, provided that you also meet, for each linked
031 independent module, the terms and conditions of the license of that
032 module. An independent module is a module which is not derived from
033 or based on this library. If you modify this library, you may extend
034 this exception to your version of the library, but you are not
035 obligated to do so. If you do not wish to do so, delete this
036 exception statement from your version. */
037
038
039 package java.beans.beancontext;
040
041 import java.util.Iterator;
042
043 /**
044 * An actual factory for services.
045 * <P>
046 *
047 * It is the <code>BeanContextServiceProvider</code>'s responsibility to
048 * register itself with whatever <code>BeanContextServices</code> object
049 * it wishes to provide services through using the
050 * <code>addService()</code> method.
051 * <P>
052 *
053 * If for some reason it can no longer provide services for a particular
054 * class, this class must invoke
055 * <code>BeanContextServices.revokeService(serviceClass,this,true)</code>
056 * for all the places it has registered the service.
057 *
058 * @author John Keiser
059 * @since JDK1.2
060 */
061
062 public interface BeanContextServiceProvider {
063 /**
064 * Get a service.
065 * Called from <code>BeanContextServices.getService()</code>.
066 *
067 * <p>If the requested service class is not available, or if this
068 * <code>BeanContextServiceProvider</code> chooses not honor the
069 * request for some reason, then this method will return
070 * <code>null</code>.</p>
071 *
072 * This method may throw unchecked exceptions, so watch out.
073 *
074 * @param services the <code>BeanContextServices</code> that wants
075 * to get the service. Only weak references to this will
076 * be retained, and it will never be changed, only queried
077 * in a read-only manner.
078 * @param requestor the actual requestor of the service. Only
079 * weak references to this will be retained, and it will
080 * never be changed, only queried in a read-only manner.
081 * @param serviceClass the <code>Class</code> of the service being
082 * requested.
083 * @param serviceSelector a parameter to customize the service
084 * returned with.
085 * @return an instance of <code>serviceClass</code> (such that
086 * <code>instanceof</code> serviceClass is true), or
087 * <code>null</code>.
088 * @see java.beans.beancontext.BeanContextServices#getService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Class,java.lang.Object,java.beans.beancontext.BeanContextServiceRevokedListener)
089 */
090 Object getService(BeanContextServices services, Object requestor, Class serviceClass, Object serviceSelector);
091
092 /**
093 * Release the service.
094 * <P>
095 *
096 * Called by <code>BeanContextServices.releaseService()</code>.
097 * <P>
098 *
099 * 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 }