You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by do...@apache.org on 2007/11/02 23:04:29 UTC

svn commit: r591489 - in /felix/sandbox/donsez/bunny: pom.xml src/main/java/org/apache/felix/sandbox/bunny/activator/Activator.java src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceActivator.java

Author: donsez
Date: Fri Nov  2 15:04:20 2007
New Revision: 591489

URL: http://svn.apache.org/viewvc?rev=591489&view=rev
Log:
set felix shell dependency as a dynamic import in order to start without the felix shell (eg Equinox, KF, SMF, ProSyst ...) 

Modified:
    felix/sandbox/donsez/bunny/pom.xml
    felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/activator/Activator.java
    felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceActivator.java

Modified: felix/sandbox/donsez/bunny/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/bunny/pom.xml?rev=591489&r1=591488&r2=591489&view=diff
==============================================================================
--- felix/sandbox/donsez/bunny/pom.xml (original)
+++ felix/sandbox/donsez/bunny/pom.xml Fri Nov  2 15:04:20 2007
@@ -65,7 +65,8 @@
           	<!-- docs in http://cwiki.apache.org/FELIX/bundle-plugin-for-maven-bnd.html and http://cwiki.apache.org/FELIX/osgi-plugin-for-maven-2.html -->
           	
             <Private-Package>${pom.artifactId}.impl,${pom.artifactId}.activator,org.apache.felix.sandbox.rest</Private-Package>
-            <Import-Package>org.osgi.framework,org.osgi.service.cm,org.osgi.service.event,org.apache.felix.shell,javax.xml.parsers, org.w3c.dom, org.xml.sax, javax.xml.transform, javax.xml.transform.dom, javax.xml.transform.stream</Import-Package>
+            <Import-Package>org.osgi.framework,org.osgi.service.cm,org.osgi.service.event,javax.xml.parsers, org.w3c.dom, org.xml.sax, javax.xml.transform, javax.xml.transform.dom, javax.xml.transform.stream</Import-Package>
+            <DynamicImport-Package>org.apache.felix.shell</DynamicImport-Package>
             <Export-Package>${pom.artifactId}.model</Export-Package>
 
             <Bundle-Activator>${pom.artifactId}.activator.Activator</Bundle-Activator>

Modified: felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/activator/Activator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/activator/Activator.java?rev=591489&r1=591488&r2=591489&view=diff
==============================================================================
--- felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/activator/Activator.java (original)
+++ felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/activator/Activator.java Fri Nov  2 15:04:20 2007
@@ -18,8 +18,11 @@
  */
 package org.apache.felix.sandbox.bunny.activator;
 
+import java.lang.reflect.Constructor;
+
 import org.apache.felix.sandbox.bunny.impl.BunnyCommand;
 import org.apache.felix.sandbox.bunny.impl.BunnyServiceActivator;
+import org.apache.felix.sandbox.bunny.model.BunnyServiceModel;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 
@@ -31,19 +34,25 @@
 
 public class Activator implements BundleActivator {
 
-	BunnyServiceActivator bunnyServiceActivator;
-	BunnyCommand bunnyCommand;
+	BundleActivator bunnyServiceActivator;
+	BundleActivator bunnyCommand;
 	
 	public void start(BundleContext bundleContext) throws Exception {
 		bunnyServiceActivator=new BunnyServiceActivator();		
 		bunnyServiceActivator.start(bundleContext);
 		
-		bunnyCommand=new BunnyCommand(bunnyServiceActivator);
-		bunnyCommand.start(bundleContext);
+		try {
+			Class clazz=this.getClass().getClassLoader().loadClass("org.apache.felix.sandbox.bunny.impl.BunnyCommand");
+			Constructor constructor=clazz.getConstructor(new Class[]{BunnyServiceModel.class});
+			bunnyCommand=(BundleActivator) constructor.newInstance(new Object[] {bunnyServiceActivator } );
+			bunnyCommand.start(bundleContext);
+		} catch (ClassNotFoundException e) {
+			// silently do nothing
+		}
 	}
 	
 	public void stop(BundleContext bundleContext) throws Exception {
-		bunnyCommand.stop(bundleContext);
+		if(bunnyCommand!=null) bunnyCommand.stop(bundleContext);
 		bunnyServiceActivator.stop(bundleContext);
 	}
 }

Modified: felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceActivator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceActivator.java?rev=591489&r1=591488&r2=591489&view=diff
==============================================================================
--- felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceActivator.java (original)
+++ felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceActivator.java Fri Nov  2 15:04:20 2007
@@ -22,6 +22,7 @@
 import java.util.Hashtable;
 
 import org.apache.felix.sandbox.bunny.model.BunnyServiceModel;
+import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
@@ -37,7 +38,7 @@
  * and registers services (ManagedService, EventHandler)
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public class BunnyServiceActivator extends BunnyServiceModelImpl implements ManagedService, EventHandler {
+public class BunnyServiceActivator extends BunnyServiceModelImpl implements BundleActivator, ManagedService, EventHandler {
 
 	private ServiceRegistration serviceRegistration;
 	
@@ -85,14 +86,14 @@
 				(String) configurationProperties.get("voice")
 			);
 		
-		Object topic=configurationProperties.get("eventtopic");
+		Object topic=configurationProperties.get("eventTopic");
 		if(topic!=null) {
 			if (topic instanceof String[]) {
 				eventTopics=(String[])topic;
 				serviceRegistration.setProperties(getRegistrationProperties());
 			}
 		} else {
-			ConfigurationException configurationException= new ConfigurationException("eventtopic","must be a String[]");
+			ConfigurationException configurationException= new ConfigurationException("eventTopic","must be a String[]");
 			throw configurationException;	
 		}