This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

@PostConstruct may be final?  RSS feed

 
Tridib Samanta
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to Java EE API (java doc), a method annotated with @PostConstruct may be final. But, according to EJB 3.0 specification (page 305)
A lifecycle callback interceptor method must not be declared as final or static
. Which one is correct?
 
Mikalai Zaikin
Ranch Hand
Posts: 3416
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right. There is some inconsistency.

I would use EJB 3.0 specification as the trusted source
 
Lawrence Johnbosco
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I can say both are right, since @PostConstruct is part of "javax.annotation" -- it means it can be used for any kind of callback implementation (not just for EJB). But when to comes to EJB, the specification further restricts the callback by saying it should not be final.


Regards..Lawrence J
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!