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 2020/01/07 14:52:21 UTC
[camel] 02/02: Remove not used classes
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 a0d45f8c844cd3a5288c08e32a9e992253986519
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jan 7 15:42:53 2020 +0100
Remove not used classes
---
.../InterceptorToAsyncProcessorBridge.java | 114 -----------------
.../camel/processor/MethodCallProcessor.java | 135 ---------------------
2 files changed, 249 deletions(-)
diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/InterceptorToAsyncProcessorBridge.java b/core/camel-base/src/main/java/org/apache/camel/processor/InterceptorToAsyncProcessorBridge.java
deleted file mode 100644
index 3720251..0000000
--- a/core/camel-base/src/main/java/org/apache/camel/processor/InterceptorToAsyncProcessorBridge.java
+++ /dev/null
@@ -1,114 +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 java.util.concurrent.CompletableFuture;
-
-import org.apache.camel.AsyncCallback;
-import org.apache.camel.AsyncProcessor;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.support.AsyncCallbackToCompletableFutureAdapter;
-import org.apache.camel.support.AsyncProcessorConverterHelper;
-import org.apache.camel.support.service.ServiceHelper;
-import org.apache.camel.support.service.ServiceSupport;
-
-// TODO: delete me
-
-/**
- * A bridge to have regular interceptors implemented as {@link org.apache.camel.Processor}
- * work with the asynchronous routing engine without causing side effects.
- */
-@Deprecated
-public class InterceptorToAsyncProcessorBridge extends ServiceSupport implements AsyncProcessor {
-
- private final AsyncProcessor interceptor;
- private volatile AsyncProcessor target;
- private volatile ThreadLocal<AsyncCallback> callback = new ThreadLocal<>();
- private volatile ThreadLocal<Boolean> interceptorDone = new ThreadLocal<>();
-
- /**
- * Constructs the bridge
- *
- * @param interceptor the interceptor to bridge
- */
- public InterceptorToAsyncProcessorBridge(Processor interceptor) {
- this.interceptor = AsyncProcessorConverterHelper.convert(interceptor);
- this.target = AsyncProcessorConverterHelper.convert(target);
- }
-
- /**
- * Process invoked by the interceptor
- * @param exchange the message exchange
- * @throws Exception
- */
- @Override
- public void process(Exchange exchange) throws Exception {
- // invoke when interceptor wants to invoke
- boolean done = interceptor.process(exchange, callback.get());
- interceptorDone.set(done);
- }
-
- @Override
- public boolean process(Exchange exchange, AsyncCallback callback) {
- // remember the callback to be used by the interceptor
- this.callback.set(callback);
- try {
- // invoke the target
- boolean done = target.process(exchange, callback);
- if (interceptorDone.get() != null) {
- // return the result from the interceptor if it was invoked
- return interceptorDone.get();
- } else {
- // otherwise from the target
- return done;
- }
- } finally {
- // cleanup
- this.callback.remove();
- this.interceptorDone.remove();
- }
- }
-
- @Override
- public CompletableFuture<Exchange> processAsync(Exchange exchange) {
- AsyncCallbackToCompletableFutureAdapter<Exchange> callback = new AsyncCallbackToCompletableFutureAdapter<>(exchange);
- process(exchange, callback);
- return callback.getFuture();
- }
-
- public void setTarget(Processor target) {
- this.target = AsyncProcessorConverterHelper.convert(target);
- }
-
- @Override
- public String toString() {
- return "AsyncBridge[" + interceptor.toString() + "]";
- }
-
- @Override
- protected void doStart() throws Exception {
- ServiceHelper.startService(target, interceptor);
- }
-
- @Override
- protected void doStop() throws Exception {
- callback.remove();
- interceptorDone.remove();
- ServiceHelper.stopService(interceptor, target);
- }
-}
diff --git a/core/camel-base/src/main/java/org/apache/camel/processor/MethodCallProcessor.java b/core/camel-base/src/main/java/org/apache/camel/processor/MethodCallProcessor.java
deleted file mode 100644
index 5c12413..0000000
--- a/core/camel-base/src/main/java/org/apache/camel/processor/MethodCallProcessor.java
+++ /dev/null
@@ -1,135 +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 org.apache.camel.AsyncCallback;
-import org.apache.camel.Exchange;
-import org.apache.camel.Expression;
-import org.apache.camel.Message;
-import org.apache.camel.Traceable;
-import org.apache.camel.spi.IdAware;
-import org.apache.camel.spi.RouteIdAware;
-import org.apache.camel.support.AsyncProcessorSupport;
-import org.apache.camel.support.DefaultMessage;
-import org.apache.camel.support.ExchangeHelper;
-import org.apache.camel.util.ObjectHelper;
-
-// TODO: delete me
-
-/**
- * A processor which are used when calling a method and setting the response as the message body
- */
-@Deprecated
-public class MethodCallProcessor extends AsyncProcessorSupport implements Traceable, IdAware, RouteIdAware {
- private String id;
- private String routeId;
- private final Expression expression;
-
- public MethodCallProcessor(Expression expression) {
- ObjectHelper.notNull(expression, "expression", this);
- this.expression = expression;
- }
-
- @Override
- public boolean process(Exchange exchange, AsyncCallback callback) {
- try {
- Object newBody = expression.evaluate(exchange, Object.class);
-
- if (exchange.getException() != null) {
- // the expression threw an exception so we should break-out
- callback.done(true);
- return true;
- }
-
- // if null/empty response its due to void / no-response, then dont change the body
- if (newBody != null) {
-
- Message old = exchange.getMessage();
-
- // create a new message container so we do not drag specialized message objects along
- // but that is only needed if the old message is a specialized message
- boolean copyNeeded = !(old.getClass().equals(DefaultMessage.class));
-
- if (copyNeeded) {
- Message msg = new DefaultMessage(exchange.getContext());
- msg.copyFromWithNewBody(old, newBody);
-
- // replace message on exchange (must set as OUT)
- ExchangeHelper.replaceMessage(exchange, msg, true);
- } else {
- // no copy needed so set replace value directly
- old.setBody(newBody);
-
- // but the message must be on OUT
- if (!exchange.hasOut()) {
- exchange.setOut(exchange.getIn());
- }
- }
- }
-
- } catch (Throwable e) {
- exchange.setException(e);
- }
-
- callback.done(true);
- return true;
- }
-
- @Override
- public String toString() {
- return "MethodCall(" + expression + ")";
- }
-
- @Override
- public String getTraceLabel() {
- return "methodCall[" + expression + "]";
- }
-
- @Override
- public String getId() {
- return id;
- }
-
- @Override
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public String getRouteId() {
- return routeId;
- }
-
- @Override
- public void setRouteId(String routeId) {
- this.routeId = routeId;
- }
-
- public Expression getExpression() {
- return expression;
- }
-
- @Override
- protected void doStart() throws Exception {
- // noop
- }
-
- @Override
- protected void doStop() throws Exception {
- // noop
- }
-}