You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2008/01/15 17:53:15 UTC

svn commit: r612155 - in /incubator/tuscany/branches/sca-java-1.1: itest/osgi-implementation/src/main/java/conversation/client/ modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/ modules/osgi-runtime/src/ma...

Author: slaws
Date: Tue Jan 15 08:53:10 2008
New Revision: 612155

URL: http://svn.apache.org/viewvc?rev=612155&view=rev
Log:
TUSCANY-1987
Fix occasional build break in itest/osig-implemention.
Rajini provided the patch for this one

Modified:
    incubator/tuscany/branches/sca-java-1.1/itest/osgi-implementation/src/main/java/conversation/client/ConversationalClientActivator.java
    incubator/tuscany/branches/sca-java-1.1/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java
    incubator/tuscany/branches/sca-java-1.1/modules/osgi-runtime/src/main/java/org/apache/tuscany/sca/osgi/runtime/FelixRuntime.java

Modified: incubator/tuscany/branches/sca-java-1.1/itest/osgi-implementation/src/main/java/conversation/client/ConversationalClientActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.1/itest/osgi-implementation/src/main/java/conversation/client/ConversationalClientActivator.java?rev=612155&r1=612154&r2=612155&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.1/itest/osgi-implementation/src/main/java/conversation/client/ConversationalClientActivator.java (original)
+++ incubator/tuscany/branches/sca-java-1.1/itest/osgi-implementation/src/main/java/conversation/client/ConversationalClientActivator.java Tue Jan 15 08:53:10 2008
@@ -55,7 +55,7 @@
         Hashtable<String, Object> serviceProps;
         
         serviceProps = new Hashtable<String, Object>();
-        
+         
         serviceProps.put("component.name", "ConversationalStatelessClientStatelessService");
         Object statelessClientFactory1 = 
             new ConversationalClientServiceFactory(ConversationalClientStatelessImpl.class, bundleContext, 1);
@@ -74,6 +74,7 @@
                 serviceProps);
         
             
+        serviceProps = new Hashtable<String, Object>();
         serviceProps.put("component.name", "ConversationalStatefulClientStatelessService");
         Object statefulClientFactory1 = 
             new ConversationalClientServiceFactory(ConversationalClientStatefulImpl.class, bundleContext, 3);
@@ -91,21 +92,6 @@
                 statefulClientFactory2, 
                 serviceProps);
       
-        serviceProps.put("component.name", "ConversationalReferenceClient");
-        ConversationalReferenceClientImpl refClient = new ConversationalReferenceClientImpl();
-        bundleContext.registerService(ConversationalReferenceClient.class.getName(), refClient, serviceProps);
-        
-        serviceProps = new Hashtable<String, Object>();
-        serviceProps.put("component.name", "ConversationalServiceStateful");
-        Object statefulService = 
-            new ConversationalClientServiceFactory(ConversationalServiceStatefulImpl.class, bundleContext, 5);
-        bundleContext.registerService(ConversationalService.class.getName(), statefulService, serviceProps);
-        
-        serviceProps = new Hashtable<String, Object>();
-        serviceProps.put("component.name", "ConversationalServiceStateless");
-        ConversationalServiceStatelessImpl statelessService = new ConversationalServiceStatelessImpl();
-        bundleContext.registerService(ConversationalService.class.getName(), statelessService, serviceProps);
-        
         
     }
     

Modified: incubator/tuscany/branches/sca-java-1.1/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.1/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java?rev=612155&r1=612154&r2=612155&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.1/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java (original)
+++ incubator/tuscany/branches/sca-java-1.1/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java Tue Jan 15 08:53:10 2008
@@ -173,6 +173,7 @@
             bundleContext.getServiceReference("org.osgi.service.packageadmin.PackageAdmin");
         if (packageAdminReference != null) {
             packageAdmin = (PackageAdmin) bundleContext.getService(packageAdminReference);
+            bundleContext.addFrameworkListener(this);
         }
         
         
@@ -333,7 +334,7 @@
                 
                 resolveBundle();
                 
-                processAnnotations();
+                processAnnotations(true);
                 
                 
                 for (Bundle bundle : dependentBundles) {
@@ -547,20 +548,7 @@
         bundle.start();
         
         if (existingBundle != null && packageAdmin != null) {
-            
-
-            bundleContext.addFrameworkListener(this);
-                      
-            packagesRefreshed = false;
-            packageAdmin.refreshPackages(null);
-                        
-            synchronized (this) {
-                if (!packagesRefreshed) {
-                    this.wait(2000);
-                }
-            }            
-            packagesRefreshed = false;
-            bundleContext.removeFrameworkListener(this);
+            refreshPackages();
             
         }
 
@@ -826,6 +814,25 @@
         
     }
     
+    private void refreshPackages() {
+    
+        if (packageAdmin != null) {
+            synchronized (this) {
+                packagesRefreshed = false;
+                packageAdmin.refreshPackages(null);
+                        
+                if (!packagesRefreshed) {
+                	try {
+                        this.wait(2000);
+                	} catch (InterruptedException e) {
+                		// ignore
+                	}
+                }
+                packagesRefreshed = false;
+            }                       
+        }
+    }
+    
     
     private void resolveBundle() throws ObjectCreationException {
         
@@ -893,6 +900,8 @@
                     }
                     index++;
                 }
+
+                refreshPackages();
                 
                 
                 index = 0;
@@ -1085,57 +1094,55 @@
         setReferencesAndProperties();
     }
         
-    public void processAnnotations() throws IntrospectionException {
+    public void processAnnotations(boolean doWait) throws IntrospectionException {
         
-        synchronized (this) {       
-            if (processedResolvedBundle || processingResolvedBundle)
+        synchronized (this) {   
+            if (processedResolvedBundle)
                 return;
+            else if (processingResolvedBundle) {            	
+                if (doWait) {
+                    while (processingResolvedBundle) {
+                        try {
+                            wait(5000);
+                        } catch (InterruptedException e) {
+                        }
+                    }
+                }
+                return;
+            }
             processingResolvedBundle = true;
         }
         
-        osgiAnnotations.processAnnotations();
+        try {
+            osgiAnnotations.processAnnotations();
         
-        Scope scope = osgiAnnotations.getScope();
-        if (scope.equals(Scope.SYSTEM) || scope.equals(Scope.COMPOSITE)) {
-            // Nothing
-        } else {
+            Scope scope = osgiAnnotations.getScope();
+            if (scope.equals(Scope.SYSTEM) || scope.equals(Scope.COMPOSITE)) {
+                // Nothing
+            } else {
 
-            if (runtimeComponent instanceof ScopedRuntimeComponent) {
+                if (runtimeComponent instanceof ScopedRuntimeComponent) {
 
-                ScopedRuntimeComponent component = (ScopedRuntimeComponent) runtimeComponent;
+                    ScopedRuntimeComponent component = (ScopedRuntimeComponent) runtimeComponent;
 
-                ScopeContainer oldScopeContainer = component.getScopeContainer();
-                component.setScopeContainer(null);
-                ScopeContainer scopeContainer = scopeRegistry.getScopeContainer(runtimeComponent);
-
-                if (oldScopeContainer != null && oldScopeContainer.getLifecycleState() == ScopeContainer.RUNNING) {
-                    scopeContainer.start();
-                }
-                
-                component.setScopeContainer(scopeContainer);
-            }
-
-            // Check for conversational contract if conversational scope
-//            if (scope.equals(Scope.CONVERSATION)) {
-//                boolean hasConversationalContract = false;
-//                for (Service serviceDef : implementation.getServices()) {
-//                    if (serviceDef.getInterfaceContract().getInterface()
-//                            .isConversational()) {
-//                        hasConversationalContract = true;
-//                        break;
-//                    }
-//                }
-//                if (!hasConversationalContract) {
-//                    Exception e = new NoConversationalContractException(
-//                            runtimeComponent.getName() + ":" + osgiBundle);
-//                    throw new RuntimeException(e);
-//                }
-//            }
-        }
-            
-        synchronized (this) {                
-            processedResolvedBundle = true;
-            this.notifyAll();
+                    ScopeContainer oldScopeContainer = component.getScopeContainer();
+                    component.setScopeContainer(null);
+                    ScopeContainer scopeContainer = scopeRegistry.getScopeContainer(runtimeComponent);
+
+                    if (oldScopeContainer != null && oldScopeContainer.getLifecycleState() == ScopeContainer.RUNNING) {
+                        scopeContainer.start();
+                    }
+                
+                    component.setScopeContainer(scopeContainer);
+                }
+
+            }
+        } finally {
+            synchronized (this) {                
+                processingResolvedBundle = false;
+                processedResolvedBundle = true;
+                this.notifyAll();
+            }
         }  
     }
     
@@ -1160,7 +1167,7 @@
     public void bundleChanged(BundleEvent event) {
         if (event.getType() == BundleEvent.RESOLVED && event.getBundle() == osgiBundle) {
             try {
-                processAnnotations();
+                processAnnotations(false);
             } catch (Throwable e) {
                 e.printStackTrace();
             }             

Modified: incubator/tuscany/branches/sca-java-1.1/modules/osgi-runtime/src/main/java/org/apache/tuscany/sca/osgi/runtime/FelixRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-1.1/modules/osgi-runtime/src/main/java/org/apache/tuscany/sca/osgi/runtime/FelixRuntime.java?rev=612155&r1=612154&r2=612155&view=diff
==============================================================================
--- incubator/tuscany/branches/sca-java-1.1/modules/osgi-runtime/src/main/java/org/apache/tuscany/sca/osgi/runtime/FelixRuntime.java (original)
+++ incubator/tuscany/branches/sca-java-1.1/modules/osgi-runtime/src/main/java/org/apache/tuscany/sca/osgi/runtime/FelixRuntime.java Tue Jan 15 08:53:10 2008
@@ -171,8 +171,17 @@
         bundleContext = null;
         instance = null;
         
+        // We could potentially use Felix.stopAndWait, but use timed wait for now because
+        // stopAndWait hangs with Felix 1.0.0
         if (felix instanceof Bundle) {
-            ((Bundle)felix).stop();
+            Bundle felixBundle = (Bundle)felix;
+            felixBundle.stop();
+            int retries = 50;
+            synchronized (felix) {
+                while (retries-- > 0 && felixBundle.getState() != Bundle.UNINSTALLED) {
+                    felix.wait(100);
+                }
+            }
         }
         else if (felix != null) {
             Method shutdownMethod = felixClass.getMethod("shutdown");



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org