OSID 2.0 Design Patterns
More Fun With Registries
Tom Coppeto
OnTapSolutions
28 April 2005

The OsidTypeRegistry probably seems like a lot of work to do for something I normally try to avoid. So, I apply it to other problems.

The OsidContext and Properties also have the problem of falling outside the Specification when their consistent use is an essential ingredient for interoperability. I have proposed the use of an identification scheme for each in Identifying Properties and Osid Context to provide the means in which agreements can be forged. Similar benefits of managing these definitions can be realized through the use of a Registry.

OsidContextRegistry

The OsidContextRegistry, like its Type oriented cousin, is a HashMap of ContextElements. Each ContextElement houses an identifier to be used as a key into the OsidContext along with a display name and description.


    public abstract class OsidContextRegistry
        implements java.io.Serializable {

        private static java.util.HashMap elements = new java.util.HashMap();

        protected OsidContextRegistry();

        public static String getDisplayNameForContextElement(String id);

        public static String getDescriptionForContextElement(String id);

        protected synchronized static void loadContextInfo(String authority, String file);
}

Listing 1: the methods of OsidContextRegistry

Sets of context elements can be registered by subclassing OsidContextRegistry that specifies the data file and handy constants that can be used to manage the identifiers.


    public class OsidContextOIDRegistry
        extends OsidContextRegistry {

        static String DOMAIN      = "OID";
        static String AUTHORITY   = "org.osid";
        static String FILE        = "OsidContextOID.dat";
    
        public static String PRINCIPAL_AUTHENTICATION_CONTEXT = "oid/1.3.6.1.4.122316.1.1.3.3.1.0@osid.org";
    
        public static String PASSWORD_AUTHENTICATION_CONTEXT  = "oid/1.3.6.1.4.122316.1.1.3.3.2.0@osid.org";

    static {
            loadContextInfo(AUTHORITY, FILE);
        }
    }

Listing 2: an OsidContext registry module

    oid/1.3.6.1.4.1.22316.1.1.3.3.1.0@osid.org:principal:The name of the prinicpal or username identified in this authentication implementation.
    oid/1.3.6.1.4.1.22316.1.1.3.3.2.0@osid.org:password:The password used in a username/password scheme of authentication.

Listing 3: the corresponding data file
OsidPropertyRegistry

The same mechanism can be used to register Properties. Once again, a container class, Property, will be used to house the Property definition to include a richer set of display information such as a name, label, description and designation.


    public abstract class OsidPropertyRegistry
        implements java.io.Serializable {

        private static java.util.HashMap properties = new java.util.HashMap();


        protected OsidPropertyRegistry();

        public static String getNameForPropertye(String id);

        public static String getLabelForProperty(String id);

        public static String getDescriptionForProperty(String id);

        public static String getDesignationForProperty(String id);

        protected synchronized static void loadPropertyInfo(String authority, String file);
}

Code Listings