Page 1 of 1

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

Posted: Sun May 17, 2015 7:07 pm
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.

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

Posted: Sun May 17, 2015 8:14 pm
by admin
Yes, of course, if the method is not there then there is no question about calling it.

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

Posted: Mon May 18, 2015 8:41 am
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.

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

Posted: Mon May 18, 2015 8:01 pm
by admin
Yes, if the method is there then it must call it.

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

Posted: Wed Jun 10, 2015 6:20 pm
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."

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

Posted: Wed Jun 10, 2015 9:40 pm
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.