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