This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 92d5ac3b0672650e7c2cf9af9bb19cf4952dbba3
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Tue Jun 25 10:08:22 2019 +0200

    camel3 - Remove deprecated TypeConverterAware
---
 MIGRATION.md                                       |  2 +
 .../org/apache/camel/spi/TypeConverterAware.java   | 37 --------------
 .../impl/converter/BaseTypeConverterRegistry.java  | 11 ----
 .../converter/InstanceMethodTypeConverter.java     |  9 ----
 .../camel/converter/TypeConverterAwareTest.java    | 40 ---------------
 .../myconverter/PurchaseOrderConverter.java        | 59 ----------------------
 6 files changed, 2 insertions(+), 156 deletions(-)

diff --git a/MIGRATION.md b/MIGRATION.md
index 8a2f453..251eb9e 100644
--- a/MIGRATION.md
+++ b/MIGRATION.md
@@ -264,6 +264,8 @@ The classes `ReloadStrategySupport` and 
`FileWatcherReloadStrategy` has been rem
 
 The `MessageHistoryFactory` interface has some options to filter and copy the 
message and a slight change in its API.
 
+Remove 'TypeConverterAware' as you shoudld instead use `Exchange` as parameter 
to the type converter method.
+
 #### camel-test
 
 If you are using camel-test and override the `createRegistry` method, for 
example to register beans from the `JndiRegisty` class, then this is no longer 
necessary, and instead
diff --git 
a/core/camel-api/src/main/java/org/apache/camel/spi/TypeConverterAware.java 
b/core/camel-api/src/main/java/org/apache/camel/spi/TypeConverterAware.java
deleted file mode 100644
index 2a83829..0000000
--- a/core/camel-api/src/main/java/org/apache/camel/spi/TypeConverterAware.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.camel.spi;
-
-import org.apache.camel.TypeConverter;
-
-/**
- * An interface for an object which is interested in being injected with the 
root {@link TypeConverter}
- * such as for implementing a fallback type converter
- *
- * @see TypeConverterRegistry
- * @deprecated to be removed in the near future
- */
-@Deprecated
-public interface TypeConverterAware {
-
-    /**
-     * Injects the root type converter.
-     *
-     * @param parentTypeConverter the root type converter
-     */
-    void setTypeConverter(TypeConverter parentTypeConverter);
-}
diff --git 
a/core/camel-base/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
 
b/core/camel-base/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
index 958c4f2..acc58b2 100644
--- 
a/core/camel-base/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
+++ 
b/core/camel-base/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
@@ -52,7 +52,6 @@ import org.apache.camel.spi.CamelLogger;
 import org.apache.camel.spi.FactoryFinder;
 import org.apache.camel.spi.Injector;
 import org.apache.camel.spi.PackageScanClassResolver;
-import org.apache.camel.spi.TypeConverterAware;
 import org.apache.camel.spi.TypeConverterLoader;
 import org.apache.camel.spi.TypeConverterRegistry;
 import org.apache.camel.support.MessageHelper;
@@ -399,11 +398,6 @@ public abstract class BaseTypeConverterRegistry extends 
ServiceSupport implement
         // the last one which is add to the FallbackTypeConverter will be 
called at the first place
         fallbackConverters.add(0, new FallbackTypeConverter(typeConverter, 
canPromote));
 
-        // TODO: Remove this in the near future as this is no longer needed 
(you can use exchange as parameter)
-        if (typeConverter instanceof TypeConverterAware) {
-            TypeConverterAware typeConverterAware = (TypeConverterAware) 
typeConverter;
-            typeConverterAware.setTypeConverter(this);
-        }
         if (typeConverter instanceof CamelContextAware) {
             CamelContextAware camelContextAware = (CamelContextAware) 
typeConverter;
             if (camelContext != null) {
@@ -419,11 +413,6 @@ public abstract class BaseTypeConverterRegistry extends 
ServiceSupport implement
         // the last one which is add to the FallbackTypeConverter will be 
called at the first place
         converters.add(0, new FallbackTypeConverter(typeConverter, 
canPromote));
 
-        // TODO: Remove this in the near future as this is no longer needed 
(you can use exchange as parameter)
-        if (typeConverter instanceof TypeConverterAware) {
-            TypeConverterAware typeConverterAware = (TypeConverterAware) 
typeConverter;
-            typeConverterAware.setTypeConverter(this);
-        }
         if (typeConverter instanceof CamelContextAware) {
             CamelContextAware camelContextAware = (CamelContextAware) 
typeConverter;
             if (camelContext != null) {
diff --git 
a/core/camel-base/src/main/java/org/apache/camel/impl/converter/InstanceMethodTypeConverter.java
 
b/core/camel-base/src/main/java/org/apache/camel/impl/converter/InstanceMethodTypeConverter.java
index 2eb0927..02fc8a5 100644
--- 
a/core/camel-base/src/main/java/org/apache/camel/impl/converter/InstanceMethodTypeConverter.java
+++ 
b/core/camel-base/src/main/java/org/apache/camel/impl/converter/InstanceMethodTypeConverter.java
@@ -21,7 +21,6 @@ import java.lang.reflect.Method;
 import org.apache.camel.Exchange;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.TypeConverter;
-import org.apache.camel.spi.TypeConverterAware;
 import org.apache.camel.spi.TypeConverterRegistry;
 import org.apache.camel.support.ObjectHelper;
 import org.apache.camel.support.TypeConverterSupport;
@@ -61,14 +60,6 @@ public class InstanceMethodTypeConverter extends 
TypeConverterSupport {
         if (instance == null) {
             throw new RuntimeCamelException("Could not instantiate an instance 
of: " + type.getCanonicalName());
         }
-        // inject parent type converter
-        // TODO: Remove this in the near future as this is no longer needed 
(you can use exchange as parameter)
-        if (instance instanceof TypeConverterAware) {
-            if (registry instanceof TypeConverter) {
-                TypeConverter parentTypeConverter = (TypeConverter) registry;
-                ((TypeConverterAware) 
instance).setTypeConverter(parentTypeConverter);
-            }
-        }
         return useExchange
             ? (T)ObjectHelper.invokeMethod(method, instance, value, exchange) 
: (T) ObjectHelper
                 .invokeMethod(method, instance, value);
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/converter/TypeConverterAwareTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/converter/TypeConverterAwareTest.java
deleted file mode 100644
index 4b916c8..0000000
--- 
a/core/camel-core/src/test/java/org/apache/camel/converter/TypeConverterAwareTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.camel.converter;
-
-import org.apache.camel.ContextTestSupport;
-import org.junit.Test;
-
-public class TypeConverterAwareTest extends ContextTestSupport {
-
-    @Override
-    protected boolean isLoadTypeConverters() {
-        return true;
-    }
-
-    @Test
-    public void testPurchaseOrderConverter() throws Exception {
-        byte[] data = "##START##AKC4433   179       3##END##".getBytes();
-        PurchaseOrder order = 
context.getTypeConverter().convertTo(PurchaseOrder.class, data);
-        assertNotNull(order);
-
-        assertEquals("AKC4433", order.getName());
-        assertEquals("179.00", order.getPrice().toString());
-        assertEquals(3, order.getAmount());
-    }
-
-}
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/converter/myconverter/PurchaseOrderConverter.java
 
b/core/camel-core/src/test/java/org/apache/camel/converter/myconverter/PurchaseOrderConverter.java
deleted file mode 100644
index c49258a..0000000
--- 
a/core/camel-core/src/test/java/org/apache/camel/converter/myconverter/PurchaseOrderConverter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.camel.converter.myconverter;
-
-import java.math.BigDecimal;
-
-import org.apache.camel.Converter;
-import org.apache.camel.TypeConverter;
-import org.apache.camel.converter.PurchaseOrder;
-import org.apache.camel.spi.TypeConverterAware;
-
-@Converter
-public class PurchaseOrderConverter implements TypeConverterAware {
-
-    private TypeConverter converter;
-
-    public void setTypeConverter(TypeConverter parentTypeConverter) {
-        this.converter = parentTypeConverter;
-    }
-
-    @Converter
-    public PurchaseOrder toPurchaseOrder(byte[] data) {
-        String s = converter.convertTo(String.class, data);
-
-        if (s == null || s.length() < 30) {
-            throw new IllegalArgumentException("data is invalid");
-        }
-
-        s = s.replaceAll("##START##", "");
-        s = s.replaceAll("##END##", "");
-
-        String name = s.substring(0, 9).trim();
-        String s2 = s.substring(10, 19).trim();
-        String s3 = s.substring(20).trim();
-
-        BigDecimal price = new BigDecimal(s2);
-        price = price.setScale(2);
-
-        Integer amount = converter.convertTo(Integer.class, s3);
-
-        PurchaseOrder order = new PurchaseOrder(name, price, amount);
-        return order;
-    }
-
-}

Reply via email to