You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ps...@apache.org on 2004/02/07 21:01:33 UTC

svn commit: rev 6562 - incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming

Author: psteitz
Date: Sat Feb  7 12:01:33 2004
New Revision: 6562

Added:
   incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/building.xml
   incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/using.xml
Modified:
   incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/index.xml
   incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/navigation.xml
Log:
Added naming xdocs

Added: incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/building.xml
==============================================================================
--- (empty file)
+++ incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/building.xml	Sat Feb  7 12:01:33 2004
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<document>
+ <properties>
+  <title>Building Naming</title>
+ </properties>
+
+ <body>
+
+ <section name="Maven targets">
+   <p>
+     Naming consists of two subprojects: core and factory.  These can be built separately
+     by executing maven build targets from the /core or /factory directories. All subprojects can be
+     built using the following targets, executed from the top level directory/naming directory:
+     <ul>
+        <li>multiproject:clean -- cleans all subprojects</li>
+        <li>multiproject:install -- builds, tests and jars all subprojects</li>
+        <li>multiproject:site -- generates an integrated site including all subprojects</li>
+        <li>clean -- cleans top level project</li>
+     </ul>
+   </p>
+    
+ </section>
+ <section name="Dependencies">
+   <p>
+     The dependencies common to both subprojects are the ones that appear in the top level 
+     project.xml, viz.:
+     <ul>
+        <li>Common Collections 2.1</li>
+        <li>mx4j+jmx 1.1.1</li>
+        <li>junit 3.7</li>
+     </ul>
+     The core subproject has no dependencies beyond these.  The factory subproject depends on
+     core and has the following additional dependencies, specified in factory/project.xml 
+     (see <a href="multiproject/directory-naming-factory/dependencies.html">dependencies</a>):
+     <ul>
+        <li>jta-spec 1.0.1 (runtime only, must be added to local repo, 
+            since not available on ibiblio)</li>
+        <li>javamail 1.2  (must be added to local repo, since not available on ibiblio)</li>
+        <li>commons-dbcp 1.0 and commons-pool 1.0.1 (only required if using the default 
+            resource factory to obtain database connections)</li>
+        <li>commons-digester 1.4.1 (for reading XML configuration files)</li>
+        <li>commons-logging 1.0.3</li>
+        <li>commons-beanutils 1.6.1 (runtime only for digester)</li>
+        <li>commons-lang 1.0.1</li>
+        <li>hsqldb 1.7.1 (testing only - used to setup a simple database to perform resource factory testing)</li>
+     </ul>
+    </p>
+ </section>
+ </body>
+</document>
+

Modified: incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/index.xml
==============================================================================
--- incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/index.xml	(original)
+++ incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/index.xml	Sat Feb  7 12:01:33 2004
@@ -1,20 +1,21 @@
 <?xml version="1.0"?>
 
 <document>
+ <properties>
+  <title>Naming</title>
+ </properties>
 
-  <properties>
-    <author email="akarasulu@apache.org">Alex Karasulu</author>
-    <title>Apache Directory Project: Naming Commons Subproject</title>
-  </properties>
-
-  <body>
-    <section name="Naming Commons">
-      <p>
-        Coming soon ...
-      </p>
-    </section>
-  </body>
+ <body>
 
+ <section name="What is Naming?">
+   <p>
+     Naming is a lightweight, in-memory JNDI service provider.  The 
+     initial code base was extracted from the Jakarta Tomcat JNDI implementation.
+   </p>
+    
+ </section>
+ 
+ </body>
 </document>
 
 

Modified: incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/navigation.xml
==============================================================================
--- incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/navigation.xml	(original)
+++ incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/navigation.xml	Sat Feb  7 12:01:33 2004
@@ -25,7 +25,11 @@
         <item name="Eve" href="/subprojects/eve/index.html"/>
         <item name="LDAP" href="/subprojects/ldap/index.html"/>
         <item name="Janus" href="/subprojects/janus/index.html"/>
-        <item name="Naming" href="/subprojects/naming/index.html"/>
+        <item name="Naming" href="/subprojects/naming/index.html">
+          <item name="Overview" href="/subprojects/naming/index.html"/>
+          <item name="Building"  href="/subprojects/naming/building.html"/>
+           <item name="Using"   href="/subprojects/naming/using.html"/>
+         </item>
         <item name="Snickers" href="/subprojects/snickers/index.html"/>
         <item name="Sitedocs" href="/subprojects/sitedocs/index.html"/>
       </item>

Added: incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/using.xml
==============================================================================
--- (empty file)
+++ incubator/directory/sitedocs/trunk/sitedocs/xdocs/subprojects/naming/using.xml	Sat Feb  7 12:01:33 2004
@@ -0,0 +1,158 @@
+<?xml version="1.0"?>
+<document>
+ <properties>
+  <title>Using naming</title>
+ </properties>
+
+ <body>
+
+ <section name="Introduction">
+   <p>
+   </p>
+ </section>
+ 
+ <section name="Installation and setup">
+   <p>
+   </p>
+ </section>
+
+ <section name="Examples">
+   <subsection name="Configuring JNDI resources using XMLConfigurator">
+     <p>
+     The <code>XMLConfigurator</code> allows you to configure and load JNDI 
+     resources using xml configuration files using a syntax very similar to that 
+     used by Jakarta Tomcat's server.xml file. [FIXME -- add schema/dtd reference.]
+     For a full introduction to JNDI resources and resource factories, see
+     <a href="http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources-howto.html">
+     Tomcat JNDI Resources HOW-TO</a>
+     </p>
+     <p>
+     Here is an example, showing how to configure a database connection pool and 
+     then get a connection from the pool in your application.
+     </p>
+     <p>
+       Start by setting up a JNDI environment including a datasource in an xml 
+       configuration file, like so:
+       <source><![CDATA[
+        <naming>
+          <context>
+            <resource name="jdbc/pool" type="javax.sql.DataSource">
+              <parameter>
+                <name>driverClassName</name>
+                <value>org.hsqldb.jdbcDriver</value>
+              </parameter>
+              <parameter>
+                <name>url</name>
+                <value>jdbc:hsqldb:target/hsqldb</value>
+             </parameter>
+             <parameter>
+               <name>username</name>
+               <value>sa</value>
+             </parameter>
+             <parameter>
+               <name>password</name>
+               <value></value>
+             </parameter>
+           </resource>
+         </context>
+       </naming>
+       ]]>
+       </source>
+     </p>
+     <p>
+       The JNDI resource being configured above is a database connection pool. Naming
+       provides a default resource factory for database connection pools using Jakarta
+       Commons DBCP.  This is the factory that will be used to create the pool. In order 
+       for this factory to work, you need to have Jakarta Commons DBCP (version 1.0) 
+       and Jakarta Commons Pool (version 1.0.1) in your classpath. 
+     </p>
+     <p>
+       The parameters that follow specify the database driver, url, username and password. 
+     </p>
+     <p>
+       To use a connection from the pool at run time, you need to do three things:
+       <ol>
+         <li>
+           <p>
+             Initialize JNDI using the xml configuration file above. Assuming the xml file
+             is stored in "/example-jndi.xml", you can do this in one line:
+             <source>
+               XmlConfigurator.loadConfiguration(getClass().getResourceAsStream("/example-jndi.xml"));
+             </source>
+           </p>
+         </li>
+         <li>
+           <p>
+             Perform a JNDI lookup to get a DataSource reference:
+             <source>
+               Context ctx = new InitialContext();
+               Context env = (Context) ctx.lookup("java:comp/env");
+               DataSource ds = (DataSource) env.lookup("jdbc/pool");
+             </source>
+           </p>
+         </li>
+         <li>
+           <p>
+             Use the reference to access the database:
+             <source>
+               Connection con = null;
+               try {
+                   con = ds.getConnection();
+                   // use con to access db
+                   ...
+               } finally {
+                   // cleanup database access objects
+                   ...
+                   if (con != null) { 
+                      con.close(); 
+                   }
+               }
+             </source>
+           </p>
+         </li>
+       </ol>
+     </p>
+   </subsection>
+   <subsection name="Using the Naming APIs directly to set up JNDI">
+     <p>
+       To set up and use a JNDI naming context using the JNDI APIs directly, 
+       you need to set some JNDI environment properties, create an initial context
+       and then use the standard JNDI APIs to set up bindings and perform lookups.
+     </p>
+     <p>
+       You can use a jndi.properties properties file to set the environment properties 
+       for the initial context, or you can do it as follows in your code:
+       <source>
+         Hashtable env = new Hashtable();
+         env.put(Context.INITIAL_CONTEXT_FACTORY,
+            "org.apache.naming.java.javaURLContextFactory");
+         env.put(Context.URL_PKG_PREFIXES,"org.apache.naming");
+        </source>
+     </p>
+     <p>
+       Then create the initial context:
+       <source>
+         Context initialContext = new InitialContext(env);
+       </source>
+     </p>
+     <p>
+       Once created, you can add bindings to the context using the 
+       <code>javax.naming.Context</code> API:
+       <source>
+         compContext = initialContext.createSubcontext("java:comp");
+         envContext =  compContext.createSubcontext("env");
+         envContext.bind("host", "www.apache.org");
+         envContext.bind("port", new Integer(80)); 
+       </source>
+     </p>
+     <p>
+       Now <code>initialContext.lookup("java:comp/env/host"))</code> will return 
+       a <code>String</code> holding the value "www.apache.org" and 
+       <code>initialContext.lookup("java:comp/env/port"))</code> will return an
+       <code>Integer</code> with <code>intValue</code> equal to 80.
+     </p>      
+   </subsection>
+ </section>      
+ </body>
+</document>
+