@PostConstruct Use Instructions __postconstruct

Source: Internet
Author: User

Instructions for the use of javax.annotation.PostConstruct


The following is the original translation, the note has been made clear


The postconstruct annotation is used on a (a) method this needs to being executed after dependency injection are done to perform a NY initialization.
Postconstruct annotations are used on methods, and this method needs to be executed after dependency injection initialization.


This method must to be invoked before the class are put into service.
This method must be executed before the service class is used.


This annotation must is supported on all classes that support dependency.
All classes that support dependency injection must support this annotation.


The method annotated with Postconstruct must is invoked even if the class does not request any of the injected.
The method must be executed, even if the class in which it resides does not inject any resources.


Only one of the can is annotated with this annotation.
Only one method can use the annotation.


The method on which the postconstruct annotation are applied must fulfill all of the criteria--
The method used for this annotation must all conform to the following guidelines:


The method must not have any parameters except in the case of EJB interceptors in which case it takes a invocation T object as defined by the EJB specification.
You cannot have any arguments except the EJB interface.


-The return type of the method must is void.
The return value must be void


-The method must not throw a checked exception.
The method cannot throw an exception


-the ' method ' which postconstruct is applied to public, protected, package private or private.
You can use modifiers such as public, protected, and so on


-The method must is static except for the application client.
method is not a static decoration, unless it is an application client


-the method is final.
Method can use the final modification


-If The method throws a unchecked exception the class must not being put into service except in the case of EJBs WH Ere the EJB can handle exceptions and even recover from them.
Method if an unknown exception is thrown, the class must not be used as a service class, unless it is an EJB component that can handle exceptions or even restore normalcy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.