RE: EO Object Lifespan / Editing Context
RE: EO Object Lifespan / Editing Context
- Subject: RE: EO Object Lifespan / Editing Context
- From: "Pierre Bernard" <email@hidden>
- Date: Wed, 16 Jul 2003 14:17:28 +0200
- Thread-topic: EO Object Lifespan / Editing Context
Hi!
The object lifetime depends on the version of WebObjects you are using. In versions prior to WO 5.2 editing contexts hold strong references to the objects they watch. Thus EOs cannot be releases unless their editing context is. For EOs living in the session's default editing context this implies that they don't get released until the session terminates. This assumes the default behavior where the session'sediting context has the same lifespan as the session itself.
Starting with WO 5.2 editing contexts hold strong references only to modified EOs. Other EOs are held by weak references and may thus be picked up by garbage collection as soon as they are no longer reachable through a strong reference. EOs however hold strong references to their editing context which was not the case in prior versions and could lead to errors.
In your example, the most sensible approach would be to reference the Member object from your session. E.g. have an instance variable on your WOSession subclass that holds the Member instance. This is OK as the information on the user currently logged in pertains to the session.
There are other instances where passing the EO from one page to another is more appropriate. E.g you go from a list to a detail page. Here you would have to make sure that when you manipulate multiple EOs all of them live in the same EC. Under WO versions prior to 5.2 you also have to ensure that the lifetime of the EC is no shorter than the livetime of the EOs you pass. To do this you can either pass the EC from page to page or have it atteached elsewhere. E.g. the default EC lioves as long as the session.
Pierre.
-----Original Message-----
From: Goodbye Bill [mailto:email@hidden]
Sent: Wednesday, July 16, 2003 10:21 AM
To: List: WebObjects-Dev
Subject: EO Object Lifespan / Editing Context
Once an object is loaded, and probably manipulated, within the default
editing context, how long does it remain there? And, do I have to
specifically pass the object from one page to the next in order to keep it
in memory and have it accessible?
EXAMPLE:
Assume, for a moment that a WebObjects application exists with the following
pages:
Signup
Login
Member Home
Update Member Info
Also assume that there is one object, the "Member" object with the following
properties:
User Name
Password
Email Address
Name
In this example, the member would log into the application using the "Login"
page. Once the "Member" object is successfully loaded from the database the
user is bounced to the "Member Home" page. If the user wanted to change
their account information, they would navigate to the "Update Member Info"
page.
QUESTION:
In the example above, does the "Member" object have to be passed from one
page to the next at runtime or does the "Member" object remain accessible
somewhere for the life of the session?
I'm reading books as I write this. Hopefully someone can save me some pain.
Thanks! =S
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
**********************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender
of this message. (email@hidden)
This email message has been checked for the presence of computer
viruses; however this protection does not ensure this message is
virus free.
Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
**********************************************************************
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.