# Resource configuration

In this section, the new resource model of Jigsaw 2.0 will be presented, along with a tutorial on how to create and edit a resource in Jigsaw.

## What is a resource?

A resource is the basic object served by Jigsaw. It encapsulate a "real" object like a file (text, image or whatever) or a generated content (by a cgi-script or a servlet). This object is accessible within the server according to its URL. To be able to serve this object, Jigsaw needs to know a protocol that can serve this object. All the informations about the resource are stored in "Frames". Those frames may be of different kinds: protocol frames, describing the way to serve this resource for a specific protocol (ex: `HTTPFrame`), or describing the resource itself (ex: a metada frame encoded in RDF). The combination of an HTTPFrame and a basic resource corresponds to the HTTPResource of the Jigsaw 1.0.

## Description of a resource

Basically, there are not many things in the resource itself as all the information is stored in the frames. There are two kinds of resource, the containers and the leafs. A basic resource will only have the identifier and last-modified attributes. A container will have also an indexer attribute to select the indexer used to index this the resources contained. There are extra attributes for:

`org.w3c.jigsaw.resources.DirectoryResource`
  `extensible`
    If true, new resources can be created by the indexer.
  `negotiable`
    If true, Content-Negotiation is activated, it means that an image named "foo" will match foo.png or foo.gif depending on the browser's preferences.
`org.w3c.tools.resources.FileResource`
  `filename`
    If set, gives the relative name of the real resource (default file name is the identifier).

## Configuration of a resource

To configure a resource, you have to add frames and edit the attributes of this resource. If the resource is a container, you can also add resources to it.

### Frames

Using JigAdmin, click on the resource in the tree, on the right part of the window, you will have some buttons (usually, two if the resource is a leaf, three if it is a container) located at the top. These button are used to select the helpers. To edit the frames, click on "frames" and the corresponding helper will appear below the button bar.

At the bottom of the window, a new tree browser will appear, containing the resource. if you open it, you will see all the frames attached to it. To add a new frame to the resource, click on the resource (highlight in a pinkish color) then click on "back to add frame menu", or, if you did not open the little tree, add directly the frame by selecting (or typing) the frame class.

To edit the attributes of a frame, just click on the frame, its own attribute helper will show up in the top part of the window.

A filter is now a frame of a protocol frame. If you want to add a CounterFilter to a HTTPFrame:

1. Click on the resource
2. select the frames helper
3. open the resource in the little tree
4. click on the HTTPFrame to edit it
5. click on "back to add frame menu"
6. select `org.w3c.jigsaw.filters.CounterFilter`
7. click on Add Frame

Now you can click on the new filter added and edit its attributes.

### Attributes

Using JigAdmin, click on the resource in the tree, then select the Attributes helper. You will then have, in the attributes helper, the descrition of attributes on the left hand size, and the editable fields on the right hand side. To understand the meaning of the attributes names for each resource, see the reference documentation. For example, the meaning of the "negotiable" attribute of `org.w3c.jigsaw.resources.DirectoryResource` is:

`negotiable`

semantics
  Should the directory resource automatically create resource with NegotiatedFrame? When this flag is turned to true, the directory resource will automatically create negotiable frames on top of normal resources: each time a new resource is added to the directory, the resource looks up for a resource having the new child name, but possibly different extensions. If this succeeds, either the found resource is already a negotiated resource, in which case the new child is added as one of its variant resource; otherwise (the negotiated resource doesn't exist), the directory resource creates it with only one variant (the new child resource).
type
  This attribute is an editable BooleanAttribute
default value
  This attribute defaults to false.

There is also a specific tutorial on the edition of the attributes.

Jigsaw Team

$Id: resource.html,v 1.10 1998/04/02 09:31:36 yves Exp $