W3C home > Mailing lists > Public > www-jigsaw@w3.org > September to October 1997

Re: Beta API questions (adding an extension)

From: Mark Friedman <mark@intraspect.com>
Date: Fri, 26 Sep 1997 16:42:22 -0700
Message-ID: <342C485E.10D86B90@intraspect.com>
To: Benoit Mahe <Benoit.Mahe@sophia.inria.fr>, www-jigsaw@w3.org, jigsaw@w3.org, bmahe@www43.inria.fr
Well I ended up figuring it out myself. It may not be optimum but here's
what I came up with to progamatically add extensions. Unfortunately a
couple of potentially useful methods (SampleContainer.getExtensions()
and DirectoryResource.getIndexer()) where "protected" so I had to cut
and paste code from them:

    // Add extension resources

    DirectoryResource dirRes = (DirectoryResource) rootRes;
    ResourceContext context = server.getDefaultContext();
    IndexerModule   module =
      (IndexerModule) context.getModule(IndexerModule.NAME);
    SampleResourceIndexer indexer =
      (SampleResourceIndexer) module.getIndexer(context);
    SampleContainer extensions =

    // Add extension resource for .bat
    try {
      if (extensions.lookup("bat") == null) {
        // We used to use "application/x-msdownload" but
        // "application/octet-stream" seems better
        addExtension ("bat",
                      new MimeType ("application",
    } catch (InvalidResourceException ex) {
      System.out.println ("The extensions resource was invalid");

where addExtension is defined as:

  static void addExtension (String extString,
                            MimeType type,
                            SampleContainer extensions) {
    FileResource ext = new FileResource();
    ext.setValue ("identifier", extString);
    extensions.registerResource(extString, ext, null);
    ext.setValue ("content-type", type);
    System.out.println("Added " + extString +
                       " extension resource to Jigsaw");

Received on Friday, 26 September 1997 19:46:25 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:41:23 UTC