BeanContextServiceProvider.java 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* java.beans.beancontext.BeanContextServiceProvider
  2. Copyright (C) 1999 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.beans.beancontext;
  32. import java.util.Iterator;
  33. /**
  34. * An actual factory for services.
  35. * <P>
  36. *
  37. * It is the <code>BeanContextServiceProvider</code>'s responsibility to
  38. * register itself with whatever <code>BeanContextServices</code> object
  39. * it wishes to provide services through using the
  40. * <code>addService()</code> method.
  41. * <P>
  42. *
  43. * If for some reason it can no longer provide services for a particular
  44. * class, this class must invoke
  45. * <code>BeanContextServices.revokeService(serviceClass,this,true)</code>
  46. * for all the places it has registered the service.
  47. *
  48. * @author John Keiser
  49. * @since JDK1.2
  50. */
  51. public interface BeanContextServiceProvider {
  52. /**
  53. * Get a service.
  54. * Called from <code>BeanContextServices.getService()</code>.
  55. *
  56. * <p>If the requested service class is not available, or if this
  57. * <code>BeanContextServiceProvider</code> chooses not honor the
  58. * request for some reason, then this method will return
  59. * <code>null</code>.</p>
  60. *
  61. * This method may throw unchecked exceptions, so watch out.
  62. *
  63. * @param services the <code>BeanContextServices</code> that wants
  64. * to get the service. Only weak references to this will
  65. * be retained, and it will never be changed, only queried
  66. * in a read-only manner.
  67. * @param requestor the actual requestor of the service. Only
  68. * weak references to this will be retained, and it will
  69. * never be changed, only queried in a read-only manner.
  70. * @param serviceClass the <code>Class</code> of the service being
  71. * requested.
  72. * @param serviceSelector a parameter to customize the service
  73. * returned with.
  74. * @return an instance of <code>serviceClass</code> (such that
  75. * <code>instanceof</code> serviceClass is true), or
  76. * <code>null</code>.
  77. * @see java.beans.beancontext.BeanContextServices#getService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Class,java.lang.Object,java.beans.beancontext.BeanContextServiceRevokedListener)
  78. */
  79. Object getService(BeanContextServices services, Object requestor, Class serviceClass, Object serviceSelector);
  80. /**
  81. * Release the service.
  82. * <P>
  83. *
  84. * Called by <code>BeanContextServices.releaseService()</code>.
  85. * <P>
  86. *
  87. * Most <code>BeanContextServiceProvider</code>s won't have to do
  88. * anything here.
  89. *
  90. * @param services the <code>BeanContextServices</code> that wants
  91. * to release the service. Only weak references to this will
  92. * be retained, and it will never be changed, only queried
  93. * in a read-only manner.
  94. * @param requestor the original requestor of the service.
  95. * @param service the service to relinquish
  96. * @see java.beans.beancontext.BeanContextServices#releaseService(java.beans.beancontext.BeanContextChild,java.lang.Object,java.lang.Object)
  97. */
  98. void releaseService(BeanContextServices services, Object requestor, Object service);
  99. /**
  100. * Get a list of valid service selectors for the specified service class.
  101. * This method is called from
  102. * <code>BeanContextServices.getCurrentServiceSelectors()</code>.
  103. * <P>
  104. *
  105. * If the specified service class does not have a finite number of
  106. * valid service selectors, it should return <code>null</code>.
  107. * If it takes a general <code>Integer</code> parameter, for
  108. * example, you may as well return <code>null</code> or the poor
  109. * soul who called this method will be iterating all day.
  110. * <P>
  111. *
  112. * If it has no valid service selectors, it should still return an empty
  113. * <code>Iterator</code>.
  114. *
  115. * @param services the <code>BeanContextServices</code> that wants
  116. * to get the service selectors. Only weak references to this will
  117. * be retained, and it will never be changed, only queried
  118. * in a read-only manner.
  119. * @param serviceClass the service class to get selectors for.
  120. * @return a list of valid service selectors for the service
  121. * class, or <code>null</code>.
  122. * @see java.beans.beancontext.BeanContextServices#getCurrentServiceSelectors(java.lang.Class)
  123. */
  124. Iterator getCurrentServiceSelectors(BeanContextServices services, Class serviceClass);
  125. }