You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tylertreat edited this page Dec 31, 2012
·
1 revision
The PostConstruct annotation indicates that the annotated method is to be invoked after the bean has been instantiated by Infinitum. Only one method can carry this annotation, and it does not have to be public. A method marked with this annotation must not have any arguments.
A PostConstruct method can be used to do additional bean initialization which relies on Autowired dependencies. The reason this initialization cannot be done in the constructor is because autowiring does not occur until after the constructor has been invoked. The bean initialization process is the following:
Invoke constructor (Autowired constructor, if available, otherwise the empty constructor).
Perform Autowired field injections.
Perform Autowired setter injections.
Invoke PostConstruct method.
PostConstruct Example
The below example illustrates the usage of the PostConstruct annotation.