The Carbon Java Framework  

The Carbon JNDI-based Config Module

Config-JNDI Service Usage

Author: Douglas Voet (dvoet at sapient.com)
Version: $Revision: 1.4 $($Author: araman $ / $Date: 2003/05/05 07:42:45 $)
Created: March 2003

Overview

This service is not used directly by client code. Once configured, it plugs into Carbon's configuration subsystem and used behind the scenes. The purpose of this document is to describe the configuration.

Configuration

In order to access configurations stored in a JNDI directory, a link to the directory must be created in the configuration hierachy. The link configuration needs to be of type org.sape.carbon.services.config.jndi.JNDILinkNodeConfiguration. Within a JNDILinkNodeConfiguration, there are 5 configuration properties that are used in most cases. The following table describes them.

Property Name Description Required (Y/N)
InitialContextFactory The fully qualified class name of the initial context factory used to create the initial context. E.g. com.sun.jndi.ldap.LdapCtxFactory Y
ProviderUrl The URL of the server hosting the directory. E.g. ldap://localhost:389. Other JNDI application may combine this with the next property, TargetContectName, but this should not be done here. Y
TargetContextName The name of the context that is the root of the configuration hierachy within the directory. E.g. name=configRoot,dc=example,dc=org Y
SecurityPrincipal The principal name used to authenticate into the directory server. E.g. cn=Manager,dc=example,dc=org N
SecurityCredentials The credential to be used to authenticate into the directory server. E.g. password N

If the JNDI and/or directory provider requires other properties, they can be passed in via the EnvironmentProperties Map.

Example of a JNDI Link Configuration

<Configuration
  ConfigurationInterface="org.sape.carbon.services.config.jndi.JNDILinkNodeConfiguration">

  <LinkNodeFactoryClass>org.sape.carbon.services.config.jndi.JNDILinkNodeFactory</LinkNodeFactoryClass>
  <InitialContextFactory>com.sun.jndi.ldap.LdapCtxFactory</InitialContextFactory>
  <ProviderUrl>ldap://localhost:389</ProviderUrl>
  <TargetContextName>name=configRoot,dc=example,dc=org</TargetContextName>
  <SecurityPrincipal>cn=Manager,dc=example,dc=org</SecurityPrincipal>
  <SecurityCredentials>password</SecurityCredentials>

  <!--not normally used, but provided as an example of the EnvironmentProperties Map-->
  <EnvironmentPropertiesMap>
    <EnvironmentProperties key="java.naming.security.protocol">ssl</EnvironmentProperties>
  </EnvironmentPropertiesMap>

</Configuration>
            

If the above example were stored in a file called "foo.link" in the root configuration directory, configurations in the JNDI directory could be accessed by calling Config.getInstance().fetchConfiguration("/foo/...").

Advanced Configuration

If the default JNDI attribute names will not work in your situation, read on, otherwise, skip this section.

The names and values of the attributes that are used by this service are configurable. Below are the configuration properties that should be set within the link configuration in order to change the names and values from their defaults. Please see the Design section for information about where these are used.

Property Name Description Default
NodeTypeAttributeName The name of the attribute that determines if a context is a Folder or a ConfigurationDocument. objectClass
FolderNodeTypeAttributeValue The value of the attribute named by NodeTypeAttributeName that specifies that a context is a Folder. configFolder
DocumentNodeTypeAttributeValue The value of the attribute named by NodeTypeAttributeName that specifies that a context is a ConfigurationDocument. configDoc
DocumentTypeAttributeName The name of the attribute that determines if a ConfigurationDocument context is a document or a link. type
LinkDocumentTypeAttributeValue The value of the attribute named by LinkDocumentTypeAttributeValue that specifies that a ConfigurationDocument context is a link. link
DocumentDocumentTypeAttributeValue The value of the attribute named by LinkDocumentTypeAttributeValue that specifies that a ConfigurationDocument context is a document. doc
DocumentContectAttributeName The name of the attribute that store the content in a ConfigurationDocument context. content
NodeNameAttributeName The name of the attribute that store the name of a Node. name
AttributeNameValueSeparator The String that the directory uses to separate attributes and their values when they are represented as Strings. =

Best Practices

In a typical example usage of this service, multiple application serviers would use a single directory server to store configuration. The problem then arrises that each individual application server requires some configuration that is specific to itself (e.g. file paths, Deployment Service's CurrentDeployment link). This information cannot go into a communal configuration store. For this reason, the entirety of the configuration hierachy should never come from the JNDI directory. The root of the configuration system should always reside on a store specific to each application server (e.g. file system). A link to the JNDI directory can then be placed in the root. Also never place configurations directly in the root. A simple example would have the root of configuration contain two Folders, one for application server specific configuration and another for communal configuration.


Copyright © 2001-2003, Sapient Corporation