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.component.bean;
018
019 import org.apache.camel.CamelExchangeException;
020 import org.apache.camel.Exchange;
021 import org.apache.camel.util.ObjectHelper;
022
023 /**
024 * @version
025 */
026 public class MethodNotFoundException extends CamelExchangeException {
027 private static final long serialVersionUID = -7411465307141051012L;
028
029 private final Object bean;
030 private final String methodName;
031
032 public MethodNotFoundException(Exchange exchange, Object pojo, String methodName) {
033 super("Method with name: " + methodName + " not found on bean: " + pojo + " of type: " + ObjectHelper.className(pojo), exchange);
034 this.methodName = methodName;
035 this.bean = pojo;
036 }
037
038 public MethodNotFoundException(Exchange exchange, Class<?> type, String methodName, boolean isStaticMethod) {
039 super((isStaticMethod ? "Static method" : "Method") + " with name: " + methodName + " not found on class: " + ObjectHelper.name(type), exchange);
040 this.methodName = methodName;
041 this.bean = null;
042 }
043
044 public MethodNotFoundException(Object pojo, String methodName, Throwable cause) {
045 super("Method with name: " + methodName + " not found on bean: " + pojo + " of type:" + ObjectHelper.className(pojo), null, cause);
046 this.methodName = methodName;
047 this.bean = pojo;
048 }
049
050 public MethodNotFoundException(Class<?> type, String methodName, Throwable cause) {
051 super("Method with name: " + methodName + " not found on class: " + ObjectHelper.className(type), null, cause);
052 this.methodName = methodName;
053 this.bean = null;
054 }
055
056 public String getMethodName() {
057 return methodName;
058 }
059
060 public Object getBean() {
061 return bean;
062 }
063 }