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 2023/02/25 11:17:58 UTC
[camel] branch main updated: CAMEL-19090: Remove deprecated apis in core
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 262fbffbae9 CAMEL-19090: Remove deprecated apis in core
262fbffbae9 is described below
commit 262fbffbae94a17d5853039e73aafca616bbb734
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Feb 25 12:17:39 2023 +0100
CAMEL-19090: Remove deprecated apis in core
---
.../issues/JmsBlockedAsyncRoutingEngineTest.java | 160 ----------
.../org/apache/camel/spring/MyVetoLifecycle.java | 2 +-
.../component/thrift/ThriftProducerAsyncTest.java | 298 ------------------
.../java/org/apache/camel/ProducerTemplate.java | 95 ------
.../org/apache/camel/spi/LifecycleStrategy.java | 23 --
.../org/apache/camel/spi/OnCamelContextStart.java | 27 --
.../org/apache/camel/spi/OnCamelContextStop.java | 27 --
.../camel/impl/engine/AbstractCamelContext.java | 2 -
.../camel/impl/engine/DefaultProducerTemplate.java | 58 ----
.../engine/OnCamelContextLifecycleStrategy.java | 26 --
.../component/bean/BeanOgnlPerformanceTest.java | 23 +-
.../component/bean/ProxyReturnFutureListTest.java | 93 ------
...melContextWithLifecycleStrategyRestartTest.java | 2 +-
.../impl/DefaultProducerTemplateAsyncTest.java | 335 ---------------------
.../apache/camel/impl/DummyLifecycleStrategy.java | 8 +-
.../camel/impl/LifecycleStrategyDiscoveryTest.java | 19 +-
.../impl/LifecycleStrategyFailOnStartupTest.java | 2 +-
.../camel/impl/VetoCamelContextStartTest.java | 2 +-
.../camel/processor/BeanCachedProcessorTest.java | 103 -------
.../org/apache/camel/main/BaseMainSupport.java | 1 -
.../java/org/apache/camel/main/MainListener.java | 12 +-
.../org/apache/camel/main/MainListenerSupport.java | 8 -
.../org/apache/camel/main/ContextEventsTest.java | 8 +-
.../org/apache/camel/main/MainListenerTest.java | 2 +-
.../java/org/apache/camel/main/MainVetoTest.java | 2 +-
.../camel/support/LifecycleStrategySupport.java | 64 ----
.../ROOT/pages/camel-4-migration-guide.adoc | 3 +
.../camel/itest/async/HttpAsyncCallbackTest.java | 106 -------
28 files changed, 37 insertions(+), 1474 deletions(-)
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsBlockedAsyncRoutingEngineTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsBlockedAsyncRoutingEngineTest.java
deleted file mode 100644
index 5d2c6b194b4..00000000000
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsBlockedAsyncRoutingEngineTest.java
+++ /dev/null
@@ -1,160 +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.component.jms.issues;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import jakarta.jms.ConnectionFactory;
-
-import org.apache.activemq.artemis.api.core.ActiveMQException;
-import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.core.server.ServerSession;
-import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin;
-import org.apache.activemq.artemis.core.transaction.Transaction;
-import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
-import org.apache.camel.CamelContext;
-import org.apache.camel.Exchange;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.spi.Synchronization;
-import org.apache.camel.test.infra.artemis.services.ArtemisEmbeddedServiceBuilder;
-import org.apache.camel.test.infra.artemis.services.ArtemisService;
-import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Timeout;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-/**
- * Tests CAMEL-5769. Camel JMS producer can block a thread under specific circumstances.
- */
-@Timeout(30)
-public class JmsBlockedAsyncRoutingEngineTest extends CamelTestSupport {
-
- private static final Logger LOG = LoggerFactory.getLogger(JmsBlockedAsyncRoutingEngineTest.class);
- @RegisterExtension
- public ArtemisService service = new ArtemisEmbeddedServiceBuilder()
- .withPersistent(false)
- .withCustomConfiguration(configuration -> configuration.registerBrokerPlugin(new DelayerBrokerPlugin()))
- .build();
- private final CountDownLatch latch = new CountDownLatch(5);
- private final Synchronization callback = new Synchronization() {
- @Override
- public void onFailure(Exchange exchange) {
- LOG.info(">>>> Callback onFailure");
- latch.countDown();
- }
-
- @Override
- public void onComplete(Exchange exchange) {
- LOG.info(">>>> Callback onComplete");
- latch.countDown();
- }
- };
-
- @Override
- protected CamelContext createCamelContext() throws Exception {
- CamelContext camelContext = super.createCamelContext();
- ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(service.serviceAddress());
- camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
- return camelContext;
- }
-
- @Test
- public void testBlockedAsyncRoutingEngineTest() throws Exception {
- // 0. This message takes 2000ms to ACK from the broker due to the DelayerBrokerPlugin
- // Until then, the correlation ID doesn't get updated locally
- try {
- template.asyncRequestBody(
- "activemq:queue:JmsBlockedAsyncRoutingEngineTest?requestTimeout=500&useMessageIDAsCorrelationID=true",
- "hello");
- } catch (Exception e) {
- }
-
- // 1. We wait a bit for the CorrelationTimeoutMap purge process to run
- Thread.sleep(3000);
-
- // 2. We send 5 messages that take 2 seconds so that they time out
- template.asyncCallbackRequestBody(
- "activemq:queue:JmsBlockedAsyncRoutingEngineTest?requestTimeout=500&useMessageIDAsCorrelationID=true", "beSlow",
- callback);
- template.asyncCallbackRequestBody(
- "activemq:queue:JmsBlockedAsyncRoutingEngineTest?requestTimeout=500&useMessageIDAsCorrelationID=true", "beSlow",
- callback);
- template.asyncCallbackRequestBody(
- "activemq:queue:JmsBlockedAsyncRoutingEngineTest?requestTimeout=500&useMessageIDAsCorrelationID=true", "beSlow",
- callback);
- template.asyncCallbackRequestBody(
- "activemq:queue:JmsBlockedAsyncRoutingEngineTest?requestTimeout=500&useMessageIDAsCorrelationID=true", "beSlow",
- callback);
- template.asyncCallbackRequestBody(
- "activemq:queue:JmsBlockedAsyncRoutingEngineTest?requestTimeout=500&useMessageIDAsCorrelationID=true", "beSlow",
- callback);
-
- // 3. We assert that we were notified of all timeout exceptions
- assertTrue(latch.await(3000, TimeUnit.MILLISECONDS));
- }
-
- @AfterEach
- public void cleanup() {
- LOG.info(">>>>> Latch countdown count was: {}", latch.getCount());
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- public void configure() {
- from("activemq:queue:JmsBlockedAsyncRoutingEngineTest?concurrentConsumers=5&useMessageIDAsCorrelationID=true&transacted=true")
- .filter().simple("${in.body} == 'beSlow'")
- .delay(constant(2000))
- .log(">>>>> Received message on test queue")
- .setBody(constant("Reply"))
- .log(">>>>> Sending back reply");
- }
- };
- }
-
- private static class DelayerBrokerPlugin implements ActiveMQServerPlugin {
- int i;
-
- @Override
- public void beforeSend(
- ServerSession session, Transaction tx, Message message, boolean direct, boolean noAutoCreateQueue)
- throws ActiveMQException {
- //by default call the old method for backwards compatibility
- String destinationName = message.getAddress();
- LOG.info("******** Received message for destination {}", destinationName);
-
- if (destinationName.toLowerCase().contains("JmsBlockedAsyncRoutingEngineTest") && i == 0) {
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- LOG.info("******** Waited 2 seconds for destination: {}", destinationName);
- i++;
- }
-
- this.beforeSend(tx, message, direct, noAutoCreateQueue);
- }
- }
-}
diff --git a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MyVetoLifecycle.java b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MyVetoLifecycle.java
index e5758046e5a..ffd62d03c81 100644
--- a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MyVetoLifecycle.java
+++ b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MyVetoLifecycle.java
@@ -23,7 +23,7 @@ import org.apache.camel.support.LifecycleStrategySupport;
public class MyVetoLifecycle extends LifecycleStrategySupport {
@Override
- public void onContextStart(CamelContext context) throws VetoCamelContextStartException {
+ public void onContextStarting(CamelContext context) throws VetoCamelContextStartException {
throw new VetoCamelContextStartException("We do not like this route", context, false);
}
diff --git a/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerAsyncTest.java b/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerAsyncTest.java
deleted file mode 100644
index 9420afa1033..00000000000
--- a/components/camel-thrift/src/test/java/org/apache/camel/component/thrift/ThriftProducerAsyncTest.java
+++ /dev/null
@@ -1,298 +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.component.thrift;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.thrift.generated.InvalidOperation;
-import org.apache.camel.component.thrift.generated.Operation;
-import org.apache.camel.component.thrift.generated.Work;
-import org.apache.camel.support.SynchronizationAdapter;
-import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class ThriftProducerAsyncTest extends ThriftProducerBaseTest {
- private static final Logger LOG = LoggerFactory.getLogger(ThriftProducerAsyncTest.class);
-
- private Object responseBody;
-
- @Test
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void testCalculateMethodInvocation() throws Exception {
- LOG.info("Thrift calculate method async test start");
-
- List requestBody = new ArrayList();
- final CountDownLatch latch = new CountDownLatch(1);
-
- requestBody.add(1);
- requestBody.add(new Work(THRIFT_TEST_NUM1, THRIFT_TEST_NUM2, Operation.MULTIPLY));
-
- template.asyncCallbackSendBody("direct:thrift-calculate", requestBody, new SynchronizationAdapter() {
-
- @Override
- public void onComplete(Exchange exchange) {
- responseBody = exchange.getMessage().getBody();
- latch.countDown();
- }
-
- @Override
- public void onFailure(Exchange exchange) {
- responseBody = exchange.getException();
- latch.countDown();
- }
- });
- latch.await(5, TimeUnit.SECONDS);
-
- assertNotNull(responseBody);
- assertTrue(responseBody instanceof Integer);
- assertEquals(THRIFT_TEST_NUM1 * THRIFT_TEST_NUM2, responseBody);
- }
-
- @Test
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void testAddMethodInvocation() throws Exception {
- LOG.info("Thrift add method (primitive parameters only) async test start");
-
- final CountDownLatch latch = new CountDownLatch(1);
- List requestBody = new ArrayList();
- responseBody = null;
-
- requestBody.add(THRIFT_TEST_NUM1);
- requestBody.add(THRIFT_TEST_NUM2);
-
- template.asyncCallbackSendBody("direct:thrift-add", requestBody, new SynchronizationAdapter() {
-
- @Override
- public void onComplete(Exchange exchange) {
- responseBody = exchange.getMessage().getBody();
- latch.countDown();
- }
-
- @Override
- public void onFailure(Exchange exchange) {
- responseBody = exchange.getException();
- latch.countDown();
- }
- });
- latch.await(5, TimeUnit.SECONDS);
-
- assertNotNull(responseBody);
- assertTrue(responseBody instanceof Integer);
- assertEquals(THRIFT_TEST_NUM1 + THRIFT_TEST_NUM2, responseBody);
- }
-
- @Test
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void testCalculateWithException() throws Exception {
- LOG.info("Thrift calculate method with business exception async test start");
-
- final CountDownLatch latch = new CountDownLatch(1);
- List requestBody = new ArrayList();
-
- requestBody.add(1);
- requestBody.add(new Work(THRIFT_TEST_NUM1, 0, Operation.DIVIDE));
-
- template.asyncCallbackSendBody("direct:thrift-calculate", requestBody, new SynchronizationAdapter() {
-
- @Override
- public void onComplete(Exchange exchange) {
- latch.countDown();
- }
-
- @Override
- public void onFailure(Exchange exchange) {
- responseBody = exchange.getException();
- latch.countDown();
- }
- });
- latch.await(5, TimeUnit.SECONDS);
-
- assertTrue(responseBody instanceof InvalidOperation, "Get an InvalidOperation exception");
-
- }
-
- @Test
- public void testVoidMethodInvocation() throws Exception {
- LOG.info("Thrift method with empty parameters and void output async test start");
-
- final CountDownLatch latch = new CountDownLatch(1);
- final Object requestBody = null;
-
- responseBody = new Object();
- template.asyncCallbackSendBody("direct:thrift-ping", requestBody, new SynchronizationAdapter() {
-
- @Override
- public void onComplete(Exchange exchange) {
- responseBody = exchange.getMessage().getBody();
- latch.countDown();
- }
-
- @Override
- public void onFailure(Exchange exchange) {
- responseBody = exchange.getException();
- latch.countDown();
- }
- });
- latch.await(5, TimeUnit.SECONDS);
-
- assertNull(responseBody);
- }
-
- @Test
- public void testOneWayMethodInvocation() throws Exception {
- LOG.info("Thrift one-way method async test start");
-
- final CountDownLatch latch = new CountDownLatch(1);
- final Object requestBody = null;
-
- responseBody = new Object();
- template.asyncCallbackSendBody("direct:thrift-zip", requestBody, new SynchronizationAdapter() {
-
- @Override
- public void onComplete(Exchange exchange) {
- responseBody = exchange.getMessage().getBody();
- latch.countDown();
- }
-
- @Override
- public void onFailure(Exchange exchange) {
- responseBody = exchange.getException();
- latch.countDown();
- }
- });
- latch.await(5, TimeUnit.SECONDS);
-
- assertNull(responseBody);
- }
-
- @Test
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void testAllTypesMethodInvocation() throws Exception {
- LOG.info("Thrift method with all possile types async test start");
-
- final CountDownLatch latch = new CountDownLatch(1);
- List requestBody = new ArrayList();
-
- requestBody.add(true);
- requestBody.add((byte) THRIFT_TEST_NUM1);
- requestBody.add((short) THRIFT_TEST_NUM1);
- requestBody.add(THRIFT_TEST_NUM1);
- requestBody.add((long) THRIFT_TEST_NUM1);
- requestBody.add((double) THRIFT_TEST_NUM1);
- requestBody.add("empty");
- requestBody.add(ByteBuffer.allocate(10));
- requestBody.add(new Work(THRIFT_TEST_NUM1, THRIFT_TEST_NUM2, Operation.MULTIPLY));
- requestBody.add(new ArrayList<Integer>());
- requestBody.add(new HashSet<String>());
- requestBody.add(new HashMap<String, Long>());
-
- responseBody = new Object();
- template.asyncCallbackSendBody("direct:thrift-alltypes", requestBody, new SynchronizationAdapter() {
-
- @Override
- public void onComplete(Exchange exchange) {
- responseBody = exchange.getMessage().getBody();
- latch.countDown();
- }
-
- @Override
- public void onFailure(Exchange exchange) {
- responseBody = exchange.getException();
- latch.countDown();
- }
- });
- latch.await(5, TimeUnit.SECONDS);
-
- assertNotNull(responseBody);
- assertTrue(responseBody instanceof Integer);
- assertEquals(1, responseBody);
- }
-
- @Test
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public void testEchoMethodInvocation() throws Exception {
- LOG.info("Thrift echo method (return output as pass input parameter) async test start");
-
- final CountDownLatch latch = new CountDownLatch(1);
- List requestBody = new ArrayList();
-
- requestBody.add(new Work(THRIFT_TEST_NUM1, THRIFT_TEST_NUM2, Operation.MULTIPLY));
-
- responseBody = new Object();
- template.asyncCallbackSendBody("direct:thrift-echo", requestBody, new SynchronizationAdapter() {
-
- @Override
- public void onComplete(Exchange exchange) {
- responseBody = exchange.getMessage().getBody();
- latch.countDown();
- }
-
- @Override
- public void onFailure(Exchange exchange) {
- responseBody = exchange.getException();
- latch.countDown();
- }
- });
- latch.await(5, TimeUnit.SECONDS);
-
- assertNotNull(responseBody);
- assertTrue(responseBody instanceof Work);
- assertEquals(THRIFT_TEST_NUM1, ((Work) responseBody).num1);
- assertEquals(Operation.MULTIPLY, ((Work) responseBody).op);
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:thrift-calculate")
- .to("thrift://localhost:" + THRIFT_TEST_PORT
- + "/org.apache.camel.component.thrift.generated.Calculator?method=calculate");
- from("direct:thrift-add")
- .to("thrift://localhost:" + THRIFT_TEST_PORT
- + "/org.apache.camel.component.thrift.generated.Calculator?method=add");
- from("direct:thrift-ping")
- .to("thrift://localhost:" + THRIFT_TEST_PORT
- + "/org.apache.camel.component.thrift.generated.Calculator?method=ping");
- from("direct:thrift-zip")
- .to("thrift://localhost:" + THRIFT_TEST_PORT
- + "/org.apache.camel.component.thrift.generated.Calculator?method=zip");
- from("direct:thrift-alltypes")
- .to("thrift://localhost:" + THRIFT_TEST_PORT
- + "/org.apache.camel.component.thrift.generated.Calculator?method=alltypes");
- from("direct:thrift-echo")
- .to("thrift://localhost:" + THRIFT_TEST_PORT
- + "/org.apache.camel.component.thrift.generated.Calculator?method=echo");
- }
- };
- }
-}
diff --git a/core/camel-api/src/main/java/org/apache/camel/ProducerTemplate.java b/core/camel-api/src/main/java/org/apache/camel/ProducerTemplate.java
index 9854d84d432..22c5e761800 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ProducerTemplate.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ProducerTemplate.java
@@ -23,8 +23,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.apache.camel.spi.Synchronization;
-
/**
* Template for working with Camel and sending {@link Message} instances in an {@link Exchange} to an {@link Endpoint}.
* <br/>
@@ -1140,97 +1138,4 @@ public interface ProducerTemplate extends Service {
<T> T extractFutureBody(Future<?> future, long timeout, TimeUnit unit, Class<T> type)
throws TimeoutException, CamelExecutionException;
- // Asynchronous methods with callback
- // -----------------------------------------------------------------------
-
- /**
- * Sends an asynchronous exchange to the given endpoint.
- *
- * @param endpointUri the endpoint URI to send the exchange to
- * @param exchange the exchange to send
- * @param onCompletion callback invoked when exchange has been completed
- * @return a handle to be used to get the response in the future
- */
- @Deprecated
- CompletableFuture<Exchange> asyncCallback(String endpointUri, Exchange exchange, Synchronization onCompletion);
-
- /**
- * Sends an asynchronous exchange to the given endpoint.
- *
- * @param endpoint the endpoint to send the exchange to
- * @param exchange the exchange to send
- * @param onCompletion callback invoked when exchange has been completed
- * @return a handle to be used to get the response in the future
- */
- @Deprecated
- CompletableFuture<Exchange> asyncCallback(Endpoint endpoint, Exchange exchange, Synchronization onCompletion);
-
- /**
- * Sends an asynchronous exchange to the given endpoint using a supplied processor.
- *
- * @param endpointUri the endpoint URI to send the exchange to
- * @param processor the transformer used to populate the new exchange {@link Processor} to populate the exchange
- * @param onCompletion callback invoked when exchange has been completed
- * @return a handle to be used to get the response in the future
- */
- @Deprecated
- CompletableFuture<Exchange> asyncCallback(String endpointUri, Processor processor, Synchronization onCompletion);
-
- /**
- * Sends an asynchronous exchange to the given endpoint using a supplied processor.
- *
- * @param endpoint the endpoint to send the exchange to
- * @param processor the transformer used to populate the new exchange {@link Processor} to populate the exchange
- * @param onCompletion callback invoked when exchange has been completed
- * @return a handle to be used to get the response in the future
- */
- @Deprecated
- CompletableFuture<Exchange> asyncCallback(Endpoint endpoint, Processor processor, Synchronization onCompletion);
-
- /**
- * Sends an asynchronous body to the given endpoint. Uses an {@link ExchangePattern#InOnly} message exchange
- * pattern.
- *
- * @param endpointUri the endpoint URI to send the exchange to
- * @param body the body to send
- * @param onCompletion callback invoked when exchange has been completed
- * @return a handle to be used to get the response in the future
- */
- @Deprecated
- CompletableFuture<Object> asyncCallbackSendBody(String endpointUri, Object body, Synchronization onCompletion);
-
- /**
- * Sends an asynchronous body to the given endpoint. Uses an {@link ExchangePattern#InOnly} message exchange
- * pattern.
- *
- * @param endpoint the endpoint to send the exchange to
- * @param body the body to send
- * @param onCompletion callback invoked when exchange has been completed
- * @return a handle to be used to get the response in the future
- */
- @Deprecated
- CompletableFuture<Object> asyncCallbackSendBody(Endpoint endpoint, Object body, Synchronization onCompletion);
-
- /**
- * Sends an asynchronous body to the given endpoint. Uses an {@link ExchangePattern#InOut} message exchange pattern.
- *
- * @param endpointUri the endpoint URI to send the exchange to
- * @param body the body to send
- * @param onCompletion callback invoked when exchange has been completed
- * @return a handle to be used to get the response in the future
- */
- @Deprecated
- CompletableFuture<Object> asyncCallbackRequestBody(String endpointUri, Object body, Synchronization onCompletion);
-
- /**
- * Sends an asynchronous body to the given endpoint. Uses an {@link ExchangePattern#InOut} message exchange pattern.
- *
- * @param endpoint the endpoint to send the exchange to
- * @param body the body to send
- * @param onCompletion callback invoked when exchange has been completed
- * @return a handle to be used to get the response in the future
- */
- @Deprecated
- CompletableFuture<Object> asyncCallbackRequestBody(Endpoint endpoint, Object body, Synchronization onCompletion);
-
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/LifecycleStrategy.java b/core/camel-api/src/main/java/org/apache/camel/spi/LifecycleStrategy.java
index 5af5175d3ed..4b397c27f3c 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/LifecycleStrategy.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/LifecycleStrategy.java
@@ -53,19 +53,6 @@ public interface LifecycleStrategy {
default void onContextInitialized(CamelContext context) throws VetoCamelContextStartException {
}
- /**
- * Notification on starting a {@link CamelContext}.
- *
- * @param context the camel context
- * @throws VetoCamelContextStartException can be thrown to veto starting {@link CamelContext}. Any other runtime
- * exceptions will be logged at <tt>WARN</tt> level by Camel will
- * continue starting itself. *
- * @deprecated use {@link #onContextStarting(CamelContext)}.
- */
- @Deprecated
- default void onContextStart(CamelContext context) throws VetoCamelContextStartException {
- }
-
/**
* Notification on starting a {@link CamelContext}.
*
@@ -85,16 +72,6 @@ public interface LifecycleStrategy {
default void onContextStarted(CamelContext context) {
}
- /**
- * Notification on stopping a {@link CamelContext}.
- *
- * @param context the camel context
- * @deprecated use {@link #onContextStopping(CamelContext)}.
- */
- @Deprecated
- default void onContextStop(CamelContext context) {
- }
-
/**
* Notification on stopping a {@link CamelContext}.
*
diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/OnCamelContextStart.java b/core/camel-api/src/main/java/org/apache/camel/spi/OnCamelContextStart.java
deleted file mode 100644
index 2f5b662b4a8..00000000000
--- a/core/camel-api/src/main/java/org/apache/camel/spi/OnCamelContextStart.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spi;
-
-import org.apache.camel.CamelContext;
-
-/**
- * Notification on starting a {@link CamelContext}.
- */
-@FunctionalInterface
-public interface OnCamelContextStart extends OnCamelContextEvent {
- void onContextStart(CamelContext context);
-}
diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/OnCamelContextStop.java b/core/camel-api/src/main/java/org/apache/camel/spi/OnCamelContextStop.java
deleted file mode 100644
index 0e8b8f203b3..00000000000
--- a/core/camel-api/src/main/java/org/apache/camel/spi/OnCamelContextStop.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.spi;
-
-import org.apache.camel.CamelContext;
-
-/**
- * Notification on stopping a {@link CamelContext}.
- */
-@FunctionalInterface
-public interface OnCamelContextStop extends OnCamelContextEvent {
- void onContextStop(CamelContext context);
-}
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index de8eb2e970d..3f6ae4502a1 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -2726,7 +2726,6 @@ public abstract class AbstractCamelContext extends BaseService
for (LifecycleStrategy strategy : lifecycleStrategies) {
try {
strategy.onContextStopping(this);
- strategy.onContextStop(this);
} catch (Throwable e) {
LOG.warn("Lifecycle strategy {} failed on CamelContext ({}) due to: {}. This exception will be ignored",
strategy,
@@ -3292,7 +3291,6 @@ public abstract class AbstractCamelContext extends BaseService
for (LifecycleStrategy strategy : lifecycleStrategies) {
try {
strategy.onContextStarting(this);
- strategy.onContextStart(this);
} catch (VetoCamelContextStartException e) {
// okay we should not start Camel since it was vetoed
LOG.warn("Lifecycle strategy {} vetoed starting CamelContext ({}) due to: {}", strategy, getName(),
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultProducerTemplate.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultProducerTemplate.java
index 9fbf9d29e7d..1c2fb22a384 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultProducerTemplate.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultProducerTemplate.java
@@ -655,36 +655,6 @@ public class DefaultProducerTemplate extends ServiceSupport implements ProducerT
return ExchangeHelper.extractFutureBody(camelContext, future, timeout, unit, type);
}
- @Override
- public CompletableFuture<Object> asyncCallbackSendBody(String uri, Object body, Synchronization onCompletion) {
- return asyncCallbackSendBody(resolveMandatoryEndpoint(uri), body, onCompletion);
- }
-
- @Override
- public CompletableFuture<Object> asyncCallbackSendBody(Endpoint endpoint, Object body, Synchronization onCompletion) {
- return asyncCallback(endpoint, ExchangePattern.InOnly, body, onCompletion);
- }
-
- @Override
- public CompletableFuture<Object> asyncCallbackRequestBody(String uri, Object body, Synchronization onCompletion) {
- return asyncCallbackRequestBody(resolveMandatoryEndpoint(uri), body, onCompletion);
- }
-
- @Override
- public CompletableFuture<Object> asyncCallbackRequestBody(Endpoint endpoint, Object body, Synchronization onCompletion) {
- return asyncCallback(endpoint, ExchangePattern.InOut, body, onCompletion);
- }
-
- @Override
- public CompletableFuture<Exchange> asyncCallback(String uri, Exchange exchange, Synchronization onCompletion) {
- return asyncCallback(resolveMandatoryEndpoint(uri), exchange, onCompletion);
- }
-
- @Override
- public CompletableFuture<Exchange> asyncCallback(String uri, Processor processor, Synchronization onCompletion) {
- return asyncCallback(resolveMandatoryEndpoint(uri), processor, onCompletion);
- }
-
@Override
public CompletableFuture<Object> asyncRequestBody(final Endpoint endpoint, final Object body) {
return asyncRequestBody(endpoint, createSetBodyProcessor(body));
@@ -744,18 +714,6 @@ public class DefaultProducerTemplate extends ServiceSupport implements ProducerT
.thenApply(this::extractResultBody);
}
- @Override
- public CompletableFuture<Exchange> asyncCallback(
- final Endpoint endpoint, final Exchange exchange, final Synchronization onCompletion) {
- return asyncSend(endpoint, exchange).thenApply(createCompletionFunction(onCompletion));
- }
-
- @Override
- public CompletableFuture<Exchange> asyncCallback(
- final Endpoint endpoint, final Processor processor, final Synchronization onCompletion) {
- return asyncSend(endpoint, processor).thenApply(createCompletionFunction(onCompletion));
- }
-
protected CompletableFuture<Object> asyncRequestBody(final Endpoint endpoint, Processor processor) {
return asyncRequestBody(endpoint, processor, (Processor) null);
}
@@ -786,22 +744,6 @@ public class DefaultProducerTemplate extends ServiceSupport implements ProducerT
return exchangeFuture;
}
- protected CompletableFuture<Object> asyncCallback(
- final Endpoint endpoint, final ExchangePattern pattern,
- final Object body, final Synchronization onCompletion) {
- return asyncSend(endpoint, pattern, createSetBodyProcessor(body), null)
- .thenApply(createCompletionFunction(onCompletion))
- .thenApply(answer -> {
- Object result = extractResultBody(answer, pattern);
- if (pattern == ExchangePattern.InOnly) {
- // return null if not OUT capable
- return null;
- } else {
- return result;
- }
- });
- }
-
private org.apache.camel.spi.ProducerCache getProducerCache() {
if (!isStarted()) {
throw new IllegalStateException("ProducerTemplate has not been started");
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/OnCamelContextLifecycleStrategy.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/OnCamelContextLifecycleStrategy.java
index de6a728418f..15563080fae 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/OnCamelContextLifecycleStrategy.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/OnCamelContextLifecycleStrategy.java
@@ -22,10 +22,8 @@ import org.apache.camel.VetoCamelContextStartException;
import org.apache.camel.spi.LifecycleStrategy;
import org.apache.camel.spi.OnCamelContextInitialized;
import org.apache.camel.spi.OnCamelContextInitializing;
-import org.apache.camel.spi.OnCamelContextStart;
import org.apache.camel.spi.OnCamelContextStarted;
import org.apache.camel.spi.OnCamelContextStarting;
-import org.apache.camel.spi.OnCamelContextStop;
import org.apache.camel.spi.OnCamelContextStopped;
import org.apache.camel.spi.OnCamelContextStopping;
import org.apache.camel.support.LifecycleStrategySupport;
@@ -60,18 +58,6 @@ class OnCamelContextLifecycleStrategy extends LifecycleStrategySupport {
}
}
- @Override
- public void onContextStart(CamelContext context) throws VetoCamelContextStartException {
- for (OnCamelContextStart handler : context.getRegistry().findByType(OnCamelContextStart.class)) {
- // RoutesBuilder should register them-self to the camel context
- // to avoid invoking them multiple times if routes are discovered
- // from the registry (i.e. camel-main)
- if (!(handler instanceof RoutesBuilder)) {
- handler.onContextStart(context);
- }
- }
- }
-
@Override
public void onContextStarting(CamelContext context) throws VetoCamelContextStartException {
for (OnCamelContextStarting handler : context.getRegistry().findByType(OnCamelContextStarting.class)) {
@@ -96,18 +82,6 @@ class OnCamelContextLifecycleStrategy extends LifecycleStrategySupport {
}
}
- @Override
- public void onContextStop(CamelContext context) {
- for (OnCamelContextStop handler : context.getRegistry().findByType(OnCamelContextStop.class)) {
- // RoutesBuilder should register them-self to the camel context
- // to avoid invoking them multiple times if routes are discovered
- // from the registry (i.e. camel-main)
- if (!(handler instanceof RoutesBuilder)) {
- handler.onContextStop(context);
- }
- }
- }
-
@Override
public void onContextStopping(CamelContext context) {
for (OnCamelContextStopping handler : context.getRegistry().findByType(OnCamelContextStopping.class)) {
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanOgnlPerformanceTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanOgnlPerformanceTest.java
index 4015c02a66e..5333a859aae 100644
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanOgnlPerformanceTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/component/bean/BeanOgnlPerformanceTest.java
@@ -28,7 +28,8 @@ import org.junit.jupiter.api.Test;
public class BeanOgnlPerformanceTest extends ContextTestSupport {
private int size = 1000;
- private String cache = "true";
+
+ private String scope = "Singleton";
@Override
protected Registry createRegistry() throws Exception {
@@ -57,16 +58,16 @@ public class BeanOgnlPerformanceTest extends ContextTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("direct:start").toF("bean:foo?cache=%s&method=hello('Camel')", cache)
- .toF("bean:foo?cache=%s&method=hello('Camel')", cache)
- .toF("bean:foo?cache=%s&method=hello('Camel')", cache)
- .toF("bean:foo?cache=%s&method=hello('Camel')", cache)
- .toF("bean:foo?cache=%s&method=hello('Camel')", cache)
- .toF("bean:foo?cache=%s&method=hello('Camel')", cache)
- .toF("bean:foo?cache=%s&method=hello('Camel')", cache)
- .toF("bean:foo?cache=%s&method=hello('Camel')", cache)
- .toF("bean:foo?cache=%s&method=hello('Camel')", cache)
- .toF("bean:foo?cache=%s&method=hello('Camel')", cache).to("mock:result");
+ from("direct:start").toF("bean:foo?scope=%s&method=hello('Camel')", scope)
+ .toF("bean:foo?scope=%s&method=hello('Camel')", scope)
+ .toF("bean:foo?scope=%s&method=hello('Camel')", scope)
+ .toF("bean:foo?scope=%s&method=hello('Camel')", scope)
+ .toF("bean:foo?scope=%s&method=hello('Camel')", scope)
+ .toF("bean:foo?scope=%s&method=hello('Camel')", scope)
+ .toF("bean:foo?scope=%s&method=hello('Camel')", scope)
+ .toF("bean:foo?scope=%s&method=hello('Camel')", scope)
+ .toF("bean:foo?scope=%s&method=hello('Camel')", scope)
+ .toF("bean:foo?scope=%s&method=hello('Camel')", scope).to("mock:result");
}
};
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/component/bean/ProxyReturnFutureListTest.java b/core/camel-core/src/test/java/org/apache/camel/component/bean/ProxyReturnFutureListTest.java
deleted file mode 100644
index a0525578f6d..00000000000
--- a/core/camel-core/src/test/java/org/apache/camel/component/bean/ProxyReturnFutureListTest.java
+++ /dev/null
@@ -1,93 +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.component.bean;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-
-public class ProxyReturnFutureListTest extends ContextTestSupport {
-
- @Test
- public void testFutureList() throws Exception {
- Users service = ProxyHelper.createProxy(context.getEndpoint("direct:echo"), Users.class);
-
- Future<List<String>> future = service.getUsers(true);
- log.info("Got future");
- assertFalse(future.isDone(), "Should not be done");
- log.info("Waiting for future to be done ...");
-
- List<String> users = future.get(2, TimeUnit.SECONDS);
- assertEquals("Claus", users.get(0));
- assertEquals("Jonathan", users.get(1));
- }
-
- @Test
- public void testFutureListCallTwoTimes() throws Exception {
- Users service = ProxyHelper.createProxy(context.getEndpoint("direct:echo"), Users.class);
-
- Future<List<String>> future = service.getUsers(true);
- log.info("Got future");
- assertFalse(future.isDone(), "Should not be done");
- log.info("Waiting for future to be done ...");
-
- List<String> users = future.get(2, TimeUnit.SECONDS);
- assertEquals("Claus", users.get(0));
- assertEquals("Jonathan", users.get(1));
-
- future = service.getUsers(true);
- log.info("Got future");
- assertFalse(future.isDone(), "Should not be done");
- log.info("Waiting for future to be done ...");
-
- users = future.get(2, TimeUnit.SECONDS);
- assertEquals("Claus", users.get(0));
- assertEquals("Jonathan", users.get(1));
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:echo").delay(50).process(new Processor() {
- public void process(Exchange exchange) throws Exception {
- List<String> users = new ArrayList<>();
- users.add("Claus");
- users.add("Jonathan");
- exchange.getIn().setBody(users);
- }
- });
- }
- };
- }
-
- public interface Users {
- Future<List<String>> getUsers(boolean gold);
- }
-
-}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java
index 028a7d53646..83b493c2e8c 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextWithLifecycleStrategyRestartTest.java
@@ -104,7 +104,7 @@ public class DefaultCamelContextWithLifecycleStrategyRestartTest extends Context
private AtomicInteger removeCounter = new AtomicInteger();
@Override
- public void onContextStart(CamelContext context) throws VetoCamelContextStartException {
+ public void onContextStarting(CamelContext context) throws VetoCamelContextStartException {
contextStartCounter.incrementAndGet();
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java
index cc0bf0643e9..ed09a391a2e 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java
@@ -18,20 +18,15 @@ package org.apache.camel.impl;
import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePattern;
import org.apache.camel.Processor;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.support.DefaultExchange;
-import org.apache.camel.support.SynchronizationAdapter;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
@@ -259,336 +254,6 @@ public class DefaultProducerTemplateAsyncTest extends ContextTestSupport {
assertTrue(delta > 50, "Should take longer than: " + delta);
}
- @Test
- public void testAsyncCallbackExchangeInOnly() throws Exception {
- final AtomicInteger order = new AtomicInteger();
-
- getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-
- final CountDownLatch latch = new CountDownLatch(1);
-
- Exchange exchange = context.getEndpoint("direct:start").createExchange();
- exchange.getIn().setBody("Hello");
-
- template.asyncCallback("direct:start", exchange, new SynchronizationAdapter() {
- @Override
- public void onDone(Exchange exchange) {
- assertEquals("Hello World", exchange.getIn().getBody());
- order.addAndGet(2);
- latch.countDown();
- }
- });
-
- order.addAndGet(1);
- assertTrue(latch.await(10, TimeUnit.SECONDS));
- order.addAndGet(4);
-
- assertMockEndpointsSatisfied();
- assertEquals(7, order.get());
- }
-
- @Test
- public void testAsyncCallbackExchangeInOut() throws Exception {
- final AtomicInteger order = new AtomicInteger();
-
- final CountDownLatch latch = new CountDownLatch(1);
-
- Exchange exchange = context.getEndpoint("direct:start").createExchange();
- exchange.getIn().setBody("Hello");
- exchange.setPattern(ExchangePattern.InOut);
-
- template.asyncCallback("direct:echo", exchange, new SynchronizationAdapter() {
- @Override
- public void onDone(Exchange exchange) {
- assertEquals("HelloHello", exchange.getMessage().getBody());
- order.addAndGet(2);
- latch.countDown();
- }
- });
-
- order.addAndGet(1);
- assertTrue(latch.await(10, TimeUnit.SECONDS));
- order.addAndGet(4);
-
- assertEquals(7, order.get());
- }
-
- @Test
- public void testAsyncCallbackExchangeInOnlyGetResult() throws Exception {
- final AtomicInteger order = new AtomicInteger();
-
- getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-
- Exchange exchange = context.getEndpoint("direct:start").createExchange();
- exchange.getIn().setBody("Hello");
-
- Future<Exchange> future = template.asyncCallback("direct:start", exchange, new SynchronizationAdapter() {
- @Override
- public void onDone(Exchange exchange) {
- assertEquals("Hello World", exchange.getIn().getBody());
- order.addAndGet(2);
- }
- });
-
- order.addAndGet(1);
- Exchange reply = future.get(10, TimeUnit.SECONDS);
- order.addAndGet(4);
-
- assertMockEndpointsSatisfied();
- assertEquals(7, order.get());
- assertNotNull(reply);
- }
-
- @Test
- public void testAsyncCallbackExchangeInOutGetResult() throws Exception {
- final AtomicInteger order = new AtomicInteger();
-
- Exchange exchange = context.getEndpoint("direct:start").createExchange();
- exchange.getIn().setBody("Hello");
- exchange.setPattern(ExchangePattern.InOut);
-
- Future<Exchange> future = template.asyncCallback("direct:echo", exchange, new SynchronizationAdapter() {
- @Override
- public void onDone(Exchange exchange) {
- assertEquals("HelloHello", exchange.getMessage().getBody());
- order.addAndGet(2);
- }
- });
-
- order.addAndGet(1);
- Exchange reply = future.get(10, TimeUnit.SECONDS);
- order.addAndGet(4);
-
- assertEquals(7, order.get());
- assertNotNull(reply);
- assertEquals("HelloHello", reply.getMessage().getBody());
- }
-
- @Test
- public void testAsyncCallbackBodyInOnly() throws Exception {
- final AtomicInteger order = new AtomicInteger();
-
- getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-
- final CountDownLatch latch = new CountDownLatch(1);
-
- template.asyncCallbackSendBody("direct:start", "Hello", new SynchronizationAdapter() {
- @Override
- public void onDone(Exchange exchange) {
- assertEquals("Hello World", exchange.getIn().getBody());
- order.addAndGet(2);
- latch.countDown();
- }
- });
-
- order.addAndGet(1);
- assertTrue(latch.await(10, TimeUnit.SECONDS));
- order.addAndGet(4);
-
- assertMockEndpointsSatisfied();
- assertEquals(7, order.get());
- }
-
- @Test
- public void testAsyncCallbackBodyInOut() throws Exception {
- final AtomicInteger order = new AtomicInteger();
-
- final CountDownLatch latch = new CountDownLatch(1);
-
- template.asyncCallbackRequestBody("direct:echo", "Hello", new SynchronizationAdapter() {
- @Override
- public void onDone(Exchange exchange) {
- assertEquals("HelloHello", exchange.getMessage().getBody());
- order.addAndGet(2);
- latch.countDown();
- }
- });
-
- order.addAndGet(1);
- assertTrue(latch.await(10, TimeUnit.SECONDS));
- order.addAndGet(4);
-
- assertEquals(7, order.get());
- }
-
- @Test
- public void testAsyncCallbackBodyInOnlyGetResult() throws Exception {
- final AtomicInteger order = new AtomicInteger();
-
- getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-
- Future<Object> future = template.asyncCallbackSendBody("direct:start", "Hello", new SynchronizationAdapter() {
- @Override
- public void onDone(Exchange exchange) {
- assertEquals("Hello World", exchange.getIn().getBody());
- order.addAndGet(2);
- }
- });
-
- order.addAndGet(1);
- Object reply = future.get(10, TimeUnit.SECONDS);
- order.addAndGet(4);
-
- assertMockEndpointsSatisfied();
- assertEquals(7, order.get());
- // no reply when in only
- assertNull(reply);
- }
-
- @Test
- public void testAsyncCallbackBodyInOutGetResult() throws Exception {
- final AtomicInteger order = new AtomicInteger();
-
- Future<Object> future = template.asyncCallbackRequestBody("direct:echo", "Hello", new SynchronizationAdapter() {
- @Override
- public void onDone(Exchange exchange) {
- assertEquals("HelloHello", exchange.getMessage().getBody());
- order.addAndGet(2);
- }
- });
-
- order.addAndGet(1);
- Object reply = future.get(10, TimeUnit.SECONDS);
- order.addAndGet(4);
-
- assertEquals(7, order.get());
- assertEquals("HelloHello", reply);
- }
-
- @Test
- public void testAsyncCallbackInOnlyProcessor() throws Exception {
- final AtomicInteger order = new AtomicInteger();
-
- getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
-
- final CountDownLatch latch = new CountDownLatch(1);
-
- template.asyncCallback("direct:start", new Processor() {
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setBody("Hello");
- }
- }, new SynchronizationAdapter() {
- @Override
- public void onDone(Exchange exchange) {
- assertEquals("Hello World", exchange.getIn().getBody());
- order.addAndGet(2);
- latch.countDown();
- }
- });
-
- order.addAndGet(1);
- assertTrue(latch.await(10, TimeUnit.SECONDS));
- order.addAndGet(4);
-
- assertMockEndpointsSatisfied();
- assertEquals(7, order.get());
- }
-
- @Test
- public void testAsyncCallbackInOutProcessor() throws Exception {
- final AtomicInteger order = new AtomicInteger();
-
- final CountDownLatch latch = new CountDownLatch(1);
-
- template.asyncCallback("direct:echo", new Processor() {
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setBody("Hello");
- exchange.setPattern(ExchangePattern.InOut);
- }
- }, new SynchronizationAdapter() {
- @Override
- public void onDone(Exchange exchange) {
- assertEquals("HelloHello", exchange.getMessage().getBody());
- order.addAndGet(2);
- latch.countDown();
- }
- });
-
- order.addAndGet(1);
- assertTrue(latch.await(10, TimeUnit.SECONDS));
- order.addAndGet(4);
-
- assertEquals(7, order.get());
- }
-
- @Test
- public void testAsyncCallbackThreadsInOutProcessor() throws Exception {
- final AtomicInteger order = new AtomicInteger();
-
- final CountDownLatch latch = new CountDownLatch(1);
-
- template.asyncCallback("direct:threads", new Processor() {
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setBody("Bye");
- exchange.setPattern(ExchangePattern.InOut);
- }
- }, new SynchronizationAdapter() {
- @Override
- public void onDone(Exchange exchange) {
- assertEquals("ByeBye", exchange.getMessage().getBody());
- order.addAndGet(2);
- latch.countDown();
- }
- });
-
- order.addAndGet(1);
- assertTrue(latch.await(10, TimeUnit.SECONDS));
- order.addAndGet(4);
-
- assertEquals(7, order.get());
- }
-
- @Test
- public void testAsyncCallbackExchangeInOnlyWithFailure() throws Exception {
- final AtomicInteger order = new AtomicInteger();
-
- final CountDownLatch latch = new CountDownLatch(1);
-
- Exchange exchange = context.getEndpoint("direct:error").createExchange();
- exchange.getIn().setBody("Hello");
-
- template.asyncCallback("direct:error", exchange, new SynchronizationAdapter() {
- @Override
- public void onFailure(Exchange exchange) {
- assertEquals("Damn forced by unit test", exchange.getException().getMessage());
- order.addAndGet(2);
- latch.countDown();
- }
- });
-
- order.addAndGet(1);
- assertTrue(latch.await(10, TimeUnit.SECONDS));
- order.addAndGet(4);
-
- assertEquals(7, order.get());
- }
-
- @Test
- public void testAsyncCallbackExchangeInOutWithFailure() throws Exception {
- final AtomicInteger order = new AtomicInteger();
-
- final CountDownLatch latch = new CountDownLatch(1);
-
- Exchange exchange = context.getEndpoint("direct:error").createExchange();
- exchange.getIn().setBody("Hello");
- exchange.setPattern(ExchangePattern.InOut);
-
- template.asyncCallback("direct:error", exchange, new SynchronizationAdapter() {
- @Override
- public void onFailure(Exchange exchange) {
- assertEquals("Damn forced by unit test", exchange.getException().getMessage());
- order.addAndGet(2);
- latch.countDown();
- }
- });
-
- order.addAndGet(1);
- assertTrue(latch.await(10, TimeUnit.SECONDS));
- order.addAndGet(4);
-
- assertEquals(7, order.get());
- }
-
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/DummyLifecycleStrategy.java b/core/camel-core/src/test/java/org/apache/camel/impl/DummyLifecycleStrategy.java
index d1dca8923b2..f368ac24a12 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/DummyLifecycleStrategy.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/DummyLifecycleStrategy.java
@@ -34,13 +34,13 @@ public class DummyLifecycleStrategy extends LifecycleStrategySupport {
private final List<String> events = new ArrayList<>();
@Override
- public void onContextStart(CamelContext context) throws VetoCamelContextStartException {
- events.add("onContextStart");
+ public void onContextStarting(CamelContext context) throws VetoCamelContextStartException {
+ events.add("onContextStarting");
}
@Override
- public void onContextStop(CamelContext context) {
- events.add("onContextStop");
+ public void onContextStopping(CamelContext context) {
+ events.add("onContextStopping");
}
@Override
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyDiscoveryTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyDiscoveryTest.java
index 81d29410c01..9d1349b7c64 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyDiscoveryTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyDiscoveryTest.java
@@ -23,16 +23,14 @@ import org.apache.camel.TestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.spi.OnCamelContextInitialized;
import org.apache.camel.spi.OnCamelContextInitializing;
-import org.apache.camel.spi.OnCamelContextStart;
-import org.apache.camel.spi.OnCamelContextStop;
+import org.apache.camel.spi.OnCamelContextStarting;
+import org.apache.camel.spi.OnCamelContextStopping;
import org.junit.jupiter.api.Test;
import static org.apache.camel.support.LifecycleStrategySupport.onCamelContextInitialized;
import static org.apache.camel.support.LifecycleStrategySupport.onCamelContextInitializing;
-import static org.apache.camel.support.LifecycleStrategySupport.onCamelContextStart;
import static org.apache.camel.support.LifecycleStrategySupport.onCamelContextStarted;
import static org.apache.camel.support.LifecycleStrategySupport.onCamelContextStarting;
-import static org.apache.camel.support.LifecycleStrategySupport.onCamelContextStop;
import static org.apache.camel.support.LifecycleStrategySupport.onCamelContextStopped;
import static org.apache.camel.support.LifecycleStrategySupport.onCamelContextStopping;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -42,10 +40,8 @@ public class LifecycleStrategyDiscoveryTest extends TestSupport {
public void testLifecycleStrategyDiscovery() throws Exception {
final AtomicInteger onInitializing = new AtomicInteger();
final AtomicInteger onInitialized = new AtomicInteger();
- final AtomicInteger onStart = new AtomicInteger();
final AtomicInteger onStarting = new AtomicInteger();
final AtomicInteger onStarted = new AtomicInteger();
- final AtomicInteger onStop = new AtomicInteger();
final AtomicInteger onStopping = new AtomicInteger();
final AtomicInteger onStopped = new AtomicInteger();
final AtomicInteger onInitializingRoute = new AtomicInteger();
@@ -56,17 +52,16 @@ public class LifecycleStrategyDiscoveryTest extends TestSupport {
CamelContext context = new DefaultCamelContext();
context.getRegistry().bind("myOnInitializing", onCamelContextInitializing(c -> onInitializing.incrementAndGet()));
context.getRegistry().bind("myOnInitialized", onCamelContextInitialized(c -> onInitialized.incrementAndGet()));
- context.getRegistry().bind("myOnStart", onCamelContextStart(c -> onStart.incrementAndGet()));
context.getRegistry().bind("myOnStarting", onCamelContextStarting(c -> onStarting.incrementAndGet()));
context.getRegistry().bind("myOnStarted", onCamelContextStarted(c -> onStarted.incrementAndGet()));
- context.getRegistry().bind("myOnStop", onCamelContextStop(c -> onStop.incrementAndGet()));
context.getRegistry().bind("myOnStopping", onCamelContextStopping(c -> onStopping.incrementAndGet()));
context.getRegistry().bind("myOnStopped", onCamelContextStopped(c -> onStopped.incrementAndGet()));
try {
class MyBuilder
extends RouteBuilder
- implements OnCamelContextInitializing, OnCamelContextInitialized, OnCamelContextStart, OnCamelContextStop {
+ implements OnCamelContextInitializing, OnCamelContextInitialized, OnCamelContextStarting,
+ OnCamelContextStopping {
@Override
public void configure() throws Exception {
@@ -83,12 +78,12 @@ public class LifecycleStrategyDiscoveryTest extends TestSupport {
}
@Override
- public void onContextStart(CamelContext context) {
+ public void onContextStarting(CamelContext context) {
onStartRoute.incrementAndGet();
}
@Override
- public void onContextStop(CamelContext context) {
+ public void onContextStopping(CamelContext context) {
onStopRoute.incrementAndGet();
}
}
@@ -101,10 +96,8 @@ public class LifecycleStrategyDiscoveryTest extends TestSupport {
assertEquals(1, onInitializing.get());
assertEquals(1, onInitialized.get());
- assertEquals(1, onStart.get());
assertEquals(1, onStarting.get());
assertEquals(1, onStarted.get());
- assertEquals(1, onStop.get());
assertEquals(1, onStopping.get());
assertEquals(1, onStopped.get());
assertEquals(1, onInitializingRoute.get());
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java
index 0c505691888..9939f0b2c7c 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/LifecycleStrategyFailOnStartupTest.java
@@ -48,7 +48,7 @@ public class LifecycleStrategyFailOnStartupTest extends TestSupport {
private static class MyLifecycleStrategy extends DummyLifecycleStrategy {
@Override
- public void onContextStart(CamelContext context) throws VetoCamelContextStartException {
+ public void onContextStarting(CamelContext context) throws VetoCamelContextStartException {
throw new IllegalArgumentException("Forced");
}
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/VetoCamelContextStartTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/VetoCamelContextStartTest.java
index e073e9a7b3f..dc883214b4c 100644
--- a/core/camel-core/src/test/java/org/apache/camel/impl/VetoCamelContextStartTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/impl/VetoCamelContextStartTest.java
@@ -63,7 +63,7 @@ public class VetoCamelContextStartTest extends ContextTestSupport {
private static class MyVeto extends LifecycleStrategySupport {
@Override
- public void onContextStart(CamelContext context) throws VetoCamelContextStartException {
+ public void onContextStarting(CamelContext context) throws VetoCamelContextStartException {
// we just want camel context to not startup, but do not rethrow
// exception
throw new VetoCamelContextStartException("Forced", context, false);
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/BeanCachedProcessorTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/BeanCachedProcessorTest.java
deleted file mode 100644
index 9527710da2f..00000000000
--- a/core/camel-core/src/test/java/org/apache/camel/processor/BeanCachedProcessorTest.java
+++ /dev/null
@@ -1,103 +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.processor;
-
-import javax.naming.Context;
-
-import org.apache.camel.CamelExecutionException;
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.spi.Registry;
-import org.apache.camel.support.DefaultRegistry;
-import org.apache.camel.support.jndi.JndiBeanRepository;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-public class BeanCachedProcessorTest extends ContextTestSupport {
-
- private Context context;
-
- private Registry registry;
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- from("direct:noCache").to("bean:something?cache=false");
- from("direct:cached").to("bean:something?cache=true");
-
- }
- };
- }
-
- @Override
- protected Registry createRegistry() throws Exception {
- context = createJndiContext();
- context.bind("something", new MyBean());
- registry = new DefaultRegistry(new JndiBeanRepository(context));
- return registry;
- }
-
- @Test
- public void testFreshBeanInContext() throws Exception {
- // Just make sure the bean processor doesn't work if the cached is false
- MyBean originalInstance = registry.lookupByNameAndType("something", MyBean.class);
- template.sendBody("direct:noCache", null);
- context.unbind("something");
- context.bind("something", new MyBean());
- // Make sure we can get the object from the registry
- assertNotSame(registry.lookupByName("something"), originalInstance);
- template.sendBody("direct:noCache", null);
- }
-
- @Test
- public void testBeanWithCached() throws Exception {
- // Just make sure the bean processor doesn't work if the cached is false
- MyBean originalInstance = registry.lookupByNameAndType("something", MyBean.class);
- template.sendBody("direct:cached", null);
- context.unbind("something");
- context.bind("something", new MyBean());
- // Make sure we can get the object from the registry
- assertNotSame(registry.lookupByName("something"), originalInstance);
- try {
- template.sendBody("direct:cached", null);
- fail("The IllegalStateException is expected");
- } catch (CamelExecutionException ex) {
- boolean b = ex.getCause() instanceof IllegalStateException;
- assertTrue(b, "IllegalStateException is expected!");
- assertEquals("This bean is not supported to be invoked again!", ex.getCause().getMessage());
- }
- }
-
- public static class MyBean implements Processor {
- private boolean invoked;
-
- @Override
- public void process(Exchange exchange) throws Exception {
- if (invoked) {
- throw new IllegalStateException("This bean is not supported to be invoked again!");
- } else {
- invoked = true;
- }
- }
- }
-
-}
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
index ce1b2aaa190..2d7e942d2de 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java
@@ -702,7 +702,6 @@ public abstract class BaseMainSupport extends BaseService {
// allow doing custom configuration before camel is started
for (MainListener listener : listeners) {
listener.afterConfigure(this);
- listener.configure(camelContext);
}
// we want to log the property placeholder summary after routes has been started,
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainListener.java b/core/camel-main/src/main/java/org/apache/camel/main/MainListener.java
index 057287418df..d02190a16c7 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainListener.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainListener.java
@@ -16,22 +16,20 @@
*/
package org.apache.camel.main;
-import org.apache.camel.CamelContext;
-
/**
* A lifecycle listener to receive callbacks when the Main is started and stopped.
*/
public interface MainListener {
/**
- * Callback invoked after the the CamelContext has been created and before the auto-configured step starts.
+ * Callback invoked after the CamelContext has been created and before the auto-configured step starts.
*
* @param main the main instance
*/
void beforeInitialize(BaseMainSupport main);
/**
- * Callback invoked after the the CamelContext has been created and before the auto-configured step starts.
+ * Callback invoked after the CamelContext has been created and before the auto-configured step starts.
*
* @param main the main instance
*/
@@ -44,12 +42,6 @@ public interface MainListener {
*/
void afterConfigure(BaseMainSupport main);
- /**
- * @deprecated Use {@link #afterConfigure(BaseMainSupport)} instead
- */
- @Deprecated
- void configure(CamelContext context);
-
/**
* Callback before the CamelContext is being created and started.
*
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/MainListenerSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/MainListenerSupport.java
index 8c8809945ff..41284a9719a 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainListenerSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainListenerSupport.java
@@ -16,8 +16,6 @@
*/
package org.apache.camel.main;
-import org.apache.camel.CamelContext;
-
/**
* A useful base class for {@link org.apache.camel.main.MainListener} implementations.
*/
@@ -38,12 +36,6 @@ public class MainListenerSupport implements MainListener {
// noop
}
- @Override
- @Deprecated
- public void configure(CamelContext context) {
- // noop
- }
-
@Override
public void beforeStart(BaseMainSupport main) {
// noop
diff --git a/core/camel-main/src/test/java/org/apache/camel/main/ContextEventsTest.java b/core/camel-main/src/test/java/org/apache/camel/main/ContextEventsTest.java
index 4062ddeff9d..dccd49630ed 100644
--- a/core/camel-main/src/test/java/org/apache/camel/main/ContextEventsTest.java
+++ b/core/camel-main/src/test/java/org/apache/camel/main/ContextEventsTest.java
@@ -22,8 +22,8 @@ import org.apache.camel.BindToRegistry;
import org.apache.camel.CamelConfiguration;
import org.apache.camel.spi.OnCamelContextInitialized;
import org.apache.camel.spi.OnCamelContextInitializing;
-import org.apache.camel.spi.OnCamelContextStart;
-import org.apache.camel.spi.OnCamelContextStop;
+import org.apache.camel.spi.OnCamelContextStarting;
+import org.apache.camel.spi.OnCamelContextStopping;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -61,12 +61,12 @@ public class ContextEventsTest {
}
@BindToRegistry
- public OnCamelContextStart onContextStart() {
+ public OnCamelContextStarting onContextStart() {
return context -> onStart.incrementAndGet();
}
@BindToRegistry
- public OnCamelContextStop onContextStop() {
+ public OnCamelContextStopping onContextStop() {
return context -> onStop.incrementAndGet();
}
}
diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainListenerTest.java b/core/camel-main/src/test/java/org/apache/camel/main/MainListenerTest.java
index e6f2505f765..36b6e2142b7 100644
--- a/core/camel-main/src/test/java/org/apache/camel/main/MainListenerTest.java
+++ b/core/camel-main/src/test/java/org/apache/camel/main/MainListenerTest.java
@@ -52,7 +52,7 @@ public class MainListenerTest {
main.completed();
thread.join();
assertEquals(Arrays.asList("beforeInitialize", "beforeConfigure", "afterConfigure",
- "configure", "beforeStart", "afterStart", "beforeStop", "afterStop"), events);
+ "beforeStart", "afterStart", "beforeStop", "afterStop"), events);
}
@Test
diff --git a/core/camel-main/src/test/java/org/apache/camel/main/MainVetoTest.java b/core/camel-main/src/test/java/org/apache/camel/main/MainVetoTest.java
index c67800858ca..2b161e53083 100644
--- a/core/camel-main/src/test/java/org/apache/camel/main/MainVetoTest.java
+++ b/core/camel-main/src/test/java/org/apache/camel/main/MainVetoTest.java
@@ -56,7 +56,7 @@ public class MainVetoTest {
private class MyVetoLifecycle extends LifecycleStrategySupport {
@Override
- public void onContextStart(CamelContext context) throws VetoCamelContextStartException {
+ public void onContextStarting(CamelContext context) throws VetoCamelContextStartException {
throw new VetoCamelContextStartException("We do not like this route", context, false);
}
}
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/LifecycleStrategySupport.java b/core/camel-support/src/main/java/org/apache/camel/support/LifecycleStrategySupport.java
index ef482f6335a..7c085e26bd6 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/LifecycleStrategySupport.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/LifecycleStrategySupport.java
@@ -30,10 +30,8 @@ import org.apache.camel.spi.LifecycleStrategy;
import org.apache.camel.spi.OnCamelContextEvent;
import org.apache.camel.spi.OnCamelContextInitialized;
import org.apache.camel.spi.OnCamelContextInitializing;
-import org.apache.camel.spi.OnCamelContextStart;
import org.apache.camel.spi.OnCamelContextStarted;
import org.apache.camel.spi.OnCamelContextStarting;
-import org.apache.camel.spi.OnCamelContextStop;
import org.apache.camel.spi.OnCamelContextStopped;
import org.apache.camel.spi.OnCamelContextStopping;
@@ -64,13 +62,6 @@ public abstract class LifecycleStrategySupport implements LifecycleStrategy {
}
}
- @Override
- public void onContextStart(CamelContext context) throws VetoCamelContextStartException {
- if (handler instanceof OnCamelContextStart) {
- ((OnCamelContextStart) handler).onContextStart(context);
- }
- }
-
@Override
public void onContextStarting(CamelContext context) throws VetoCamelContextStartException {
if (handler instanceof OnCamelContextStarting) {
@@ -85,13 +76,6 @@ public abstract class LifecycleStrategySupport implements LifecycleStrategy {
}
}
- @Override
- public void onContextStop(CamelContext context) {
- if (handler instanceof OnCamelContextStop) {
- ((OnCamelContextStop) handler).onContextStop(context);
- }
- }
-
@Override
public void onContextStopping(CamelContext context) {
if (handler instanceof OnCamelContextStopping) {
@@ -126,16 +110,6 @@ public abstract class LifecycleStrategySupport implements LifecycleStrategy {
};
}
- @Deprecated
- public static LifecycleStrategy adapt(OnCamelContextStart handler) {
- return new LifecycleStrategySupport() {
- @Override
- public void onContextStart(CamelContext context) throws VetoCamelContextStartException {
- handler.onContextStart(context);
- }
- };
- }
-
public static LifecycleStrategy adapt(OnCamelContextStarting handler) {
return new LifecycleStrategySupport() {
@Override
@@ -154,16 +128,6 @@ public abstract class LifecycleStrategySupport implements LifecycleStrategy {
};
}
- @Deprecated
- public static LifecycleStrategy adapt(OnCamelContextStop handler) {
- return new LifecycleStrategySupport() {
- @Override
- public void onContextStop(CamelContext context) {
- handler.onContextStop(context);
- }
- };
- }
-
public static LifecycleStrategy adapt(OnCamelContextStopping handler) {
return new LifecycleStrategySupport() {
@Override
@@ -196,11 +160,6 @@ public abstract class LifecycleStrategySupport implements LifecycleStrategy {
return consumer::accept;
}
- @Deprecated
- public static OnCamelContextStart onCamelContextStart(Consumer<CamelContext> consumer) {
- return consumer::accept;
- }
-
public static OnCamelContextStarting onCamelContextStarting(Consumer<CamelContext> consumer) {
return consumer::accept;
}
@@ -209,11 +168,6 @@ public abstract class LifecycleStrategySupport implements LifecycleStrategy {
return consumer::accept;
}
- @Deprecated
- public static OnCamelContextStop onCamelContextStop(Consumer<CamelContext> consumer) {
- return consumer::accept;
- }
-
public static OnCamelContextStopping onCamelContextStopping(Consumer<CamelContext> consumer) {
return consumer::accept;
}
@@ -228,24 +182,6 @@ public abstract class LifecycleStrategySupport implements LifecycleStrategy {
//
// ********************************
- /**
- * @deprecated see {@link LifecycleStrategy#onContextStart(CamelContext)}
- */
- @Deprecated
- @Override
- public void onContextStart(CamelContext context) throws VetoCamelContextStartException {
- // noop
- }
-
- /**
- * @deprecated see {@link LifecycleStrategy#onContextStop(CamelContext)}
- */
- @Deprecated
- @Override
- public void onContextStop(CamelContext context) {
- // noop
- }
-
@Override
public void onComponentAdd(String name, Component component) {
// noop
diff --git a/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc b/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc
index 3773f80e466..a6b564c66f5 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc
@@ -69,6 +69,9 @@ We have removed deprecated APIs such as the following:
- Removed `uri` attribute on `@EndpointInject`, `@Produce`, and `@Consume` as you should use `value` (default) instead.
For example `@Produce(uri = "kafka:cheese")` should be changed to `@Produce("kafka:cheese")`
- Removed `label` on `@UriEndpoint` as you should use `category` instead.
+- Removed all `asyncCallback` methods on `ProducerTemplate`. Use `asyncSend` or `asyncRequest` instead.
+- Removed `org.apache.camel.spi.OnCamelContextStart`. Use `org.apache.camel.spi.OnCamelContextStarting` instead.
+- Removed `org.apache.camel.spi.OnCamelContextStop`. Use `org.apache.camel.spi.OnCamelContextStopping` instead.
== YAML DSL
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java
deleted file mode 100644
index 2838126b4e8..00000000000
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncCallbackTest.java
+++ /dev/null
@@ -1,106 +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.itest.async;
-
-import java.util.List;
-import java.util.Vector;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.support.SynchronizationAdapter;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class HttpAsyncCallbackTest extends HttpAsyncTestSupport {
-
- private static final CountDownLatch LATCH = new CountDownLatch(3);
-
- @Test
- void testAsyncAndSyncAtSameTimeWithHttp() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedBodiesReceivedInAnyOrder("Hello Claus", "Hello Hadrian", "Hello Willem");
-
- // START SNIPPET: e3
- MyCallback callback = new MyCallback();
-
- // Send 3 async request/reply message to the http endpoint
- // where we let the callback handle gathering the responses
- String url = "http://localhost:" + getPort() + "/myservice";
- template.asyncCallbackRequestBody(url, "Claus", callback);
- template.asyncCallbackRequestBody(url, "Hadrian", callback);
- template.asyncCallbackRequestBody(url, "Willem", callback);
-
- // END SNIPPET: e3
- MockEndpoint.assertIsSatisfied(context);
-
- assertTrue(LATCH.await(10, TimeUnit.SECONDS), "Should get 3 callbacks");
-
- // assert that we got all the correct data in our callback
- assertTrue(callback.getData().contains("Hello Claus"), "Claus is missing");
- assertTrue(callback.getData().contains("Hello Hadrian"), "Hadrian is missing");
- assertTrue(callback.getData().contains("Hello Willem"), "Willem is missing");
- }
-
- // START SNIPPET: e2
- /**
- * Our own callback that will gather all the responses. We extend the SynchronizationAdapter class as we then only
- * need to override the onComplete method.
- */
- private static class MyCallback extends SynchronizationAdapter {
-
- // below the String elements are added in the context of different threads so that we should make
- // sure that this's done in a thread-safe manner, that's no two threads should call the data.add()
- // method below concurrently, so why we use Vector here and not e.g. ArrayList
- private final List<String> data = new Vector<>();
-
- @Override
- public void onComplete(Exchange exchange) {
- // this method is invoked when the exchange was a success and we can get the response
- String body = exchange.getMessage().getBody(String.class);
- data.add(body);
-
- // the latch is used for testing purposes
- LATCH.countDown();
- }
-
- public List<String> getData() {
- return data;
- }
- }
- // END SNIPPET: e2
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
- // START SNIPPET: e1
- // The mocks are here for unit test
- // Simulate a slow http service (delaying a bit) we want to invoke async
- from("jetty:http://0.0.0.0:" + getPort() + "/myservice")
- .delay(300)
- .transform(body().prepend("Hello "))
- .to("mock:result");
- // END SNIPPET: e1
- }
- };
- }
-}