W3C home > Mailing lists > Public > www-jigsaw@w3.org > January to February 1997

Global Information Store between resources

From: Anselm Baird_Smith <abaird@www43.inria.fr>
Date: Thu, 23 Jan 1997 19:10:52 +0100 (MET)
Message-Id: <199701231810.TAA21589@www43.inria.fr>
To: karenkay@sholink.com (Karen Cheng)
Cc: www-jigsaw@www10.w3.org
Karen Cheng writes:
 > >  And the in your resources, use:
 > >
 > >  Resource r = SharedContext.getSomeResource();
 > >  r.getValue("some-attribute");
 > > 
 > >  Anselm.
 > 
 > Hi,
 > 
 > Could you please give an example of how one can restore the resource
 > out of its store in the getSomeResource() method above?   That is,
 > could you please fill in the code in the method?

It really depends on a number of things. The simplest way is to assume
that th resource is in the same resource store as the calling
resource. In this case:

public class MyResource ... {

    public Resource getSomeResource(String name) {
        // Get the container resource:
        Resource parent = getParent();
        // Lookup the shared context resource within that container:
        if ( ! ( resource instanceof COntainerResource) )
            throw new Exception();
        return parent.lookup(name);
    }
}

Then, before using MyResource you should make sure to create the
shared context resource in the store (ie either when initializing
MyResource, or by using the /Admin/Editor)

Anselm.
Received on Thursday, 23 January 1997 13:11:20 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:25 GMT