1. /*
  2. * @(#)BeanContextServiceProvider.java 1.6 00/02/02
  3. *
  4. * Copyright 1998-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package java.beans.beancontext;
  11. import java.util.Iterator;
  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. public interface BeanContextServiceProvider {
  34. /**
  35. * Invoked by <code>BeanContextServices</code>, this method
  36. * requests an instance of a
  37. * service from this <code>BeanContextServiceProvider</code>.
  38. *
  39. * @param bcs The <code>BeanContextServices</code> associated with this
  40. * particular request. This parameter enables the
  41. * <code>BeanContextServiceProvider</code> to distinguish service
  42. * requests from multiple sources.
  43. *
  44. * @param requestor The object requesting the service
  45. *
  46. * @param serviceClass The service requested
  47. *
  48. * @param serviceSelector the service dependent parameter
  49. * for a particular service, or <code>null</code> if not applicable.
  50. *
  51. * @return a reference to the requested service
  52. */
  53. Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector);
  54. /**
  55. * Invoked by <code>BeanContextServices</code>,
  56. * this method releases a nested <code>BeanContextChild</code>'s
  57. * (or any arbitrary object associated with a
  58. * <code>BeanContextChild</code>) reference to the specified service.
  59. *
  60. * @param bcs the <code>BeanContextServices</code> associated with this
  61. * particular release request
  62. *
  63. * @param requestor the object requesting the service to be released
  64. *
  65. * @param service the service that is to be released
  66. */
  67. public void releaseService(BeanContextServices bcs, Object requestor, Object service);
  68. /**
  69. * Invoked by <code>BeanContextServices</code>, this method
  70. * gets the current service selectors for the specified service.
  71. * A service selector is a service specific parameter,
  72. * typical examples of which could include: a
  73. * parameter to a constructor for the service implementation class,
  74. * a value for a particular service's property, or a key into a
  75. * map of existing implementations.
  76. * @param bcs the <code>BeanContextServices</code> for this request
  77. * @param service the specified service
  78. * @return the current service selectors for the specified serviceClass
  79. */
  80. Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass);
  81. }