1. /*
  2. * @(#)BeanContextServiceRevokedEvent.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.beans.beancontext.BeanContextEvent;
  12. import java.beans.beancontext.BeanContextServices;
  13. /**
  14. * <p>
  15. * This event type is used by the
  16. * <code>BeanContextServiceRevokedListener</code> in order to
  17. * identify the service being revoked.
  18. * </p>
  19. */
  20. public class BeanContextServiceRevokedEvent extends BeanContextEvent {
  21. /**
  22. * Construct a <code>BeanContextServiceEvent</code>.
  23. * @param bcs the <code>BeanContextServices</code>
  24. * from which this service is being revoked
  25. * @param sc the service that is being revoked
  26. * @param invalidate <code>true</code> for immediate revocation
  27. */
  28. public BeanContextServiceRevokedEvent(BeanContextServices bcs, Class sc, boolean invalidate) {
  29. super((BeanContext)bcs);
  30. serviceClass = sc;
  31. invalidateRefs = invalidate;
  32. }
  33. /**
  34. * Gets the source as a reference of type <code>BeanContextServices</code>
  35. * @return the <code>BeanContextServices</code> from which
  36. * this service is being revoked
  37. */
  38. public BeanContextServices getSourceAsBeanContextServices() {
  39. return (BeanContextServices)getBeanContext();
  40. }
  41. /**
  42. * Gets the service class that is the subject of this notification
  43. * @return A <code>Class</code> reference to the
  44. * service that is being revoked
  45. */
  46. public Class getServiceClass() { return serviceClass; }
  47. /**
  48. * Checks this event to determine whether or not
  49. * the service being revoked is of a particular class.
  50. * @param service the service of interest
  51. * @return <code>true</code> if the service being revoked is of the
  52. * same class as the specified service
  53. */
  54. public boolean isServiceClass(Class service) {
  55. return serviceClass.equals(service);
  56. }
  57. /**
  58. * Reports if the current service is being forcibly revoked,
  59. * in which case the references are now invalidated and unusable.
  60. * @return <code>true</code> if current service is being forcibly revoked
  61. */
  62. public boolean isCurrentServiceInvalidNow() { return invalidateRefs; }
  63. /**
  64. * fields
  65. */
  66. /**
  67. * A <code>Class</code> reference to the service that is being revoked.
  68. */
  69. protected Class serviceClass;
  70. private boolean invalidateRefs;
  71. }