< prev index next >

src/java.desktop/share/classes/java/beans/beancontext/BeanContextServiceProvider.java

Print this page




  35  * <p>
  36  * A JavaBean nested within a BeanContext, may ask that BeanContext to
  37  * provide an instance of a "service", based upon a reference to a Java
  38  * Class object that represents that service.
  39  * </p>
  40  * <p>
  41  * If such a service has been registered with the context, or one of its
  42  * nesting context's, in the case where a context delegate to its context
  43  * to satisfy a service request, then the BeanContextServiceProvider associated with
  44  * the service is asked to provide an instance of that service.
  45  * </p>
  46  * <p>
  47  * The ServcieProvider may always return the same instance, or it may
  48  * construct a new instance for each request.
  49  * </p>
  50  */
  51 
  52 public interface BeanContextServiceProvider {
  53 
  54    /**
  55     * Invoked by <code>BeanContextServices</code>, this method
  56     * requests an instance of a
  57     * service from this <code>BeanContextServiceProvider</code>.
  58     *
  59     * @param bcs The <code>BeanContextServices</code> associated with this
  60     * particular request. This parameter enables the
  61     * <code>BeanContextServiceProvider</code> to distinguish service
  62     * requests from multiple sources.
  63     *
  64     * @param requestor          The object requesting the service
  65     *
  66     * @param serviceClass       The service requested
  67     *
  68     * @param serviceSelector the service dependent parameter
  69     * for a particular service, or <code>null</code> if not applicable.
  70     *
  71     * @return a reference to the requested service
  72     */
  73     Object getService(BeanContextServices bcs, Object requestor, Class<?> serviceClass, Object serviceSelector);
  74 
  75     /**
  76      * Invoked by <code>BeanContextServices</code>,
  77      * this method releases a nested <code>BeanContextChild</code>'s
  78      * (or any arbitrary object associated with a
  79      * <code>BeanContextChild</code>) reference to the specified service.
  80      *
  81      * @param bcs the <code>BeanContextServices</code> associated with this
  82      * particular release request
  83      *
  84      * @param requestor the object requesting the service to be released
  85      *
  86      * @param service the service that is to be released
  87      */
  88     public void releaseService(BeanContextServices bcs, Object requestor, Object service);
  89 
  90     /**
  91      * Invoked by <code>BeanContextServices</code>, this method
  92      * gets the current service selectors for the specified service.
  93      * A service selector is a service specific parameter,
  94      * typical examples of which could include: a
  95      * parameter to a constructor for the service implementation class,
  96      * a value for a particular service's property, or a key into a
  97      * map of existing implementations.
  98      *
  99      * @param bcs           the <code>BeanContextServices</code> for this request
 100      * @param serviceClass  the specified service
 101      * @return   the current service selectors for the specified serviceClass
 102      */
 103     Iterator<?> getCurrentServiceSelectors(BeanContextServices bcs, Class<?> serviceClass);
 104 }


  35  * <p>
  36  * A JavaBean nested within a BeanContext, may ask that BeanContext to
  37  * provide an instance of a "service", based upon a reference to a Java
  38  * Class object that represents that service.
  39  * </p>
  40  * <p>
  41  * If such a service has been registered with the context, or one of its
  42  * nesting context's, in the case where a context delegate to its context
  43  * to satisfy a service request, then the BeanContextServiceProvider associated with
  44  * the service is asked to provide an instance of that service.
  45  * </p>
  46  * <p>
  47  * The ServcieProvider may always return the same instance, or it may
  48  * construct a new instance for each request.
  49  * </p>
  50  */
  51 
  52 public interface BeanContextServiceProvider {
  53 
  54    /**
  55     * Invoked by {@code BeanContextServices}, this method
  56     * requests an instance of a
  57     * service from this {@code BeanContextServiceProvider}.
  58     *
  59     * @param bcs The {@code BeanContextServices} associated with this
  60     * particular request. This parameter enables the
  61     * {@code BeanContextServiceProvider} to distinguish service
  62     * requests from multiple sources.
  63     *
  64     * @param requestor          The object requesting the service
  65     *
  66     * @param serviceClass       The service requested
  67     *
  68     * @param serviceSelector the service dependent parameter
  69     * for a particular service, or {@code null} if not applicable.
  70     *
  71     * @return a reference to the requested service
  72     */
  73     Object getService(BeanContextServices bcs, Object requestor, Class<?> serviceClass, Object serviceSelector);
  74 
  75     /**
  76      * Invoked by {@code BeanContextServices},
  77      * this method releases a nested {@code BeanContextChild}'s
  78      * (or any arbitrary object associated with a
  79      * {@code BeanContextChild}) reference to the specified service.
  80      *
  81      * @param bcs the {@code BeanContextServices} associated with this
  82      * particular release request
  83      *
  84      * @param requestor the object requesting the service to be released
  85      *
  86      * @param service the service that is to be released
  87      */
  88     public void releaseService(BeanContextServices bcs, Object requestor, Object service);
  89 
  90     /**
  91      * Invoked by {@code BeanContextServices}, this method
  92      * gets the current service selectors for the specified service.
  93      * A service selector is a service specific parameter,
  94      * typical examples of which could include: a
  95      * parameter to a constructor for the service implementation class,
  96      * a value for a particular service's property, or a key into a
  97      * map of existing implementations.
  98      *
  99      * @param bcs           the {@code BeanContextServices} for this request
 100      * @param serviceClass  the specified service
 101      * @return   the current service selectors for the specified serviceClass
 102      */
 103     Iterator<?> getCurrentServiceSelectors(BeanContextServices bcs, Class<?> serviceClass);
 104 }
< prev index next >