Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

Saving request scope bean reference to session scone bean

Thread view: 
gallas.robert@gmail.com - 19 Mar 2008 08:49 GMT
Hi,

Maybe dump question.

What happens when reqest scope bean reference is set in some field of
session scoped bean. Normally at the end of the request request scope
bean should be discarded by Garbage Collector.

What I deduct is that since reference to reqest scope bean exists in
session bean, request scope bean will not be discarded. However after
next request web container will create new request scope bean and old
one will be invalid. Until I save reference to new request scope bean
in session bean.  Old one will be not discarded by Garbage collector
even if from  web container point of view this objct is invalid.

Is this correct?

Robert
Lew - 19 Mar 2008 14:09 GMT
> Maybe dump question.
>
[quoted text clipped - 10 lines]
>
> Is this correct?

I expect not, but I'm interested in the evidence for your deduction.

Does the object hold a circular reference to the request instance?

Unless something live refers to the request, then it becomes unreachable at
the end of the servlet service() method.  It should go away in an upcoming GC.

As for object X, request-lived objects ("scope" is a compile-time term;
runtime deals with lifecycles) also go away - /unless/ there's a live
reference to them somewhere else, in your case from a session-lived object.
References don't flow "upstream", so nothing keeps the request alive unless X
itself does.

R -->\
S --> X

When the "R" arrow breaks, the "S" arrow keeps X alive.  No one is holding on
to R after service() exits.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.