001 /******************************************************************************* 002 * Portions created by Sebastian Thomschke are copyright (c) 2005-2011 Sebastian 003 * Thomschke. 004 * 005 * All Rights Reserved. This program and the accompanying materials 006 * are made available under the terms of the Eclipse Public License v1.0 007 * which accompanies this distribution, and is available at 008 * http://www.eclipse.org/legal/epl-v10.html 009 * 010 * Contributors: 011 * Sebastian Thomschke - initial implementation. 012 *******************************************************************************/ 013 package net.sf.oval.internal.util; 014 015 import java.lang.reflect.Method; 016 017 import net.sf.oval.exception.ConstraintsViolatedException; 018 import net.sf.oval.exception.InvokingMethodFailedException; 019 020 /** 021 * @author Sebastian Thomschke 022 */ 023 public final class MethodInvocationCommand 024 { 025 private final Object target; 026 private final Method method; 027 private final Object[] args; 028 029 public MethodInvocationCommand(final Object target, final Method method, final Object[] args) 030 { 031 this.target = target; 032 this.method = method; 033 this.args = args; 034 } 035 036 public Object execute() throws InvokingMethodFailedException, ConstraintsViolatedException 037 { 038 return ReflectionUtils.invokeMethod(method, target, args); 039 } 040 }