KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > beans > beancontext > BeanContextServiceRevokedEvent


1 /*
2  * @(#)BeanContextServiceRevokedEvent.java 1.10 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.beans.beancontext;
9
10 import java.beans.beancontext.BeanContextEvent JavaDoc;
11
12 import java.beans.beancontext.BeanContextServices JavaDoc;
13
14 /**
15  * <p>
16  * This event type is used by the
17  * <code>BeanContextServiceRevokedListener</code> in order to
18  * identify the service being revoked.
19  * </p>
20  */

21 public class BeanContextServiceRevokedEvent extends BeanContextEvent JavaDoc {
22
23     /**
24      * Construct a <code>BeanContextServiceEvent</code>.
25      * @param bcs the <code>BeanContextServices</code>
26      * from which this service is being revoked
27      * @param sc the service that is being revoked
28      * @param invalidate <code>true</code> for immediate revocation
29      */

30     public BeanContextServiceRevokedEvent(BeanContextServices JavaDoc bcs, Class JavaDoc sc, boolean invalidate) {
31     super((BeanContext JavaDoc)bcs);
32
33     serviceClass = sc;
34     invalidateRefs = invalidate;
35     }
36
37     /**
38      * Gets the source as a reference of type <code>BeanContextServices</code>
39      * @return the <code>BeanContextServices</code> from which
40      * this service is being revoked
41      */

42     public BeanContextServices JavaDoc getSourceAsBeanContextServices() {
43     return (BeanContextServices JavaDoc)getBeanContext();
44     }
45
46     /**
47      * Gets the service class that is the subject of this notification
48      * @return A <code>Class</code> reference to the
49      * service that is being revoked
50      */

51     public Class JavaDoc getServiceClass() { return serviceClass; }
52
53     /**
54      * Checks this event to determine whether or not
55      * the service being revoked is of a particular class.
56      * @param service the service of interest (should be non-null)
57      * @return <code>true</code> if the service being revoked is of the
58      * same class as the specified service
59      */

60     public boolean isServiceClass(Class JavaDoc service) {
61     return serviceClass.equals(service);
62     }
63
64     /**
65      * Reports if the current service is being forcibly revoked,
66      * in which case the references are now invalidated and unusable.
67      * @return <code>true</code> if current service is being forcibly revoked
68      */

69     public boolean isCurrentServiceInvalidNow() { return invalidateRefs; }
70
71     /**
72      * fields
73      */

74
75     /**
76      * A <code>Class</code> reference to the service that is being revoked.
77      */

78     protected Class JavaDoc serviceClass;
79     private boolean invalidateRefs;
80 }
81
82
83
84
85
86
87
Popular Tags