Re: Global Information Store between resources

Hi Anselm,

>  > >  > public class ResourceManager extends HTTPResource {
>  > >  >   static GlobalResource gr;
>  > >  > 
>  > >  >   public ResourceManager() {}
>  > >  > 
>  > >  >   public synchronized GlobalResource getGlobalResource() {
>  > >  >     if (gr == null) {
>  > >  >       // Get the container resource.
>  > >  >       Resource parent = getParent();
>  > >  >       // Lookup the global resource within that container.
>  > >  >       gr = (GlobalResource) ((DirectoryResource) parent).lookup("globalResource\
>  > >  > ");
>  > >  >     }
>  > >  >     return gr;
>  > >  >   }
>  > >  > }
> 
> Where do you get the above "parent" from ? It should rather be
> getParent() by the way.
>  > The following is my GlobalResource class:
>  > ...
> This looks ok to me,
> 
> Can you point out line 17 in getGlobalResource ?

I think I gave you the wrong method in my last mail.  It should be:

  public synchronized GlobalResource getGlobalResource() {
    if (gr == null) {
      // Get the container resource.
      Resource parent = getParent();
      if (parent == null) {
        System.out.println("No parent!!!");
      }
      // Lookup the global resource within that container.
line 17: gr = (GlobalResource) ((DirectoryResource) parent).lookup("globalResource\
");
    }
    return gr;
  }

The "No parent!!!" message that I have in the method got printed, so
I guess getParent() returned null.  How is the parent attribute computed,
btw?  How do I make it so that it's the same as the parent of globalResource?

Thanks,
Karen

Received on Wednesday, 29 January 1997 01:02:33 UTC