You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2016/09/09 20:49:23 UTC

svn commit: r1760111 - in /felix/sandbox/configurator/src: main/java/org/apache/felix/configurator/impl/ test/java/org/apache/felix/configurator/impl/

Author: cziegeler
Date: Fri Sep  9 20:49:23 2016
New Revision: 1760111

URL: http://svn.apache.org/viewvc?rev=1760111&view=rev
Log:
Adjust to new converter api

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=1760111&r1=1760110&r2=1760111&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 Fri Sep  9 20:49:23 2016
@@ -26,7 +26,6 @@ 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
@@ -41,9 +40,6 @@ 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;
 
@@ -56,10 +52,8 @@ public class ServicesListener {
     public ServicesListener(final BundleContext bundleContext) {
         this.bundleContext = bundleContext;
         this.caListener = new Listener(ConfigurationAdmin.class.getName());
-        this.converterListener = new Listener(Converter.class.getName());
         this.coordinatorListener = new Listener("org.osgi.service.coordinator.Coordinator");
         this.caListener.start();
-        this.converterListener.start();
         this.coordinatorListener.start();
         SystemLogger.debug("Started services listener for configurator.");
     }
@@ -71,15 +65,12 @@ 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();
-        SystemLogger.debug("Services updated for configurator: " + ca + " - " + converter + " - " + coordinator);
+        SystemLogger.debug("Services updated for configurator: " + ca + " - " + coordinator);
 
-        if ( ca != null && converter != null ) {
+        if ( ca != null ) {
             boolean isNew = configurator == null;
             if ( isNew ) {
-                TypeConverter.setConverter(converter);
-
                 SystemLogger.debug("Starting new configurator");
                 configurator = new Configurator(this.bundleContext, ca);
             }
@@ -102,7 +93,6 @@ 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=1760111&r1=1760110&r2=1760111&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 Fri Sep  9 20:49:23 2016
@@ -25,18 +25,13 @@ import java.util.List;
 
 import org.osgi.framework.Bundle;
 import org.osgi.service.converter.Converter;
+import org.osgi.service.converter.StandardConverter;
 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 converter;
+        return new StandardConverter();
     }
 
     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=1760111&r1=1760110&r2=1760111&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 Fri Sep  9 20:49:23 2016
@@ -18,6 +18,11 @@
  */
 package org.apache.felix.configurator.impl;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 import java.io.IOException;
 import java.lang.reflect.Array;
 import java.util.Collection;
@@ -25,21 +30,10 @@ import java.util.Map;
 
 import org.apache.felix.configurator.impl.yaml.YAMLUtil;
 import org.apache.felix.configurator.impl.yaml.YAMLUtilTest;
-import org.junit.Before;
 import org.junit.Test;
-import org.osgi.service.converter.util.ConverterFactory;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
 
 public class TypeConverterTest {
 
-    @Before public void setup() {
-        TypeConverter.setConverter(ConverterFactory.standardConverter());
-    }
-
     @Test public void testStringConversionNoTypeInfo() throws IOException {
         final String v_String = "world";
         final TypeConverter converter = new TypeConverter(null);