001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.camel.processor;
018
019 import org.apache.camel.Exchange;
020 import org.apache.camel.Processor;
021 import org.apache.camel.util.ServiceHelper;
022
023 /**
024 * An interceptor which provides the processing logic as a pluggable processor
025 * which allows the {@link #proceed(Exchange)} method to be called at some point
026 *
027 * @version $Revision: 36321 $
028 */
029 public class Interceptor extends DelegateProcessor {
030 private Processor interceptorLogic;
031
032 public Interceptor() {
033 }
034
035 public Interceptor(Processor interceptorLogic) {
036 this.interceptorLogic = interceptorLogic;
037 }
038
039 public void process(Exchange exchange) throws Exception {
040 interceptorLogic.process(exchange);
041 }
042
043 public Processor getInterceptorLogic() {
044 return interceptorLogic;
045 }
046
047 public void setInterceptorLogic(Processor interceptorLogic) {
048 this.interceptorLogic = interceptorLogic;
049 }
050
051 @Override
052 protected void doStart() throws Exception {
053 ServiceHelper.startService(interceptorLogic);
054 super.doStart();
055 }
056
057 @Override
058 protected void doStop() throws Exception {
059 ServiceHelper.stopService(interceptorLogic);
060 super.doStop();
061 }
062 }