src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java

Print this page




  29 
  30 import java.beans.beancontext.BeanContextServices;
  31 
  32 /**
  33  * <p>
  34  * This event type is used by the
  35  * <code>BeanContextServiceRevokedListener</code> in order to
  36  * identify the service being revoked.
  37  * </p>
  38  */
  39 public class BeanContextServiceRevokedEvent extends BeanContextEvent {
  40     private static final long serialVersionUID = -1295543154724961754L;
  41 
  42     /**
  43      * Construct a <code>BeanContextServiceEvent</code>.
  44      * @param bcs the <code>BeanContextServices</code>
  45      * from which this service is being revoked
  46      * @param sc the service that is being revoked
  47      * @param invalidate <code>true</code> for immediate revocation
  48      */
  49     public BeanContextServiceRevokedEvent(BeanContextServices bcs, Class sc, boolean invalidate) {
  50         super((BeanContext)bcs);
  51 
  52         serviceClass    = sc;
  53         invalidateRefs  = invalidate;
  54     }
  55 
  56     /**
  57      * Gets the source as a reference of type <code>BeanContextServices</code>
  58      * @return the <code>BeanContextServices</code> from which
  59      * this service is being revoked
  60      */
  61     public BeanContextServices getSourceAsBeanContextServices() {
  62         return (BeanContextServices)getBeanContext();
  63     }
  64 
  65     /**
  66      * Gets the service class that is the subject of this notification
  67      * @return A <code>Class</code> reference to the
  68      * service that is being revoked
  69      */
  70     public Class getServiceClass() { return serviceClass; }
  71 
  72     /**
  73      * Checks this event to determine whether or not
  74      * the service being revoked is of a particular class.
  75      * @param service the service of interest (should be non-null)
  76      * @return <code>true</code> if the service being revoked is of the
  77      * same class as the specified service
  78      */
  79     public boolean isServiceClass(Class service) {
  80         return serviceClass.equals(service);
  81     }
  82 
  83     /**
  84      * Reports if the current service is being forcibly revoked,
  85      * in which case the references are now invalidated and unusable.
  86      * @return <code>true</code> if current service is being forcibly revoked
  87      */
  88     public boolean isCurrentServiceInvalidNow() { return invalidateRefs; }
  89 
  90     /**
  91      * fields
  92      */
  93 
  94     /**
  95      * A <code>Class</code> reference to the service that is being revoked.
  96      */
  97     protected Class                      serviceClass;
  98     private   boolean                    invalidateRefs;
  99 }


  29 
  30 import java.beans.beancontext.BeanContextServices;
  31 
  32 /**
  33  * <p>
  34  * This event type is used by the
  35  * <code>BeanContextServiceRevokedListener</code> in order to
  36  * identify the service being revoked.
  37  * </p>
  38  */
  39 public class BeanContextServiceRevokedEvent extends BeanContextEvent {
  40     private static final long serialVersionUID = -1295543154724961754L;
  41 
  42     /**
  43      * Construct a <code>BeanContextServiceEvent</code>.
  44      * @param bcs the <code>BeanContextServices</code>
  45      * from which this service is being revoked
  46      * @param sc the service that is being revoked
  47      * @param invalidate <code>true</code> for immediate revocation
  48      */
  49     public BeanContextServiceRevokedEvent(BeanContextServices bcs, Class<?> sc, boolean invalidate) {
  50         super((BeanContext)bcs);
  51 
  52         serviceClass    = sc;
  53         invalidateRefs  = invalidate;
  54     }
  55 
  56     /**
  57      * Gets the source as a reference of type <code>BeanContextServices</code>
  58      * @return the <code>BeanContextServices</code> from which
  59      * this service is being revoked
  60      */
  61     public BeanContextServices getSourceAsBeanContextServices() {
  62         return (BeanContextServices)getBeanContext();
  63     }
  64 
  65     /**
  66      * Gets the service class that is the subject of this notification
  67      * @return A <code>Class</code> reference to the
  68      * service that is being revoked
  69      */
  70     public Class<?> getServiceClass() { return serviceClass; }
  71 
  72     /**
  73      * Checks this event to determine whether or not
  74      * the service being revoked is of a particular class.
  75      * @param service the service of interest (should be non-null)
  76      * @return <code>true</code> if the service being revoked is of the
  77      * same class as the specified service
  78      */
  79     public boolean isServiceClass(Class<?> service) {
  80         return serviceClass.equals(service);
  81     }
  82 
  83     /**
  84      * Reports if the current service is being forcibly revoked,
  85      * in which case the references are now invalidated and unusable.
  86      * @return <code>true</code> if current service is being forcibly revoked
  87      */
  88     public boolean isCurrentServiceInvalidNow() { return invalidateRefs; }
  89 
  90     /**
  91      * fields
  92      */
  93 
  94     /**
  95      * A <code>Class</code> reference to the service that is being revoked.
  96      */
  97     protected Class<?>                   serviceClass;
  98     private   boolean                    invalidateRefs;
  99 }