This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JSF and the fly likes @PostConstruct ,@Preestroy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "@PostConstruct ,@Preestroy" Watch "@PostConstruct ,@Preestroy" New topic
Author

@PostConstruct ,@Preestroy

komal ekbote
Greenhorn

Joined: Jun 20, 2007
Posts: 17
Hello,
Can anyone please explain me the use of @PostConstruct ,@Preestroy in JSF with an example.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17155
    
  27

I don't think that these are part of JSF - they're part of the JSR-250 lifecycle spec.

Spring supports these annotations, I believe.


An IDE is no substitute for an Intelligent Developer.
Ryan Lubke
Ranch Hand

Joined: Jun 20, 2007
Posts: 36
Originally posted by Tim Holloway:
I don't think that these are part of JSF - they're part of the JSR-250 lifecycle spec.

Spring supports these annotations, I believe.


The JSF 1.2 spec requires support of these annotations in a Java EE 5 environment. That said Mojarra (the RI) supports these two annotations
outside of an EE environment if the annotations are present in the classpath.

As to their explanation, it's pretty straight forward.
Methods marked with the @PostConstruct annotation will be invoked after the bean has been created, any resources have been injected, and any managed properties set, but *before* the bean is actually pushed into scope.

Methods marked with @PreDestroy will be called before the bean has been
removed from scope.

This blog has some examples -> http://weblogs.java.net/blog/jhook/archive/2007/05/jsf_12_ri_backi.html
[ January 22, 2008: Message edited by: Ryan Lubke ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @PostConstruct ,@Preestroy
 
It's not a secret anymore!