Author: sanka
Date: Sun Oct 21 23:59:42 2007
New Revision: 587012
URL: http://svn.apache.org/viewvc?rev=587012&view=rev
Log:
Applied the patch to fix the issue described in
https://issues.apache.org/jira/browse/BSF-3
Modified:
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/AbstractScriptEngine.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Bindings.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Invocable.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptContext.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngine.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineFactory.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineManager.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleBindings.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleScriptContext.java
Modified:
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/AbstractScriptEngine.java
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/AbstractScriptEngine.java?rev=587012&r1=587011&r2=587012&view=diff
==============================================================================
---
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/AbstractScriptEngine.java
(original)
+++
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/AbstractScriptEngine.java
Sun Oct 21 23:59:42 2007
@@ -181,6 +181,8 @@
* @param bindings the namespace to be associated with specified scope
* @param scope the level of scope of the specified namespace
* @throws IllegalArgumentException if scope is invalid
+ * @throws IllegalArgumentException if the bindings is null and the scope
+ * is ScriptContext.ENGINE_SCOPE
*/
public void setBindings(Bindings bindings, int scope)
throws UnsupportedOperationException {
Modified:
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Bindings.java
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Bindings.java?rev=587012&r1=587011&r2=587012&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Bindings.java
(original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Bindings.java Sun
Oct 21 23:59:42 2007
@@ -36,7 +36,7 @@
* @throws IllegalArgumentException if the key is null not an
* instance of java.lang.String
* */
- public Object put(Object key,Object value)throws
IllegalArgumentException;
+ public Object put(Object key,Object value);
/**
@@ -48,9 +48,9 @@
* @throws IllegalArgumentException if a key is null or is not an
* instance of java.lang.String
*/
- public void putAll(Map toMerge) throws IllegalArgumentException;
+ public void putAll(Map toMerge);
public boolean containsKey(Object key);
- public Object get(Object key) throws NullPointerException,
ClassCastException, IllegalArgumentException;
- public Object remove(Object key) throws NullPointerException,
ClassCastException, IllegalArgumentException;
+ public Object get(Object key);
+ public Object remove(Object key);
}
Modified:
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Invocable.java
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Invocable.java?rev=587012&r1=587011&r2=587012&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Invocable.java
(original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Invocable.java
Sun Oct 21 23:59:42 2007
@@ -33,9 +33,11 @@
* @return resultant object after the execution of the procedure
* @throws ScriptException if the invocation of the scripting procedure
* fails
+ * @throws NoSuchMethodException if method with given name or matching
+ * argument types cannot be found
*/
public Object invokeFunction(String name, Object[] args)
- throws ScriptException;
+ throws ScriptException, NoSuchMethodException;
/**
* Invokes a procedure on an object which already defined in the
@@ -48,9 +50,11 @@
* procedure
* @throws ScriptException if the invocation of the procedure
* fails
+ * @throws NoSuchMethodException if a method with given name or matching
+ * argument types cannot be found
*/
public Object invokeMethod(Object thiz, String name, Object[] args)
throws
- ScriptException;
+ ScriptException, NoSuchMethodException;
/**
* Retrieves an instance of java class whose methods are
Modified:
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptContext.java
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptContext.java?rev=587012&r1=587011&r2=587012&view=diff
==============================================================================
---
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptContext.java
(original)
+++
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptContext.java
Sun Oct 21 23:59:42 2007
@@ -44,7 +44,7 @@
* @return the associated value with the specified name
* @throws IllegalArgumentException if the name is null
*/
- public Object getAttribute(String name) throws IllegalArgumentException;
+ public Object getAttribute(String name);
/**
* Retrieves the value of an attribute in the specified scope.
@@ -57,8 +57,7 @@
* @throws IllegalArgumentException if the name is null or the
* scope is invalid
*/
- public Object getAttribute(String name, int scope) throws
- IllegalArgumentException;
+ public Object getAttribute(String name, int scope);
/**
* Retrieves the lowest value of the scope for which the
@@ -110,8 +109,7 @@
* @throws IllegalArgumentException if the name is null or if the
* scope is invalid
*/
- public Object removeAttribute(String name, int scope) throws
- IllegalArgumentException;
+ public Object removeAttribute(String name, int scope);
/**
* Associates a specified value with the specifed name in the
@@ -123,8 +121,7 @@
* @throws IllegalArgumentException if the name is null or the
* scope is invalid
*/
- public void setAttribute(String key,Object value,int scope) throws
- IllegalArgumentException;
+ public void setAttribute(String key,Object value,int scope);
/**
* Associates the specified namespace with the specified scope.
@@ -132,10 +129,11 @@
* @param bindings the namespace to be associated with the
* specified level of scope
* @param scope the specified level of scope
- * @throws IllegalArgumentException if the scope is invalid
+ * @throws IllegalArgumentException if the scope is invalid
+ * @throws NullPointerException if the bindings is null and the
+ * scope is ScriptEngine.ENGINE_SCOPE
*/
- public void setBindings(Bindings bindings,int scope) throws
- IllegalArgumentException;
+ public void setBindings(Bindings bindings,int scope);
public List getScopes();
Modified:
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngine.java
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngine.java?rev=587012&r1=587011&r2=587012&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngine.java
(original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngine.java
Sun Oct 21 23:59:42 2007
@@ -187,7 +187,7 @@
* @return associated namespace for the specified level of scope
* @throws IllegalArgumentException if the scope is invalid
*/
- public Bindings getBindings(int scope) throws IllegalArgumentException;
+ public Bindings getBindings(int scope);
/**
* Associates a key and a value in the ScriptEngine namespace.
@@ -197,7 +197,7 @@
* specified key
* @throws IllegalArgumentException if the key is null
*/
- public void put(String key, Object value) throws
IllegalArgumentException;
+ public void put(String key, Object value);
/**
* Associates the specified namespace with the specified level of
@@ -209,7 +209,7 @@
* be associated with
* @throws if the scope is invalid
*/
- public void setBindings(Bindings bindings, int scope) throws
IllegalArgumentException;
+ public void setBindings(Bindings bindings, int scope);
/**
* Returns the default ScriptContext of the ScriptEngine whose Bindings,
Readers
Modified:
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineFactory.java
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineFactory.java?rev=587012&r1=587011&r2=587012&view=diff
==============================================================================
---
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineFactory.java
(original)
+++
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineFactory.java
Sun Oct 21 23:59:42 2007
@@ -99,7 +99,7 @@
*/
public Object getParameter(String key);
- public String getMethodCallSyntax(Object o, String method, String[]
args);
+ public String getMethodCallSyntax(String obj, String method, String[]
args);
public String getOutputStatement(String toDisplay);
Modified:
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineManager.java
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineManager.java?rev=587012&r1=587011&r2=587012&view=diff
==============================================================================
---
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineManager.java
(original)
+++
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineManager.java
Sun Oct 21 23:59:42 2007
@@ -60,19 +60,22 @@
* Constructs ScriptEngineManager and initializes it.
*/
public ScriptEngineManager() {
-
- Iterator iterator = Service.providers(ScriptEngineFactory.class);
-
+ this(Thread.currentThread().getContextClassLoader());
+ }
+
+ public ScriptEngineManager(ClassLoader loader) {
+ Iterator iterator = Service.providers(ScriptEngineFactory.class,
loader);
+
while (iterator.hasNext()) {
- ScriptEngineFactory factory;
- try {
- factory = (ScriptEngineFactory) iterator.next();
- } catch (Throwable e) {
- // likely jars required by every script engine not on
classpath
- // TODO: log exception
- continue;
- }
- engineSpis.add(factory);
+ ScriptEngineFactory factory;
+ try {
+ factory = (ScriptEngineFactory) iterator.next();
+ } catch (Throwable e) {
+ // likely jars required by every script engine not on classpath
+ // TODO: log exception
+ continue;
+ }
+ engineSpis.add(factory);
List data = factory.getNames();
// gets all descriptinve names for Scripting Engine
@@ -89,8 +92,8 @@
for (int i=0; i<data.size(); i++) {
mimeTypeAssociations.put(data.get(i), factory);
}
- }
- }
+ }
+ }
/**
* Retrieves the associated value for the spefied key in the
@@ -181,26 +184,25 @@
* Retrieves an array of instances of ScriptEngineFactory class
* which are found by the discovery mechanism.
*
- * @return an array of all discovered ScriptEngineFactory
+ * @return a list of all discovered ScriptEngineFactory
* instances
*/
- public ScriptEngineFactory[] getEngineFactories(){
+ public List getEngineFactories(){
ArrayList factories = new ArrayList();
Iterator iter = engineSpis.iterator();
while(iter.hasNext()) {
factories.add(iter.next());
}
- return (ScriptEngineFactory[]) factories.toArray(
- new ScriptEngineFactory[factories.size()]);
+ return factories;
}
/**
- * Retrieves the namespace corresponds to GLOBAL_SCOPE.
+ * Retrieves the bindings corresponds to GLOBAL_SCOPE.
*
- * @return the namespace of GLOBAL_SCOPE
+ * @return the bindings of GLOBAL_SCOPE
*/
- public Bindings getNamespace(){
+ public Bindings getBindings(){
return globalscope;
}
@@ -216,33 +218,33 @@
}
/**
- * Register a extension with a ScriptEngineFactory class. It
+ * Register a extension with a ScriptEngineFactory. It
* overrides any such association discovered previously.
*
* @param extension the extension associated with the specified
* ScriptEngineFactory class
- * @param factory the ScriptEngineFactory class associated with
+ * @param factory the ScriptEngineFactory associated with
* the specified extension
*/
- public void registerEngineExtension(String extension, Class factory){
+ public void registerEngineExtension(String extension, ScriptEngineFactory
factory){
extensionAssocitions.put(extension, factory);
}
/**
- * Registers descriptive name with a ScriptEngineFactory class.
+ * Registers descriptive name with a ScriptEngineFactory.
* It overrides any associations discovered previously.
*
* @param name a descriptive name associated with the specifed
* ScriptEngineFactory class
- * @param factory the ScriptEngineFactory class associated with
+ * @param factory the ScriptEngineFactory associated with
* the specified descriptive name
*/
- public void registerEngineName(String name, Class factory){
+ public void registerEngineName(String name, ScriptEngineFactory factory){
nameAssociations.put(name, factory);
}
/**
- * Registers a MIME type with a ScriptEngineFactory class. It
+ * Registers a MIME type with a ScriptEngineFactory. It
* overrides any associations discovered previously.
*
* @param mimeType the MIME type associated with specified
@@ -250,16 +252,16 @@
* @param factory the ScriptEngineFactory associated with the
* specified MIME type
*/
- public void registerEngineMimeType(String mimeType,Class factory){
+ public void registerEngineMimeType(String mimeType,ScriptEngineFactory
factory){
mimeTypeAssociations.put(mimeType,factory);
}
/**
* Sets the GLOBAL_SCOPE value to the specified namespace.
*
- * @param namespace the namespace to be stored in GLOBAL_SCOPE
+ * @param bindings the namespace to be stored in GLOBAL_SCOPE
*/
- public void setNamespace(Bindings namespace){
- globalscope = namespace;
+ public void setBindings(Bindings bindings){
+ globalscope = bindings;
}
}
Modified:
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleBindings.java
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleBindings.java?rev=587012&r1=587011&r2=587012&view=diff
==============================================================================
---
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleBindings.java
(original)
+++
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleBindings.java
Sun Oct 21 23:59:42 2007
@@ -52,6 +52,12 @@
public SimpleBindings(Map map){
this.map = map;
}
+
+
+
+ public Object put(Object key, Object value) {
+ return put((String) key, value);
+ }
/**
* Associates the specified value with the specified key in a
@@ -61,14 +67,17 @@
* @param key the String value which uniquely identifies the
* object
* @param value the object to be stored.
- * @throws IllegalArgumentException if the key is null or is not
- * java.lang.String type
+ * @throws NullPointerException if the key is null
+ * @throws IllegalArgumentException if the key empty
*/
- public Object put(Object key, Object value)
- throws IllegalArgumentException{
+ public Object put(String key, Object value) {
- if ((key == null) || !(key instanceof java.lang.String) ) {
- throw new IllegalArgumentException("key is null or not a String");
+ if (key == null) {
+ throw new NullPointerException("key is null");
+ }
+
+ if (key.length() == 0) {
+ throw new IllegalArgumentException("key is empty");
}
return map.put(key,value);
@@ -83,7 +92,7 @@
* @throws IllegalArgumentException if a key is null or is not
* java.lang.String type in the specified map
*/
- public void putAll(Map toMerge) throws IllegalArgumentException {
+ public void putAll(Map toMerge) {
Set keySet= toMerge.keySet();
Iterator keys= keySet.iterator();
Modified:
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleScriptContext.java
URL:
http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleScriptContext.java?rev=587012&r1=587011&r2=587012&view=diff
==============================================================================
---
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleScriptContext.java
(original)
+++
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleScriptContext.java
Sun Oct 21 23:59:42 2007
@@ -58,7 +58,7 @@
* @param name the name of the attribute
* @return the value of the attribute
*/
- public Object getAttribute(String name) throws IllegalArgumentException{
+ public Object getAttribute(String name) {
if (name == null) {
throw new IllegalArgumentException("name cannot be null");
@@ -83,8 +83,7 @@
* @return the value value associated with the specified name in
* specified level of scope
*/
- public Object getAttribute(String name, int scope)
- throws IllegalArgumentException{
+ public Object getAttribute(String name, int scope) {
if (name == null) {
throw new IllegalArgumentException("name cannot be null");
@@ -148,8 +147,7 @@
* @return value which is removed
* @throws
*/
- public Object removeAttribute(String name, int scope)
- throws IllegalArgumentException{
+ public Object removeAttribute(String name, int scope) {
if (name == null) {
throw new IllegalArgumentException("name is null");
@@ -177,8 +175,7 @@
* @throws IllegalArguementException if the name is null scope is
* invlaid
*/
- public void setAttribute(String name, Object value, int scope)
- throws IllegalArgumentException{
+ public void setAttribute(String name, Object value, int scope) {
if (name == null) {
throw new IllegalArgumentException("name is null");
@@ -204,11 +201,13 @@
* level of scope
* @param scope the level of scope
*/
- public void setBindings(Bindings namespace, int scope)
- throws IllegalArgumentException {
+ public void setBindings(Bindings namespace, int scope) {
switch (scope) {
case ENGINE_SCOPE:
+ if (namespace == null) {
+ throw new NullPointerException("binding is null for
ENGINE_SCOPE scope");
+ }
engineScope = namespace;
break;
case GLOBAL_SCOPE:
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]