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 b56f2cf  CAMEL-15727: Remove xml exporter model that was no longer in 
use, removed from camel-cdi.
b56f2cf is described below

commit b56f2cf7ac4a79198cc0fdb36884c3a9a2fdbbf6
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Mon Jan 10 09:55:17 2022 +0100

    CAMEL-15727: Remove xml exporter model that was no longer in use, removed 
from camel-cdi.
---
 components/camel-cdi/pom.xml                       | 17 ++--
 .../org/apache/camel/cdi/XmlCdiBeanFactory.java    | 48 -----------
 .../apache/camel/cdi/XmlServiceExporterBean.java   | 98 ----------------------
 .../camel/cdi/xml/CamelContextFactoryBean.java     | 12 ---
 .../src/main/resources/META-INF/beans.xml          |  2 -
 .../camel/cdi/test/XmlServiceExporterTest.java     | 79 -----------------
 .../resources/org/apache/camel/core/xml/jaxb.index |  1 -
 .../core/xml/CamelServiceExporterDefinition.java   | 97 ---------------------
 8 files changed, 8 insertions(+), 346 deletions(-)

diff --git a/components/camel-cdi/pom.xml b/components/camel-cdi/pom.xml
index 8c5dd8a..02fd9f0 100644
--- a/components/camel-cdi/pom.xml
+++ b/components/camel-cdi/pom.xml
@@ -96,9 +96,8 @@
             
         </dependencies>
     </dependencyManagement>
-    <dependencies>
-        <!-- compile dependencies -->
 
+    <dependencies>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-support</artifactId>
@@ -109,15 +108,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-mock</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-bean</artifactId>
+            <artifactId>camel-jta</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
-            <artifactId>camel-jta</artifactId>
+            <artifactId>camel-mock</artifactId>
         </dependency>
 
         <!-- DeltaSpike is only used to provide Main support thus optional -->
@@ -129,7 +124,6 @@
         </dependency>
 
         <!-- provided dependencies -->
-
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-core-xml</artifactId>
@@ -152,6 +146,11 @@
         <!-- test dependencies -->
         <dependency>
             <groupId>org.apache.camel</groupId>
+            <artifactId>camel-bean</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
             <artifactId>camel-cloud</artifactId>
             <scope>test</scope>
         </dependency>
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 58af540..489b821e 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
@@ -19,11 +19,9 @@ package org.apache.camel.cdi;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
 import java.net.URL;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Stream;
 
@@ -45,7 +43,6 @@ import 
org.apache.camel.cdi.xml.RouteConfigurationContextDefinition;
 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.CamelServiceExporterDefinition;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.model.IdentifiedType;
 import org.apache.camel.model.OptionalIdentifiedDefinition;
@@ -66,7 +63,6 @@ import static 
org.apache.camel.cdi.ApplicationScopedLiteral.APPLICATION_SCOPED;
 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.isNotEmpty;
 
 @Vetoed
@@ -230,12 +226,6 @@ final class XmlCdiBeanFactory {
                     .forEach(beans::add);
         }
 
-        if (factory.getExports() != null) {
-            factory.getExports().stream()
-                    .map(export -> serviceExporterBean(context, export, url))
-                    .forEach(beans::add);
-        }
-
         // TODO: define in beans
         if (factory.getRedeliveryPolicies() != null) {
             factory.getRedeliveryPolicies().stream()
@@ -274,44 +264,6 @@ final class XmlCdiBeanFactory {
                         + "with qualifiers " + bean.getQualifiers());
     }
 
-    private SyntheticBean<?> serviceExporterBean(Bean<?> context, 
CamelServiceExporterDefinition exporter, URL url) {
-        // TODO: replace with CreationException
-        requireNonNull(exporter.getServiceRef(),
-                () -> format("Missing [%s] attribute for imported bean [%s] 
from resource [%s]",
-                        "serviceRef", Objects.toString(exporter.getId(), 
"export"), url));
-
-        Class<?> type;
-        if (exporter.getServiceInterface() != null) {
-            type = exporter.getServiceInterface();
-        } else {
-            Bean<?> bean = 
manager.resolve(manager.getBeans(exporter.getServiceRef()));
-            if (bean != null) {
-                type = bean.getBeanClass();
-            } else {
-                requireNonNull(exporter.getServiceInterface(),
-                        () -> format("Missing [%s] attribute for imported bean 
[%s] from resource [%s]",
-                                "serviceInterface", 
Objects.toString(exporter.getId(), "export"), url));
-                type = exporter.getServiceInterface();
-            }
-        }
-
-        Set<Type> types = new 
HashSet<>(manager.createAnnotatedType(type).getTypeClosure());
-        // Weld does not add Object.class for interfaces as they do not extend 
Object.class.
-        // Though let's add it so that it's possible to lookup by bean type 
Object.class
-        // beans whose bean class is an interface (for startup beans).
-        types.add(Object.class);
-
-        return new XmlServiceExporterBean<>(
-                manager,
-                new SyntheticAnnotated(
-                        type, types, APPLICATION_SCOPED, ANY, STARTUP,
-                        hasId(exporter) ? NamedLiteral.of(exporter.getId()) : 
DEFAULT),
-                type, bean -> "imported bean [" + 
Objects.toString(exporter.getId(), "export") + "] "
-                              + "from resource [" + url + "] "
-                              + "with qualifiers " + bean.getQualifiers(),
-                context, exporter);
-    }
-
     private SyntheticBean<?> restContextBean(RestContextDefinition definition, 
URL url) {
         requireNonNull(definition.getId(),
                 () -> format("Missing [%s] attribute for imported bean [%s] 
from resource [%s]",
diff --git 
a/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlServiceExporterBean.java
 
b/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlServiceExporterBean.java
deleted file mode 100644
index 3df61e2..0000000
--- 
a/components/camel-cdi/src/main/java/org/apache/camel/cdi/XmlServiceExporterBean.java
+++ /dev/null
@@ -1,98 +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.Consumer;
-import org.apache.camel.Endpoint;
-import org.apache.camel.FailedToCreateConsumerException;
-import org.apache.camel.component.bean.BeanProcessor;
-import org.apache.camel.core.xml.CamelServiceExporterDefinition;
-
-import static org.apache.camel.cdi.BeanManagerHelper.getReference;
-import static org.apache.camel.cdi.BeanManagerHelper.getReferenceByName;
-import static org.apache.camel.support.CamelContextHelper.getMandatoryEndpoint;
-import static org.apache.camel.support.service.ServiceHelper.initService;
-import static org.apache.camel.util.ObjectHelper.isNotEmpty;
-
-@Vetoed
-final class XmlServiceExporterBean<T> extends SyntheticBean<T> {
-
-    private final BeanManager manager;
-
-    private final Bean<?> context;
-
-    private final CamelServiceExporterDefinition exporter;
-
-    private final Class<?> type;
-
-    XmlServiceExporterBean(BeanManager manager, SyntheticAnnotated annotated, 
Class<?> type, Function<Bean<T>, String> toString,
-                           Bean<?> context, CamelServiceExporterDefinition 
exporter) {
-        super(manager, annotated, type, null, toString);
-        this.manager = manager;
-        this.context = context;
-        this.exporter = exporter;
-        this.type = type;
-    }
-
-    @Override
-    public T create(CreationalContext<T> creationalContext) {
-        try {
-            CamelContext context = isNotEmpty(exporter.getCamelContextId())
-                    ? getReferenceByName(manager, 
exporter.getCamelContextId(), CamelContext.class).get()
-                    : getReference(manager, CamelContext.class, this.context);
-
-            Bean<?> bean = 
manager.resolve(manager.getBeans(exporter.getServiceRef()));
-            if (bean == null) {
-                throw new UnsatisfiedResolutionException("No bean with name [" 
+ exporter.getServiceRef() + "] is deployed!");
-            }
-
-            @SuppressWarnings("unchecked")
-            T service = (T) manager.getReference(bean, type, 
manager.createCreationalContext(bean));
-
-            Endpoint endpoint = getMandatoryEndpoint(context, 
exporter.getUri());
-            try {
-                // need to start endpoint before we create consumer
-                initService(endpoint);
-                Consumer consumer = endpoint.createConsumer(new 
BeanProcessor(service, context));
-                // add and start consumer
-                context.addService(consumer, true, false);
-            } catch (Exception cause) {
-                throw new FailedToCreateConsumerException(endpoint, cause);
-            }
-
-            return service;
-        } 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 20c3745..d859554 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
@@ -42,7 +42,6 @@ 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.CamelRouteControllerDefinition;
-import org.apache.camel.core.xml.CamelServiceExporterDefinition;
 import org.apache.camel.core.xml.CamelStreamCachingStrategyDefinition;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.model.ContextScanDefinition;
@@ -249,9 +248,6 @@ public class CamelContextFactoryBean extends 
AbstractCamelContextFactoryBean<Def
     @XmlElement(name = "errorHandler", type = ErrorHandlerDefinition.class)
     private List<ErrorHandlerDefinition> errorHandlers;
 
-    @XmlElement(name = "export", type = CamelServiceExporterDefinition.class)
-    private List<CamelServiceExporterDefinition> exports;
-
     @XmlElement(name = "routeConfigurationContextRef")
     private List<RouteConfigurationContextRefDefinition> 
routeConfigurationRefs = new ArrayList<>();
 
@@ -1104,14 +1100,6 @@ public class CamelContextFactoryBean extends 
AbstractCamelContextFactoryBean<Def
         this.dependsOn = dependsOn;
     }
 
-    public List<CamelServiceExporterDefinition> getExports() {
-        return exports;
-    }
-
-    public void setExports(List<CamelServiceExporterDefinition> exports) {
-        this.exports = exports;
-    }
-
     public boolean isImplicitId() {
         return implicitId;
     }
diff --git a/components/camel-cdi/src/main/resources/META-INF/beans.xml 
b/components/camel-cdi/src/main/resources/META-INF/beans.xml
index 6faf557..e741d90 100644
--- a/components/camel-cdi/src/main/resources/META-INF/beans.xml
+++ b/components/camel-cdi/src/main/resources/META-INF/beans.xml
@@ -33,8 +33,6 @@
         <exclude name="org.apache.camel.cdi.XmlCdiJaxbContexts"/>
         <exclude name="org.apache.camel.cdi.XmlErrorHandlerFactoryBean"/>
         <exclude name="org.apache.camel.cdi.XmlFactoryBeanInjectionTarget"/>
-        <exclude name="org.apache.camel.cdi.XmlProxyFactoryBean"/>
-        <exclude name="org.apache.camel.cdi.XmlServiceExporterBean"/>
     </scan>
 
 </beans>
\ No newline at end of file
diff --git 
a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlServiceExporterTest.java
 
b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlServiceExporterTest.java
deleted file mode 100644
index e2e9d91..0000000
--- 
a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlServiceExporterTest.java
+++ /dev/null
@@ -1,79 +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.Named;
-
-import org.apache.camel.ProducerTemplate;
-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 XmlServiceExporterTest {
-
-    @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-export.xml").toFile(),
-                        "imported-context.xml")
-                // Bean archive deployment descriptor
-                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
-    }
-
-    @Test
-    public void sendMessageToService(ProducerTemplate service) {
-        String response = service.requestBody("direct:service", "request", 
String.class);
-        assertThat("Response is incorrect!", response,
-                is(equalTo("test response to [request]")));
-    }
-
-    @Test
-    public void invokeService(@Named("service") Service service) {
-        String response = service.service("request");
-        assertThat("Response is incorrect!", response,
-                is(equalTo("test response to [request]")));
-    }
-
-    @Named("implementation")
-    static class TestService implements Service {
-
-        @Override
-        public String service(String request) {
-            return "test response to [" + request + "]";
-        }
-    }
-}
diff --git 
a/core/camel-core-xml/src/generated/resources/org/apache/camel/core/xml/jaxb.index
 
b/core/camel-core-xml/src/generated/resources/org/apache/camel/core/xml/jaxb.index
index 309a9c2..bd6dcf4 100644
--- 
a/core/camel-core-xml/src/generated/resources/org/apache/camel/core/xml/jaxb.index
+++ 
b/core/camel-core-xml/src/generated/resources/org/apache/camel/core/xml/jaxb.index
@@ -4,5 +4,4 @@ CamelPropertyPlaceholderDefinition
 CamelPropertyPlaceholderFunctionDefinition
 CamelPropertyPlaceholderLocationDefinition
 CamelRouteControllerDefinition
-CamelServiceExporterDefinition
 CamelStreamCachingStrategyDefinition
diff --git 
a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelServiceExporterDefinition.java
 
b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelServiceExporterDefinition.java
deleted file mode 100644
index 78c2c4d..0000000
--- 
a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/CamelServiceExporterDefinition.java
+++ /dev/null
@@ -1,97 +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.core.xml;
-
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.camel.model.IdentifiedType;
-import org.apache.camel.spi.Metadata;
-
-/**
- * Used for export a service using Spring Remoting to hide the network call 
using an interface.
- */
-@Metadata(label = "spring,configuration")
-@XmlRootElement(name = "export")
-public class CamelServiceExporterDefinition extends IdentifiedType {
-
-    @XmlAttribute(required = true)
-    private String uri;
-    @XmlAttribute
-    private String serviceRef;
-    @XmlAttribute
-    private String method;
-    @XmlAttribute
-    private Class<?> serviceInterface;
-    @XmlAttribute
-    private String camelContextId;
-
-    public String getUri() {
-        return uri;
-    }
-
-    /**
-     * Camel endpoint uri to use a remote transport when calling the service
-     */
-    public void setUri(String uri) {
-        this.uri = uri;
-    }
-
-    public String getServiceRef() {
-        return serviceRef;
-    }
-
-    /**
-     * Reference to the service name to lookup in the registry.
-     */
-    public void setServiceRef(String serviceRef) {
-        this.serviceRef = serviceRef;
-    }
-
-    public String getMethod() {
-        return method;
-    }
-
-    /**
-     * Name of method to invoke on service
-     */
-    public void setMethod(String method) {
-        this.method = method;
-    }
-
-    public Class<?> getServiceInterface() {
-        return serviceInterface;
-    }
-
-    /**
-     * Java interfaces to use as facade for the service to be exported
-     */
-    public void setServiceInterface(Class<?> serviceInterface) {
-        this.serviceInterface = serviceInterface;
-    }
-
-    public String getCamelContextId() {
-        return camelContextId;
-    }
-
-    /**
-     * The id of the CamelContext to use, if there is multiple CamelContext in 
the same JVM.
-     */
-    public void setCamelContextId(String camelContextId) {
-        this.camelContextId = camelContextId;
-    }
-}

Reply via email to