Author: davidb
Date: Thu Jul  7 15:42:29 2016
New Revision: 1751810

URL: http://svn.apache.org/viewvc?rev=1751810&view=rev
Log:
Felix Converter Service - fix a bug with improper recursion.

Added:
    
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/InternalConverter.java
    
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/InternalConverting.java
Modified:
    
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java
    
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConverterImpl.java
    
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java

Modified: 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java?rev=1751810&r1=1751809&r2=1751810&view=diff
==============================================================================
--- 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java
 (original)
+++ 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/AdapterImpl.java
 Thu Jul  7 15:42:29 2016
@@ -29,18 +29,19 @@ import org.osgi.service.converter.Functi
 import org.osgi.service.converter.Rule;
 import org.osgi.service.converter.TypeReference;
 
-public class AdapterImpl implements Adapter {
-    private final Converter delegate;
+public class AdapterImpl implements Adapter, InternalConverter {
+    private final InternalConverter delegate;
     private final Map<TypePair, FunctionThrowsException<Object, Object>> 
classRules =
             new ConcurrentHashMap<>();
 
-    public AdapterImpl(Converter converter) {
+    AdapterImpl(InternalConverter converter) {
         this.delegate = converter;
     }
 
     @Override
-    public Converting convert(Object obj) {
-        Converting converting = delegate.convert(obj);
+    public InternalConverting convert(Object obj) {
+        InternalConverting converting = delegate.convert(obj);
+        converting.setConverter(this);
         return new ConvertingWrapper(obj, converting);
     }
 
@@ -87,13 +88,13 @@ public class AdapterImpl implements Adap
         return null;
     }
 
-    private class ConvertingWrapper implements Converting {
-        private final Converting del;
+    private class ConvertingWrapper implements InternalConverting {
+        private final InternalConverting del;
         private final Object object;
         private volatile Object defaultValue;
         private volatile boolean hasDefault;
 
-        ConvertingWrapper(Object obj, Converting c) {
+        ConvertingWrapper(Object obj, InternalConverting c) {
             object = obj;
             del = c;
         }
@@ -106,6 +107,11 @@ public class AdapterImpl implements Adap
             return this;
         }
 
+        @Override
+        public void setConverter(Converter c) {
+            del.setConverter(c);
+        }
+
         @SuppressWarnings("unchecked")
         @Override
         public <T> T to(Class<T> cls)  {

Modified: 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConverterImpl.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConverterImpl.java?rev=1751810&r1=1751809&r2=1751810&view=diff
==============================================================================
--- 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConverterImpl.java
 (original)
+++ 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConverterImpl.java
 Thu Jul  7 15:42:29 2016
@@ -17,17 +17,15 @@
 package org.apache.felix.converter.impl;
 
 import org.osgi.service.converter.Adapter;
-import org.osgi.service.converter.Converter;
-import org.osgi.service.converter.Converting;
 
-public class ConverterImpl implements Converter {
+public class ConverterImpl implements InternalConverter {
     @Override
     public Adapter getAdapter() {
         return new AdapterImpl(this);
     }
 
     @Override
-    public Converting convert(Object obj) {
+    public InternalConverting convert(Object obj) {
         return new ConvertingImpl(this, obj);
     }
 }

Modified: 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java?rev=1751810&r1=1751809&r2=1751810&view=diff
==============================================================================
--- 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java
 (original)
+++ 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/ConvertingImpl.java
 Thu Jul  7 15:42:29 2016
@@ -44,7 +44,7 @@ import org.osgi.service.converter.Conver
 import org.osgi.service.converter.Converting;
 import org.osgi.service.converter.TypeReference;
 
-public class ConvertingImpl implements Converting {
+public class ConvertingImpl implements Converting, InternalConverting {
     private static final Map<Class<?>, Class<?>> interfaceImplementations;
     static {
         Map<Class<?>, Class<?>> m = new HashMap<>();
@@ -73,6 +73,11 @@ public class ConvertingImpl implements C
         return this;
     }
 
+    @Override
+    public void setConverter(Converter c) {
+        converter = c;
+    }
+
     @SuppressWarnings("unchecked")
     @Override
     public <T> T to(Class<T> cls)  {

Added: 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/InternalConverter.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/InternalConverter.java?rev=1751810&view=auto
==============================================================================
--- 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/InternalConverter.java
 (added)
+++ 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/InternalConverter.java
 Thu Jul  7 15:42:29 2016
@@ -0,0 +1,23 @@
+/*
+ * 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.felix.converter.impl;
+
+import org.osgi.service.converter.Converter;
+
+public interface InternalConverter extends Converter {
+    public InternalConverting convert(Object obj);
+}

Added: 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/InternalConverting.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/InternalConverting.java?rev=1751810&view=auto
==============================================================================
--- 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/InternalConverting.java
 (added)
+++ 
felix/trunk/converter/src/main/java/org/apache/felix/converter/impl/InternalConverting.java
 Thu Jul  7 15:42:29 2016
@@ -0,0 +1,24 @@
+/*
+ * 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.felix.converter.impl;
+
+import org.osgi.service.converter.Converter;
+import org.osgi.service.converter.Converting;
+
+public interface InternalConverting extends Converting {
+    public void setConverter(Converter c);
+}


Reply via email to