⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jndi-dsml.html

📁 J[2]EE JavaJNDI examples
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<HTML><HEAD><title>JNDI/DSML v1 Service Provider</title></HEAD><BODY BGCOLOR="#FFFFFF" TEXT=#000000 LINK=#0000ff VLINK=#000077ALINK=#ff0000><hr SIZE=3 NOSHADE WIDTH="100%"><center><h1>DSML v1 Service Provider for the <br>Java Naming Directory Interface<font size=4><sup>TM</sup></font> (JNDI)</h1></center><hr SIZE=3 NOSHADE WIDTH="100%"><P><FONT SIZE=-1>Please send feedback to<a href="mailto:jndi@java.sun.com">jndi@java.sun.com</a></FONT><P><P><I>Table of Contents</I><UL><LI><A HREF="#INTRO">Introduction</A></LI><LI> <A HREF="#CONF">Conformance</A></LI><LI><A HREF="#PROP">Environment Properties</A></LI><LI><A HREF="#TYPE">Mapping DSML v1 Content to JNDI</A></LI><LI><A HREF="#API">API Mapping</A></LI><LI><A HREF="#CONFIG">LDAP URL Handler</A></LI><li><A HREF="#FED">Federation</A></LI></UL><P><HR><P> <A NAME="INTRO"><H2>Introduction</H2><p>DSML is Directory Services Markup Language. It is a markup languagefor representing directory data. See <a href=http://www.dsml.org>http://www.dsml.org</a> for details.<p>The DSML v1 service provider implements the <tt>DirContext</tt> interfacefor accessing DSML 1.0 documents.The provider presents the DSML v1 data as JNDI <tt>DirContext</tt> and<tt>Attribute</tt> objects. You can make updates to these objectsand then re-export them in DSML v1 format (see discussion later in this document).<p>This document describes the features of the DSML v1 service providerand contains details of how JNDI is mapped to the DSML v1.<hr><p><A NAME="CONF"><H2>Conformance</H2><p>The DSML v1 service provider supports Version 1.0 of the <a href=http://www.dsml.org>DSML</a>.<hr><p><A NAME="PROP"><H2>Environment Properties</H2><p>The following JNDI environment properties are relevant for the DSML v1service provider. See the <a href=http://java.sun.com//products/jndi/1.2/javadoc/javax/naming/InitialContext.html#ENVIRONMENT>JNDI documentation</a>for a description of how properties are initialized by using the environment properties, system properties, applet parameters, and resource files.<p><b><pre>java.naming.factory.initial</pre></b><blockquote>    This environment property is used to select the DSML v1 provider;    it is not actually used by the provider itself. It specifies the    class name of the initial context factory for the provider.    This environment property must be set as follows if you are using     the DSML v1 provider.<blockquote><pre>env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dsml.DsmlCtxFactory");</pre></blockquote><p></blockquote><b><pre>java.naming.provider.url</b></pre><blockquote>    Specifies the URL that contains the DSML v1 document. For example, this could    be a "file", "http", or "ldap" URL. The document's content type must    be "text/xml" or "application/xml".    For example, this setting<blockquote><pre>env.put(Context.PROVIDER_URL, "file:/tmp/group.xml");</pre></blockquote>    will cause the provider to process the DSML v1 document found in    the file <tt>/tmp/group.xml</tt>. See the    <a href=#CONFIG>LDAP URL Handler</a> section for details on    configuration with respect to schema data.<p>    This property must be set for the DSML v1 provider to work.</blockquote><b><pre>java.naming.factory.object</pre></b><blockquote>    A colon-separated list of the fully qualified class names    of object factory classes for transforming objects read from the DSML v1    document. You can use this mechanism to transform an object into forms expected    by the application. See<a href="http://java.sun.com/products/jndi/1.2/javadoc/javax/naming/spi/DirectoryManager.html#getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable, javax.naming.directory.Attributes)"><tt>javax.naming.spi.DirectoryManager.getObjectInstance()</tt></a> for details.</blockquote><b><pre>com.sun.jndi.dsml.ignoreContentType</pre></b><blockquote>    If the value is the string "true", the DSML v1 provider will ignore    the content type of the document. Otherwise, the content type    of the document must be "text/xml" or "application/xml". This is     a workaround for Java runtime configurations that do not    return the correct content type for "file" or "http" URLs.</blockquote><hr><p><A NAME="TYPE"><H2>Mapping DSML v1 Content to JNDI</H2>The DSML v1 provider converts DSML v1 data into JNDI objects as follows.<h4>Directory Data</h4>Elements from<tt>dsml:directory-entries</tt> are used to create a <tt>DirContext</tt>tree. The tree is constructed by using the distinguished names of the entries(i.e., the <tt>dn</tt> attribute of the <tt>dsml:entry</tt> element).Consequently, some <tt>DirContext</tt> near the root might not have any attributes.<p>To name a node in the directory tree, you use its distinguished name.<h4>Schema Data</h4>Elements from<tt>dsml:directory-schema</tt> are used to create a schema tree.The directory tree will use this schema tree to satisfy the following schema operations.<tt><ul><li>DirContext.getSchema(Name name);<li>DirContext.getSchemaClassDefinition(Name name);<li>Attribute.getAttributeDefinition();</ul></tt><tt>Attribute.getAttributeSyntaxDefinition()</tt> is not supportedbecause the DSML v1 does not define syntax schema data.<p>Relative URIs named in the <tt>superior</tt> attribute of the<tt>dsml:class</tt> and <tt>dsml:attribute-type</tt> elementsare resolved by using schema definitions found in the same document.Nonrelative URIs and unresolved URIs are left unchanged.<p>If no <tt>dsml:directory-schema</tt> is available, the attributeand object class trees will be empty.See the <a href=#CONFIG>LDAP URL Handler</a> sectionfor details on configuration with respect to schema data.<h4>Updating Directory and Schema Data</h4>The DSML v1 provider is a read-only provider; it cannot be usedto update the source of the DSML v1 document. It can, however,be used to update the in-memory copy of thedirectory and schema data constructed from theDSML v1 document. You can update the in-memory data by using the<tt>Context</tt>/<tt>DirContext</tt> methods.Again, such updates do <em>not</em> affect the source of the DSML v1 document.For example, if the <tt>DirContext</tt> was constructedfrom a DSML v1 document read from a file, updates to the <tt>DirContext</tt>affect only the in-memory data, not the file.Similarly, if the <tt>DirContext</tt> was constructedfrom input from an LDAP directory, updates to the <tt>DirContext</tt>will not update the contents of the LDAP directory.<p><h4>Generating DSML v1 formatted Directory and Schema Data</h4>The in-memory directory and schema data constructedfrom DSML v1 document can be displayedin DSML v1 format by using the <tt>toString()</tt> method onthe appropriate objects. Here are some examples.<p>The following code fragment returns the string representation ofthe entire directory tree in DSML v1 format.<blockquote><pre>new InitialDirContext(env).lookup("").toString();</pre></blockquote><p>The following code fragment returns the string representation ofthe subtree rooted at <tt>"o=jnditutorial"</tt> in DSML v1 format.<blockquote><pre>ctx.lookup("o=jnditutorial").toString();</pre></blockquote><p>The following code fragment returns the string representation of theentire schema tree in DSML v1 format.<blockquote><pre>(DirContext schema = ctx.getSchema("")).toString();</pre></blockquote><p>The following code fragment returns the string representation of allof the attribute definitions in the schema tree in DSML v1 format.<blockquote><pre>schema.lookup("AttributeDefinition").toString();</pre></blockquote><p>The following code fragment returns the string representation of allof the object class definitions in the schema tree in DSML v1 format.<blockquote><pre>schema.lookup("ClassDefinition").toString();</pre></blockquote><p>The following code fragment returns the string representation of allof the object class definitions of an object in DSML v1 format.<blockquote><pre>ctx.getSchemaClassDefinition("cn=Ted,o=jnditutorial").toString();</pre></blockquote><p>The following code fragment returns the string representation of theobject class definition for the "Person" object class in DSML v1 format.<blockquote><pre>schema.lookup("ClassDefinition/Person").toString();</pre></blockquote><p>The following code fragment returns the string representation of theattribute definition for the "mail" attribute in DSML v1 format.<blockquote><pre>Attributes attrs = ctx.getAttributes("cn=Ted,o=jnditutorial");Attribute attr = attrs.get("mail");attr.getAttributeDefinition().toString();</pre></blockquote><hr><p><A NAME="API"><H2>API Mapping</H2><p><b><pre>addToEnvironment()</pre></b><blockquote>    Environment properties can be added or changed via this method    but such changes do not affect the current context.    </blockquote><b><pre>bind()</pre></b>    <blockquote>    Operation not supported. Use <tt>createSubcontext()</tt> to create

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -