Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Org.eclipse.higgins.idas.udi

Revision as of 13:45, 19 August 2008 by Markus.sabadello.gmail.com (Talk | contribs) (UDIResolver)

{{#eclipseproject:technology.higgins}}

Higgins logo 76Wx100H.jpg

This page describes the component higgins.udi, which implements UDI Resolution in Higgins. See http://www.parity.com/udi for details on UDIs.

A UDI is a string (URI, XRI, Cool URI or anything else) that somehow can be dereferenced to a Context, Entity or Attribute.

Details

  • Javadoc: Javadoc
  • Status: first code in Higgins B-1-1-M3
  • Language: Java
  • Packaging: OSGI bundle

Service

Context UDIs

The following interfaces are provided to support the concept of Context UDIs:

/*
 * A Context UDI is defined to be any string that can be used to obtain Context UDI Metadata.
 */
 
interface IContextUDI {
 
	public IContextUDIMetadata getContextUDIMetadata();
}
 
/*
 * Context UDI Metadata is defined to be everything needed to instantiate an IContext:
 *   - required: one or more Context Types
 *   - optional: a configuration map of the Context
 */
 
interface IContextMetadata {
 
	public String[] getTypes();
	public Map getConfiguration();
}

Entity UDIs

The following interfaces are provided to support the concept of Entity UDIs:

/*
 * An Entity UDI (also called Resource UDI) is defined to be any string that can be used to obtain Entity UDI Metadata.
 */
 
interface IEntityUDI {
 
	public IEntityUDIMetadata getEntityUDIMetadata();
}
 
/*
 * Entity UDI Metadata is defined to be everything needed to instantiate an IEntity:
 *   - required: Context UDI Metadata of the Context the Entity is in
 *   - required: A relative Entity ID which identifies the Entity within its Context
 */
 
interface IEntityUDIMetadata {
 
	public IContextUDIMetadata getContextUDIMetadata();
	public String getEntityID();
}

Attribute UDIs

The following interfaces are provided to support the concept of Attribute UDIs:

/*
 * An Attribute UDI is defined to be any string that can be used to obtain Attribute Metadata.
 */
 
interface IAttributeUDI {
 
	public IAttributeMetadata getAttributeMetadata();
}
 
/*
 * Attribute Metadata is defined to be everything needed to instantiate an IAttribute:
 *   - required: Entity Metadata of the Entity the Attribute belongs to
 *   - required: A relative Attribute ID which identifies the Attribute on its Entity
 */
 
interface IAttributeMetadata {
 
	public IEntityMetadata getEntityMetadata();
	public URI getAttributeID();
}

UDIResolver

The UDIResolver is the most important piece of the idas.udi project. It is a singleton class that you use to parse and resolve UDIs.

It is agnostic of any specific UDI implementation. Instead, it uses a list of IUDIFactorys (see next section) for parsing UDIs.

public class UDIResolver implements IConfigurableComponent {
 
	private static UDIResolver impl = null;
 
	private List udiFactoryList;
 
	public UDIResolver() {
 
		this.udiFactoryList = new ArrayList();
	}
 
	public static synchronized UDIResolver getInstance() {
 
		if (impl == null) impl = new UDIResolver();
		return(impl);
	}
 
	/**
	 * Register the IUDIFactorys from the configuration
	 */
	public void configure(Map mapGlobalSettings, String strComponentName, Map mapComponentSettings) throws Exception { ... }
 
	/**
	 * Parse a string into an IContextUDI by trying all registered IUDIFactorys
	 * until one succeeds.
	 */
	public IContextUDI parseContextUDI(String contextUDIStr) throws IdASException { ... }
 
 
	/**
	 * Parse a string into an IEntityUDI by trying all registered IUDIFactorys
	 * until one succeeds.
	 */
	public IEntityUDI parseEntityUDI(String entityUDIStr) throws IdASException { ... }
 
	/**
	 * Parse a string into an IAttributeUDI by trying all registered IUDIFactorys
	 * until one succeeds.
	 */
	public IAttributeUDI parseAttributeUDI(String attributeUDIStr) throws IdASException { ... }
 
	/**
	 * Resolve an IContextUDI to an IContext by retrieving the IContextUDIMetadata
	 */
	public IContext resolve(IContextUDI contextUDI, Object authentication) throws IdASException { ... }
 
	/**
	 * Resolve an IEntityUDI to an IEntity by retrieving the IEntityUDIMetadata
	 */
	public IEntity resolve(IEntityUDI entityUDI, Object authentication) throws IdASException { ... }
 
	/**
	 * Resolve an IAttributeUDI to an IAttribute by retrieving the IAttributeUDIMetadata
	 */
	public IAttribute resolve(IAttributeUDI attributeUDI, Object authentication) throws IdASException { ... }
}

IUDIFactory

A UDI Factory is one specific implementation of the generic UDI concept. It can parse strings into IContextUDIs, IEntityUDIs and IAttributeUDIs. The UDIResolver singleton class keeps a list of IUDIFactorys. This list can be configured via the Configuration API.

The IUDIFactory interface is simple:

public interface IUDIFactory {
 
	public IContextUDI parseContextUDI(String contextUDI);
	public IEntityUDI parseEntityUDI(String entityUDI);
	public IAttributeUDI parseAttributeUDI(String attributeUDI);
}

At least the following IUDIFactory implementations will come out of the box:

  • XDIUDIFactory: Can parse XRIs into Context UDIs, Entity UDIs and Attribute UDIs.
  • URIUDIFactory: Can parse URIs without fragments into Context UDIs and Entity UDIs.
  • HashURIUDIFactory: Can parse URIs with fragments into Context UDIs and Entity UDIs.
  • ConfUDIFactory: This makes it possible to also use the Context IDs stored in IdASRegistry as Context UDIs.

Because of this configurable IUDIFactory mechanism, the UDI concept is extensible. New kinds of UDIs (pointers to Contexts, Entities and Attributes) can be invented by simply writing another IUDIFactory implementation.

The following is an example configuration XML file for UDIResolver that shows a possible default list of IUDIFactorys:

<Setting Name="UDIResolver" Type="htf:map">
	<Setting Name="UDIFactoryInstancesList" Type="htf:list">
		<Setting Name="XRIUDIFactory" Type="htf:string">XRIUDIFactory</Setting>
		<Setting Name="URIUDIFactory" Type="htf:string">URIUDIFactory</Setting>
		<Setting Name="HashURIUDIFactory" Type="htf:string">HashURIUDIFactory</Setting>
		<Setting Name="ConfUDIFactory" Type="htf:string">ConfUDIFactory</Setting>
	</Setting>
</Setting>
 
		<Setting Name="XRIUDIFactory" Type="htf:classinstance">org.eclipse.higgins.idas.udi.impl.xri.XRIUDIFactory</Setting>
		<Setting Name="URIUDIFactory" Type="htf:classinstance">org.eclipse.higgins.idas.udi.impl.uri.URIUDIFactory</Setting>
		<Setting Name="HashURIUDIFactory" Type="htf:classinstance">org.eclipse.higgins.idas.udi.impl.hashuri.HashURIUDIFactory</Setting>
		<Setting Name="ConfUDIFactory" Type="htf:classinstance">org.eclipse.higgins.idas.udi.impl.conf.ConfUDIFactory</Setting>
 
		<Setting Name="UDIResolver" Type="htf:classsingleton">org.eclipse.higgins.idas.udi.UDIResolver</Setting>

Example usage

Here is some example code that contains two examples of how you can start with an Entity UDI and end up with a fully instantiated IEntity:

import org.eclipse.higgins.configuration.xml.ConfigurationHandler;
import org.eclipse.higgins.idas.api.IEntity;
import org.eclipse.higgins.idas.udi.IEntityUDI;
import org.eclipse.higgins.idas.udi.UDIResolver;
 
ConfigurationHandler handler = new ConfigurationHandler();
 
handler.setConfigurationBase(".");
handler.setFileName("test.xml");
handler.configure(null);
 
UDIResolver resolver = (UDIResolver) handler.getSettings().get("UDIResolver");
 
// Example 1: Entity UDI in XRI form
 
IEntityUDI entityUDI1 = resolver.parseEntityUDI("@parity*contexts/(+ldap)//=(uid=saba,dc=parityinc,dc=net)");
Object authnMaterials1 = /* ... */;
 
IEntity entity1 = resolver.resolve(entityUDI1, authnMaterials1);
 
// Example 2: Entity UDI in URI form (Linked Data "303" Cool URI):
 
IEntityUDI entityUDI2 = resolver.parseEntityUDI("http://www.acme.com/id/alice");
Object authnMaterials2 = /* ... */;
 
IEntity entity2 = resolver.resolve(entityUDI2, authnMaterials2);

The only difference between Example 1 and Example 2 is that a different IUDIFactory implementation is used internally by the UDIResolver.

Q&A

  • Why are there separate IxxxUDI and IxxxUDIMetadata interfaces? Why isn't it enough to have IxxxUDI?

The IxxxUDI interface represents the UDI itself. The IxxxUDIMetadata interface provides all the information needed to instantiate the object the UDI points to. The reason why the two interfaces are separate is that an Entity UDI (IEntityUDI) does NOT necessarily have to contain within itself a Context UDI, but it DOES have to provide Context UDI Metadata for the Context the Entity is in. Similarly, an Attribute UDI (IAttributeUDI) does NOT necessarily have to contain within itself an Entity UDI, but it DOES have to provide Entity UDI Metadata for the Entity the Attribute belongs to.

The current idea is that Context IDs from the Configuration API are considered one flavor of Context UDIs, i.e. you are able to parse and resolve them with the UDIResolver class. However, the idas.udi project is not required, if all you need is read/write Context IDs in your configuration file.

Implications on existing components and concepts

Context Types

The concept of Context Types is not changed by the introduction of UDIs. Context Types are still used to look up Context Factories from the IdASRegistry.

See Also

Back to the top