cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msch...@apache.org
Subject svn commit: r953701 - in /cxf/dosgi/trunk/dsw: cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/ cxf-topology-manager/src/t...
Date Fri, 11 Jun 2010 13:50:38 GMT
Author: mschaaf
Date: Fri Jun 11 13:50:37 2010
New Revision: 953701

URL: http://svn.apache.org/viewvc?rev=953701&view=rev
Log:
- Fixed the import of services if the DSW is detected after a service candidate was detected
as this was not possible before
- Removed some obsolete log messages

Added:
    cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImportTest.java
Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java
    cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManager.java
    cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImport.java

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java?rev=953701&r1=953700&r2=953701&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java Fri
Jun 11 13:50:37 2010
@@ -591,7 +591,6 @@ public final class OsgiUtils {
             LOG.finest("Looking for Package: " + pack);
 
             for (ExportedPackage p : ep) {
-                // LOG.severe("comparing package: " + p.getName() + "   " + p.getVersion());
                 if (pack.equals(p.getName())) {
                     LOG.fine("found package -> Version: " + p.getVersion());
                     return p.getVersion().toString();

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java?rev=953701&r1=953700&r2=953701&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java
Fri Jun 11 13:50:37 2010
@@ -40,10 +40,6 @@ import org.osgi.framework.ServiceReferen
 
 public class ServiceDecoratorImplTest extends TestCase {
     
-    public void testDUMMY(){
-        assertTrue(true);
-    }
-    
     public void testServiceDecorator() {
         final BundleListener[] bundleListener = new BundleListener[1]; 
         

Modified: cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManager.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManager.java?rev=953701&r1=953700&r2=953701&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManager.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManager.java
Fri Jun 11 13:50:37 2010
@@ -1,21 +1,21 @@
 /** 
-  * Licensed to the Apache Software Foundation (ASF) under one 
-  * or more contributor license agreements. See the NOTICE file 
-  * distributed with this work for additional information 
-  * regarding copyright ownership. The ASF licenses this file 
-  * to you 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. 
-  */
+ * Licensed to the Apache Software Foundation (ASF) under one 
+ * or more contributor license agreements. See the NOTICE file 
+ * distributed with this work for additional information 
+ * regarding copyright ownership. The ASF licenses this file 
+ * to you 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. 
+ */
 package org.apache.cxf.dosgi.topologymanager;
 
 import java.util.ArrayList;
@@ -215,7 +215,8 @@ public class TopologyManager {
             LOG
                 .info("TopologyManager: adding service to exportedServices list to export
it --- from bundle:  "
                       + sref.getBundle().getSymbolicName());
-            exportedServices.put(sref, new LinkedHashMap<RemoteServiceAdmin, Collection<ExportRegistration>>());
+            exportedServices.put(sref,
+                                 new LinkedHashMap<RemoteServiceAdmin, Collection<ExportRegistration>>());
         }
 
         // trigger the export
@@ -328,7 +329,9 @@ public class TopologyManager {
                     if (filter.match(d)) {
                         LOG.info("Listener mached one of the Endpoints !!!!: " + epl);
 
-                        epl.endpointAdded(exReg.getExportReference().getExportedEndpoint(),
filter.toString());
+                        epl
+                            .endpointAdded(exReg.getExportReference().getExportedEndpoint(),
filter
+                                .toString());
                     }
                 }
             }
@@ -363,7 +366,8 @@ public class TopologyManager {
                     if (filter.match(d)) {
                         LOG.info("Listener matched one of the Endpoints !!!! --> calling
removed() ...");
 
-                        epl.endpointRemoved(exReg.getExportReference().getExportedEndpoint(),
filter.toString());
+                        epl.endpointRemoved(exReg.getExportReference().getExportedEndpoint(),
filter
+                            .toString());
                     }
                 }
             }
@@ -404,9 +408,14 @@ public class TopologyManager {
         }
     }
 
+    /**
+     * This method is called once a RemoteServiceAdminEvent for an removed export reference
is received.
+     * However the current implementation has no special support for multiple topology managers,
therefore this method
+     * does nothing for the moment.
+     */
     public void removeExportReference(ExportReference anyObject) {
         // TODO Auto-generated method stub
-        LOG.severe("NOT implemented !!!");
+        // LOG.severe("NOT implemented !!!");
     }
 
 }

Modified: cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImport.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImport.java?rev=953701&r1=953700&r2=953701&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImport.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-topology-manager/src/main/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImport.java
Fri Jun 11 13:50:37 2010
@@ -23,6 +23,8 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -325,11 +327,23 @@ public class TopologyManagerImport {
     }
 
     public void triggerExportImportForRemoteSericeAdmin(RemoteServiceAdmin rsa) {
-        LOG.severe("NOT IMPLEMENTED !!!");
+        LOG.fine("New RSA detected trying to import services with it");
+        synchronized (importPossibilities) {
+            Set<Map.Entry<String, List<EndpointDescription>>> entries =
importPossibilities.entrySet();
+            for (Entry<String, List<EndpointDescription>> entry : entries) {
+                triggerImport(entry.getKey());
+            }
+        }
     }
 
+    
+    /**
+     * This method is called once a RemoteServiceAdminEvent for an removed import reference
is received.
+     * However the current implementation has no special support for multiple topology managers,
therefore this method
+     * does nothing for the moment.
+     */
     public void removeImportReference(ImportReference anyObject) {
-        LOG.severe("NOT IMPLEMENTED !!!");
+        //LOG.severe("NOT IMPLEMENTED !!!");
     }
 
 }

Added: cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImportTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImportTest.java?rev=953701&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImportTest.java
(added)
+++ cxf/dosgi/trunk/dsw/cxf-topology-manager/src/test/java/org/apache/cxf/dosgi/topologymanager/TopologyManagerImportTest.java
Fri Jun 11 13:50:37 2010
@@ -0,0 +1,57 @@
+package org.apache.cxf.dosgi.topologymanager;
+
+import java.util.Dictionary;
+
+import org.easymock.IMocksControl;
+import org.easymock.classextension.EasyMock;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.ImportRegistration;
+import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
+
+import org.junit.Test;
+
+public class TopologyManagerImportTest {
+
+    
+    @Test
+    public void testImportForNewlyAddedRSA(){
+        
+        IMocksControl c = EasyMock.createNiceControl();
+
+        BundleContext bc = c.createMock(BundleContext.class);
+        ServiceRegistration sreg = c.createMock(ServiceRegistration.class);
+        EasyMock.expect(bc.registerService((String)EasyMock.anyObject(), EasyMock.anyObject(),
(Dictionary)EasyMock.anyObject())).andReturn(sreg).anyTimes();
+        
+        
+        EndpointDescription epd = c.createMock(EndpointDescription.class);
+        RemoteServiceAdmin rsa  = c.createMock(RemoteServiceAdmin.class);
+        ImportRegistration ireg = c.createMock(ImportRegistration.class);
+        
+        EasyMock.expect(rsa.importService(EasyMock.eq(epd))).andReturn(ireg).once();
+
+        c.replay();
+        
+        
+        RemoteServiceAdminList rsaList = new RemoteServiceAdminList(bc);
+        
+        TopologyManagerImport tm = new TopologyManagerImport(bc, rsaList);
+
+        tm.start();
+        
+        // no RSa available yet so no import ...  
+        tm.addImportableService("myFilter", epd);
+        
+        rsaList.add(rsa);
+        
+        tm.triggerExportImportForRemoteSericeAdmin(rsa);
+        
+        tm.stop();
+        
+        c.verify();
+        
+    }
+    
+}



Mime
View raw message