tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r830811 - in /tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca: node/osgi/impl/ osgi/remoteserviceadmin/impl/
Date Thu, 29 Oct 2009 00:45:49 GMT
Author: rfeng
Date: Thu Oct 29 00:45:49 2009
New Revision: 830811

URL: http://svn.apache.org/viewvc?rev=830811&view=rev
Log:
Add more checks for the stop() method

Modified:
    tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java
    tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java
    tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java
    tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java

Modified: tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java?rev=830811&r1=830810&r2=830811&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java
(original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java
Thu Oct 29 00:45:49 2009
@@ -21,6 +21,9 @@
 
 import static org.apache.tuscany.sca.node.osgi.impl.NodeManager.isSCABundle;
 
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
 import org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.RemoteServiceAdminImpl;
 import org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.TopologyManagerImpl;
 import org.apache.tuscany.sca.osgi.service.discovery.impl.DiscoveryActivator;
@@ -34,10 +37,11 @@
  * Bundle activator to receive the BundleContext
  */
 public class NodeActivator implements BundleActivator, SynchronousBundleListener {
+    private final static Logger logger = Logger.getLogger(NodeActivator.class.getName());
     private static BundleContext bundleContext;
     private boolean inited;
     private NodeManager manager;
-    
+
     private DiscoveryActivator discoveryActivator = new DiscoveryActivator();
     private RemoteServiceAdminImpl remoteAdmin;
     private TopologyManagerImpl controller;
@@ -55,50 +59,57 @@
     }
 
     public void start(BundleContext context) throws Exception {
-        bundleContext = context;
+        try {
+            bundleContext = context;
+
+            // FIXME: We should try to avoid aggressive initialization
+            init();
+
+            remoteAdmin = new RemoteServiceAdminImpl(context);
+            remoteAdmin.start();
+
+            discoveryActivator.start(context);
 
-        // FIXME: We should try to avoid aggressive initialization
-        init();
-        
-        remoteAdmin = new RemoteServiceAdminImpl(context);
-        remoteAdmin.start();
-        
-        discoveryActivator.start(context);
-        
-        controller = new TopologyManagerImpl(context);
-        controller.start();
-        
-        boolean found = false;
-        for (Bundle b : context.getBundles()) {
-            if (isSCABundle(b)) {
-                found = true;
-                break;
+            controller = new TopologyManagerImpl(context);
+            controller.start();
+
+            boolean found = false;
+            for (Bundle b : context.getBundles()) {
+                if (isSCABundle(b)) {
+                    found = true;
+                    break;
+                }
             }
-        }
 
-        if (found) {
-            init();
-        } else {
-            context.addBundleListener(this);
+            if (found) {
+                init();
+            } else {
+                context.addBundleListener(this);
+            }
+        } catch (Exception e) {
+            logger.log(Level.SEVERE, e.getMessage(), e);
+            throw e;
         }
     }
 
     public void stop(BundleContext context) throws Exception {
-        context.removeBundleListener(this);
-        controller.stop();
-        controller = null;
-
-        discoveryActivator.stop(context);
-        discoveryActivator = null;
-        
-        remoteAdmin.stop();
-        remoteAdmin = null;
-        
-        manager.stop();
-        bundleContext.removeBundleListener(manager);
-        manager = null;
-        bundleContext = null;
-        inited = false;
+        if (inited) {
+            context.removeBundleListener(this);
+            controller.stop();
+            controller = null;
+
+            discoveryActivator.stop(context);
+            discoveryActivator = null;
+
+            remoteAdmin.stop();
+            remoteAdmin = null;
+
+            manager.stop();
+            bundleContext.removeBundleListener(manager);
+            manager = null;
+            bundleContext = null;
+            inited = false;
+        }
     }
 
     public static BundleContext getBundleContext() {

Modified: tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java?rev=830811&r1=830810&r2=830811&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java
(original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java
Thu Oct 29 00:45:49 2009
@@ -96,12 +96,15 @@
 
     public synchronized void init() {
         if (!inited) {
-            super.init();
-
             // Register the ExtensionPointRegistry as an OSGi service
             Dictionary<Object, Object> props = new Hashtable<Object, Object>();
+            registry = createExtensionPointRegistry();
+            registry.start();
             registration =
                 bundleContext.registerService(ExtensionPointRegistry.class.getName(), registry,
props);
+
+            // Call super.init after the extension point registry is registered
+            super.init();
         }
     }
 

Modified: tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java?rev=830811&r1=830810&r2=830811&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java
(original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java
Thu Oct 29 00:45:49 2009
@@ -73,12 +73,14 @@
     }
 
     public void stop() {
-        discoveryTracker.close();
-        discoveryTracker = null;
-        introspector = null;
-        nodeFactory = null;
-        registry = null;
-        context = null;
+        if (nodeFactory != null) {
+            discoveryTracker.close();
+            discoveryTracker = null;
+            introspector = null;
+            nodeFactory = null;
+            registry = null;
+            context = null;
+        }
     }
 
     public void setDomainRegistry(String domainRegistry) {

Modified: tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java?rev=830811&r1=830810&r2=830811&view=diff
==============================================================================
--- tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java
(original)
+++ tuscany/java/sca/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java
Thu Oct 29 00:45:49 2009
@@ -48,6 +48,7 @@
     }
 
     public void start() {
+        // Defer init() to importService()
     }
 
     public ImportRegistration importService(Bundle bundle, EndpointDescription endpointDescription)
{



Mime
View raw message