Author: donsez
Date: Sat Oct 20 13:51:33 2007
New Revision: 586798

URL: http://svn.apache.org/viewvc?rev=586798&view=rev
Log:
add org.osgi.service.ManagedService for configuration purpose

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

Modified: felix/sandbox/donsez/bunny/pom.xml
URL: 
http://svn.apache.org/viewvc/felix/sandbox/donsez/bunny/pom.xml?rev=586798&r1=586797&r2=586798&view=diff
==============================================================================
--- felix/sandbox/donsez/bunny/pom.xml (original)
+++ felix/sandbox/donsez/bunny/pom.xml Sat Oct 20 13:51:33 2007
@@ -65,7 +65,7 @@
                <!-- 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</Private-Package>
-            
<Import-Package>org.osgi.framework,org.apache.felix.shell</Import-Package>
+            
<Import-Package>org.osgi.framework,org.osgi.service.cm,org.apache.felix.shell</Import-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/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=586798&r1=586797&r2=586798&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
 Sat Oct 20 13:51:33 2007
@@ -18,25 +18,50 @@
  */
 package org.apache.felix.sandbox.bunny.impl;
 
+import java.util.Dictionary;
+import java.util.Hashtable;
+
 import org.apache.felix.sandbox.bunny.model.BunnyServiceModel;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
 
 
 /**
  * this class provides an activator to instanciate a bunny service
  * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
  */
-public class BunnyServiceActivator extends BunnyServiceModelImpl {
+public class BunnyServiceActivator extends BunnyServiceModelImpl implements 
ManagedService {
 
        private ServiceRegistration serviceRegistration;
        
        public void start(BundleContext bundleContext) throws Exception {
-               
serviceRegistration=bundleContext.registerService(BunnyServiceModel.class.getName(),
 this, null);
+               
+               Dictionary registrationProperties=new Hashtable();
+               registrationProperties.put(Constants.SERVICE_PID, 
bundleContext.getBundle().getSymbolicName());
+               
+               serviceRegistration=bundleContext.registerService(new 
String[]{BunnyServiceModel.class.getName(),ManagedService.class.getName()},
+                               this,
+                               registrationProperties);
        }
 
        public void stop(BundleContext bundleContext) throws Exception {
                if(serviceRegistration!=null) serviceRegistration.unregister();
+       }
+
+       public void updated(Dictionary conigurationProperties) throws 
ConfigurationException {
+//             try {
+               configure(
+                               (String) 
conigurationProperties.get("serialNumber"),
+                               (String) conigurationProperties.get("token"),
+                               (String) conigurationProperties.get("voice")
+                       );
+//             } catch (Exception e) {
+//                     ConfigurationException configurationException= new 
ConfigurationException();
+//                     throw configurationException;
+//             }
        }
 
 }

Modified: 
felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceModelImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceModelImpl.java?rev=586798&r1=586797&r2=586798&view=diff
==============================================================================
--- 
felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceModelImpl.java
 (original)
+++ 
felix/sandbox/donsez/bunny/src/main/java/org/apache/felix/sandbox/bunny/impl/BunnyServiceModelImpl.java
 Sat Oct 20 13:51:33 2007
@@ -29,6 +29,7 @@
 import java.text.MessageFormat;
 
 import org.apache.felix.sandbox.bunny.model.BunnyServiceModel;
+import org.osgi.framework.BundleContext;
 
 /**
  * this class provides implementation of a bunny service.
@@ -51,7 +52,14 @@
 
        private boolean trace=true;
 
+       private BundleContext bundleContext=null;
 
+
+       public BunnyServiceModelImpl(BundleContext bundleContext) {
+               this.bundleContext=bundleContext;
+               loadConfiguration();
+       }
+       
        public BunnyServiceModelImpl() {
                loadConfiguration();
        }
@@ -96,17 +104,17 @@
                MessageFormat messageFormat = new MessageFormat(urlString);
                urlString = messageFormat.format(arguments);
 
-               if (textToSpeech!=null) {
+               if (textToSpeech!=null && !textToSpeech.equals("")) {
                        urlString += "&tts="+URLEncoder.encode(textToSpeech);
                }
                
-               if (voice!=null) {
+               if (voice!=null && !voice.equals("")) {
                        urlString += "&voice=" + voice;
                } else if (this.voice!=null) {
                        urlString += "&voice=" + this.voice;
                }
 
-               if (chor!=null) {
+               if (chor!=null && !chor.equals("")) {
                        urlString += "&chor="+chor;
                }
 


Reply via email to