1 /* java.beans.beancontext.BeanContextServiceProvider
2 Copyright (C) 1999 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
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)
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.
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., 59 Temple Place, Suite 330, Boston, MA
21 As a special exception, if you link this library with other files to
22 produce an executable, this library does not by itself cause the
23 resulting executable to be covered by the GNU General Public License.
24 This exception does not however invalidate any other reasons why the
25 executable file might be covered by the GNU General Public License. */
28 package java.beans.beancontext;
30 import java.util.Iterator;
33 * An actual factory for services.
36 * It is the <code>BeanContextServiceProvider</code>'s responsibility to
37 * register itself with whatever <code>BeanContextServices</code> object
38 * it wishes to provide services through using the
39 * <code>addService()</code> method.
42 * If for some reason it can no longer provide services for a particular
43 * class, this class must invoke
44 * <code>BeanContextServices.revokeService(serviceClass,this,true)</code>
45 * for all the places it has registered the service.
51 public interface BeanContextServiceProvider {
54 * Called from <code>BeanContextServices.getService().
57 * If the requested service class is not available, or if this
58 * <code>BeanContextServiceProvider</code> chooses not honor the
59 * request for some reason, then this method will return
63 * This method may throw unchecked exceptions, so watch out.
65 * @param services the <code>BeanContextServices</code> that wants
66 * to get the service. Only weak references to this will
67 * be retained, and it will never be changed, only queried
68 * in a read-only manner.
69 * @param requestor the actual requestor of the service. Only
70 * weak references to this will be retained, and it will
71 * never be changed, only queried in a read-only manner.
72 * @param serviceClass the <code>Class</code> of the service being
74 * @param serviceSelector a parameter to customize the service
76 * @return an instance of <code>serviceClass</code> (such that
77 * <code>instanceof</code> serviceClass is true), or
79 * @see java.beans.beancontext.BeanContextServices#getService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Class,java.lang.Object,java.beans.beancontext.BeanContextServiceRevokedListener)
81 public Object getService(BeanContextServices services, Object requestor, Class serviceClass, Object serviceSelector);
84 * Release the service.
87 * Called by <code>BeanContextServices.releaseService()</code>.
90 * Most <code>BeanContextServiceProvider</code>s won't have to do
93 * @param services the <code>BeanContextServices</code> that wants
94 * to release the service. Only weak references to this will
95 * be retained, and it will never be changed, only queried
96 * in a read-only manner.
97 * @param requestor the original requestor of the service.
98 * @param service the service to relinquish
99 * @see java.beans.beancontext.BeanContextServices#releaseService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Object)
101 public void releaseService(BeanContextServices services, Object requestor, Object service);
104 * Get a list of valid service selectors for the specified service class.
105 * This method is called from
106 * <code>BeanContextServices.getCurrentServiceSelectors()</code>.
109 * If the specified service class does not have a finite number of
110 * valid service selectors, it should return <code>null</code>.
111 * If it takes a general <code>Integer</code> parameter, for
112 * example, you may as well return <code>null</code> or the poor
113 * soul who called this method will be iterating all day.
116 * If it has no valid service selectors, it should still return an empty
117 * <code>Iterator</code>.
119 * @param services the <code>BeanContextServices</code> that wants
120 * to get the service selectors. Only weak references to this will
121 * be retained, and it will never be changed, only queried
122 * in a read-only manner.
123 * @param serviceClass the service class to get selectors for.
124 * @return a list of valid service selectors for the service
125 * class, or <code>null</code>.
126 * @see java.beans.beancontext.BeanContextServices#getCurrentServiceSelectors(java.lang.Class)
128 public Iterator getCurrentServiceSelectors(BeanContextServices services, Class serviceClass);