Debian Codegraph @

src/jakarta/annotation/PreDestroy.java

raw symbols SCIP
1 /*
2 * Copyright (c) 2005, 2020 Oracle and/or its affiliates. All rights reserved.
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v. 2.0, which is available at
6 * http://www.eclipse.org/legal/epl-2.0.
7 *
8 * This Source Code may also be made available under the following Secondary
9 * Licenses when the conditions for such availability set forth in the
10 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11 * version 2 with the GNU Classpath Exception, which is available at
12 * https://www.gnu.org/software/classpath/license.html.
13 *
14 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15 */
16
17 package jakarta.annotation;
18
19 import java.lang.annotation.*;
20 import static java.lang.annotation.ElementType.*;
21 import static java.lang.annotation.RetentionPolicy.*;
22
23 /**
24 * The <code>PreDestroy</code> annotation is used on a method as a
25 * callback notification to signal that the instance is in the
26 * process of being removed by the container. The method annotated
27 * with <code>PreDestroy</code> is typically used to
28 * release resources that it has been holding. This annotation must be
29 * supported by all container-managed objects that support the use of
30 * the <code>PostConstruct</code> annotation except the Jakarta EE application
31 * client. The method on which the <code>PreDestroy</code> annotation
32 * is applied must fulfill all of the following criteria:
33 * <ul>
34 * <li>The method must not have any parameters except in the case of
35 * interceptors in which case it takes an <code>InvocationContext</code>
36 * object as defined by the Jakarta Interceptors specification.</li>
37 * <li>The method defined on an interceptor class or superclass of an
38 * interceptor class must have one of the following signatures:
39 * <p>
40 * void &#060;METHOD&#062;(InvocationContext)
41 * <p>
42 * Object &#060;METHOD&#062;(InvocationContext) throws Exception
43 * <p>
44 * <i>Note: A PreDestroy interceptor method must not throw application
45 * exceptions, but it may be declared to throw checked exceptions including
46 * the java.lang.Exception if the same interceptor method interposes on
47 * business or timeout methods in addition to lifecycle events. If a
48 * PreDestroy interceptor method returns a value, it is ignored by
49 * the container.</i>
50 * </li>
51 * <li>The method defined on a non-interceptor class must have the
52 * following signature:
53 * <p>
54 * void &#060;METHOD&#062;()
55 * </li>
56 * <li>The method on which PreDestroy is applied may be public, protected,
57 * package private or private.</li>
58 * <li>The method must not be static.</li>
59 * <li>The method should not be final.</li>
60 * <li>If the method throws an unchecked exception it is ignored by
61 * the container.</li>
62 * </ul>
63 *
64 * @see jakarta.annotation.PostConstruct
65 * @see jakarta.annotation.Resource
66 * @since 1.6, Common Annotations 1.0
67 */
68
69 @Documented
70 @Retention (RUNTIME)
71 @Target(METHOD)
72 public @interface PreDestroy {
73 }