Hello. Is it possible to use @PostConstruct annotation on a non-abstract method of an abstract class? In our application the annotation works perfectly if is placed on a method of a managed bean. But it doesn't work if I pull it up in the class hierarchy. For example:
In this example method AbstractParentBean.init() is not invoked despite the fact it is marked with @PostConstruct. Is it incorrect to put @PostConstruct annotation on a parent class (abstract or non-abstract)?
@PostConstruct will only work when the object is being managed by the container.
If a class isn't being managed, there isn't really a need for @PostConstruct, since there are no properties being set after construction, and what-not.
Joined: Mar 15, 2006
Zack, thanks for reply. The thing is that in my example class MyBean is managed by the container. And so is AbstractParentBean, as it is a "part" of MyBean. So I don't understand why the container doesn't call the init() method. In my opinion, there is no reason not to call it.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Using @PostConstruct in an abstract class