directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r280082 - in /directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration: impl/ConfigurationAdminFactory.java impl/ConfigurationDispatcher.java impl/PluginManager.java impl/Update.java metadata.xml
Date Sun, 11 Sep 2005 05:27:38 GMT
Author: erodriguez
Date: Sat Sep 10 22:27:33 2005
New Revision: 280082

URL: http://svn.apache.org/viewcvs?rev=280082&view=rev
Log:
Updated the Configuration Admin Factory to use the dynamic Service Binder, replacing temporary
"stepping-stone" code in ConfigurationFactory.

Added:
    directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/metadata.xml
  (with props)
Modified:
    directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/ConfigurationAdminFactory.java
    directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/ConfigurationDispatcher.java
    directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/PluginManager.java
    directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/Update.java

Modified: directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/ConfigurationAdminFactory.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/ConfigurationAdminFactory.java?rev=280082&r1=280081&r2=280082&view=diff
==============================================================================
--- directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/ConfigurationAdminFactory.java
(original)
+++ directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/ConfigurationAdminFactory.java
Sat Sep 10 22:27:33 2005
@@ -23,10 +23,11 @@
 import java.util.Hashtable;
 import java.util.List;
 
-import org.apache.configuration.ConfigurationFactory;
+import javax.naming.spi.InitialContextFactory;
+
 import org.apache.configuration.ConfigurationListener;
-import org.apache.configuration.ConfigurationStore;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
 import org.osgi.framework.Constants;
@@ -43,18 +44,21 @@
 import org.osgi.service.cm.ManagedServiceFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.ungoverned.gravity.servicebinder.Lifecycle;
+import org.ungoverned.gravity.servicebinder.ServiceBinderContext;
 
 /**
  * ConfigurationAdmin implementation
  */
-public class ConfigurationAdminFactory implements ServiceFactory, ServiceListener, BundleListener,
ConfigurationListener
+public class ConfigurationAdminFactory implements ServiceFactory, ServiceListener, BundleListener,
+        ConfigurationListener, Lifecycle
 {
     /** the log for this class */
     private static final Logger log = LoggerFactory.getLogger( ConfigurationAdminFactory.class
);
 
     private Hashtable locationToPids = new Hashtable();
     private Hashtable existingBundleLocations = new Hashtable();
-    private ConfigurationStore store;
+    private JndiConfigurationStore store;
     private PluginManager pluginManager;
     private ConfigurationDispatcher configurationDispatcher;
 
@@ -65,10 +69,23 @@
 
     static String DYNAMIC_BUNDLE_LOCATION = "dynamic.service.bundleLocation";
 
-    public ConfigurationAdminFactory( ConfigurationStore store )
+    public static BundleContext bc;
+
+    private InitialContextFactory factory;
+
+    public ConfigurationAdminFactory( ServiceBinderContext sbc )
     {
-        this.store = store;
+        bc = sbc.getBundleContext();
+        log.debug( "Got Bundle Context " + bc );
+    }
 
+    /**
+     * All required services have been bound, but our service(s) are not yet
+     * registered.
+     */
+    public void activate()
+    {
+        store = new JndiConfigurationStore( factory );
         store.setConfigurationListener( this );
 
         pluginManager = new PluginManager();
@@ -79,8 +96,8 @@
 
         try
         {
-            ConfigurationFactory.bc.addServiceListener( this, FILTER );
-            ConfigurationFactory.bc.addBundleListener( this );
+            bc.addServiceListener( this, FILTER );
+            bc.addBundleListener( this );
         }
         catch ( InvalidSyntaxException ignored )
         {
@@ -90,6 +107,32 @@
         lookForAlreadyRegisteredServices();
     }
 
+    /**
+     * Invalidation has started and our services have been unregistered, but
+     * any required services have not been unbound yet.
+     */
+    public void deactivate()
+    {
+        store.deactivate();
+    }
+
+    public String getName()
+    {
+        return "Apache Configuration Admin Service Factory";
+    }
+
+    public void setInitialContextFactory( InitialContextFactory factory )
+    {
+        this.factory = factory;
+        log.debug( getName() + " has bound to " + factory );
+    }
+
+    public void unsetInitialContextFactory( InitialContextFactory factory )
+    {
+        this.factory = null;
+        log.debug( getName() + " has unbound from " + factory );
+    }
+
     public void configurationChanged( Dictionary configuration )
     {
         try
@@ -104,11 +147,13 @@
 
     public Object getService( Bundle bundle, ServiceRegistration registration )
     {
+        log.debug( getName() + " has received a ServiceFactory.getService() call" );
         return new ConfigurationAdminImpl( store, bundle );
     }
 
     public void ungetService( Bundle bundle, ServiceRegistration registration, Object service
)
     {
+        log.debug( getName() + " has received a ServiceFactory.ungetService() call" );
         // For now we do nothing here
     }
 
@@ -151,7 +196,7 @@
     {
         try
         {
-            ServiceReference[] srs = ConfigurationFactory.bc.getServiceReferences( className,
null );
+            ServiceReference[] srs = bc.getServiceReferences( className, null );
 
             for ( int ii = 0; srs != null && ii < srs.length; ++ii )
             {
@@ -165,7 +210,7 @@
 
     private void lookForExistingBundleLocations()
     {
-        Bundle[] bs = ConfigurationFactory.bc.getBundles();
+        Bundle[] bs = bc.getBundles();
 
         for ( int ii = 0; bs != null && ii < bs.length; ++ii )
         {
@@ -465,7 +510,7 @@
 
         try
         {
-            ServiceReference[] srs = ConfigurationFactory.bc.getServiceReferences( clazz.getName(),
filter );
+            ServiceReference[] srs = bc.getServiceReferences( clazz.getName(), filter );
             return srs == null ? new ServiceReference[ 0 ] : srs;
         }
         catch ( InvalidSyntaxException e )

Modified: directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/ConfigurationDispatcher.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/ConfigurationDispatcher.java?rev=280082&r1=280081&r2=280082&view=diff
==============================================================================
--- directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/ConfigurationDispatcher.java
(original)
+++ directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/ConfigurationDispatcher.java
Sat Sep 10 22:27:33 2005
@@ -20,7 +20,6 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.configuration.ConfigurationFactory;
 import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -79,7 +78,7 @@
 
             if ( targetService == null )
             {
-                targetService = ConfigurationFactory.bc.getService( sr );
+                targetService = ConfigurationAdminFactory.bc.getService( sr );
 
                 if ( targetService == null )
                 {

Modified: directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/PluginManager.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/PluginManager.java?rev=280082&r1=280081&r2=280082&view=diff
==============================================================================
--- directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/PluginManager.java
(original)
+++ directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/PluginManager.java
Sat Sep 10 22:27:33 2005
@@ -21,7 +21,6 @@
 import java.util.Hashtable;
 import java.util.Vector;
 
-import org.apache.configuration.ConfigurationFactory;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceReference;
@@ -270,7 +269,7 @@
 
             if ( cmTarget == null || cmTarget.equals( pid ) )
             {
-                ConfigurationPlugin plugin = (ConfigurationPlugin) ConfigurationFactory.bc.getService(
pluginReference );
+                ConfigurationPlugin plugin = (ConfigurationPlugin) ConfigurationAdminFactory.bc.getService(
pluginReference );
 
                 if ( plugin == null )
                 {

Modified: directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/Update.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/Update.java?rev=280082&r1=280081&r2=280082&view=diff
==============================================================================
--- directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/Update.java
(original)
+++ directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/impl/Update.java
Sat Sep 10 22:27:33 2005
@@ -17,7 +17,6 @@
 
 package org.apache.configuration.impl;
 
-import org.apache.configuration.ConfigurationFactory;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedService;
@@ -104,7 +103,7 @@
             return null;
         }
 
-        return ConfigurationFactory.bc.getService( sr );
+        return ConfigurationAdminFactory.bc.getService( sr );
     }
 
     public String toString()

Added: directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/metadata.xml
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/metadata.xml?rev=280082&view=auto
==============================================================================
--- directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/metadata.xml
(added)
+++ directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/metadata.xml
Sat Sep 10 22:27:33 2005
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--<!DOCTYPE bundle SYSTEM "metadata.dtd">-->
+<bundle>
+  <component class="org.apache.configuration.impl.ConfigurationAdminFactory">
+    <provides service="org.osgi.service.cm.ConfigurationAdmin"/>
+    <requires
+        service="javax.naming.spi.InitialContextFactory"
+        filter=""
+        cardinality="1..1"
+        policy="static"
+        bind-method="setInitialContextFactory"
+        unbind-method="unsetInitialContextFactory"
+    />
+  </component>
+</bundle>

Propchange: directory/sandbox/trunk/osgi-spec/trunk/configuration/src/main/java/org/apache/configuration/metadata.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message