Path: blob/master/src/java.desktop/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java
41159 views
/*1* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.beans.beancontext;2627import java.io.Serial;2829/**30* <p>31* This event type is used by the32* {@code BeanContextServiceRevokedListener} in order to33* identify the service being revoked.34* </p>35*/36public class BeanContextServiceRevokedEvent extends BeanContextEvent {3738/**39* Use serialVersionUID from JDK 1.7 for interoperability.40*/41@Serial42private static final long serialVersionUID = -1295543154724961754L;4344/**45* Construct a {@code BeanContextServiceEvent}.46* @param bcs the {@code BeanContextServices}47* from which this service is being revoked48* @param sc the service that is being revoked49* @param invalidate {@code true} for immediate revocation50*/51public BeanContextServiceRevokedEvent(BeanContextServices bcs, Class<?> sc, boolean invalidate) {52super((BeanContext)bcs);5354serviceClass = sc;55invalidateRefs = invalidate;56}5758/**59* Gets the source as a reference of type {@code BeanContextServices}60* @return the {@code BeanContextServices} from which61* this service is being revoked62*/63public BeanContextServices getSourceAsBeanContextServices() {64return (BeanContextServices)getBeanContext();65}6667/**68* Gets the service class that is the subject of this notification69* @return A {@code Class} reference to the70* service that is being revoked71*/72public Class<?> getServiceClass() { return serviceClass; }7374/**75* Checks this event to determine whether or not76* the service being revoked is of a particular class.77* @param service the service of interest (should be non-null)78* @return {@code true} if the service being revoked is of the79* same class as the specified service80*/81public boolean isServiceClass(Class<?> service) {82return serviceClass.equals(service);83}8485/**86* Reports if the current service is being forcibly revoked,87* in which case the references are now invalidated and unusable.88* @return {@code true} if current service is being forcibly revoked89*/90public boolean isCurrentServiceInvalidNow() { return invalidateRefs; }9192/**93* fields94*/9596/**97* A {@code Class} reference to the service that is being revoked.98*/99protected Class<?> serviceClass;100101/**102* {@code true} if current service is being forcibly revoked.103*/104private boolean invalidateRefs;105}106107108