felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1752583 - in /felix/sandbox/configurator/src: main/java/org/apache/felix/configurator/impl/ test/java/org/apache/felix/configurator/impl/
Date Thu, 14 Jul 2016 04:22:10 GMT
Author: cziegeler
Date: Thu Jul 14 04:22:10 2016
New Revision: 1752583

URL: http://svn.apache.org/viewvc?rev=1752583&view=rev
Log:
Use converter as a service

Modified:
    felix/sandbox/configurator/src/main/java/org/apache/felix/configurator/impl/ServicesListener.java
    felix/sandbox/configurator/src/main/java/org/apache/felix/configurator/impl/TypeConverter.java
    felix/sandbox/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java

Modified: felix/sandbox/configurator/src/main/java/org/apache/felix/configurator/impl/ServicesListener.java
URL: http://svn.apache.org/viewvc/felix/sandbox/configurator/src/main/java/org/apache/felix/configurator/impl/ServicesListener.java?rev=1752583&r1=1752582&r2=1752583&view=diff
==============================================================================
--- felix/sandbox/configurator/src/main/java/org/apache/felix/configurator/impl/ServicesListener.java
(original)
+++ felix/sandbox/configurator/src/main/java/org/apache/felix/configurator/impl/ServicesListener.java
Thu Jul 14 04:22:10 2016
@@ -25,6 +25,7 @@ import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.converter.Converter;
 
 /**
  * The {@code ServicesListener} listens for the required services
@@ -39,6 +40,9 @@ public class ServicesListener {
     /** The listener for the config admin. */
     private final Listener caListener;
 
+    /** The listener for the converter. */
+    private final Listener converterListener;
+
     /** The listener for the coordinator. */
     private final Listener coordinatorListener;
 
@@ -52,6 +56,8 @@ public class ServicesListener {
         this.bundleContext = bundleContext;
         this.caListener = new Listener(ConfigurationAdmin.class.getName());
         this.caListener.start();
+        this.converterListener = new Listener(Converter.class.getName());
+        this.converterListener.start();
         this.coordinatorListener = new Listener("org.osgi.service.coordinator.Coordinator");
         this.coordinatorListener.start();
     }
@@ -63,11 +69,13 @@ public class ServicesListener {
     public synchronized void notifyChange() {
         // check if all services are available
         final ConfigurationAdmin ca = (ConfigurationAdmin)this.caListener.getService();
+        final Converter converter = (Converter)this.converterListener.getService();
         final Object coordinator = this.coordinatorListener.getService();
-        if ( ca != null ) {
+        if ( ca != null && converter != null ) {
             if ( configurator == null ) {
                 configurator = new Configurator(this.bundleContext, ca);
             }
+            TypeConverter.setConverter(converter);
             configurator.setCoordinator(coordinator);
         } else {
             if ( configurator != null ) {
@@ -83,6 +91,7 @@ public class ServicesListener {
     public void deactivate() {
         this.caListener.deactivate();
         this.coordinatorListener.deactivate();
+        this.converterListener.deactivate();
         if ( configurator != null ) {
             configurator.shutdown();
             configurator = null;

Modified: felix/sandbox/configurator/src/main/java/org/apache/felix/configurator/impl/TypeConverter.java
URL: http://svn.apache.org/viewvc/felix/sandbox/configurator/src/main/java/org/apache/felix/configurator/impl/TypeConverter.java?rev=1752583&r1=1752582&r2=1752583&view=diff
==============================================================================
--- felix/sandbox/configurator/src/main/java/org/apache/felix/configurator/impl/TypeConverter.java
(original)
+++ felix/sandbox/configurator/src/main/java/org/apache/felix/configurator/impl/TypeConverter.java
Thu Jul 14 04:22:10 2016
@@ -23,15 +23,20 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.felix.converter.impl.ConverterService;
 import org.osgi.framework.Bundle;
 import org.osgi.service.converter.Converter;
 import org.osgi.service.converter.TypeReference;
 
 public class TypeConverter {
 
+    private static volatile Converter converter;
+
+    public static void setConverter(final Converter c) {
+        converter = c;
+    }
+
     public static Converter getConverter() {
-        return new ConverterService(); // TODO use OSGi service
+        return converter;
     }
 
     private final List<File> allFiles = new ArrayList<File>();

Modified: felix/sandbox/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java?rev=1752583&r1=1752582&r2=1752583&view=diff
==============================================================================
--- felix/sandbox/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java
(original)
+++ felix/sandbox/configurator/src/test/java/org/apache/felix/configurator/impl/TypeConverterTest.java
Thu Jul 14 04:22:10 2016
@@ -30,10 +30,16 @@ import java.util.Map;
 
 import org.apache.felix.configurator.impl.yaml.YAMLUtil;
 import org.apache.felix.configurator.impl.yaml.YAMLUtilTest;
+import org.apache.felix.converter.impl.ConverterImpl;
+import org.junit.Before;
 import org.junit.Test;
 
 public class TypeConverterTest {
 
+    @Before public void setup() {
+        TypeConverter.setConverter(new ConverterImpl());
+    }
+
     @Test public void testStringConversionNoTypeInfo() throws IOException {
         final String v_String = "world";
         final TypeConverter converter = new TypeConverter(null);



Mime
View raw message