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. package java.beans.beancontext;
  8. import java.util.Iterator;
  9. /**
  10. * <p>
  11. * One of the primary functions of a BeanContext is to act a as rendezvous
  12. * between JavaBeans, and BeanContextServiceProviders.
  13. * </p>
  14. * <p>
  15. * A JavaBean nested within a BeanContext, may ask that BeanContext to
  16. * provide an instance of a "service", based upon a reference to a Java
  17. * Class object that represents that service.
  18. * </p>
  19. * <p>
  20. * If such a service has been registered with the context, or one of its
  21. * nesting context's, in the case where a context delegate to its context
  22. * to satisfy a service request, then the BeanContextServiceProvider associated with
  23. * the service is asked to provide an instance of that service.
  24. * </p>
  25. * <p>
  26. * The ServcieProvider may always return the same instance, or it may
  27. * construct a new instance for each request.
  28. * </p>
  29. */
  30. public interface BeanContextServiceProvider {
  31. /**
  32. * Invoked by <code>BeanContextServices</code>, this method
  33. * requests an instance of a
  34. * service from this <code>BeanContextServiceProvider</code>.
  35. *
  36. * @param bcs The <code>BeanContextServices</code> associated with this
  37. * particular request. This parameter enables the
  38. * <code>BeanContextServiceProvider</code> to distinguish service
  39. * requests from multiple sources.
  40. *
  41. * @param requestor The object requesting the service
  42. *
  43. * @param serviceClass The service requested
  44. *
  45. * @param serviceSelector the service dependent parameter
  46. * for a particular service, or <code>null</code> if not applicable.
  47. *
  48. * @return a reference to the requested service
  49. */
  50. Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector);
  51. /**
  52. * Invoked by <code>BeanContextServices</code>,
  53. * this method releases a nested <code>BeanContextChild</code>'s
  54. * (or any arbitrary object associated with a
  55. * <code>BeanContextChild</code>) reference to the specified service.
  56. *
  57. * @param bcs the <code>BeanContextServices</code> associated with this
  58. * particular release request
  59. *
  60. * @param requestor the object requesting the service to be released
  61. *
  62. * @param service the service that is to be released
  63. */
  64. public void releaseService(BeanContextServices bcs, Object requestor, Object service);
  65. /**
  66. * Invoked by <code>BeanContextServices</code>, this method
  67. * gets the current service selectors for the specified service.
  68. * A service selector is a service specific parameter,
  69. * typical examples of which could include: a
  70. * parameter to a constructor for the service implementation class,
  71. * a value for a particular service's property, or a key into a
  72. * map of existing implementations.
  73. *
  74. * @param bcs the <code>BeanContextServices</code> for this request
  75. * @param serviceClass the specified service
  76. * @return the current service selectors for the specified serviceClass
  77. */
  78. Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass);
  79. }