View Javadoc
1   /*******************************************************************************
2    * Portions created by Sebastian Thomschke are copyright (c) 2005-2011 Sebastian
3    * Thomschke.
4    * 
5    * All Rights Reserved. This program and the accompanying materials
6    * are made available under the terms of the Eclipse Public License v1.0
7    * which accompanies this distribution, and is available at
8    * http://www.eclipse.org/legal/epl-v10.html
9    * 
10   * Contributors:
11   *     Sebastian Thomschke - initial implementation.
12   *******************************************************************************/
13  package net.sf.oval.internal.util;
14  
15  import java.lang.reflect.Method;
16  
17  import net.sf.oval.exception.ConstraintsViolatedException;
18  import net.sf.oval.exception.InvokingMethodFailedException;
19  
20  /**
21   * @author Sebastian Thomschke
22   */
23  public final class MethodInvocationCommand
24  {
25  	private final Object target;
26  	private final Method method;
27  	private final Object[] args;
28  
29  	public MethodInvocationCommand(final Object target, final Method method, final Object[] args)
30  	{
31  		this.target = target;
32  		this.method = method;
33  		this.args = args;
34  	}
35  
36  	public Object execute() throws InvokingMethodFailedException, ConstraintsViolatedException
37  	{
38  		return ReflectionUtils.invokeMethod(method, target, args);
39  	}
40  }