15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.beans.beancontext; 27 28 import java.beans.beancontext.BeanContextEvent; 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 } | 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.beans.beancontext; 27 28 import java.beans.beancontext.BeanContextEvent; 29 30 import java.beans.beancontext.BeanContextServices; 31 32 /** 33 * <p> 34 * This event type is used by the 35 * {@code BeanContextServiceRevokedListener} 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}. 44 * @param bcs the {@code BeanContextServices} 45 * from which this service is being revoked 46 * @param sc the service that is being revoked 47 * @param invalidate {@code true} 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} 58 * @return the {@code BeanContextServices} 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} 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} 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} 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} reference to the service that is being revoked. 96 */ 97 protected Class<?> serviceClass; 98 private boolean invalidateRefs; 99 } |