cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msch...@apache.org
Subject svn commit: r926967 - in /cxf/dosgi/trunk: distribution/single-bundle/ distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/ distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/ dsw/cxf-dsw/ dsw/cxf-dsw/src/...
Date Wed, 24 Mar 2010 08:04:21 GMT
Author: mschaaf
Date: Wed Mar 24 08:04:21 2010
New Revision: 926967

URL: http://svn.apache.org/viewvc?rev=926967&view=rev
Log:
Switched the DSW startup to Spring as outlined in DOSGI-66.

Added:
    cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/DSWActivator.java
    cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/DSWActivatorTest.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/resources/META-INF/
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/resources/META-INF/spring/
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/resources/META-INF/spring/dsw.xml
Modified:
    cxf/dosgi/trunk/distribution/single-bundle/pom.xml
    cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java
    cxf/dosgi/trunk/dsw/cxf-dsw/pom.xml
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java

Modified: cxf/dosgi/trunk/distribution/single-bundle/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/single-bundle/pom.xml?rev=926967&r1=926966&r2=926967&view=diff
==============================================================================
--- cxf/dosgi/trunk/distribution/single-bundle/pom.xml (original)
+++ cxf/dosgi/trunk/distribution/single-bundle/pom.xml Wed Mar 24 08:04:21 2010
@@ -239,7 +239,7 @@
     </dependency>  
     <dependency>
       <groupId>org.easymock</groupId>
-      <artifactId>easymock</artifactId>
+      <artifactId>easymockclassextension</artifactId>
       <scope>test</scope>
     </dependency>
   </dependencies>        

Modified: cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java?rev=926967&r1=926966&r2=926967&view=diff
==============================================================================
--- cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java
(original)
+++ cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/AggregatedActivator.java
Wed Mar 24 08:04:21 2010
@@ -28,6 +28,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.cxf.dosgi.dsw.Activator;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
@@ -122,6 +123,10 @@ public class AggregatedActivator impleme
             SPIActivator sba = new SPIActivator();
             sba.start(ctx);
             activators.add(sba);
+            
+            DSWActivator dsw = new DSWActivator();
+            dsw.start(ctx);
+            activators.add(dsw);
         } finally {
             Thread.currentThread().setContextClassLoader(oldClassLoader);
         }

Added: cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/DSWActivator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/DSWActivator.java?rev=926967&view=auto
==============================================================================
--- cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/DSWActivator.java
(added)
+++ cxf/dosgi/trunk/distribution/single-bundle/src/main/java/org/apache/cxf/dosgi/singlebundle/DSWActivator.java
Wed Mar 24 08:04:21 2010
@@ -0,0 +1,48 @@
+/** 
+ * 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.singlebundle;
+
+import org.apache.cxf.dosgi.dsw.Activator;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/*
+ * Starts the DSW in the singlebundle distribution 
+ * which would normally be done by the Spring OSGi Extender
+ * */
+public class DSWActivator implements BundleActivator {
+
+    private Activator dsw;
+
+    public void start(BundleContext ctx) throws Exception {
+        dsw = createActivator();
+        dsw.setBundleContext(ctx);
+        dsw.start();
+    }
+
+    public void stop(BundleContext ctx) throws Exception {
+        dsw.stop();
+    }
+
+    // separated for test case
+    protected Activator createActivator() {
+        return new Activator();
+    }
+
+}

Added: cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/DSWActivatorTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/DSWActivatorTest.java?rev=926967&view=auto
==============================================================================
--- cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/DSWActivatorTest.java
(added)
+++ cxf/dosgi/trunk/distribution/single-bundle/src/test/java/org/apache/cxf/dosgi/singlebundle/DSWActivatorTest.java
Wed Mar 24 08:04:21 2010
@@ -0,0 +1,66 @@
+/** 
+ * 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.singlebundle;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.dosgi.dsw.Activator;
+import org.easymock.classextension.EasyMock;
+import org.osgi.framework.BundleContext;
+
+public class DSWActivatorTest extends TestCase {
+
+    public void testStartStop() throws Exception{
+
+        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+        final Activator a = EasyMock.createNiceMock(Activator.class);
+        
+        a.setBundleContext(bc);
+        EasyMock.expectLastCall().atLeastOnce();
+        
+        a.start();
+        EasyMock.expectLastCall().once();
+                
+        EasyMock.replay(bc);
+        EasyMock.replay(a);
+        
+        DSWActivator da = new DSWActivator(){
+            protected org.apache.cxf.dosgi.dsw.Activator createActivator() {
+                return a;
+            };
+        };
+        
+        da.start(bc);
+        
+        EasyMock.verify(a);
+        EasyMock.reset(a);
+        
+        a.stop();
+        EasyMock.expectLastCall().once();
+
+        EasyMock.replay(a);
+        
+        da.stop(bc);
+        
+        EasyMock.verify(a);
+        EasyMock.verify(bc);
+        
+    }
+    
+}

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/pom.xml?rev=926967&r1=926966&r2=926967&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/pom.xml (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/pom.xml Wed Mar 24 08:04:21 2010
@@ -102,7 +102,6 @@
                         <Bundle-Description>This bundle contains the implementation
required by the CXF Distributed Software Bundle</Bundle-Description>
                         <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
                         <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
-                        <Bundle-Activator>org.apache.cxf.dosgi.dsw.Activator</Bundle-Activator>
                         <Import-Package>${bundle.import.package}</Import-Package>
                         <Export-Package>${bundle.export.package}</Export-Package>
                         <DynamicImport-Package>*</DynamicImport-Package>

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java?rev=926967&r1=926966&r2=926967&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java Wed
Mar 24 08:04:21 2010
@@ -37,8 +37,11 @@ import org.osgi.framework.ServiceRegistr
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedService;
 import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
+import org.springframework.osgi.context.BundleContextAware;
 
-public class Activator implements BundleActivator, ManagedService {
+
+// registered as spring bean -> start / stop called accordingly 
+public class Activator implements ManagedService,BundleContextAware {
 
     private final static Logger LOG = Logger.getLogger(Activator.class.getName());
 
@@ -50,19 +53,15 @@ public class Activator implements Bundle
 
     private ServiceRegistration decoratorReg;
 
-    public synchronized void start(BundleContext context) throws Exception {
+    public synchronized void start() {
         // Disable the fast infoset as it's not compatible (yet) with OSGi
         System.setProperty("org.apache.cxf.nofastinfoset", "true");
 
-        bc = context;
         // should we have a seperate PID for a find and publish hook ?
         // context.registerService(ManagedService.class.getName(), this, getDefaults());
 
         rsaFactory = registerRemoteServiceAdminService();
 
-        /**
-         * What is this decorator doing ?!?!?! Why as a service ?
-         */
         decoratorReg = bc.registerService(ServiceDecorator.class.getName(), new ServiceDecoratorImpl(bc),
                                           null);
 
@@ -106,8 +105,10 @@ public class Activator implements Bundle
         }
     }
 
-    public void stop(BundleContext context) {
+    public void stop() {
         LOG.fine("RemoteServiceAdmin Implementation is shutting down now");
+        
+        // This also triggers the unimport and unexport of the remote services
         rsaFactoryReg.unregister();
         decoratorReg.unregister();
 
@@ -121,16 +122,14 @@ public class Activator implements Bundle
         // unregister other registered services (ManagedService + Hooks)
     }
 
-    private Dictionary<String, String> getDefaults() {
-        Dictionary<String, String> defaults = new Hashtable<String, String>();
-        defaults.put(Constants.SERVICE_PID, CONFIG_SERVICE_PID);
-        return defaults;
-    }
-
     public synchronized void updated(Dictionary props) throws ConfigurationException {
         if (props != null && CONFIG_SERVICE_PID.equals(props.get(Constants.SERVICE_PID)))
{
             // topManager.updated(props);
         }
     }
 
+    public void setBundleContext(BundleContext bundleContext) {
+        bc = bundleContext;
+    }
+
 }

Added: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/resources/META-INF/spring/dsw.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/resources/META-INF/spring/dsw.xml?rev=926967&view=auto
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/resources/META-INF/spring/dsw.xml (added)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/resources/META-INF/spring/dsw.xml Wed Mar 24 08:04:21
2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+  
+  <bean name="dsw" class="org.apache.cxf.dosgi.dsw.Activator"
+        init-method="start" 
+        destroy-method="stop" 
+  />
+</beans>

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java?rev=926967&r1=926966&r2=926967&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java
Wed Mar 24 08:04:21 2010
@@ -72,8 +72,9 @@ public class ActivatorTest extends TestC
         control.replay();
         
         
-        Activator a = new Activator();   
-        a.start(bc);
+        Activator a = new Activator();
+        a.setBundleContext(bc);
+        a.start();
         
         control.verify();
         



Mime
View raw message