About Question com.enthuware.oce-ejbd.v6.2.528

Moderator: admin

Post Reply
himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question com.enthuware.oce-ejbd.v6.2.528

Post by himaiMinh »

For option 1 "The container must always call @PrePassivate method before passivating a bean."
But it is possible that the bean provider does not define such a method.
In this case, the container will not call this method.

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question com.enthuware.oce-ejbd.v6.2.528

Post by admin »

Yes, of course, if the method is not there then there is no question about calling it.
If you like our products and services, please help us by posting your review here.

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question com.enthuware.oce-ejbd.v6.2.528

Post by himaiMinh »

So, is option 1 still the correct option ? The word "must always" is the key.
The container does not call the @PrePassivate method if the bean provider does not define one.

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question com.enthuware.oce-ejbd.v6.2.528

Post by admin »

Yes, if the method is there then it must call it.
If you like our products and services, please help us by posting your review here.

himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question com.enthuware.oce-ejbd.v6.2.528

Post by himaiMinh »

For option 4's explanation "In 3.x, the container calls @PostConstruct method, in which the bean can initialize itself."
I think it can be more specific to say "the container calls @PostConstruct method, in which the bean can initialize its instance variables."

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question com.enthuware.oce-ejbd.v6.2.528

Post by admin »

himaiMinh wrote:For option 4's explanation "In 3.x, the container calls @PostConstruct method, in which the bean can initialize itself."
I think it can be more specific to say "the container calls @PostConstruct method, in which the bean can initialize its instance variables."
An object's state is in its instance variables so both mean the same thing.

But if you want to split hair, then what you are saying is not correct :) Instance variables would be "initialized" to their default values by the JVM as soon as the bean object is created.
Initializing a bean implies that you are setting those variables to values that make more sense from the business logic perspective. For example, int rate; would be initialized to 0 by default anyway. But the bean may want to set it to some other value. This is a bean initialization and not just instance variable initialization.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests