summaryrefslogtreecommitdiff
path: root/scripting/java/com/sun/star/script/framework/provider/java
diff options
context:
space:
mode:
Diffstat (limited to 'scripting/java/com/sun/star/script/framework/provider/java')
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/java/Resolver.java50
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java212
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java364
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/java/ScriptProxy.java92
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java128
5 files changed, 846 insertions, 0 deletions
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/Resolver.java b/scripting/java/com/sun/star/script/framework/provider/java/Resolver.java
new file mode 100755
index 000000000000..548425ca3e44
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/java/Resolver.java
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.script.framework.provider.java;
+
+/**
+ * The Resolver interface is an interface common to all classes which
+ * want to implement an algorithm for obtaining a ScriptProxy object
+ * for a particular ScriptDescriptor and Class
+ *
+ * @author Tomas O'Connor
+ * @created August 2, 2002
+ */
+
+public interface Resolver {
+ /**
+ * Returns a ScriptProxy object for the given ScriptDescriptor and Class
+ *
+ * @param sd A script Descriptor
+ * @param c A Class
+ * @return The ScriptProxy value
+ */
+ public ScriptProxy getProxy( ScriptDescriptor sd, Class c )
+ throws NoSuchMethodException;
+}
+
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java b/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java
new file mode 100755
index 000000000000..59e9952b5837
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/java/ScriptDescriptor.java
@@ -0,0 +1,212 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+package com.sun.star.script.framework.provider.java;
+
+import java.util.Vector;
+import java.util.StringTokenizer;
+
+/**
+ * The <code>ScriptDescriptor</code> object is used to store the search
+ * criteria that should be used for finding a particular script
+ *
+ * @author Tomas O'Connor
+ * @created August 2, 2002
+ */
+public class ScriptDescriptor
+{
+ private String m_name;
+ private String m_methodName;
+ private String m_className;
+ private Vector m_classpath;
+ private Vector m_argumentTypes = new Vector( 11 );
+
+
+ /**
+ * Constructs a ScriptDescriptor for the given name
+ *
+ * @param name Script Name
+ * @exception IllegalArgumentException if the given name does not contain a "."
+ */
+ public ScriptDescriptor( String name )
+ throws IllegalArgumentException
+ {
+ int idx = name.lastIndexOf( '.' );
+
+ if ( idx == -1 )
+ {
+ throw new IllegalArgumentException( "Invalid method name" );
+ }
+
+ this.m_name = name;
+ this.m_methodName = name.substring( idx + 1 );
+ this.m_className = name.substring( 0, idx );
+ }
+
+
+ /**
+ * Gets the fully qualified name of this <code>ScriptDescriptor</code>
+ *
+ * @return The Script Name value
+ */
+ public String getName()
+ {
+ return m_name;
+ }
+
+ /**
+ * Gets the fully qualified name of this <code>ScriptDescriptor</code>
+ *
+ * @return The Script Name value
+ */
+ public String getClassName()
+ {
+ return m_className;
+ }
+
+
+ /**
+ * Gets the method name of this <code>ScriptDescriptor</code>
+ *
+ * @return The methodName value
+ */
+ public String getMethodName()
+ {
+ return m_methodName;
+ }
+
+
+ /**
+ * Sets the classpath value stored by this <code>ScriptDescriptor</code>
+ *
+ * @param classpath The new classpath value
+ */
+ public void setClasspath( String classpath )
+ {
+ StringTokenizer stk = new StringTokenizer( classpath, ":" );
+ while( stk.hasMoreElements() )
+ {
+ this.m_classpath.add( (String) stk.nextElement() );
+ }
+ }
+
+ /**
+ * Sets the classpath value stored by this <code>ScriptDescriptor</code>
+ *
+ * @param classpath The new classpath value
+ */
+ public void setClasspath( Vector classpath )
+ {
+ this.m_classpath = classpath;
+ }
+
+
+ /**
+ * Gets the classpath value stored by this <code>ScriptDescriptor</code>
+ *
+ * @return The classpath value
+ */
+ public Vector getClasspath()
+ {
+ return m_classpath;
+ }
+
+
+ /**
+ * Adds the given <code>Class</code> to the list of argument types stored in
+ * this ScriptDescriptor
+ *
+ * @param clazz The feature to be added to the ArgumentType attribute
+ */
+ public synchronized void addArgumentType( Class clazz )
+ {
+ m_argumentTypes.addElement( clazz );
+ }
+
+
+ /**
+ * Adds the given array of <code>Class</code> to the list of argument types
+ * stored in this ScriptDescriptor
+ *
+ * @param classes The feature to be added to the ArgumentTypes attribute
+ */
+ public synchronized void addArgumentTypes( Class[] classes )
+ {
+ for ( int i = 0; i < classes.length; i++ )
+ {
+ addArgumentType( classes[ i ] );
+ }
+ }
+
+
+ /**
+ * Gets a list of the types of the arguments stored in this
+ * <code>ScriptDescriptor</code>
+ *
+ * return the argument types as an array of Class
+ *
+ * @return The argumentTypes value
+ */
+ public synchronized Class[]
+ getArgumentTypes()
+ {
+ if ( m_argumentTypes.size() > 0 )
+ return ( Class[] ) m_argumentTypes.toArray( new Class[ 0 ] );
+ else
+ return null;
+ }
+
+
+ /**
+ * Returns a <code>String</code> representation of this
+ * <code>ScriptDescriptor</code>
+ *
+ * @return The scriptName including the parameters.
+ */
+ public String toString()
+ {
+ StringBuffer description = new StringBuffer( m_name );
+ Class[] types = getArgumentTypes();
+
+ description.append( " (" );
+
+ if ( types != null )
+ {
+ for ( int i = 0; i < types.length - 1; i++ )
+ {
+ description.append( types[ i ].getName() );
+ description.append( ", " );
+ }
+
+ description.append( types[ types.length - 1 ].getName() );
+ }
+ description.append( ")" );
+
+ return description.toString();
+ }
+}
+
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java
new file mode 100755
index 000000000000..707ea05624d9
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java
@@ -0,0 +1,364 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+package com.sun.star.script.framework.provider.java;
+
+import com.sun.star.frame.XModel;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.document.XScriptInvocationContext;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.Any;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.net.MalformedURLException;
+
+import com.sun.star.script.provider.XScriptContext;
+import com.sun.star.script.provider.XScript;
+import com.sun.star.script.provider.ScriptExceptionRaisedException;
+import com.sun.star.script.provider.ScriptFrameworkErrorException;
+import com.sun.star.script.provider.ScriptFrameworkErrorType;
+
+import com.sun.star.script.framework.container.ScriptMetaData;
+
+import com.sun.star.script.framework.provider.*;
+import com.sun.star.script.framework.log.LogUtils;
+/**
+ * Description of the Class
+ *
+ * @author Noel Power
+ * @created August 2, 2002
+ */
+public class ScriptProviderForJava
+{
+ /**
+ * Description of the Class
+ *
+ * @author Noel Power
+ * @created August 2, 2002
+ */
+ public static class _ScriptProviderForJava extends ScriptProvider
+ {
+ private Resolver m_resolutionPolicy = new StrictResolver();
+
+ public _ScriptProviderForJava( XComponentContext ctx )
+ {
+ super (ctx, "Java");
+ }
+
+ public XScript getScript( /*IN*/String scriptURI )
+ throws com.sun.star.uno.RuntimeException,
+ ScriptFrameworkErrorException
+ {
+ ScriptMetaData scriptData = null;
+ scriptData = getScriptData( scriptURI );
+ ScriptImpl script = null;
+ try
+ {
+ script = new ScriptImpl( m_xContext, m_resolutionPolicy, scriptData, m_xModel, m_xInvocContext );
+ return script;
+ }
+ catch ( com.sun.star.uno.RuntimeException re )
+ {
+ throw new ScriptFrameworkErrorException( "Failed to create script object: " + re.getMessage(),
+ null, scriptData.getLanguageName(), language, ScriptFrameworkErrorType.UNKNOWN );
+ }
+
+ }
+
+ public boolean hasScriptEditor()
+ {
+ return false;
+ }
+
+ public ScriptEditor getScriptEditor()
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ *
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be used if needed
+ * @param regKey the registryKey
+ * @return returns a <code>XSingleServiceFactory</code> for creating
+ * the component
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory( String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey )
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if ( implName.equals( ScriptProviderForJava._ScriptProviderForJava.class.getName() ) )
+ {
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(
+ ScriptProviderForJava._ScriptProviderForJava.class,
+ "com.sun.star.script.provider.ScriptProviderForJava",
+ multiFactory,
+ regKey );
+ }
+
+ return xSingleServiceFactory;
+ }
+}
+
+class ScriptImpl implements XScript
+{
+ private ScriptMetaData metaData;
+ private XComponentContext m_xContext;
+ private XModel m_xModel;
+ private XScriptInvocationContext m_xInvocContext;
+ private XMultiComponentFactory m_xMultiComponentFactory;
+ private Resolver m_resolutionPolicy;
+ ScriptImpl( XComponentContext ctx, Resolver resolver, ScriptMetaData metaData, XModel xModel, XScriptInvocationContext xInvocContext ) throws com.sun.star.uno.RuntimeException
+ {
+ this.metaData = metaData;
+ this.m_xContext = ctx;
+ this.m_xModel = xModel;
+ this.m_xInvocContext = xInvocContext;
+ this.m_resolutionPolicy = resolver;
+ try
+ {
+ this.m_xMultiComponentFactory = m_xContext.getServiceManager();
+ }
+ catch ( Exception e )
+ {
+ LogUtils.DEBUG( LogUtils.getTrace( e ) );
+ throw new com.sun.star.uno.RuntimeException(
+ "Error constructing ScriptProvider: "
+ + e.getMessage() );
+ }
+
+ LogUtils.DEBUG("ScriptImpl [java] script data = " + metaData );
+ }
+ /**
+ * Invoke
+ *
+ *
+ * @param aParams All parameters; pure, out params are undefined in
+ * sequence, i.e., the value has to be ignored by the callee
+ * @param aOutParamIndex Out indices
+ * @param aOutParam Out parameters
+ * @returns The value returned from the function being invoked
+ * @throws IllegalArgumentException If there is no matching script name
+ * @throws CannotConvertException If args do not match or cannot be converted
+ * the those of the invokee
+ * @throws InvocationTargetException If the running script throws an exception
+ * this information is captured and rethrown as this exception type.
+ */
+
+ public Object invoke(
+ /*IN*/Object[] params,
+ /*OUT*/short[][] aOutParamIndex,
+ /*OUT*/Object[][] aOutParam )
+
+ throws ScriptFrameworkErrorException, com.sun.star.reflection.InvocationTargetException
+ {
+ LogUtils.DEBUG( "** ScriptProviderForJava::invoke: Starting..." );
+
+ // Initialise the out paramters - not used at the moment
+ aOutParamIndex[0] = new short[0];
+ aOutParam[0] = new Object[0];
+
+
+ Map languageProps = metaData.getLanguageProperties();
+
+ ScriptDescriptor scriptDesc =
+ new ScriptDescriptor( metaData.getLanguageName() );
+
+ ClassLoader scriptLoader = null;
+
+ try {
+ LogUtils.DEBUG( "Classloader starting..." );
+ scriptLoader = ClassLoaderFactory.getURLClassLoader(
+ metaData );
+ LogUtils.DEBUG( "Classloader finished..." );
+ }
+ catch (MalformedURLException mfe )
+ {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ mfe.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.MALFORMED_URL );
+ }
+ catch (NoSuitableClassLoaderException ncl )
+ {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ ncl.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+ }
+ catch (ArrayStoreException e )
+ {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ e.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+ }
+
+ ArrayList invocationArgList = new ArrayList();
+ Object[] invocationArgs = null;
+
+ LogUtils.DEBUG( "Parameter Mapping..." );
+
+ // Setup Context Object
+ XScriptContext xSc = ScriptContext.createContext(m_xModel, m_xInvocContext,
+ m_xContext, m_xMultiComponentFactory);
+ scriptDesc.addArgumentType( XScriptContext.class );
+ invocationArgList.add( xSc );
+
+ for ( int i = 0; i < params.length; i++ )
+ {
+ scriptDesc.addArgumentType( params[ i ].getClass() );
+ invocationArgList.add( params[ i ] );
+ }
+
+ if ( !invocationArgList.isEmpty() )
+ {
+ invocationArgs = invocationArgList.toArray();
+ }
+
+
+
+ LogUtils.DEBUG( "ScriptProxy starting... " );
+ ScriptProxy script = null;
+ try
+ {
+ String className = metaData.getLanguageName().substring( 0,
+ metaData.getLanguageName().lastIndexOf( '.' ) );
+ LogUtils.DEBUG( "About to load Class " + className + " starting... " );
+
+ long start = new java.util.Date().getTime();
+ Class c = scriptLoader.loadClass( className );
+ long end = new java.util.Date().getTime();
+
+ LogUtils.DEBUG("loadClass took: " + String.valueOf(end - start) +
+ "milliseconds");
+
+ try
+ {
+ LogUtils.DEBUG( "class loaded ... " );
+ script = m_resolutionPolicy.getProxy( scriptDesc, c );
+ LogUtils.DEBUG( "script resolved ... " );
+ }
+ catch( NoSuchMethodException e )
+ {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ e.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.NO_SUCH_SCRIPT );
+ }
+ }
+ catch ( ClassNotFoundException e )
+ {
+ // Framework error
+ throw new ScriptFrameworkErrorException(
+ e.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.NO_SUCH_SCRIPT );
+ }
+
+ LogUtils.DEBUG( "Starting Invoke on Proxy ..." );
+ Object result = null;
+
+ try
+ {
+ long start = new java.util.Date().getTime();
+ result = script.invoke( invocationArgs );
+ long end = new java.util.Date().getTime();
+
+ LogUtils.DEBUG("invoke took: " +
+ String.valueOf(end - start) + "milliseconds");
+ }
+ catch ( java.lang.IllegalArgumentException iae )
+ {
+ throw new ScriptFrameworkErrorException(
+ iae.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+
+ }
+ catch ( java.lang.IllegalAccessException ia )
+ {
+ throw new ScriptFrameworkErrorException(
+ ia.getMessage(), null,
+ metaData.getLanguageName(), metaData.getLanguage(),
+ ScriptFrameworkErrorType.UNKNOWN );
+ }
+ catch ( java.lang.reflect.InvocationTargetException ite )
+ {
+ Throwable targetException = ite.getTargetException();
+ ScriptExceptionRaisedException se =
+ new ScriptExceptionRaisedException(
+ targetException.toString() );
+ se.lineNum = -1;
+ se.scriptName = metaData.getLanguageName();
+ se.language = "Java";
+ se.exceptionType = targetException.getClass().getName();
+ throw new com.sun.star.reflection.InvocationTargetException(
+ "Scripting Framework error executing script ", null, se );
+ }
+ catch ( Exception unknown )
+ {
+ ScriptExceptionRaisedException se =
+ new ScriptExceptionRaisedException(
+ unknown.toString() );
+ se.lineNum = -1;
+ se.scriptName = metaData.getLanguageName();
+ se.language = "Java";
+ se.exceptionType = unknown.getClass().getName();
+ throw new com.sun.star.reflection.InvocationTargetException(
+ "Scripting Framework error executing script ", null, se );
+ }
+ if ( result == null )
+ {
+ LogUtils.DEBUG( "Got Nothing Back" );
+ // in the case where there is no return type
+ Any voidAny = new Any(new Type(), null);
+ result = voidAny;
+ }
+ else
+ {
+ LogUtils.DEBUG( "Got object " + result );
+ }
+ return result;
+ }
+}
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProxy.java b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProxy.java
new file mode 100755
index 000000000000..6cd36c83710f
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProxy.java
@@ -0,0 +1,92 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+package com.sun.star.script.framework.provider.java;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * A ScriptProxy object acts as a proxy for a Java <code>Method</code>
+ *
+ * @author Tomas O'Connor
+ * @created August 2, 2002
+ * @see java.lang.reflect.Method
+ */
+public class ScriptProxy
+{
+ private Object m_targetObject;
+ private Method m_method;
+
+
+ /**
+ * Constructs a <code>ScriptProxy</code> object for the given
+ * <code>Method</code>
+ *
+ * @param method Description of the Parameter
+ */
+ public ScriptProxy( Method method )
+ {
+ this.m_method = method;
+ }
+
+
+ /**
+ * Sets the <code>Object</code> on which the ScriptProxy should invoke
+ * the method
+ *
+ * @param obj The new targetObject value
+ */
+ public void setTargetObject( Object obj )
+ {
+ m_targetObject = obj;
+ }
+
+
+ /**
+ * Invokes the method contained in this <code>ScriptProxy</code>,
+ * any exceptions resulting from the invocation will be thrown
+ *
+ * @param args the arguments to be passed when invoking
+ * the method
+ * @return the Object returned from the method
+ * invocation, may be null
+ * @exception IllegalAccessException Description of the Exception
+ * @exception InvocationTargetException Description of the Exception
+ * @exception IllegalArgumentException Description of the Exception
+ * @exception Exception Description of the Exception
+ * @see java.lang.reflect.Method for the exceptions
+ * that may be thrown
+ */
+ public Object invoke( Object[] args )
+ throws IllegalAccessException, InvocationTargetException,
+ IllegalArgumentException
+ {
+ return m_method.invoke( m_targetObject, args );
+ }
+}
+
diff --git a/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java b/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java
new file mode 100755
index 000000000000..8adb6e66e5e8
--- /dev/null
+++ b/scripting/java/com/sun/star/script/framework/provider/java/StrictResolver.java
@@ -0,0 +1,128 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+package com.sun.star.script.framework.provider.java;
+
+import java.lang.reflect.*;
+import com.sun.star.script.framework.log.LogUtils;
+
+/**
+ * A StrictResolver can be used to get a ScriptProxy object for a given
+ * ScriptDescriptor and Class. The StrictResolver is an implementation of
+ * the Resolver strategy. It will only return a ScriptProxy object if a
+ * method accepting all of the arguments specified in the ScriptDescriptor
+ * can be found in the Class.
+ *
+ * @author Tomas O'Connor
+ * @created August 2, 2002
+ */
+public class StrictResolver implements Resolver
+{
+ /**
+ *Constructor for the StrictResolver object
+ */
+ public StrictResolver()
+ {
+ LogUtils.DEBUG( this.getClass().getName() + " created" );
+ }
+
+
+ /**
+ * Returns a ScriptProxy object for the given ScriptDescriptor and Class.
+ * Only a strict match will be returned ie. where all of the arguments in
+ * the given ScriptDescriptor match the types of the
+ *
+ * @param sd the ScriptDescriptor for which a ScriptProxy is required
+ * @param c the Class file in which to search for the method
+ * @return the ScriptProxy matching the criteria, or null if no match is found
+ */
+ public ScriptProxy getProxy( ScriptDescriptor sd, Class c )
+ throws NoSuchMethodException
+ {
+ Method m = null;
+ ScriptProxy sp = null;
+
+ LogUtils.DEBUG( "StrictResolver.getProxy() for: " + sd.toString() );
+
+ try
+ {
+ m = resolveArguments( sd, c );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ throw new NoSuchMethodException( "StrictResolver.getProxy: Cant find method: "
+ + sd.getMethodName() + ":" + e.getMessage() );
+ }
+ catch ( NoSuchMethodException e )
+ {
+ throw new NoSuchMethodException( "StrictResolver.getProxy: Cant find method: "
+ + sd.getMethodName() + ":" + e.getMessage() );
+ }
+
+ sp = new ScriptProxy( m );
+
+ int modifiers = m.getModifiers();
+ if ( !Modifier.isStatic( modifiers ) )
+ {
+ Object o;
+ try
+ {
+ o = c.newInstance();
+ }
+ catch ( InstantiationException ie )
+ {
+ throw new NoSuchMethodException( "getScriptProxy: Cant instantiate: " +
+ c.getName() );
+ }
+ catch ( IllegalAccessException iae )
+ {
+ throw new NoSuchMethodException( "getScriptProxy: Cant access: "
+ + c.getName() );
+ }
+ sp.setTargetObject( o );
+ }
+
+ return sp;
+ }
+
+
+ /**
+ * Description of the Method
+ *
+ * @param sd Description of the Parameter
+ * @param c Description of the Parameter
+ * @return Description of the Return Value
+ * @exception ClassNotFoundException
+ * @exception NoSuchMethodException
+ */
+ private Method resolveArguments( ScriptDescriptor sd, Class c )
+ throws ClassNotFoundException, NoSuchMethodException
+ {
+ return c.getMethod( sd.getMethodName(), sd.getArgumentTypes() );
+ }
+}
+