You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/07/27 08:13:11 UTC
[camel] 01/05: CAMEL-13793: Support for multiple camel contexts on
various Camel annotations dropped as we only support 1 context per
app/deployment.
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 87998250fb56e561643e192874ba00c5ff3a1b9c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jul 27 09:17:39 2019 +0200
CAMEL-13793: Support for multiple camel contexts on various Camel annotations dropped as we only support 1 context per app/deployment.
---
MIGRATION.md | 17 +-
.../apache/camel/component/bean/MethodInfo.java | 20 +-
components/camel-cdi/src/main/docs/cdi.adoc | 214 +--------------------
.../camel/cdi/CdiCamelBeanPostProcessor.java | 60 ------
.../org/apache/camel/cdi/CdiCamelExtension.java | 10 +-
.../java/org/apache/camel/cdi/ContextName.java | 26 ---
.../camel/cdi/xml/ErrorHandlerDefinition.java | 2 +
.../cdi/bean/EndpointInjectWrongContextRoute.java | 36 ----
.../bean/FirstCamelContextProduceTemplateBean.java | 30 ---
.../bean/FirstCamelContextPropertyInjectBean.java | 38 ----
.../SecondCamelContextEndpointInjectRoute.java | 34 ----
.../SecondCamelContextProduceTemplateBean.java | 30 ---
.../bean/SecondCamelContextPropertyInjectBean.java | 38 ----
.../InjectedTypeConverterMultipleContextsTest.java | 1 +
.../cdi/test/MultiCamelContextProducerTest.java | 1 +
.../MultiCamelContextReusedRouteCdi20Test.java | 1 +
.../camel/cdi/test/MultiCamelContextTest.java | 1 +
.../cdi/test/MultiContextConsumerTemplateTest.java | 1 +
.../cdi/test/MultiContextEndpointInjectTest.java | 137 -------------
.../cdi/test/MultiContextEventEndpointTest.java | 1 +
.../cdi/test/MultiContextEventNotifierTest.java | 1 +
.../cdi/test/MultiContextProduceTemplateTest.java | 157 ---------------
.../cdi/test/MultiContextProducerTemplateTest.java | 137 -------------
.../cdi/test/MultiContextPropertyInjectTest.java | 193 -------------------
.../cdi/test/QualifiedMultiCamelContextTest.java | 1 +
.../test/RouteBuildersWithContextNamesTest.java | 113 -----------
.../UnsatisfiedContextForEndpointInjectTest.java | 58 ------
.../camel/cdi/test/XmlMultiContextsTest.java | 1 +
.../src/main/java/org/apache/camel/BeanInject.java | 4 -
.../main/java/org/apache/camel/BindToRegistry.java | 5 -
.../src/main/java/org/apache/camel/Consume.java | 5 -
.../main/java/org/apache/camel/DynamicRouter.java | 7 -
.../main/java/org/apache/camel/EndpointInject.java | 4 -
.../main/java/org/apache/camel/InvokeOnHeader.java | 2 +
.../java/org/apache/camel/InvokeOnHeaders.java | 2 +
.../src/main/java/org/apache/camel/Produce.java | 5 -
.../main/java/org/apache/camel/PropertyInject.java | 4 -
.../main/java/org/apache/camel/RecipientList.java | 5 -
.../main/java/org/apache/camel/RoutingSlip.java | 5 -
.../impl/engine/CamelPostProcessorHelper.java | 14 +-
.../impl/engine/DefaultCamelBeanPostProcessor.java | 24 +--
.../impl/engine/CamelPostProcessorHelperTest.java | 7 -
.../processor/routingslip/RoutingSlipPOJOTest.java | 2 +-
43 files changed, 51 insertions(+), 1403 deletions(-)
diff --git a/MIGRATION.md b/MIGRATION.md
index 1251c57..280c0c0 100644
--- a/MIGRATION.md
+++ b/MIGRATION.md
@@ -4,11 +4,10 @@ Apache Camel 3 Migration Guide
This document is intended for helping you migrate your Apache Camel applications
from version 2.x to 3.0.
-Before you start
-----------------
+Java versions
+-------------
-// TODO when we drop Java8
-// TODO Apache Camel 3 requires Java 11. Java 8 are no longer supported.
+Camel 3 supports Java 11. Support for Java 8 is best effort for the earlier versions of Camel 3. However at some time in the 3.x lifeline we will drop support for Java 8.
Modularization of camel-core
----------------------------
@@ -62,6 +61,14 @@ We have also modularized many of the core components and moved them out of `came
- camel-zip-deflater
+Multiple CamelContexts per application not supported
+----------------------------------------------------
+
+Support for multiple CamelContext's has been deprecated and only 1 CamelContext per deployment is supported.
+The latter was not recommended anyway and was also not 100% implemented (for example in camel-cdi). For Camel 3 only 1 CamelContext per deployment is recommended and supported.
+
+The `context` attribute on the various Camel annotations such as `@EndpointInject`, `@Produce`, `@Consume` etc has therefore been removed.
+
Migrating custom components
---------------------------
@@ -69,8 +76,6 @@ You should depend on `camel-support` and not `camel-core` directly.
The classes from `org.apache.camel.impl` that was intended to support Camel developers building custom components has been moved out of `camel-core` into `camel-support` into the `org.apache.camel.support` package. For example classes such as `DefaultComponent`, `DefaultEndpoint` etc has been moved and migration is necessary.
-// TODO: Should we create a camel2-support JAR with an adapter to bridge between 2.x and 3.0
-
Migrating custom languages
--------------------------
diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java
index 1fa3374..2bd512f 100644
--- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java
+++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java
@@ -124,7 +124,7 @@ public class MethodInfo {
org.apache.camel.RoutingSlip routingSlipAnnotation =
(org.apache.camel.RoutingSlip)collectedMethodAnnotation.get(org.apache.camel.RoutingSlip.class);
- if (routingSlipAnnotation != null && matchContext(routingSlipAnnotation.context())) {
+ if (routingSlipAnnotation != null) {
routingSlip = camelContext.adapt(ExtendedCamelContext.class).getAnnotationBasedProcessorFactory().createRoutingSlip(camelContext, routingSlipAnnotation);
// add created routingSlip as a service so we have its lifecycle managed
try {
@@ -136,8 +136,7 @@ public class MethodInfo {
org.apache.camel.DynamicRouter dynamicRouterAnnotation =
(org.apache.camel.DynamicRouter)collectedMethodAnnotation.get(org.apache.camel.DynamicRouter.class);
- if (dynamicRouterAnnotation != null
- && matchContext(dynamicRouterAnnotation.context())) {
+ if (dynamicRouterAnnotation != null) {
dynamicRouter = camelContext.adapt(ExtendedCamelContext.class).getAnnotationBasedProcessorFactory().createDynamicRouter(camelContext, dynamicRouterAnnotation);
// add created dynamicRouter as a service so we have its lifecycle managed
try {
@@ -149,8 +148,7 @@ public class MethodInfo {
org.apache.camel.RecipientList recipientListAnnotation =
(org.apache.camel.RecipientList)collectedMethodAnnotation.get(org.apache.camel.RecipientList.class);
- if (recipientListAnnotation != null
- && matchContext(recipientListAnnotation.context())) {
+ if (recipientListAnnotation != null) {
recipientList = camelContext.adapt(ExtendedCamelContext.class).getAnnotationBasedProcessorFactory().createRecipientList(camelContext, recipientListAnnotation);
// add created recipientList as a service so we have its lifecycle managed
try {
@@ -185,18 +183,6 @@ public class MethodInfo {
}
}
- /**
- * Does the given context match this camel context
- */
- private boolean matchContext(String context) {
- if (org.apache.camel.util.ObjectHelper.isNotEmpty(context)) {
- if (!camelContext.getName().equals(context)) {
- return false;
- }
- }
- return true;
- }
-
public String toString() {
return method.toString();
}
diff --git a/components/camel-cdi/src/main/docs/cdi.adoc b/components/camel-cdi/src/main/docs/cdi.adoc
index fecba27..05cf6548 100644
--- a/components/camel-cdi/src/main/docs/cdi.adoc
+++ b/components/camel-cdi/src/main/docs/cdi.adoc
@@ -14,11 +14,6 @@ bridges Camel events (e.g. `RouteAddedEvent`,
and provides a CDI events endpoint that can be used to consume / produce
CDI events from / to Camel routes.
-While the Camel CDI component is available as of **Camel 2.10**, it's
-been rewritten in *Camel 2.17* to better fit into the CDI programming
-model. Hence some of the features like the Camel events to CDI events
-bridge and the CDI events endpoint only apply starting Camel 2.17.
-
More details on how to test Camel CDI applications are available in
Camel CDI testing.
@@ -58,7 +53,7 @@ route is as simple as declaring a class, e.g.:
[source,java]
----
class MyRouteBean extends RouteBuilder {
-
+
@Override
public void configure() {
from("jms:invoices").to("file:/invoices");
@@ -71,8 +66,6 @@ Besides, `RouteContainer` beans are also automatically collected,
instantiated and added to the `CamelContext` bean instance managed by
Camel CDI when the container initializes.
-*Available as of Camel 2.19*
-
In some situations, it may be necessary to disable the auto-configuration of the `RouteBuilder` and `RouteContainer` beans. That can be achieved by observing for the `CdiCamelConfiguration` event, e.g.:
[source,java]
@@ -126,7 +119,7 @@ you can used the `@ContextName` qualifier provided by Camel CDI, e.g.:
----
@ContextName("camel-context")
class MyRouteBean extends RouteBuilder {
-
+
@Override
public void configure() {
from("jms:invoices").to("file:/invoices");
@@ -214,100 +207,6 @@ class ManualStartupCamelContext extends DefaultCamelContext {
}
----
-=== Multiple Camel contexts
-
-Any number of `CamelContext` beans can actually be declared in the
-application as documented above. In that case, the CDI qualifiers
-declared on these `CamelContext` beans are used to bind the Camel routes
-and other Camel primitives to the corresponding Camel contexts. From
-example, if the following beans get declared:
-
-[source,java]
-----
-@ApplicationScoped
-@ContextName("foo")
-class FooCamelContext extends DefaultCamelContext {
-}
-
-@ApplicationScoped
-@BarContextQualifier
-class BarCamelContext extends DefaultCamelContext {
-}
-
-@ContextName("foo")
-class RouteAddedToFooCamelContext extends RouteBuilder {
-
- @Override
- public void configure() {
- // ...
- }
-}
-
-@BarContextQualifier
-class RouteAddedToBarCamelContext extends RouteBuilder {
-
- @Override
- public void configure() {
- // ...
- }
-}
-
-@ContextName("baz")
-class RouteAddedToBazCamelContext extends RouteBuilder {
-
- @Override
- public void configure() {
- // ...
- }
-}
-
-@MyOtherQualifier
-class RouteNotAddedToAnyCamelContext extends RouteBuilder {
-
- @Override
- public void configure() {
- // ...
- }
-}
-----
-
-The `RoutesBuilder` beans qualified with `@ContextName` are
-automatically added to the corresponding `CamelContext` beans by Camel
-CDI. If no such `CamelContext` bean exists, it gets automatically
-created, as for the `RouteAddedToBazCamelContext` bean. Note this only
-happens for the `@ContextName` qualifier provided by Camel CDI. Hence
-the `RouteNotAddedToAnyCamelContext` bean qualified with the
-user-defined `@MyOtherQualifier` qualifier does not get added to any
-Camel contexts. That may be useful, for example, for Camel routes that
-may be required to be added later during the application execution.
-
-Camel CDI is capable of managing any kind of `CamelContext` beans (e.g. `DefaultCamelContext`).
-
-The CDI qualifiers declared on the `CamelContext` beans are also used to
-bind the corresponding Camel primitives, e.g.:
-
-[source,java]
-----
-@Inject
-@ContextName("foo")
-@Uri("direct:inbound")
-ProducerTemplate producerTemplate;
-
-@Inject
-@ContextName("foo")
-@Uri("direct:inbound")
-FluentProducerTemplate fluentProducerTemplate;
-
-@Inject
-@BarContextQualifier
-MockEndpoint outbound; // URI defaults to the member name, i.e. mock:outbound
-
-@Inject
-@ContextName("baz")
-@Uri("direct:inbound")
-Endpoint endpoint;
-----
-
=== Configuration properties
To configure the sourcing of the configuration properties used by Camel
@@ -450,16 +349,6 @@ Endpoint endpoint;
Endpoint endpoint;
----
-|Endpoint injection (Camel context by name) a|
-[source,java]
-----
-@EndpointInject(value = "direct:inbound",
- context = "foo")
-Endpoint contextEndpoint;
-----
-
- a|
-[source,java]
----
@Inject
@ContextName("foo")
@@ -564,8 +453,6 @@ PlatformTransactionManager createTransactionManager(TransactionManager transacti
=== Camel events to CDI events
-*Available as of Camel 2.17*
-
Camel provides a set
of http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/management/event/package-summary.html[management
events] that can be subscribed to for listening to Camel context,
@@ -581,7 +468,7 @@ void onContextStarting(@Observes CamelContextStartingEvent event) {
}
----
-As of Camel 2.18, it is possible to observe events for a particular route (`RouteAddedEvent`,
+It is possible to observe events for a particular route (`RouteAddedEvent`,
`RouteStartedEvent`, `RouteStoppedEvent` and `RouteRemovedEvent`) should it have
an explicit defined, e.g.:
@@ -631,8 +518,6 @@ detected in the deployment, and that per Camel context.
=== CDI events endpoint
-*Available as of Camel 2.17*
-
The CDI event endpoint bridges
the http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#events[CDI
events] with the Camel routes so that CDI events can be seamlessly
@@ -777,8 +662,6 @@ deployment phase.
=== Camel XML configuration import
-*Available as of Camel 2.18*
-
While CDI favors a typesafe dependency injection mechanism, it may be
useful to reuse existing Camel XML configuration files into a Camel CDI
application. In other use cases, it might be handy to rely on the Camel
@@ -862,8 +745,6 @@ configuration, e.g.:
=== Transaction support
-*Available as of Camel 2.19*
-
Camel CDI provides support for Camel transactional client using JTA.
That support is optional hence you need to have JTA in your application classpath, e.g., by explicitly add JTA as a dependency when using Maven:
@@ -959,29 +840,6 @@ class MyRouteBean extends CdiRouteBuilder {
----
-=== Auto-configured OSGi integration
-
-*Available as of Camel 2.17*
-
-The Camel context beans are automatically adapted by Camel CDI so that
-they are registered as OSGi services and the various resolvers
-(like `ComponentResolver` and `DataFormatResolver`) integrate with the
-OSGi registry. That means that the Karaf Camel commands
-can be used to operate the Camel contexts auto-configured by Camel CDI,
-e.g.:
-
-[source,text]
-----
-karaf@root()> camel:context-list
- Context Status Total # Failed # Inflight # Uptime
- ------- ------ ------- -------- ---------- ------
- camel-cdi Started 1 0 0 1 minute
-----
-
-See the `camel-example-cdi-osgi` example for a working example of the
-Camel CDI OSGi integration.
-
-
=== Lazy Injection / Programmatic Lookup
While the CDI programmatic model favors a http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#typesafe_resolution[typesafe resolution]
@@ -1077,72 +935,6 @@ a Camel CDI Maven project, e.g.:
mvn archetype:generate -DarchetypeGroupId=org.apache.camel.archetypes -DarchetypeArtifactId=camel-archetype-cdi
----
-=== Supported containers
-
-The Camel CDI component is compatible with any CDI 1.0, CDI 1.1 and CDI
-1.2 compliant runtime. It's been successfully tested against the
-following runtimes:
-
-[width="100%",cols="2,1m,2",options="header",]
-|============================================
-|Container |Version |Runtime
-|Weld SE |1.1.28.Final |CDI 1.0 / Java SE 7
-|OpenWebBeans |1.2.7 |CDI 1.0 / Java SE 7
-|Weld SE |2.4.2.Final |CDI 1.2 / Java SE 7
-|OpenWebBeans |1.7.2 |CDI 1.2 / Java SE 7
-|WildFly |8.2.1.Final |CDI 1.2 / Java EE 7
-|WildFly |9.0.1.Final |CDI 1.2 / Java EE 7
-|WildFly |10.1.0.Final |CDI 1.2 / Java EE 7
-|============================================
-
-
-=== Examples
-
-The following examples are available in the `examples` directory of the
-Camel project:
-
-[width="100%",cols="1m,3",options="header",]
-|===
-|Example |Description
-
-|camel-example-cdi
-|Illustrates how to work with Camel using CDI to configure components,
-endpoints and beans
-
-|camel-example-cdi-kubernetes
-|Illustrates the integration between Camel, CDI and Kubernetes
-
-|camel-example-cdi-metrics
-|Illustrates the integration between Camel, Dropwizard Metrics and CDI
-
-|camel-example-cdi-properties
-|Illustrates the integration between Camel, DeltaSpike and CDI for
-configuration properties
-
-|camel-example-cdi-osgi
-|A CDI application using the SJMS component that can be executed
-inside an OSGi container using PAX CDI
-
-|camel-example-cdi-rest-servlet
-|Illustrates the Camel REST DSL being used in a Web application that
-uses CDI as dependency injection framework
-
-|camel-example-cdi-test
-|Demonstrates the testing features that are provided as part of
-the integration between Camel and CDI
-
-|camel-example-cdi-xml
-|Illustrates the use of Camel XML configuration
-files into a Camel CDI application
-
-|camel-example-swagger-cdi
-|An example using REST DSL and Swagger Java with CDI
-
-|camel-example-widget-gadget-cdi
-|The Widget and Gadget use-case from the EIP book implemented
-in Java with CDI dependency Injection
-
-|===
=== See Also
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelBeanPostProcessor.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelBeanPostProcessor.java
index 4d33020..a959049 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelBeanPostProcessor.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelBeanPostProcessor.java
@@ -16,21 +16,14 @@
*/
package org.apache.camel.cdi;
-import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
-import javax.enterprise.inject.InjectionException;
import javax.enterprise.inject.UnsatisfiedResolutionException;
import javax.enterprise.inject.spi.BeanManager;
-import org.apache.camel.BeanInject;
import org.apache.camel.CamelContext;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.Produce;
-import org.apache.camel.PropertyInject;
import org.apache.camel.impl.engine.CamelPostProcessorHelper;
import org.apache.camel.impl.engine.DefaultCamelBeanPostProcessor;
-import org.apache.camel.util.ReflectionHelper;
import static org.apache.camel.cdi.BeanManagerHelper.getReferenceByType;
import static org.apache.camel.cdi.DefaultLiteral.DEFAULT;
@@ -42,63 +35,10 @@ final class CdiCamelBeanPostProcessor extends DefaultCamelBeanPostProcessor {
private final Map<String, CamelPostProcessorHelper> postProcessorHelpers = new HashMap<>();
- // TODO: proper support for multi Camel contexts and custom context qualifiers
CdiCamelBeanPostProcessor(BeanManager manager) {
this.manager = manager;
}
- // TODO: Not sure overriding this is needed
- protected void injectFields(final Object bean, final String beanName) {
- ReflectionHelper.doWithFields(bean.getClass(), field -> {
- PropertyInject propertyInject = field.getAnnotation(PropertyInject.class);
- if (propertyInject != null) {
- try {
- injectFieldProperty(field, propertyInject.value(), propertyInject.defaultValue(), propertyInject.context(), bean, beanName);
- } catch (Exception cause) {
- throw new InjectionException("Injection of [" + propertyInject + "] for field [" + field + "] failed!", cause);
- }
- }
-
- BeanInject beanInject = field.getAnnotation(BeanInject.class);
- // TODO: proper support for multi Camel contexts
- if (beanInject != null && getPostProcessorHelper().matchContext(beanInject.context())) {
- try {
- injectFieldBean(field, beanInject.value(), bean, beanName);
- } catch (Exception cause) {
- throw new InjectionException("Injection of [" + beanInject + "] for field [" + field + "] failed!", cause);
- }
- }
-
- EndpointInject endpointInject = field.getAnnotation(EndpointInject.class);
- if (endpointInject != null) {
- try {
- String uri = endpointInject.value().isEmpty() ? endpointInject.uri() : endpointInject.value();
- injectField(field, uri, endpointInject.property(), endpointInject.context(), bean, beanName);
- } catch (Exception cause) {
- throw new InjectionException("Injection of [" + endpointInject + "] for field [" + field + "] failed!", cause);
- }
- }
-
- Produce produce = field.getAnnotation(Produce.class);
- if (produce != null) {
- try {
- String uri = produce.value().isEmpty() ? produce.uri() : produce.value();
- injectField(field, uri, produce.property(), produce.context(), bean, beanName);
- } catch (Exception cause) {
- throw new InjectionException("Injection of [" + produce + "] for field [" + field + "] failed!", cause);
- }
- }
- });
- }
-
- private void injectField(Field field, String uri, String property, String context, Object bean, String beanName) {
- ReflectionHelper.setField(field, bean, getPostProcessorHelper(context).getInjectionValue(field.getType(), uri, property, field.getName(), bean, beanName));
- }
-
- private void injectFieldProperty(Field field, String property, String defaultValue, String context, Object bean, String beanName) {
- ReflectionHelper.setField(field, bean, getPostProcessorHelper(context).getInjectionPropertyValue(field.getType(), property, defaultValue, field.getName(), bean, beanName));
- }
-
private CamelPostProcessorHelper getPostProcessorHelper(String contextName) {
return postProcessorHelpers.computeIfAbsent(contextName, k -> new CamelPostProcessorHelper(getOrLookupCamelContext(k)));
}
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java
index ac557fd..af7b4a2 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java
@@ -353,11 +353,11 @@ public class CdiCamelExtension implements Extension {
.flatMap(Set::stream)
.map(Annotated::getAnnotations)
.flatMap(Set::stream)
- .anyMatch(isAnnotationType(Consume.class).and(a -> ((Consume) a).context().isEmpty())
- .or(isAnnotationType(BeanInject.class).and(a -> ((BeanInject) a).context().isEmpty()))
- .or(isAnnotationType(EndpointInject.class).and(a -> ((EndpointInject) a).context().isEmpty()))
- .or(isAnnotationType(Produce.class).and(a -> ((Produce) a).context().isEmpty()))
- .or(isAnnotationType(PropertyInject.class).and(a -> ((PropertyInject) a).context().isEmpty())))
+ .anyMatch(isAnnotationType(Consume.class)
+ .or(isAnnotationType(BeanInject.class))
+ .or(isAnnotationType(EndpointInject.class))
+ .or(isAnnotationType(Produce.class))
+ .or(isAnnotationType(PropertyInject.class)))
// Or an injection point for Camel primitives?
|| beans.stream()
// Excluding internal components...
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/ContextName.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/ContextName.java
index a134a3e..2b2fd27 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/ContextName.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/ContextName.java
@@ -36,33 +36,7 @@ import javax.inject.Qualifier;
* }
* </code></pre>
*
- * Camel resources like route builders, endpoints and producer templates can be annotated with
- * the {@code @ContextName} qualifier as well so that they are associated with the
- * corresponding Camel context, e.g.:
- *
- * <pre><code>
- * {@literal @}ContextName("foo")
- * public class FooRouteBuilder extends RouteBuilder {
- *
- * {@literal @}Override
- * public void configure() {
- * from("direct:bar").to("mock:bar");
- * }
- * }
- *
- * {@literal @}Inject
- * {@literal @}ContextName("foo")
- * {@literal @}Uri("direct:bar")
- * ProducerTemplate barProducer;
- *
- * {@literal @}Inject
- * {@literal @}ContextName("foo")
- * {@literal @}Uri("mock:bar")
- * MockEndpoint barMockEndpoint;
- * </code></pre>
- *
* @see org.apache.camel.CamelContext
- *
*/
@Qualifier
@Repeatable(ContextNames.class)
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/ErrorHandlerDefinition.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/ErrorHandlerDefinition.java
index 53a6bcc..4048f4e 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/ErrorHandlerDefinition.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/ErrorHandlerDefinition.java
@@ -47,6 +47,8 @@ public class ErrorHandlerDefinition extends IdentifiedType {
@XmlAttribute
private Boolean useOriginalMessage;
+ // TODO: add useOriginalBody
+
@XmlAttribute
private String transactionTemplateRef;
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectWrongContextRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectWrongContextRoute.java
deleted file mode 100644
index c1d01a0..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/EndpointInjectWrongContextRoute.java
+++ /dev/null
@@ -1,36 +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.bean;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.builder.RouteBuilder;
-
-public class EndpointInjectWrongContextRoute extends RouteBuilder {
-
- @EndpointInject("direct:inbound")
- private Endpoint inbound;
-
- // Wrong context name should lead to resolution exception
- @EndpointInject(value = "mock:outbound", context = "foo")
- private Endpoint outbound;
-
- @Override
- public void configure() {
- from(inbound).to(outbound);
- }
-}
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextProduceTemplateBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextProduceTemplateBean.java
deleted file mode 100644
index aca5fe4..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextProduceTemplateBean.java
+++ /dev/null
@@ -1,30 +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.bean;
-
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-
-public class FirstCamelContextProduceTemplateBean {
-
- @Produce(value = "mock:outbound", context = "first")
- private ProducerTemplate producer;
-
- public void sendToProducer(String body) {
- producer.sendBody(body + "-first");
- }
-}
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextPropertyInjectBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextPropertyInjectBean.java
deleted file mode 100644
index ce239e9..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/FirstCamelContextPropertyInjectBean.java
+++ /dev/null
@@ -1,38 +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.bean;
-
-import java.util.Map;
-
-import org.apache.camel.Handler;
-import org.apache.camel.Headers;
-import org.apache.camel.PropertyInject;
-
-public class FirstCamelContextPropertyInjectBean {
-
- @PropertyInject(value = "property", context = "first")
- private String property;
-
- @Handler
- public void process(@Headers Map<String, Object> headers) {
- headers.put("header", property);
- }
-
- public String getProperty() {
- return property;
- }
-}
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEndpointInjectRoute.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEndpointInjectRoute.java
deleted file mode 100644
index 3936923..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextEndpointInjectRoute.java
+++ /dev/null
@@ -1,34 +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.bean;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.cdi.ContextName;
-
-@ContextName("second")
-public class SecondCamelContextEndpointInjectRoute extends RouteBuilder {
-
- @EndpointInject(value = "direct:inbound", context = "second")
- private Endpoint inbound;
-
- @Override
- public void configure() {
- from(inbound).setHeader("context").constant("second").to("mock:outbound");
- }
-}
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextProduceTemplateBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextProduceTemplateBean.java
deleted file mode 100644
index c475d81..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextProduceTemplateBean.java
+++ /dev/null
@@ -1,30 +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.bean;
-
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
-
-public class SecondCamelContextProduceTemplateBean {
-
- @Produce(value = "mock:outbound", context = "second")
- private ProducerTemplate producer;
-
- public void sendToProducer(String body) {
- producer.sendBody(body + "-second");
- }
-}
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextPropertyInjectBean.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextPropertyInjectBean.java
deleted file mode 100644
index 0efa31d..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/bean/SecondCamelContextPropertyInjectBean.java
+++ /dev/null
@@ -1,38 +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.bean;
-
-import java.util.Map;
-
-import org.apache.camel.Handler;
-import org.apache.camel.Headers;
-import org.apache.camel.PropertyInject;
-
-public class SecondCamelContextPropertyInjectBean {
-
- @PropertyInject(value = "property", context = "second")
- private String property;
-
- @Handler
- public void process(@Headers Map<String, Object> headers) {
- headers.put("header", property);
- }
-
- public String getProperty() {
- return property;
- }
-}
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/InjectedTypeConverterMultipleContextsTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/InjectedTypeConverterMultipleContextsTest.java
index f43c52b..03a9e29 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/InjectedTypeConverterMultipleContextsTest.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/InjectedTypeConverterMultipleContextsTest.java
@@ -48,6 +48,7 @@ import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@RunWith(Arquillian.class)
+@Deprecated
public class InjectedTypeConverterMultipleContextsTest {
@Deployment
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextProducerTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextProducerTest.java
index 958e147..f22f11f 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextProducerTest.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextProducerTest.java
@@ -49,6 +49,7 @@ import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@RunWith(Arquillian.class)
+@Deprecated
public class MultiCamelContextProducerTest {
@Produces
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextReusedRouteCdi20Test.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextReusedRouteCdi20Test.java
index 20fe5c7..356fe72 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextReusedRouteCdi20Test.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextReusedRouteCdi20Test.java
@@ -41,6 +41,7 @@ import static org.apache.camel.cdi.expression.ExchangeExpression.fromCamelContex
import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
@RunWith(Arquillian.class)
+@Deprecated
public class MultiCamelContextReusedRouteCdi20Test {
@Inject
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextTest.java
index a46699f..020f888 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextTest.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiCamelContextTest.java
@@ -48,6 +48,7 @@ import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@RunWith(Arquillian.class)
+@Deprecated
public class MultiCamelContextTest {
@Inject
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextConsumerTemplateTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextConsumerTemplateTest.java
index 5d17d1f..2c21c62 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextConsumerTemplateTest.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextConsumerTemplateTest.java
@@ -42,6 +42,7 @@ import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@RunWith(Arquillian.class)
+@Deprecated
public class MultiContextConsumerTemplateTest {
@Inject
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEndpointInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEndpointInjectTest.java
deleted file mode 100644
index 777e3cc..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEndpointInjectTest.java
+++ /dev/null
@@ -1,137 +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.util.concurrent.TimeUnit;
-import javax.inject.Inject;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.cdi.CdiCamelExtension;
-import org.apache.camel.cdi.ContextName;
-import org.apache.camel.cdi.Uri;
-import org.apache.camel.cdi.bean.DefaultCamelContextBean;
-import org.apache.camel.cdi.bean.EndpointInjectRoute;
-import org.apache.camel.cdi.bean.FirstCamelContextBean;
-import org.apache.camel.cdi.bean.FirstCamelContextEndpointInjectRoute;
-import org.apache.camel.cdi.bean.SecondCamelContextBean;
-import org.apache.camel.cdi.bean.SecondCamelContextEndpointInjectRoute;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.junit.InSequence;
-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.apache.camel.cdi.expression.ExchangeExpression.fromCamelContext;
-import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
-
-@RunWith(Arquillian.class)
-public class MultiContextEndpointInjectTest {
-
- @Inject
- private CamelContext defaultCamelContext;
-
- @Inject @Uri("direct:inbound")
- private ProducerTemplate defaultInbound;
-
- @Inject @Uri("mock:outbound")
- private MockEndpoint defaultOutbound;
-
- @Inject @ContextName("first")
- private CamelContext firstCamelContext;
-
- @Inject @ContextName("first") @Uri("direct:inbound")
- private ProducerTemplate firstInbound;
-
- @Inject @ContextName("first") @Uri("mock:outbound")
- private MockEndpoint firstOutbound;
-
- @Inject @ContextName("second")
- private CamelContext secondCamelContext;
-
- @Inject @ContextName("second") @Uri("direct:inbound")
- private ProducerTemplate secondInbound;
-
- @Inject @ContextName("second") @Uri("mock:outbound")
- private MockEndpoint secondOutbound;
-
- @Deployment
- public static Archive<?> deployment() {
- return ShrinkWrap.create(JavaArchive.class)
- // Camel CDI
- .addPackage(CdiCamelExtension.class.getPackage())
- // Test classes
- .addClasses(
- DefaultCamelContextBean.class,
- EndpointInjectRoute.class,
- FirstCamelContextBean.class,
- FirstCamelContextEndpointInjectRoute.class,
- SecondCamelContextBean.class,
- SecondCamelContextEndpointInjectRoute.class)
- // Bean archive deployment descriptor
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Test
- @InSequence(1)
- public void configureCamelContexts() throws Exception {
- secondCamelContext.getRouteController().startAllRoutes();
- }
-
- @Test
- @InSequence(2)
- public void sendMessageToDefaultCamelContextInbound() throws InterruptedException {
- defaultOutbound.expectedMessageCount(1);
- defaultOutbound.expectedBodiesReceived("test-default");
- defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi"));
-
- defaultInbound.sendBody("test-default");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);
- }
-
- @Test
- @InSequence(3)
- public void sendMessageToFirstCamelContextInbound() throws InterruptedException {
- firstOutbound.expectedMessageCount(1);
- firstOutbound.expectedBodiesReceived("test-first");
- firstOutbound.expectedHeaderReceived("context", "first");
- firstOutbound.message(0).exchange().matches(fromCamelContext("first"));
-
- firstInbound.sendBody("test-first");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);
- }
-
- @Test
- @InSequence(4)
- public void sendMessageToSecondCamelContextInbound() throws InterruptedException {
- secondOutbound.expectedMessageCount(1);
- secondOutbound.expectedBodiesReceived("test-second");
- secondOutbound.expectedHeaderReceived("context", "second");
- secondOutbound.message(0).exchange().matches(fromCamelContext("second"));
-
- secondInbound.sendBody("test-second");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);
- }
-}
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventEndpointTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventEndpointTest.java
index 0d50d13..b7c0e55 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventEndpointTest.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventEndpointTest.java
@@ -53,6 +53,7 @@ import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertThat;
@RunWith(Arquillian.class)
+@Deprecated
public class MultiContextEventEndpointTest {
@Inject
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventNotifierTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventNotifierTest.java
index 45857ac..37167fd 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventNotifierTest.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextEventNotifierTest.java
@@ -64,6 +64,7 @@ import static org.hamcrest.Matchers.isOneOf;
import static org.junit.Assert.assertThat;
@RunWith(Arquillian.class)
+@Deprecated
public class MultiContextEventNotifierTest {
@Inject
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextProduceTemplateTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextProduceTemplateTest.java
deleted file mode 100644
index 02e3365..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextProduceTemplateTest.java
+++ /dev/null
@@ -1,157 +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.util.concurrent.TimeUnit;
-import javax.inject.Inject;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.cdi.CdiCamelExtension;
-import org.apache.camel.cdi.ContextName;
-import org.apache.camel.cdi.Uri;
-import org.apache.camel.cdi.bean.DefaultCamelContextBean;
-import org.apache.camel.cdi.bean.FirstCamelContextBean;
-import org.apache.camel.cdi.bean.FirstCamelContextProduceTemplateBean;
-import org.apache.camel.cdi.bean.ProduceTemplateBean;
-import org.apache.camel.cdi.bean.SecondCamelContextBean;
-import org.apache.camel.cdi.bean.SecondCamelContextProduceTemplateBean;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.junit.InSequence;
-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.apache.camel.cdi.expression.ExchangeExpression.fromCamelContext;
-import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
-
-@RunWith(Arquillian.class)
-public class MultiContextProduceTemplateTest {
-
- @Inject
- private CamelContext defaultCamelContext;
-
- @Inject @Uri("direct:inbound")
- private ProducerTemplate defaultInbound;
-
- @Inject @Uri("mock:outbound")
- private MockEndpoint defaultOutbound;
-
- @Inject @ContextName("first")
- private CamelContext firstCamelContext;
-
- @Inject @ContextName("first") @Uri("direct:inbound")
- private ProducerTemplate firstInbound;
-
- @Inject @ContextName("first") @Uri("mock:outbound")
- private MockEndpoint firstOutbound;
-
- @Inject @ContextName("second")
- private CamelContext secondCamelContext;
-
- @Inject @ContextName("second") @Uri("direct:inbound")
- private ProducerTemplate secondInbound;
-
- @Inject @ContextName("second") @Uri("mock:outbound")
- private MockEndpoint secondOutbound;
-
- @Deployment
- public static Archive<?> deployment() {
- return ShrinkWrap.create(JavaArchive.class)
- // Camel CDI
- .addPackage(CdiCamelExtension.class.getPackage())
- // Test classes
- .addClasses(
- DefaultCamelContextBean.class,
- ProduceTemplateBean.class,
- FirstCamelContextBean.class,
- FirstCamelContextProduceTemplateBean.class,
- SecondCamelContextBean.class,
- SecondCamelContextProduceTemplateBean.class)
- // Bean archive deployment descriptor
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Test
- @InSequence(1)
- public void configureCamelContexts() throws Exception {
- defaultCamelContext.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:inbound").bean(ProduceTemplateBean.class);
- }
- });
-
- firstCamelContext.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:inbound").bean(FirstCamelContextProduceTemplateBean.class);
- }
- });
-
- secondCamelContext.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:inbound").bean(SecondCamelContextProduceTemplateBean.class);
- }
- });
-
- secondCamelContext.getRouteController().startAllRoutes();
- }
-
- @Test
- @InSequence(2)
- public void sendMessageToDefaultCamelContextInbound() throws InterruptedException {
- defaultOutbound.expectedMessageCount(1);
- defaultOutbound.expectedBodiesReceived("test-processed");
- defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi"));
-
- defaultInbound.sendBody("test");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);
- }
-
- @Test
- @InSequence(3)
- public void sendMessageToFirstCamelContextInbound() throws InterruptedException {
- firstOutbound.expectedMessageCount(1);
- firstOutbound.expectedBodiesReceived("test-first");
- firstOutbound.message(0).exchange().matches(fromCamelContext("first"));
-
- firstInbound.sendBody("test");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);
- }
-
- @Test
- @InSequence(4)
- public void sendMessageToSecondCamelContextInbound() throws InterruptedException {
- secondOutbound.expectedMessageCount(1);
- secondOutbound.expectedBodiesReceived("test-second");
- secondOutbound.message(0).exchange().matches(fromCamelContext("second"));
-
- secondInbound.sendBody("test");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);
- }
-}
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextProducerTemplateTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextProducerTemplateTest.java
deleted file mode 100644
index 8324985..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextProducerTemplateTest.java
+++ /dev/null
@@ -1,137 +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.util.concurrent.TimeUnit;
-import javax.inject.Inject;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.cdi.CdiCamelExtension;
-import org.apache.camel.cdi.ContextName;
-import org.apache.camel.cdi.Uri;
-import org.apache.camel.cdi.bean.DefaultCamelContextBean;
-import org.apache.camel.cdi.bean.EndpointInjectRoute;
-import org.apache.camel.cdi.bean.FirstCamelContextBean;
-import org.apache.camel.cdi.bean.FirstCamelContextEndpointInjectRoute;
-import org.apache.camel.cdi.bean.SecondCamelContextBean;
-import org.apache.camel.cdi.bean.SecondCamelContextEndpointInjectRoute;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.junit.InSequence;
-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.apache.camel.cdi.expression.ExchangeExpression.fromCamelContext;
-import static org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
-
-@RunWith(Arquillian.class)
-public class MultiContextProducerTemplateTest {
-
- @Inject
- private CamelContext defaultCamelContext;
-
- @Inject
- private ProducerTemplate defaultInbound;
-
- @Inject @Uri("mock:outbound")
- private MockEndpoint defaultOutbound;
-
- @Inject @ContextName("first")
- private CamelContext firstCamelContext;
-
- @Inject @ContextName("first")
- private ProducerTemplate firstInbound;
-
- @Inject @ContextName("first") @Uri("mock:outbound")
- private MockEndpoint firstOutbound;
-
- @Inject @ContextName("second")
- private CamelContext secondCamelContext;
-
- @Inject @ContextName("second")
- private ProducerTemplate secondInbound;
-
- @Inject @ContextName("second") @Uri("mock:outbound")
- private MockEndpoint secondOutbound;
-
- @Deployment
- public static Archive<?> deployment() {
- return ShrinkWrap.create(JavaArchive.class)
- // Camel CDI
- .addPackage(CdiCamelExtension.class.getPackage())
- // Test classes
- .addClasses(
- DefaultCamelContextBean.class,
- EndpointInjectRoute.class,
- FirstCamelContextBean.class,
- FirstCamelContextEndpointInjectRoute.class,
- SecondCamelContextBean.class,
- SecondCamelContextEndpointInjectRoute.class)
- // Bean archive deployment descriptor
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Test
- @InSequence(1)
- public void configureCamelContexts() throws Exception {
- secondCamelContext.getRouteController().startAllRoutes();
- }
-
- @Test
- @InSequence(2)
- public void sendMessageToDefaultCamelContextInbound() throws InterruptedException {
- defaultOutbound.expectedMessageCount(1);
- defaultOutbound.expectedBodiesReceived("test-default");
- defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi"));
-
- defaultInbound.sendBody("direct:inbound", "test-default");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);
- }
-
- @Test
- @InSequence(3)
- public void sendMessageToFirstCamelContextInbound() throws InterruptedException {
- firstOutbound.expectedMessageCount(1);
- firstOutbound.expectedBodiesReceived("test-first");
- firstOutbound.expectedHeaderReceived("context", "first");
- firstOutbound.message(0).exchange().matches(fromCamelContext("first"));
-
- firstInbound.sendBody("direct:inbound", "test-first");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);
- }
-
- @Test
- @InSequence(4)
- public void sendMessageToSecondCamelContextInbound() throws InterruptedException {
- secondOutbound.expectedMessageCount(1);
- secondOutbound.expectedBodiesReceived("test-second");
- secondOutbound.expectedHeaderReceived("context", "second");
- secondOutbound.message(0).exchange().matches(fromCamelContext("second"));
-
- secondInbound.sendBody("direct:inbound", "test-second");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);
- }
-}
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextPropertyInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextPropertyInjectTest.java
deleted file mode 100644
index f02efb2..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/MultiContextPropertyInjectTest.java
+++ /dev/null
@@ -1,193 +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.util.Properties;
-import java.util.concurrent.TimeUnit;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Produces;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.cdi.CdiCamelExtension;
-import org.apache.camel.cdi.ContextName;
-import org.apache.camel.cdi.Uri;
-import org.apache.camel.cdi.bean.DefaultCamelContextBean;
-import org.apache.camel.cdi.bean.FirstCamelContextBean;
-import org.apache.camel.cdi.bean.FirstCamelContextPropertyInjectBean;
-import org.apache.camel.cdi.bean.PropertyInjectBean;
-import org.apache.camel.cdi.bean.SecondCamelContextBean;
-import org.apache.camel.cdi.bean.SecondCamelContextPropertyInjectBean;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.component.properties.PropertiesComponent;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.junit.InSequence;
-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.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-@RunWith(Arquillian.class)
-public class MultiContextPropertyInjectTest {
-
- @Inject
- private CamelContext defaultCamelContext;
-
- @Inject @Uri("direct:in")
- private ProducerTemplate defaultInbound;
-
- @Inject @Uri("mock:out")
- private MockEndpoint defaultOutbound;
-
- @Inject @ContextName("first")
- private CamelContext firstCamelContext;
-
- @Inject @ContextName("first") @Uri("direct:in")
- private ProducerTemplate firstInbound;
-
- @Inject @ContextName("first") @Uri("mock:out")
- private MockEndpoint firstOutbound;
-
- @Inject @ContextName("second")
- private CamelContext secondCamelContext;
-
- @Inject @ContextName("second") @Uri("direct:in")
- private ProducerTemplate secondInbound;
-
- @Inject @ContextName("second") @Uri("mock:out")
- private MockEndpoint secondOutbound;
-
- @Produces
- @ApplicationScoped
- @Named("properties")
- private static PropertiesComponent configuration() {
- Properties properties = new Properties();
- properties.put("property", "default");
- PropertiesComponent component = new PropertiesComponent();
- component.setInitialProperties(properties);
- return component;
- }
-
- @Deployment
- public static Archive<?> deployment() {
- return ShrinkWrap.create(JavaArchive.class)
- // Camel CDI
- .addPackage(CdiCamelExtension.class.getPackage())
- // Test classes
- .addClasses(
- DefaultCamelContextBean.class,
- PropertyInjectBean.class,
- FirstCamelContextBean.class,
- FirstCamelContextPropertyInjectBean.class,
- SecondCamelContextBean.class,
- SecondCamelContextPropertyInjectBean.class)
- // Bean archive deployment descriptor
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Test
- @InSequence(1)
- public void configureCamelContexts() throws Exception {
- defaultCamelContext.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:in").bean(PropertyInjectBean.class).to("mock:out");
- }
- });
-
- firstCamelContext.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:in").bean(FirstCamelContextPropertyInjectBean.class).to("mock:out");
- }
- });
-
- secondCamelContext.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:in").bean(SecondCamelContextPropertyInjectBean.class).to("mock:out");
- }
- });
-
- secondCamelContext.getRouteController().startAllRoutes();
- }
-
- @Test
- @InSequence(2)
- public void sendMessageToDefaultCamelContextInbound() throws InterruptedException {
- defaultOutbound.expectedMessageCount(1);
- defaultOutbound.expectedBodiesReceived("test");
- defaultOutbound.expectedHeaderReceived("header", "default");
-
- defaultInbound.sendBody("test");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);
- }
-
- @Test
- @InSequence(3)
- public void retrieveReferenceFromDefaultCamelContext(PropertyInjectBean bean) {
- assertThat(bean.getProperty(), is(equalTo("default")));
- }
-
- @Test
- @InSequence(4)
- public void sendMessageToFirstCamelContextInbound() throws InterruptedException {
- firstOutbound.expectedMessageCount(1);
- firstOutbound.expectedBodiesReceived("test");
- firstOutbound.expectedHeaderReceived("header", "default");
-
- firstInbound.sendBody("test");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);
- }
-
- @Test
- @InSequence(5)
- public void retrieveReferenceFromFirstCamelContext(FirstCamelContextPropertyInjectBean bean) {
- assertThat(bean.getProperty(), is(equalTo("default")));
- }
-
- @Test
- @InSequence(6)
- public void sendMessageToSecondCamelContextInbound() throws InterruptedException {
- secondOutbound.expectedMessageCount(1);
- secondOutbound.expectedBodiesReceived("test");
- secondOutbound.expectedHeaderReceived("header", "default");
-
- secondInbound.sendBody("test");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);
- }
-
- @Test
- @InSequence(7)
- public void retrieveReferenceFromSecondCamelContext(SecondCamelContextPropertyInjectBean bean) {
- assertThat(bean.getProperty(), is(equalTo("default")));
- }
-}
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedMultiCamelContextTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedMultiCamelContextTest.java
index 5d9023a..490f1d6 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedMultiCamelContextTest.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/QualifiedMultiCamelContextTest.java
@@ -51,6 +51,7 @@ import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@RunWith(Arquillian.class)
+@Deprecated
public class QualifiedMultiCamelContextTest {
@Inject
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteBuildersWithContextNamesTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteBuildersWithContextNamesTest.java
deleted file mode 100644
index be925a1..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/RouteBuildersWithContextNamesTest.java
+++ /dev/null
@@ -1,113 +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.util.concurrent.TimeUnit;
-import javax.enterprise.inject.Any;
-import javax.enterprise.inject.Instance;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.ServiceStatus;
-import org.apache.camel.cdi.CdiCamelExtension;
-import org.apache.camel.cdi.ContextName;
-import org.apache.camel.cdi.Uri;
-import org.apache.camel.cdi.bean.FirstCamelContextEndpointInjectRoute;
-import org.apache.camel.cdi.bean.SecondCamelContextEndpointInjectRoute;
-import org.apache.camel.component.mock.MockEndpoint;
-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.apache.camel.component.mock.MockEndpoint.assertIsSatisfied;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasProperty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-@RunWith(Arquillian.class)
-public class RouteBuildersWithContextNamesTest {
-
- @Deployment
- public static Archive<?> deployment() {
- return ShrinkWrap.create(JavaArchive.class)
- // Camel CDI
- .addPackage(CdiCamelExtension.class.getPackage())
- // Test classes
- .addClasses(
- FirstCamelContextEndpointInjectRoute.class,
- SecondCamelContextEndpointInjectRoute.class)
- // Bean archive deployment descriptor
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Test
- public void verifyCamelContexts(@Any Instance<CamelContext> contexts) {
- assertThat("Context instances are incorrect!", contexts,
- containsInAnyOrder(
- hasProperty("name", is(equalTo("first"))),
- hasProperty("name", is(equalTo("second")))));
- }
-
- @Test
- public void verifyFirstCamelContext(@ContextName("first") CamelContext first) {
- assertThat("Context name is incorrect!", first.getName(), is(equalTo("first")));
- assertThat("Number of routes is incorrect!", first.getRoutes().size(), is(equalTo(1)));
- assertThat("Context status is incorrect!", first.getStatus(), is(equalTo(ServiceStatus.Started)));
- }
-
- @Test
- public void verifySecondCamelContext(@ContextName("second") CamelContext second) {
- assertThat("Context name is incorrect!", second.getName(), is(equalTo("second")));
- assertThat("Number of routes is incorrect!", second.getRoutes().size(), is(equalTo(1)));
- assertThat("Context status is incorrect!", second.getStatus(), is(equalTo(ServiceStatus.Started)));
- }
-
- @Test
- public void sendMessageToFirstInbound(@Uri(value = "direct:inbound") @ContextName("first")
- ProducerTemplate inbound,
- @Uri(value = "mock:outbound") @ContextName("first")
- MockEndpoint outbound) throws InterruptedException {
- outbound.expectedMessageCount(1);
- outbound.expectedBodiesReceived("test");
- outbound.expectedHeaderReceived("context", "first");
-
- inbound.sendBody("test");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
- }
-
- @Test
- public void sendMessageToSecondInbound(@Uri("direct:inbound") @ContextName("second")
- ProducerTemplate inbound,
- @Uri("mock:outbound") @ContextName("second")
- MockEndpoint outbound) throws InterruptedException {
- outbound.expectedMessageCount(1);
- outbound.expectedBodiesReceived("test");
- outbound.expectedHeaderReceived("context", "second");
-
- inbound.sendBody("test");
-
- assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
- }
-}
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnsatisfiedContextForEndpointInjectTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnsatisfiedContextForEndpointInjectTest.java
deleted file mode 100644
index 4cbb06d..0000000
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/UnsatisfiedContextForEndpointInjectTest.java
+++ /dev/null
@@ -1,58 +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 org.apache.camel.cdi.CdiCamelExtension;
-import org.apache.camel.cdi.bean.EndpointInjectWrongContextRoute;
-import org.apache.camel.cdi.rule.ExpectedDeploymentException;
-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.ClassRule;
-import org.junit.Test;
-import org.junit.rules.TestRule;
-import org.junit.runner.RunWith;
-
-import static org.hamcrest.Matchers.containsString;
-
-@RunWith(Arquillian.class)
-public class UnsatisfiedContextForEndpointInjectTest {
-
- @ClassRule
- public static TestRule exception = ExpectedDeploymentException.none()
- .expect(RuntimeException.class)
- .expectMessage(containsString("Error adding routes of type [" + EndpointInjectWrongContextRoute.class.getName() + "] to Camel context"))
- .expectMessage(containsString("No Camel context with name [foo] is deployed!"));
-
- @Deployment
- public static Archive<?> deployment() {
- return ShrinkWrap.create(JavaArchive.class)
- // Camel CDI
- .addPackage(CdiCamelExtension.class.getPackage())
- // Test class
- .addClass(EndpointInjectWrongContextRoute.class)
- // Bean archive deployment descriptor
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Test
- public void test() {
- }
-}
diff --git a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlMultiContextsTest.java b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlMultiContextsTest.java
index cfe9252..9a787eb 100644
--- a/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlMultiContextsTest.java
+++ b/components/camel-cdi/src/test/java/org/apache/camel/cdi/test/XmlMultiContextsTest.java
@@ -49,6 +49,7 @@ import static org.junit.Assert.assertThat;
@RunWith(Arquillian.class)
@ImportResource("imported-context.xml")
+@Deprecated
public class XmlMultiContextsTest {
@Inject
diff --git a/core/camel-api/src/main/java/org/apache/camel/BeanInject.java b/core/camel-api/src/main/java/org/apache/camel/BeanInject.java
index 763b31e..829d900 100644
--- a/core/camel-api/src/main/java/org/apache/camel/BeanInject.java
+++ b/core/camel-api/src/main/java/org/apache/camel/BeanInject.java
@@ -37,8 +37,4 @@ public @interface BeanInject {
*/
String value() default "";
- /**
- * Id of {@link CamelContext} to use
- */
- String context() default "";
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/BindToRegistry.java b/core/camel-api/src/main/java/org/apache/camel/BindToRegistry.java
index c9191b4..a95e611 100644
--- a/core/camel-api/src/main/java/org/apache/camel/BindToRegistry.java
+++ b/core/camel-api/src/main/java/org/apache/camel/BindToRegistry.java
@@ -39,11 +39,6 @@ public @interface BindToRegistry {
String value() default "";
/**
- * Id of {@link CamelContext} to use
- */
- String context() default "";
-
- /**
* Whether to perform bean post processing (dependency injection) on the bean
*/
boolean beanPostProcess() default false;
diff --git a/core/camel-api/src/main/java/org/apache/camel/Consume.java b/core/camel-api/src/main/java/org/apache/camel/Consume.java
index d9c31ef..40cffad 100644
--- a/core/camel-api/src/main/java/org/apache/camel/Consume.java
+++ b/core/camel-api/src/main/java/org/apache/camel/Consume.java
@@ -55,11 +55,6 @@ public @interface Consume {
String property() default "";
/**
- * Id of {@link CamelContext} to use
- */
- String context() default "";
-
- /**
* Optional predicate (using simple language) to only consume if the predicate matches .
* This can be used to filter messages.
* <p/>
diff --git a/core/camel-api/src/main/java/org/apache/camel/DynamicRouter.java b/core/camel-api/src/main/java/org/apache/camel/DynamicRouter.java
index c41a209..f319ff2 100644
--- a/core/camel-api/src/main/java/org/apache/camel/DynamicRouter.java
+++ b/core/camel-api/src/main/java/org/apache/camel/DynamicRouter.java
@@ -36,8 +36,6 @@ import java.lang.annotation.Target;
* to an {@link org.apache.camel.Endpoint} or {@link String}.
*
* Then for each endpoint or URI the message is routed in a pipes and filter fashion.
- *
- * @see org.apache.camel.RoutingSlip
*/
@Retention(RetentionPolicy.RUNTIME)
@Documented
@@ -45,11 +43,6 @@ import java.lang.annotation.Target;
public @interface DynamicRouter {
/**
- * Id of {@link CamelContext} to use
- */
- String context() default "";
-
- /**
* Sets the uri delimiter to use
*/
String delimiter() default ",";
diff --git a/core/camel-api/src/main/java/org/apache/camel/EndpointInject.java b/core/camel-api/src/main/java/org/apache/camel/EndpointInject.java
index 661019f..76ea8e5 100644
--- a/core/camel-api/src/main/java/org/apache/camel/EndpointInject.java
+++ b/core/camel-api/src/main/java/org/apache/camel/EndpointInject.java
@@ -55,8 +55,4 @@ public @interface EndpointInject {
*/
String property() default "";
- /**
- * Id of {@link CamelContext} to use
- */
- String context() default "";
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/InvokeOnHeader.java b/core/camel-api/src/main/java/org/apache/camel/InvokeOnHeader.java
index b28b1ae..856ac2a 100644
--- a/core/camel-api/src/main/java/org/apache/camel/InvokeOnHeader.java
+++ b/core/camel-api/src/main/java/org/apache/camel/InvokeOnHeader.java
@@ -32,6 +32,8 @@ import java.lang.annotation.Target;
@Target(ElementType.METHOD)
public @interface InvokeOnHeader {
+ // TODO: Move to spi as its more for component developers
+
/**
* Name of header
*/
diff --git a/core/camel-api/src/main/java/org/apache/camel/InvokeOnHeaders.java b/core/camel-api/src/main/java/org/apache/camel/InvokeOnHeaders.java
index c45a3d9..e73439c 100644
--- a/core/camel-api/src/main/java/org/apache/camel/InvokeOnHeaders.java
+++ b/core/camel-api/src/main/java/org/apache/camel/InvokeOnHeaders.java
@@ -30,6 +30,8 @@ import java.lang.annotation.Target;
@Target(ElementType.METHOD)
public @interface InvokeOnHeaders {
+ // TODO: Move to spi as its more for component developers
+
/**
* Name of headers
*/
diff --git a/core/camel-api/src/main/java/org/apache/camel/Produce.java b/core/camel-api/src/main/java/org/apache/camel/Produce.java
index 72f5bca..ac5a93f 100644
--- a/core/camel-api/src/main/java/org/apache/camel/Produce.java
+++ b/core/camel-api/src/main/java/org/apache/camel/Produce.java
@@ -57,11 +57,6 @@ public @interface Produce {
String property() default "";
/**
- * Id of {@link CamelContext} to use
- */
- String context() default "";
-
- /**
* Whether to use bean parameter binding
*/
boolean binding() default true;
diff --git a/core/camel-api/src/main/java/org/apache/camel/PropertyInject.java b/core/camel-api/src/main/java/org/apache/camel/PropertyInject.java
index 49705bf..89f2cb3 100644
--- a/core/camel-api/src/main/java/org/apache/camel/PropertyInject.java
+++ b/core/camel-api/src/main/java/org/apache/camel/PropertyInject.java
@@ -41,8 +41,4 @@ public @interface PropertyInject {
*/
String defaultValue() default "";
- /**
- * Id of {@link CamelContext} to use
- */
- String context() default "";
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/RecipientList.java b/core/camel-api/src/main/java/org/apache/camel/RecipientList.java
index 4f3f6db..ae8157b 100644
--- a/core/camel-api/src/main/java/org/apache/camel/RecipientList.java
+++ b/core/camel-api/src/main/java/org/apache/camel/RecipientList.java
@@ -43,11 +43,6 @@ import java.lang.annotation.Target;
public @interface RecipientList {
/**
- * Id of {@link CamelContext} to use
- */
- String context() default "";
-
- /**
* Delimiter used if the Expression returned multiple endpoints. Can be turned off using the value <tt>false</tt>.
* <p/>
* The default value is ,
diff --git a/core/camel-api/src/main/java/org/apache/camel/RoutingSlip.java b/core/camel-api/src/main/java/org/apache/camel/RoutingSlip.java
index 0c320ad..3fd6acd 100644
--- a/core/camel-api/src/main/java/org/apache/camel/RoutingSlip.java
+++ b/core/camel-api/src/main/java/org/apache/camel/RoutingSlip.java
@@ -45,11 +45,6 @@ import java.lang.annotation.Target;
public @interface RoutingSlip {
/**
- * Id of {@link CamelContext} to use
- */
- String context() default "";
-
- /**
* Sets the uri delimiter to use
*/
String delimiter() default ",";
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/CamelPostProcessorHelper.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/CamelPostProcessorHelper.java
index 0d24821..3a2f129 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/CamelPostProcessorHelper.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/CamelPostProcessorHelper.java
@@ -73,21 +73,9 @@ public class CamelPostProcessorHelper implements CamelContextAware {
this.camelContext = camelContext;
}
- /**
- * Does the given context match this camel context
- */
- public boolean matchContext(String context) {
- if (ObjectHelper.isNotEmpty(context)) {
- if (!getCamelContext().getName().equals(context)) {
- return false;
- }
- }
- return true;
- }
-
public void consumerInjection(Method method, Object bean, String beanName) {
Consume consume = method.getAnnotation(Consume.class);
- if (consume != null && matchContext(consume.context())) {
+ if (consume != null) {
LOG.debug("Creating a consumer for: {}", consume);
String uri = consume.value().isEmpty() ? consume.uri() : consume.value();
subscribeMethod(method, bean, beanName, uri, consume.property(), consume.predicate());
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultCamelBeanPostProcessor.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultCamelBeanPostProcessor.java
index 541037d..3f6810e 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultCamelBeanPostProcessor.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/DefaultCamelBeanPostProcessor.java
@@ -165,24 +165,24 @@ public class DefaultCamelBeanPostProcessor implements CamelBeanPostProcessor {
protected void injectFields(final Object bean, final String beanName) {
ReflectionHelper.doWithFields(bean.getClass(), field -> {
PropertyInject propertyInject = field.getAnnotation(PropertyInject.class);
- if (propertyInject != null && getPostProcessorHelper().matchContext(propertyInject.context())) {
+ if (propertyInject != null) {
injectFieldProperty(field, propertyInject.value(), propertyInject.defaultValue(), bean, beanName);
}
BeanInject beanInject = field.getAnnotation(BeanInject.class);
- if (beanInject != null && getPostProcessorHelper().matchContext(beanInject.context())) {
+ if (beanInject != null) {
injectFieldBean(field, beanInject.value(), bean, beanName);
}
EndpointInject endpointInject = field.getAnnotation(EndpointInject.class);
- if (endpointInject != null && getPostProcessorHelper().matchContext(endpointInject.context())) {
+ if (endpointInject != null) {
@SuppressWarnings("deprecation")
String uri = endpointInject.value().isEmpty() ? endpointInject.uri() : endpointInject.value();
injectField(field, uri, endpointInject.property(), bean, beanName);
}
Produce produce = field.getAnnotation(Produce.class);
- if (produce != null && getPostProcessorHelper().matchContext(produce.context())) {
+ if (produce != null) {
@SuppressWarnings("deprecation")
String uri = produce.value().isEmpty() ? produce.uri() : produce.value();
injectField(field, uri, produce.property(), bean, beanName, produce.binding());
@@ -193,7 +193,7 @@ public class DefaultCamelBeanPostProcessor implements CamelBeanPostProcessor {
protected void injectBindToRegistryFields(final Object bean, final String beanName) {
ReflectionHelper.doWithFields(bean.getClass(), field -> {
BindToRegistry bind = field.getAnnotation(BindToRegistry.class);
- if (bind != null && getPostProcessorHelper().matchContext(bind.context())) {
+ if (bind != null) {
bindToRegistry(field, bind.value(), bean, beanName, bind.beanPostProcess());
}
});
@@ -235,7 +235,7 @@ public class DefaultCamelBeanPostProcessor implements CamelBeanPostProcessor {
final List<Method> methods = new ArrayList<Method>();
ReflectionHelper.doWithMethods(bean.getClass(), method -> {
BindToRegistry bind = method.getAnnotation(BindToRegistry.class);
- if (bind != null && getPostProcessorHelper().matchContext(bind.context())) {
+ if (bind != null) {
methods.add(method);
}
});
@@ -281,7 +281,7 @@ public class DefaultCamelBeanPostProcessor implements CamelBeanPostProcessor {
protected void injectClass(final Object bean, final String beanName) {
Class<?> clazz = bean.getClass();
BindToRegistry ann = clazz.getAnnotation(BindToRegistry.class);
- if (ann != null && getPostProcessorHelper().matchContext(ann.context())) {
+ if (ann != null) {
bindToRegistry(clazz, ann.value(), bean, beanName, ann.beanPostProcess());
}
}
@@ -289,7 +289,7 @@ public class DefaultCamelBeanPostProcessor implements CamelBeanPostProcessor {
protected void injectNestedClasses(final Object bean, final String beanName) {
ReflectionHelper.doWithClasses(bean.getClass(), clazz -> {
BindToRegistry ann = (BindToRegistry) clazz.getAnnotation(BindToRegistry.class);
- if (ann != null && getPostProcessorHelper().matchContext(ann.context())) {
+ if (ann != null) {
// its a nested class so we dont have a bean instance for it
bindToRegistry(clazz, ann.value(), null, null, ann.beanPostProcess());
}
@@ -298,23 +298,23 @@ public class DefaultCamelBeanPostProcessor implements CamelBeanPostProcessor {
protected void setterInjection(Method method, Object bean, String beanName) {
PropertyInject propertyInject = method.getAnnotation(PropertyInject.class);
- if (propertyInject != null && getPostProcessorHelper().matchContext(propertyInject.context())) {
+ if (propertyInject != null) {
setterPropertyInjection(method, propertyInject.value(), propertyInject.defaultValue(), bean, beanName);
}
BeanInject beanInject = method.getAnnotation(BeanInject.class);
- if (beanInject != null && getPostProcessorHelper().matchContext(beanInject.context())) {
+ if (beanInject != null) {
setterBeanInjection(method, beanInject.value(), bean, beanName);
}
EndpointInject endpointInject = method.getAnnotation(EndpointInject.class);
- if (endpointInject != null && getPostProcessorHelper().matchContext(endpointInject.context())) {
+ if (endpointInject != null) {
String uri = endpointInject.value().isEmpty() ? endpointInject.uri() : endpointInject.value();
setterInjection(method, bean, beanName, uri, endpointInject.property());
}
Produce produce = method.getAnnotation(Produce.class);
- if (produce != null && getPostProcessorHelper().matchContext(produce.context())) {
+ if (produce != null) {
String uri = produce.value().isEmpty() ? produce.uri() : produce.value();
setterInjection(method, bean, beanName, uri, produce.property());
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/engine/CamelPostProcessorHelperTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/engine/CamelPostProcessorHelperTest.java
index 745d72d..dd798ab 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/engine/CamelPostProcessorHelperTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/engine/CamelPostProcessorHelperTest.java
@@ -86,13 +86,6 @@ public class CamelPostProcessorHelperTest extends ContextTestSupport {
}
@Test
- public void testMatchContext() {
- CamelPostProcessorHelper helper = new CamelPostProcessorHelper(context);
- assertTrue(helper.matchContext(context.getName()));
- assertFalse(helper.matchContext("foo"));
- }
-
- @Test
public void testConsume() throws Exception {
CamelPostProcessorHelper helper = new CamelPostProcessorHelper(context);
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipPOJOTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipPOJOTest.java
index de9be27..3b2a6c4 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipPOJOTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipPOJOTest.java
@@ -54,7 +54,7 @@ public class RoutingSlipPOJOTest extends ContextTestSupport {
}
public class MyRoutingSlipPOJO {
- @RoutingSlip(context = "camel-1")
+ @RoutingSlip
public String[] doSomething(String body) {
return new String[]{"mock:foo", "direct:b", "mock:result"};
}