KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > beans > beancontext > BeanContextServiceProvider


1 /*
2  * @(#)BeanContextServiceProvider.java 1.10 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.beans.beancontext;
9
10 import java.util.Iterator JavaDoc;
11
12 /**
13  * <p>
14  * One of the primary functions of a BeanContext is to act a as rendezvous
15  * between JavaBeans, and BeanContextServiceProviders.
16  * </p>
17  * <p>
18  * A JavaBean nested within a BeanContext, may ask that BeanContext to
19  * provide an instance of a "service", based upon a reference to a Java
20  * Class object that represents that service.
21  * </p>
22  * <p>
23  * If such a service has been registered with the context, or one of its
24  * nesting context's, in the case where a context delegate to its context
25  * to satisfy a service request, then the BeanContextServiceProvider associated with
26  * the service is asked to provide an instance of that service.
27  * </p>
28  * <p>
29  * The ServcieProvider may always return the same instance, or it may
30  * construct a new instance for each request.
31  * </p>
32  */

33
34 public interface BeanContextServiceProvider {
35
36    /**
37     * Invoked by <code>BeanContextServices</code>, this method
38     * requests an instance of a
39     * service from this <code>BeanContextServiceProvider</code>.
40     *
41     * @param bcs The <code>BeanContextServices</code> associated with this
42     * particular request. This parameter enables the
43     * <code>BeanContextServiceProvider</code> to distinguish service
44     * requests from multiple sources.
45     *
46     * @param requestor The object requesting the service
47     *
48     * @param serviceClass The service requested
49     *
50     * @param serviceSelector the service dependent parameter
51     * for a particular service, or <code>null</code> if not applicable.
52     *
53     * @return a reference to the requested service
54     */

55     Object JavaDoc getService(BeanContextServices JavaDoc bcs, Object JavaDoc requestor, Class JavaDoc serviceClass, Object JavaDoc serviceSelector);
56
57     /**
58      * Invoked by <code>BeanContextServices</code>,
59      * this method releases a nested <code>BeanContextChild</code>'s
60      * (or any arbitrary object associated with a
61      * <code>BeanContextChild</code>) reference to the specified service.
62      *
63      * @param bcs the <code>BeanContextServices</code> associated with this
64      * particular release request
65      *
66      * @param requestor the object requesting the service to be released
67      *
68      * @param service the service that is to be released
69      */

70     public void releaseService(BeanContextServices JavaDoc bcs, Object JavaDoc requestor, Object JavaDoc service);
71
72     /**
73      * Invoked by <code>BeanContextServices</code>, this method
74      * gets the current service selectors for the specified service.
75      * A service selector is a service specific parameter,
76      * typical examples of which could include: a
77      * parameter to a constructor for the service implementation class,
78      * a value for a particular service's property, or a key into a
79      * map of existing implementations.
80      *
81      * @param bcs the <code>BeanContextServices</code> for this request
82      * @param serviceClass the specified service
83      * @return the current service selectors for the specified serviceClass
84      */

85     Iterator JavaDoc getCurrentServiceSelectors(BeanContextServices JavaDoc bcs, Class JavaDoc serviceClass);
86 }
87
88
89
Popular Tags