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 2005/01/25 06:39:29 UTC

svn commit: r126347 - /incubator/directory/naming/trunk/naming-core/src/java/org/apache/naming/NamingContextFactory.java /incubator/directory/naming/trunk/xdocs/changes.xml

Author: psteitz
Date: Mon Jan 24 21:39:25 2005
New Revision: 126347

URL: http://svn.apache.org/viewcvs?view=rev&rev=126347
Log:
Modified NamingContextFactory to name and persist contexts in ContextBindings (DIRNAMING-11).
Added:
   incubator/directory/naming/trunk/xdocs/changes.xml
Modified:
   incubator/directory/naming/trunk/naming-core/src/java/org/apache/naming/NamingContextFactory.java

Modified: incubator/directory/naming/trunk/naming-core/src/java/org/apache/naming/NamingContextFactory.java
Url: http://svn.apache.org/viewcvs/incubator/directory/naming/trunk/naming-core/src/java/org/apache/naming/NamingContextFactory.java?view=diff&rev=126347&p1=incubator/directory/naming/trunk/naming-core/src/java/org/apache/naming/NamingContextFactory.java&r1=126346&p2=incubator/directory/naming/trunk/naming-core/src/java/org/apache/naming/NamingContextFactory.java&r2=126347
==============================================================================
--- incubator/directory/naming/trunk/naming-core/src/java/org/apache/naming/NamingContextFactory.java	(original)
+++ incubator/directory/naming/trunk/naming-core/src/java/org/apache/naming/NamingContextFactory.java	Mon Jan 24 21:39:25 2005
@@ -27,14 +27,30 @@
  * @version $Revision$ $Date$
  */
 public class NamingContextFactory implements InitialContextFactory {
+   
+    /** Environment property holding context external name */
+    public static final String NAME = "org.apache.naming.name";
+    
+    /** 
+     * External name for shared global context created or returned when no 
+     * name environment property is set
+     */
+    public static final String DEFAULT_NAME = "Global";
     
     /**
-     * Get a new (writable) initial context.  Always returns a 
-     * {@link NamingContext}.  If
-     * {@link SynchronizedContext#isSynchronized} returns true for 
-     * <code>environment</code>  then the
-     * returned context is wrapped in a {@link SynchronizedContext}, so access
-     * to it will be synchronized.
+     * Get a new (writable) initial context. 
+     * <p> 
+     * If an external name is specified in the environment 
+     * (under NamingFactory.NAME),  the named context is returned from 
+     * {@link ContextBindings}.  If there is no such named context, a 
+     * context with this name is created and added to ContextBindings.  
+     * If there is no name property present in the environment, the default
+     * "Global" is assumed (so all "anonymous" initial context requests refer
+     * to a single, shared context).
+     * <p>
+     * If {@link SynchronizedContext#isSynchronized} returns true for 
+     * <code>environment</code>  then the returned context is wrapped in a
+     * {@link SynchronizedContext}, so accessto it will be synchronized.
      * 
      * @param environment  environment
      * @return a new Context
@@ -42,7 +58,17 @@
      */
     public Context getInitialContext(Hashtable environment)
     throws NamingException {
-        Context ctx = new NamingContext(environment, "initialContext");
+        String name = null;
+        if (environment.containsKey(NAME)) {
+            name = (String) environment.get(NAME);
+        } else {
+            name = DEFAULT_NAME;
+        }
+        Context ctx = ContextBindings.getContext(name);
+        if (ctx == null) {
+            ctx =  new NamingContext(environment, name);
+            ContextBindings.bindContext(name, ctx);
+        } 
         if (SynchronizedContext.isSynchronized(environment)) {
             return new SynchronizedContext(ctx);
         } else {

Added: incubator/directory/naming/trunk/xdocs/changes.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/naming/trunk/xdocs/changes.xml?view=auto&rev=126347
==============================================================================
--- (empty file)
+++ incubator/directory/naming/trunk/xdocs/changes.xml	Mon Jan 24 21:39:25 2005
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<!--
+   Copyright 2005 The Apache Software Foundation
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<!--
+This file is used by the maven-changes-plugin to generate the release notes.
+Useful ways of finding items to add to this file are:
+
+1.  Add items when you fix a bug or add a feature (this makes the 
+release process easy :-).
+
+2.  Do a bugzilla search for tickets closed since the previous release.
+
+3.  Use the report generated by the maven-changelog-plugin to see all
+CVS commits.  Set the project.properties' maven.changelog.range 
+property to the number of days since the last release.
+
+
+The <action> type attribute can be add,update,fix,remove.
+-->
+
+<document>
+  <properties>
+    <title>Directory Naming Release Notes</title>
+  </properties>
+  <body>
+    <release version="0.9" date="TBD"  
+       description="Apache Directory Naming 0.9 - General Availability Release">
+       <action dev="psteitz" type="update" issue="DIRNAMING-11">
+          Modified NamingContextFactory to persist contexts in ContextBindings.
+          When using NamingContextFactory, a NAME property may be specified to 
+          retrieve or create a named context. 
+      </action>
+    </release>     
+    <release version="0.8" date="2005-01-15" 
+      description="Apache Directory Naming 0.8 - Incubator Technology Preview">
+      <action type="add">
+        Initial "technology preview" release from the Apache Incubator.
+      </action>  
+    </release>   
+  </body>
+</document>