Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java
41159 views
1
/*
2
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
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.io.Serial;
29
30
/**
31
* <p>
32
* This event type is used by the
33
* {@code BeanContextServiceRevokedListener} in order to
34
* identify the service being revoked.
35
* </p>
36
*/
37
public class BeanContextServiceRevokedEvent extends BeanContextEvent {
38
39
/**
40
* Use serialVersionUID from JDK 1.7 for interoperability.
41
*/
42
@Serial
43
private static final long serialVersionUID = -1295543154724961754L;
44
45
/**
46
* Construct a {@code BeanContextServiceEvent}.
47
* @param bcs the {@code BeanContextServices}
48
* from which this service is being revoked
49
* @param sc the service that is being revoked
50
* @param invalidate {@code true} for immediate revocation
51
*/
52
public BeanContextServiceRevokedEvent(BeanContextServices bcs, Class<?> sc, boolean invalidate) {
53
super((BeanContext)bcs);
54
55
serviceClass = sc;
56
invalidateRefs = invalidate;
57
}
58
59
/**
60
* Gets the source as a reference of type {@code BeanContextServices}
61
* @return the {@code BeanContextServices} from which
62
* this service is being revoked
63
*/
64
public BeanContextServices getSourceAsBeanContextServices() {
65
return (BeanContextServices)getBeanContext();
66
}
67
68
/**
69
* Gets the service class that is the subject of this notification
70
* @return A {@code Class} reference to the
71
* service that is being revoked
72
*/
73
public Class<?> getServiceClass() { return serviceClass; }
74
75
/**
76
* Checks this event to determine whether or not
77
* the service being revoked is of a particular class.
78
* @param service the service of interest (should be non-null)
79
* @return {@code true} if the service being revoked is of the
80
* same class as the specified service
81
*/
82
public boolean isServiceClass(Class<?> service) {
83
return serviceClass.equals(service);
84
}
85
86
/**
87
* Reports if the current service is being forcibly revoked,
88
* in which case the references are now invalidated and unusable.
89
* @return {@code true} if current service is being forcibly revoked
90
*/
91
public boolean isCurrentServiceInvalidNow() { return invalidateRefs; }
92
93
/**
94
* fields
95
*/
96
97
/**
98
* A {@code Class} reference to the service that is being revoked.
99
*/
100
protected Class<?> serviceClass;
101
102
/**
103
* {@code true} if current service is being forcibly revoked.
104
*/
105
private boolean invalidateRefs;
106
}
107
108