Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PostConstruct and PreDestroy methods can be have any access modifier

 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Page 81 of EJB in action: PostConstruct and PreDestroy methods can be have any access modifier. I can't understand, how is this permitted and how can this work fine. I had a private @PostConstruct method in a stateless session bean and it worked fine. Since PostConstruct is just a method call, how can container which is outside the class invoke a private method.
Please explain.
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take time to respond to this question.
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the container it is the metadata that is required (i.e., the annotations).
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand the metadata part of it, But in the end lifecycle callbacks are just methods, and if a method is marked private, How can it be invoked from a code like the container outside the class.

Experts/Ranchers, Please take time and reply.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic