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.spi;
018
019import java.lang.reflect.Method;
020
021import org.apache.camel.CamelContext;
022import org.apache.camel.Processor;
023
024/**
025 * Factory for creating a {@link Processor} that can invoke a method on a bean and supporting using Camel
026 * bean parameter bindings.
027 * <p/>
028 * This requires to have camel-bean on the classpath.
029 */
030public interface BeanProcessorFactory {
031
032    /**
033     * Creates the bean processor from the existing bean instance
034     *
035     * @param camelContext  the camel context
036     * @param bean          the bean
037     * @param method        the method to invoke
038     * @return the created processor
039     * @throws Exception is thrown if error creating the processor
040     */
041    Processor createBeanProcessor(CamelContext camelContext, Object bean, Method method) throws Exception;
042
043    /**
044     * Creates the bean processor from a given set of parameters that can refer
045     * to the bean via an existing bean, a reference to a bean, or its class name etc.
046     *
047     * @param camelContext  the camel context
048     * @param bean          the bean instance
049     * @param beanType      or the bean class name
050     * @param beanClass     or the bean class
051     * @param ref           or bean reference to lookup the bean from the registry
052     * @param method        optional name of method to invoke
053     * @param cacheBean    whether to cache lookup up the bean
054     * @return the created processor
055     * @throws Exception is thrown if error creating the processor
056     */
057    Processor createBeanProcessor(CamelContext camelContext, Object bean, String beanType, Class<?> beanClass, String ref,
058                                         String method, boolean cacheBean) throws Exception;
059}