The Artima Developer Community
Sponsored Link

The Cyberspace Project
Proposal for URLName Entry
Bill Venners

Advertisement

Summary
This document proposes an entry named URLName that would give meaning to a fourth component of a jini: URL.


Current jini: URLs

The jini: URL as currently defined identifies a Jini lookup service. The host name or IP address specifies the host on which the lookup service is running, such as:

jini://www.artima.com
or
jini://123.45.678.9
If no port number is given, as shown in the previous examples, the default port number for Jini services, 4160, is implied. (4160 is 0xCAFE - 0xBABE by the way. If you don't know the significance of 0xCAFEBABE, Why CAFEBABE? might help.) As with all URLs, if you need to address a lookup service at a different port besides the default, you can specify the port explicitly, as in:
jini://www.artima.com:2000
or
jini://123.45.678.9:2001

A Fourth Component

Although URLs often have a fourth component after the protocol, host, and port number, jini: no fourth component is currently defined for jini: URLs. I'd like to propose that we (the Jini Community) define that fourth component to mean a Jini service that is registered within the Jini lookup service identified by the host and port number of the URL.

To locate a service referenced by a jini: URL with a fourth component, the Jini client that is handed the URL first checks to see if it already has a ServiceRegistrar for the lookup service identified by the host and port number specified in the URL. If not, the client attempts to perform Unicast Discovery on that lookup service. If successful, the Jini client instantiates a net.artima.jini.entry.URLName entry (shown later in this document), passing to the URLName constructor the fourth component of the jini: URL. The client places this URLName in the attributeSetTemplates field of a ServiceTemplate, and makes a lookup() query. If no service matches the query, then the service identified by the URL is not available. If more than one service matches the query, one matching service is selected at random. If one or more services match the query, the one selected service is the service identified by the URL.

The administrators of each Jini lookup server that contains services registered with URLName entries are responsible for maintaining the uniqueness of each name within each lookup server. The names need not be unique globally, as are service IDs. URLNames should only be unique within each individual lookup service. A single service may be registered in a lookup service with multiple URLNames, but each particular URLName should be associated with only one service in a particular lookup service.

This approach would give meaning to such URLs as:

jini://www.artima.com/cal9000
or
jini://123.45.678.9:2001/IlludiumQ36ExplosiveSpaceModulator

Class URLName

Here is the URLName class:

package net.artima.jini.entry;

import net.jini.entry.AbstractEntry;

/*
 * This source code (.java) file is Copyright (C) 2000 Bill Venners. All rights reserved.
*/
public class URLName extends AbstractEntry {

    public static class RestrictedString implements java.io.Serializable {

        private String name;

        public RestrictedString(String name) {

            if (name == null) {
                throw new NullPointerException();
            }

            for (int i = 0; i < name.length(); ++i) {

                if (name.charAt(i) > 0xff) {
                    throw new IllegalArgumentException();
                }
            }

            this.name = name;
        }

        public String getName() {
            return name;
        }
    }

    public RestrictedString name;

    /**
     * Constructs a URLName with name field set to null.
    */
    public URLName() {
    }

    /**
     * Constructs a URLName with the name field set to passed value.
    */
    public URLName(RestrictedString name) {

        this.name = name;
    }
}

Note: The reason I created RestrictedString is because my best guess is that URLs are either ASCII or perhaps ANSI strings. As they aren't Unicode, I didn't want clients of URLName to create a Unicode name string that won't work in a URL. Trouble is, I couldn't find any real specification of what's legal in a URL. (The documents at w3c all seem to be from 1996 and earlier, and quite disorganized.) So I guessed and just enforced all strings to be made up of characters that are 0xFF or less. If someone can point me to a definition of which characters are actually allowed in URL strings, and a list of the meanings of certain characters such as '#' and '?', I'd be obliged.

ServiceUI is a trademark of Artima Software, Inc.

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use