Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EntityContext  RSS feed

 
R Krishnan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the Entity bean why the entity context variable should be declared as protected.
 
Ashoke Bhowmick
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The purpose of having the context variable is to get an access to the container-provided runtime context. That enables the bean instance to make a callback method call to the container that instantiated it.
Definitely , you won't like the context object (which is very vital to the bean for getting the information regarding it's runtime env) to be modified by some other class , in which case you may get a wrong info about the context under which the bean is running.
That is the reason why it is not made public. Note that the container doesn't modify the context variable. It only calls the setEntityContext() and unsetEntityContext() and it is the responsibility of the bean developer to store the context in a variale , so that it can be accessed later.
Regards,
Ashoke Bhowmick
Originally posted by R Krishnan:
In the Entity bean why the entity context variable should be declared as protected.
 
R Krishnan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since only the associated bean instance and the container access it, i expected it to be private.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, the subclass for the bean generated at deploytime will probably have to access it directly too. That�s probably the reason it�s protected and not private.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!