OSDN Git Service

Jumbo patch:
[pf3gnuchains/gcc-fork.git] / libjava / java / beans / beancontext / BeanContextServiceProvider.java
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., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
20
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. */
26
27
28 package java.beans.beancontext;
29
30 import java.util.Iterator;
31
32 /**
33  * An actual factory for services.
34  * <P>
35  *
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.
40  * <P>
41  *
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.
46  *
47  * @author John Keiser
48  * @since JDK1.2
49  */
50
51 public interface BeanContextServiceProvider {
52         /**
53          * Get a service.
54          * Called from <code>BeanContextServices.getService().
55          * <P>
56          *
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
60          * <code>null</code>.
61          * <P>
62          *
63          * This method may throw unchecked exceptions, so watch out.
64          *
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
73          *        requested.
74          * @param serviceSelector a parameter to customize the service
75          *        returned with.
76          * @return an instance of <code>serviceClass</code> (such that
77          *        <code>instanceof</code> serviceClass is true), or
78          *        <code>null</code>.
79          * @see java.beans.beancontext.BeanContextServices#getService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Class,java.lang.Object,java.beans.beancontext.BeanContextServiceRevokedListener)
80          */
81         public Object getService(BeanContextServices services, Object requestor, Class serviceClass, Object serviceSelector);
82
83         /**
84          * Release the service.
85          * <P>
86          *
87          * Called by <code>BeanContextServices.releaseService()</code>.
88          * <P>
89          *
90          * Most <code>BeanContextServiceProvider</code>s won't have to do
91          * anything here.
92          *
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)
100          */
101         public void releaseService(BeanContextServices services, Object requestor, Object service);
102
103         /**
104          * Get a list of valid service selectors for the specified service class.
105          * This method is called from
106          * <code>BeanContextServices.getCurrentServiceSelectors()</code>.
107          * <P>
108          *
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.
114          * <P>
115          *
116          * If it has no valid service selectors, it should still return an empty
117          * <code>Iterator</code>.
118          *
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)
127          */
128         public Iterator getCurrentServiceSelectors(BeanContextServices services, Class serviceClass);
129 }