Howdy Ranchers!
I've defined a environment resource with default value using annotations:
in DD I've defined it's value in the following way:
In another
EJB I'm accessing the NewSessionBean as follows:
As you can see, I'm accessing the env-entry as a package-private field, and then I'm using a business method.
The point is that direct field access returns the default value (-1).
The business method returns properly overridden value (100). To be sure that no 'initialization' takes place, the third line still results in -1.
Well, I
guess it's because of the proxy object. Using business method, the container can intercept the method invocation and access the proper value. While accessing the field directly it cannot proxy such call and that's why it results in the default value. Is this correct?
This brings me to observation that the container doesn't simply override the environmental variable (in this case: field myValue) during it's initialization. It just fetches the overriden value 'on-the-fly'. On the other hand, if you access the 'myValue' within the NewSessionBean, like so:
it works fine and returns proper answer: 100...
Can anyone explain why it's so? I wonder if this is the default and expected behaviour, or it might be only Glassfish 3.1 specific?
Thanks in advance,
Cheers!