Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: for the plan.

Jump to: navigation, search

Context Discovery Components Without XRDS

Revision as of 12:12, 26 March 2008 by (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)



This page outlines an alternative way to perform two core services of the IdASRegistry, which are "normally" handled using XRDS documents (as described in Context Discovery Components)

On this page, "normal" means the XRDS way, whereas "alternative" means the Configuration API way, as described on this page. (Markus: Sorry for calling the XRDS way the "normal" one, it helps me write this page :) ).

These two services are:

  1. Configuration and registration of context factories
  2. Configuration of contexts

This is now possible without requiring XRDS documents. The way of doing this is to use the Configuration API. This means that IdASRegistry is now an IConfigurableComponent. The map passed to its configure() method contains the information that is "normally" found in XRDS documents, i.e. 1) a list of context factories (+ configuration) and 2) context ids (+configuration).

Configuration and registration of context factories

As described in Context Discovery Components, this "normally" happens by looking into an XRDS document (by default a local file called "contextfactories.xrds").

The alternative way is that this is also possible by including a list of context factories (and their context types) in the map passed to IdASRegistry's configure() method.

Both ways can be combined. The IdASRegistry will then "know" all context factories from the XRDS document, and all context factories obtained through the Configuration API.

There is also a "manual" way to register context factories: The registerContextFactory() methods.

Configuration of contexts

Configuring and instantiating contexts involves a context ID.

A context ID somehow can be used to obtain one or more context types, and context configuration. The context type is used to find a suitable context factory. In the "normal" way, a context ID can be an XRI, URI or a local XRDS document. From that document the necessary information is read.

The alternative way is that the map passed to IdASRegistry's configure() method contains a list (called "ContextIdsList" in the example). Each entry in the list contains a context ID, plus the usual information (context types and context configuration). These context IDs can then be used just like the "normal" XRDS-based ones, e.g. in the IdASRegistry.createContext(contextID) method.

Like before, both ways can be combined. The IdASRegistry will be able to "resolve" context IDs from the "normal" way (i.e. XRIs, URIs, and local XRDS documents), but it will also "know" the context IDs obtained through the Configuration API.


This is a sample configuration file that contains configuration for both context factories and contexts.

(Thanks to Jim, Mike, Daniel for writing the example, this helps a lot)

<Configuration xmlns:xsd=""

	<!--  The setting handlers are classes that consume Setting elements where the Type matches and generate an object of the Class -->
		<SettingHandler Type="xsd:integer" Class="java.lang.Integer" Handler="org.eclipse.higgins.configuration.xml.IntegerHandler" />
		<SettingHandler Type="xsd:string" Class="java.lang.String" Handler="org.eclipse.higgins.configuration.xml.StringHandler" />
		<SettingHandler Type="htf:uri" Class="" Handler="org.eclipse.higgins.configuration.xml.URIHandler" />
		<SettingHandler Type="htf:list" Class="java.util.List" Handler="org.eclipse.higgins.configuration.xml.ListHandler" />
		<SettingHandler Type="htf:map" Class="java.util.Map" Handler="org.eclipse.higgins.configuration.xml.MapHandler" />
		<SettingHandler Type="htf:instance" Class="Object" Handler="org.eclipse.higgins.configuration.xml.ClassInstanceHandler" />
		<SettingHandler Type="htf:singleton" Class="Object" Handler="org.eclipse.higgins.configuration.xml.SingletonHandler" />
		<SettingHandler Type="xsd:boolean" Class="java.lang.Boolean" Handler="org.eclipse.higgins.configuration.xml.BooleanHandler"/>
		<SettingHandler Type="htf:file" Class="" Handler="org.eclipse.higgins.configuration.xml.FileHandler"/>
		<SettingHandler Type="htf:keystore" Class="" Handler="org.eclipse.higgins.configuration.xml.KeyStoreHandler"/>

	<Setting Name="Configuration" Type="htf:map">

		<Setting Name="ComponentSettings" Type="htf:map">
			<Setting Name="TestContextFactory1" Type="htf:map">
				<Setting Name="value" Type="xsd:integer">10</Setting>
				<Setting Name="policy" Type="xsd:string">Hello World</Setting>
			<Setting Name="TestContextFactory2" Type="htf:map">
				<Setting Name="value" Type="xsd:integer">20</Setting>
				<Setting Name="policy" Type="xsd:string">Good Bye World</Setting>
			<Setting Name="TestContextFactory3" Type="htf:map">
				<Setting Name="value" Type="xsd:integer">30</Setting>
				<Setting Name="policy" Type="xsd:string">Hey World</Setting>
			<Setting Name="IdASRegistry" Type="htf:map">
				<Setting Name="ContextFactoryInstancesList" Type="htf:list">
					<Setting Name="ContextFactory1" Type="htf:map">
						<Setting Name="Instance" Type="xsd:string">TestContextFactory1</Setting>
						<Setting Name="ContextTypes" Type="htf:list">
							<Setting Name="ContextType1" Type="xsd:string">$context+ldap</Setting>
							<Setting Name="ContextType2" Type="xsd:string">$context+openid</Setting>
					<Setting Name="ContextFactory2" Type="htf:map">
						<Setting Name="Instance" Type="xsd:string">TestContextFactory2</Setting>
						<Setting Name="ContextTypes" Type="htf:list">
							<Setting Name="ContextType1" Type="xsd:string">$context+openid</Setting>
					<Setting Name="ContextFactory3" Type="htf:map">
						<Setting Name="Instance" Type="xsd:string">TestContextFactory3</Setting>
						<Setting Name="ContextTypes" Type="htf:list">
							<Setting Name="ContextType1" Type="xsd:string">$context+jdbc</Setting>
				<Setting Name="ContextIdsList" Type="htf:list">
					<Setting Name="ContextId1" Type="htf:map">
						<Setting Name="ContextId" Type="xsd:string">Jim's Context</Setting>
						<Setting Name="ContextTypes" Type="htf:list">
							<Setting Name="ContextType1" Type="xsd:string">$context+jndi</Setting>
						<Setting Name="ContextUris" Type="htf:list">
							<Setting Name="ContextUri1" Type="htf:uri"></Setting>
						<Setting Name="Connection" Type="htf:map">
							<Setting Name="ConnectionType" Type="xsd:string">LDAP</Setting>
							<Setting Name="AddressList" Type="htf:list">
								<Setting Name="Address" Type="xsd:string">ldap://</Setting>
							<Setting Name="jndiProvider" Type="xsd:string">com.sun.jndi.ldap.LdapCtxFactory</Setting>
							<Setting Name="searchBase" Type="xsd:string">ou=people,dc=wag,dc=bandit-project,dc=org</Setting>
						<Setting Name="env" Type="htf:map">
							<Setting Name="" Type="xsd:string">simple</Setting>
							<Setting Name="" Type="xsd:string">cn=admin,o=novell</Setting>
							<Setting Name="" Type="xsd:string">novelled8</Setting>
							<Setting Name="org.eclipse.higgins.idas.cp.jndi.startTLS" Type="xsd:string">true</Setting>
							<Setting Name="org.eclipse.higgins.idas.cp.jndi.trustStore" Type="xsd:string">JNDICPTest.keystore</Setting>
							<Setting Name="java.naming.ldap.attributes.binary" Type="xsd:string">guid</Setting>
					<Setting Name="ContextId2" Type="htf:map">
						<Setting Name="ContextId" Type="xsd:string">Mike's Context</Setting>
						<Setting Name="ContextTypes" Type="htf:list">
							<Setting Name="ContextType1" Type="xsd:string">$context+jdbc</Setting>
						<Setting Name="username" Type="xsd:string">dbuser</Setting>
						<Setting Name="password" Type="xsd:string">dbpass</Setting>
		<Setting Name="TestContextFactory1" Type="htf:instance">org.eclipse.higgins.idas.registry.test.TestContextFactory1</Setting>
		<Setting Name="TestContextFactory2" Type="htf:instance">org.eclipse.higgins.idas.registry.test.TestContextFactory2</Setting>
		<Setting Name="TestContextFactory3" Type="htf:instance">org.eclipse.higgins.idas.registry.test.TestContextFactory3</Setting>
		<Setting Name="IdASRegistry" Type="htf:singleton">org.eclipse.higgins.idas.registry.IdASRegistry</Setting>



Example code

The following code could be used to obtain the IdASRegistry instance and instantiate a context. The context configuration, the context factory configuration, and the context type that links them all are configured by the file above.

	// use the Configuration API to configure the IdASRegistry
	ConfigurationHandler handler = new ConfigurationHandler();
	registry = (IdASRegistry) handler.getSettings().get("IdASRegistry");

	// obtain a context from a context id (long way)

	IContextId contextId = ContextIdFactory.fromString("Mike's Context");
	IContextFactory factory = registry.getContextFactory(contextId);
	IContext context = factory.createContext(contextId);

	// obtain a context from a context id (short way)

	IContext context2 = registry.createContext("Jim's Context");

Back to the top