How does DirectoryResource keeps its listing?

Alexandre Rafalovitch writes:
 > Hi,
 > 
 > I was looking through the code of DirectoryResource and one small bit
 > striked me as extremely strange. Directory resource has a variable listing,
 > which is not an attribute. It is never saved anywhere and it is
 > recalculated only when underlining data is modified or when it is null. (I
 > assume on first reference for the directory listing).

Correct, it is computed when it is null, wich typically means right
after the directory resource is instantiated (provided a request hits it).

 > The problem is, I always assumed that I have a single instance of each
 > resource and when it is accessed it has its parameters set before and saved
 > after. If I am right, that under some circumstances a Directory resource
 > should show for new directory listing of old directory.

*Only* registered attributes of resources are made persistent. In the
case of the DirectoryResource this means all the one that are
registered in the static block of the class.

 > On another hand if I am wrong, then when do new instances of a resource get
 > created, by whom, and when are they released?

They gets created /released by Jigsaw runtime, according to some
policy defined by the 'ResourceStoreManager'

 > Please resolve that mistery for me, because I don't know how much I can
 > relly on non attribute variables.

Non attribute values (ie instance variables) are never saved; that's a
feature ;-)

Anselm.

Received on Friday, 21 June 1996 19:20:58 UTC