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.CamelExchangeException; 020import org.apache.camel.Exchange; 021import org.apache.camel.util.ObjectHelper; 022 023/** 024 * @version 025 */ 026public 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, Object pojo, String methodName, String postfix) { 039 super("Method with name: " + methodName + " " + postfix + " not found on bean: " + pojo + " of type: " + ObjectHelper.className(pojo), exchange); 040 this.methodName = methodName; 041 this.bean = pojo; 042 } 043 044 public MethodNotFoundException(Exchange exchange, Class<?> type, String methodName, boolean isStaticMethod) { 045 super((isStaticMethod ? "Static method" : "Method") + " with name: " + methodName + " not found on class: " + ObjectHelper.name(type), exchange); 046 this.methodName = methodName; 047 this.bean = null; 048 } 049 050 public MethodNotFoundException(Object pojo, String methodName, Throwable cause) { 051 super("Method with name: " + methodName + " not found on bean: " + pojo + " of type:" + ObjectHelper.className(pojo), null, cause); 052 this.methodName = methodName; 053 this.bean = pojo; 054 } 055 056 public MethodNotFoundException(Class<?> type, String methodName, Throwable cause) { 057 super("Method with name: " + methodName + " not found on class: " + ObjectHelper.className(type), null, cause); 058 this.methodName = methodName; 059 this.bean = null; 060 } 061 062 public String getMethodName() { 063 return methodName; 064 } 065 066 public Object getBean() { 067 return bean; 068 } 069}