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 */
017package org.apache.camel.component.bean;
018
019import org.apache.camel.AsyncCallback;
020import org.apache.camel.AsyncProcessor;
021import org.apache.camel.CamelContext;
022import org.apache.camel.Exchange;
023import org.apache.camel.Processor;
024import org.apache.camel.support.ServiceSupport;
025
026public class BeanProcessor extends ServiceSupport implements AsyncProcessor {
027
028    private final DelegateBeanProcessor delegate;
029
030    public BeanProcessor(Object pojo, BeanInfo beanInfo) {
031        this.delegate = new DelegateBeanProcessor(pojo, beanInfo);
032    }
033
034    public BeanProcessor(Object pojo, CamelContext camelContext, ParameterMappingStrategy parameterMappingStrategy) {
035        this.delegate = new DelegateBeanProcessor(pojo, camelContext, parameterMappingStrategy);
036    }
037
038    public BeanProcessor(Object pojo, CamelContext camelContext) {
039        this.delegate = new DelegateBeanProcessor(pojo, camelContext);
040    }
041
042    public BeanProcessor(BeanHolder beanHolder) {
043        this.delegate = new DelegateBeanProcessor(beanHolder);
044    }
045
046    @Override
047    public void process(Exchange exchange) throws Exception {
048        delegate.process(exchange);
049    }
050
051    @Override
052    public boolean process(Exchange exchange, AsyncCallback callback) {
053        return delegate.process(exchange, callback);
054    }
055
056    public Processor getProcessor() {
057        return delegate.getProcessor();
058    }
059
060    public BeanHolder getBeanHolder() {
061        return delegate.getBeanHolder();
062    }
063
064    public Object getBean() {
065        return delegate.getBean();
066    }
067
068    public String getMethod() {
069        return delegate.getMethod();
070    }
071
072    public boolean isMultiParameterArray() {
073        return delegate.isMultiParameterArray();
074    }
075
076    public void setMultiParameterArray(boolean mpArray) {
077        delegate.setMultiParameterArray(mpArray);
078    }
079
080    public void setMethod(String method) {
081        delegate.setMethod(method);
082    }
083
084    public boolean isShorthandMethod() {
085        return delegate.isShorthandMethod();
086    }
087
088    public void setShorthandMethod(boolean shorthandMethod) {
089        delegate.setShorthandMethod(shorthandMethod);
090    }
091
092    @Override
093    protected void doStart() throws Exception {
094        delegate.doStart();
095    }
096
097    @Override
098    protected void doStop() throws Exception {
099        delegate.doStop();
100    }
101
102    private static final class DelegateBeanProcessor extends AbstractBeanProcessor {
103
104        public DelegateBeanProcessor(Object pojo, BeanInfo beanInfo) {
105            super(pojo, beanInfo);
106        }
107
108        public DelegateBeanProcessor(Object pojo, CamelContext camelContext, ParameterMappingStrategy parameterMappingStrategy) {
109            super(pojo, camelContext, parameterMappingStrategy);
110        }
111
112        public DelegateBeanProcessor(Object pojo, CamelContext camelContext) {
113            super(pojo, camelContext);
114        }
115
116        public DelegateBeanProcessor(BeanHolder beanHolder) {
117            super(beanHolder);
118        }
119    }
120
121}