![JAR search and dependency download from the Maven repository](/logo.png)
org.apache.juneau.rest.annotation.RestDestroy Maven / Gradle / Ivy
// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
// * with the License. You may obtain a copy of the License at *
// * *
// * http://www.apache.org/licenses/LICENSE-2.0 *
// * *
// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
package org.apache.juneau.rest.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
import jakarta.servlet.*;
import org.apache.juneau.rest.*;
/**
* Identifies a method that gets called during servlet destroy.
*
*
* This method is called from within the {@link Servlet#destroy()}.
*
*
* The only valid parameter type for this method is {@link RestContext}, although typically no arguments will
* be specified.
*
*
Example:
*
* @Rest (...)
* public class PetStoreResource extends BasicRestServlet implements BasicUniversalJenaConfig {
*
* // Our database.
* private Map<Integer,Pet> petDB ;
*
* @RestDestroy
* public void onDestroy() {
* petDB = null ;
* }
* }
*
*
* Notes:
* -
* The method should return
void although if it does return any value, the value will be ignored.
* -
* The method should be
public although other visibilities are valid if the security manager allows it.
* -
* Static methods can be used.
*
-
* Multiple destroy methods can be defined on a class.
*
Destroy methods on child classes are invoked before destroy methods on parent classes.
*
The order of destroy method invocations within a class is alphabetical, then by parameter count, then by parameter types.
* -
* In general, destroy methods should not throw any exceptions, although if any are thrown, the stack trace will be
* printed to
System.err .
* -
* Note that if you override a parent method, you probably need to call
super .parentMethod(...)
.
*
The method is still considered part of the parent class for ordering purposes even though it's
* overridden by the child class.
*
*
* See Also:
* - Lifecycle Hooks
*
*/
@Target({METHOD,TYPE})
@Retention(RUNTIME)
@Inherited
@Repeatable(RestDestroyAnnotation.Array.class)
public @interface RestDestroy {
/**
* Dynamically apply this annotation to the specified methods.
*
* See Also:
*
* @return The annotation value.
*/
String[] on() default {};
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy