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

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


The following commit(s) were added to refs/heads/main by this push:
     new e868d44  CAMEL-16183: Remove <proxy> in old spring xml XSD which is 
deprecated and no longer in use.
e868d44 is described below

commit e868d44b6e13a8ad9e90331f946bd99bc8d41cac
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Tue Sep 21 15:54:02 2021 +0200

    CAMEL-16183: Remove <proxy> in old spring xml XSD which is deprecated and 
no longer in use.
---
 .../org/apache/camel/cdi/XmlCdiBeanFactory.java    | 27 ------
 .../org/apache/camel/cdi/XmlProxyFactoryBean.java  | 95 ----------------------
 .../camel/cdi/xml/CamelContextFactoryBean.java     | 12 ---
 .../apache/camel/cdi/test/XmlProxyFactoryTest.java | 68 ----------------
 4 files changed, 202 deletions(-)

diff --git 
a/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlCdiBeanFactory.java
 
b/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlCdiBeanFactory.java
index 3ffbcf2..8cd204e 100644
--- 
a/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlCdiBeanFactory.java
+++ 
b/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlCdiBeanFactory.java
@@ -44,7 +44,6 @@ import org.apache.camel.cdi.xml.RestContextDefinition;
 import org.apache.camel.cdi.xml.RouteContextDefinition;
 import org.apache.camel.cdi.xml.RouteTemplateContextDefinition;
 import org.apache.camel.core.xml.AbstractCamelFactoryBean;
-import org.apache.camel.core.xml.CamelProxyFactoryDefinition;
 import org.apache.camel.core.xml.CamelServiceExporterDefinition;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.model.IdentifiedType;
@@ -66,7 +65,6 @@ import static 
org.apache.camel.cdi.CdiSpiHelper.createCamelContextWithTCCL;
 import static org.apache.camel.cdi.DefaultLiteral.DEFAULT;
 import static org.apache.camel.cdi.ResourceHelper.getResource;
 import static org.apache.camel.cdi.Startup.Literal.STARTUP;
-import static org.apache.camel.util.ObjectHelper.isEmpty;
 import static org.apache.camel.util.ObjectHelper.isNotEmpty;
 
 @Vetoed
@@ -233,13 +231,6 @@ final class XmlCdiBeanFactory {
                     .forEach(beans::add);
         }
 
-        if (factory.getProxies() != null) {
-            factory.getProxies().stream()
-                    .filter(XmlCdiBeanFactory::hasId)
-                    .map(proxy -> proxyFactoryBean(context, proxy, url))
-                    .forEach(beans::add);
-        }
-
         // TODO: define in beans
         if (factory.getRedeliveryPolicies() != null) {
             factory.getRedeliveryPolicies().stream()
@@ -278,24 +269,6 @@ final class XmlCdiBeanFactory {
                         + "with qualifiers " + bean.getQualifiers());
     }
 
-    private SyntheticBean<?> proxyFactoryBean(Bean<?> context, 
CamelProxyFactoryDefinition proxy, URL url) {
-        if (isEmpty(proxy.getServiceUrl())) {
-            throw new CreationException(
-                    format("Missing serviceUrl attribute for imported bean 
[%s] from resource [%s]", proxy.getId(), url));
-        }
-
-        return new XmlProxyFactoryBean<>(
-                manager,
-                new SyntheticAnnotated(
-                        proxy.getServiceInterface(),
-                        
manager.createAnnotatedType(proxy.getServiceInterface()).getTypeClosure(),
-                        APPLICATION_SCOPED, ANY, 
NamedLiteral.of(proxy.getId())),
-                proxy.getServiceInterface(), bean -> "imported bean [" + 
proxy.getId() + "] "
-                                                     + "from resource [" + url 
+ "] "
-                                                     + "with qualifiers " + 
bean.getQualifiers(),
-                context, proxy);
-    }
-
     private SyntheticBean<?> serviceExporterBean(Bean<?> context, 
CamelServiceExporterDefinition exporter, URL url) {
         // TODO: replace with CreationException
         requireNonNull(exporter.getServiceRef(),
diff --git 
a/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlProxyFactoryBean.java
 
b/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlProxyFactoryBean.java
deleted file mode 100644
index 59f35a5..0000000
--- 
a/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlProxyFactoryBean.java
+++ /dev/null
@@ -1,95 +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.cdi;
-
-import java.util.function.Function;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.CreationException;
-import javax.enterprise.inject.UnsatisfiedResolutionException;
-import javax.enterprise.inject.Vetoed;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.FailedToCreateProducerException;
-import org.apache.camel.Producer;
-import org.apache.camel.core.xml.CamelProxyFactoryDefinition;
-
-import static org.apache.camel.cdi.BeanManagerHelper.getReference;
-import static org.apache.camel.cdi.BeanManagerHelper.getReferenceByName;
-import static org.apache.camel.component.bean.ProxyHelper.createProxy;
-import static org.apache.camel.support.service.ServiceHelper.startService;
-import static org.apache.camel.util.ObjectHelper.isNotEmpty;
-
-@Vetoed
-final class XmlProxyFactoryBean<T> extends SyntheticBean<T> {
-
-    private final BeanManager manager;
-
-    private final Bean<?> context;
-
-    private final CamelProxyFactoryDefinition proxy;
-
-    XmlProxyFactoryBean(BeanManager manager, SyntheticAnnotated annotated, 
Class<?> type, Function<Bean<T>, String> toString,
-                        Bean<?> context, CamelProxyFactoryDefinition proxy) {
-        super(manager, annotated, type, null, toString);
-        this.manager = manager;
-        this.context = context;
-        this.proxy = proxy;
-    }
-
-    @Override
-    public T create(CreationalContext<T> creationalContext) {
-        try {
-            CamelContext context = isNotEmpty(proxy.getCamelContextId())
-                    ? getReferenceByName(manager, proxy.getCamelContextId(), 
CamelContext.class).get()
-                    : getReference(manager, CamelContext.class, this.context);
-
-            Endpoint endpoint;
-            if (isNotEmpty(proxy.getServiceUrl())) {
-                endpoint = context.getEndpoint(proxy.getServiceUrl());
-            } else {
-                throw new IllegalStateException("serviceUrl must not be 
empty!");
-            }
-
-            if (endpoint == null) {
-                throw new UnsatisfiedResolutionException("Could not resolve 
endpoint: " + proxy.getServiceUrl());
-            }
-
-            try {
-                // Start the endpoint before we create the producer
-                startService(endpoint);
-                Producer producer = endpoint.createProducer();
-                // Add and start the producer
-                context.addService(producer, true, true);
-                return createProxy(endpoint, true, producer, (Class<T>) 
proxy.getServiceInterface());
-            } catch (Exception cause) {
-                throw new FailedToCreateProducerException(endpoint, cause);
-            }
-        } catch (Exception cause) {
-            throw new CreationException("Error while creating instance for " + 
this, cause);
-        }
-    }
-
-    @Override
-    public void destroy(T instance, CreationalContext<T> creationalContext) {
-        // We let the Camel context manage the lifecycle of the consumer and
-        // shut it down when Camel stops.
-    }
-}
diff --git 
a/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
 
b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
index 96b7170..318f1d3 100644
--- 
a/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
+++ 
b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
@@ -41,7 +41,6 @@ import 
org.apache.camel.core.xml.AbstractCamelContextFactoryBean;
 import org.apache.camel.core.xml.AbstractCamelFactoryBean;
 import org.apache.camel.core.xml.CamelJMXAgentDefinition;
 import org.apache.camel.core.xml.CamelPropertyPlaceholderDefinition;
-import org.apache.camel.core.xml.CamelProxyFactoryDefinition;
 import org.apache.camel.core.xml.CamelRouteControllerDefinition;
 import org.apache.camel.core.xml.CamelServiceExporterDefinition;
 import org.apache.camel.core.xml.CamelStreamCachingStrategyDefinition;
@@ -243,9 +242,6 @@ public class CamelContextFactoryBean extends 
AbstractCamelContextFactoryBean<Def
     @XmlElement(name = "export", type = CamelServiceExporterDefinition.class)
     private List<CamelServiceExporterDefinition> exports;
 
-    @XmlElement(name = "proxy")
-    private List<CamelProxyFactoryDefinition> proxies;
-
     @XmlElement(name = "routeTemplateContextRef")
     private List<RouteTemplateContextRefDefinition> routeTemplateRefs = new 
ArrayList<>();
 
@@ -1059,14 +1055,6 @@ public class CamelContextFactoryBean extends 
AbstractCamelContextFactoryBean<Def
         this.dependsOn = dependsOn;
     }
 
-    public List<CamelProxyFactoryDefinition> getProxies() {
-        return proxies;
-    }
-
-    public void setProxies(List<CamelProxyFactoryDefinition> proxies) {
-        this.proxies = proxies;
-    }
-
     public List<CamelServiceExporterDefinition> getExports() {
         return exports;
     }
diff --git 
a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlProxyFactoryTest.java
 
b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlProxyFactoryTest.java
deleted file mode 100644
index a6eb4af..0000000
--- 
a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlProxyFactoryTest.java
+++ /dev/null
@@ -1,68 +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.cdi.test;
-
-import java.nio.file.Paths;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.apache.camel.cdi.CdiCamelExtension;
-import org.apache.camel.cdi.ImportResource;
-import org.apache.camel.cdi.bean.Service;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.EmptyAsset;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-
-@RunWith(Arquillian.class)
-@ImportResource("imported-context.xml")
-public class XmlProxyFactoryTest {
-
-    @Named
-    @Inject
-    private Service proxy;
-
-    @Deployment
-    public static Archive<?> deployment() {
-        return ShrinkWrap.create(JavaArchive.class)
-                // Camel CDI
-                .addPackage(CdiCamelExtension.class.getPackage())
-                // Test Camel XML
-                .addAsResource(
-                        
Paths.get("src/test/resources/camel-context-proxy.xml").toFile(),
-                        "imported-context.xml")
-                // Bean archive deployment descriptor
-                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
-    }
-
-    @Test
-    public void sendMessageToProxy() {
-        String response = proxy.service("request");
-
-        assertThat("Proxy response is incorrect!",
-                response, is(equalTo("Service called with: [request]")));
-    }
-}

Reply via email to