1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package com.sun.star.script.framework.provider.java; 25 26 import java.lang.reflect.Method; 27 import java.lang.reflect.InvocationTargetException; 28 29 /** 30 * A ScriptProxy object acts as a proxy for a Java <code>Method</code> 31 * 32 * @author Tomas O'Connor 33 * @created August 2, 2002 34 * @see java.lang.reflect.Method 35 */ 36 public class ScriptProxy 37 { 38 private Object m_targetObject; 39 private Method m_method; 40 41 42 /** 43 * Constructs a <code>ScriptProxy</code> object for the given 44 * <code>Method</code> 45 * 46 * @param method Description of the Parameter 47 */ ScriptProxy( Method method )48 public ScriptProxy( Method method ) 49 { 50 this.m_method = method; 51 } 52 53 54 /** 55 * Sets the <code>Object</code> on which the ScriptProxy should invoke 56 * the method 57 * 58 * @param obj The new targetObject value 59 */ setTargetObject( Object obj )60 public void setTargetObject( Object obj ) 61 { 62 m_targetObject = obj; 63 } 64 65 66 /** 67 * Invokes the method contained in this <code>ScriptProxy</code>, 68 * any exceptions resulting from the invocation will be thrown 69 * 70 * @param args the arguments to be passed when invoking 71 * the method 72 * @return the Object returned from the method 73 * invocation, may be null 74 * @exception IllegalAccessException Description of the Exception 75 * @exception InvocationTargetException Description of the Exception 76 * @exception IllegalArgumentException Description of the Exception 77 * @exception Exception Description of the Exception 78 * @see java.lang.reflect.Method for the exceptions 79 * that may be thrown 80 */ invoke( Object[] args )81 public Object invoke( Object[] args ) 82 throws IllegalAccessException, InvocationTargetException, 83 IllegalArgumentException 84 { 85 return m_method.invoke( m_targetObject, args ); 86 } 87 } 88 89