incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r1021782 - in /incubator/aries/trunk/jndi: jndi-api/ jndi-api/src/main/java/org/apache/aries/jndi/spi/ jndi-bundle/ jndi-core/src/main/java/org/apache/aries/jndi/ jndi-core/src/main/java/org/apache/aries/jndi/startup/
Date Tue, 12 Oct 2010 14:15:50 GMT
Author: not
Date: Tue Oct 12 14:15:49 2010
New Revision: 1021782

URL: http://svn.apache.org/viewvc?rev=1021782&view=rev
Log:
ARIES-452 Deliver ability to call out to augment the JNDI environment.

Added:
    incubator/aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/
    incubator/aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/EnvironmentAugmentation.java
Modified:
    incubator/aries/trunk/jndi/jndi-api/pom.xml
    incubator/aries/trunk/jndi/jndi-bundle/pom.xml
    incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextManagerService.java
    incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiInitialContextFactoryBuilder.java
    incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/Utils.java
    incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java

Modified: incubator/aries/trunk/jndi/jndi-api/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-api/pom.xml?rev=1021782&r1=1021781&r2=1021782&view=diff
==============================================================================
--- incubator/aries/trunk/jndi/jndi-api/pom.xml (original)
+++ incubator/aries/trunk/jndi/jndi-api/pom.xml Tue Oct 12 14:15:49 2010
@@ -32,7 +32,8 @@
     <properties>
         <aries.osgi.export>
             org.osgi.service.jndi;version="1.0.0",
-            org.apache.aries.jndi.urls;version=${version}
+            org.apache.aries.jndi.urls;version=${version},
+            org.apache.aries.jndi.spi;version=${version}
         </aries.osgi.export>
         <aries.osgi.import>
             !org.osgi.service.jndi*,

Added: incubator/aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/EnvironmentAugmentation.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/EnvironmentAugmentation.java?rev=1021782&view=auto
==============================================================================
--- incubator/aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/EnvironmentAugmentation.java
(added)
+++ incubator/aries/trunk/jndi/jndi-api/src/main/java/org/apache/aries/jndi/spi/EnvironmentAugmentation.java
Tue Oct 12 14:15:49 2010
@@ -0,0 +1,8 @@
+package org.apache.aries.jndi.spi;
+
+import java.util.Hashtable;
+
+public interface EnvironmentAugmentation 
+{
+  public void augmentEnvironment(Hashtable<?, ?> env);
+}
\ No newline at end of file

Modified: incubator/aries/trunk/jndi/jndi-bundle/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-bundle/pom.xml?rev=1021782&r1=1021781&r2=1021782&view=diff
==============================================================================
--- incubator/aries/trunk/jndi/jndi-bundle/pom.xml (original)
+++ incubator/aries/trunk/jndi/jndi-bundle/pom.xml Tue Oct 12 14:15:49 2010
@@ -33,7 +33,8 @@
     <properties>
         <aries.osgi.export>
             org.osgi.service.jndi;version="1.0",
-            org.apache.aries.jndi.urls;version=${version}
+            org.apache.aries.jndi.urls;version=${version},
+            org.apache.aries.jndi.spi;version=${version}
         </aries.osgi.export>
         <aries.osgi.import>
             net.sf.cglib*;resolution:=optional,

Modified: incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextManagerService.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextManagerService.java?rev=1021782&r1=1021781&r2=1021782&view=diff
==============================================================================
--- incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextManagerService.java
(original)
+++ incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/ContextManagerService.java
Tue Oct 12 14:15:49 2010
@@ -71,6 +71,7 @@ public class ContextManagerService imple
     
     private Context getInitialContext(Map<?,?> environment) throws NamingException
{        
         Hashtable<?,?> env = Utils.toHashtable(environment);
+        Utils.augmentEnvironment(env);
         Context context = ContextHelper.getInitialContext(callerContext, env);
         contexts.add(context);
         return context;

Modified: incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiInitialContextFactoryBuilder.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiInitialContextFactoryBuilder.java?rev=1021782&r1=1021781&r2=1021782&view=diff
==============================================================================
--- incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiInitialContextFactoryBuilder.java
(original)
+++ incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/OSGiInitialContextFactoryBuilder.java
Tue Oct 12 14:15:49 2010
@@ -40,6 +40,8 @@ public class OSGiInitialContextFactoryBu
 	public Context getInitialContext(Hashtable<?, ?> environment) 
 	    throws NamingException {
 	    
+	    Utils.augmentEnvironment(environment);
+	  
 	    BundleContext context = Utils.getBundleContext(environment, InitialContext.class.getName());
    
 	    if (context == null) {
 	        context = Utils.getBundleContext(environment, InitialDirContext.class.getName());

Modified: incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/Utils.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/Utils.java?rev=1021782&r1=1021781&r2=1021782&view=diff
==============================================================================
--- incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/Utils.java (original)
+++ incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/Utils.java Tue
Oct 12 14:15:49 2010
@@ -28,6 +28,8 @@ import java.util.Map;
 
 import javax.naming.NamingException;
 
+import org.apache.aries.jndi.spi.EnvironmentAugmentation;
+import org.apache.aries.jndi.startup.Activator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleReference;
 import org.osgi.framework.ServiceReference;
@@ -162,4 +164,17 @@ public final class Utils {
             }
         }
     }
-}
+
+    public static void augmentEnvironment(Hashtable<?, ?> environment) 
+    {
+      Object[] objects = Activator.getEnvironmentAugmentors();
+      
+      if (objects != null) {
+        for (Object obj : objects) {
+          if (obj instanceof EnvironmentAugmentation) {
+            ((EnvironmentAugmentation)obj).augmentEnvironment(environment);
+          }
+        }
+      }
+    }
+}
\ No newline at end of file

Modified: incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java?rev=1021782&r1=1021781&r2=1021782&view=diff
==============================================================================
--- incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
(original)
+++ incubator/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
Tue Oct 12 14:15:49 2010
@@ -34,6 +34,7 @@ import org.apache.aries.jndi.OSGiInitial
 import org.apache.aries.jndi.OSGiObjectFactoryBuilder;
 import org.apache.aries.jndi.ProviderAdminServiceFactory;
 import org.apache.aries.jndi.Utils;
+import org.apache.aries.jndi.spi.EnvironmentAugmentation;
 import org.apache.aries.jndi.tracker.ServiceTrackerCustomizers;
 import org.apache.aries.jndi.urls.URLObjectFactoryFinder;
 import org.osgi.framework.BundleActivator;
@@ -56,6 +57,7 @@ public class Activator implements Bundle
     private static ServiceTracker urlObjectFactoryFinders;
     private static ServiceTracker initialContextFactories;
     private static ServiceTracker objectFactories;
+    private static ServiceTracker environmentAugmentors;
     
     public void start(BundleContext context) {
         
@@ -63,6 +65,7 @@ public class Activator implements Bundle
         objectFactories = initServiceTracker(context, ObjectFactory.class, ServiceTrackerCustomizers.URL_FACTORY_CACHE);
         icfBuilders = initServiceTracker(context, InitialContextFactoryBuilder.class, ServiceTrackerCustomizers.LAZY);
         urlObjectFactoryFinders = initServiceTracker(context, URLObjectFactoryFinder.class,
ServiceTrackerCustomizers.LAZY);
+        environmentAugmentors = initServiceTracker(context, EnvironmentAugmentation.class,
null);
         
         try {
             OSGiInitialContextFactoryBuilder builder = new OSGiInitialContextFactoryBuilder();
@@ -121,7 +124,7 @@ public class Activator implements Bundle
         urlObjectFactoryFinders.close();
         objectFactories.close();
         initialContextFactories.close();
-        
+        environmentAugmentors.close();
     }
     
     /*
@@ -168,4 +171,9 @@ public class Activator implements Bundle
       
       return refs;
     }
+    
+    public static Object[] getEnvironmentAugmentors()
+    {
+      return environmentAugmentors.getServices();
+    }
 }



Mime
View raw message