Return-Path:
X-Original-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org
Delivered-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by minotaur.apache.org (Postfix) with SMTP id 448027E34
for ;
Sat, 27 Aug 2011 23:39:55 +0000 (UTC)
Received: (qmail 73135 invoked by uid 500); 27 Aug 2011 23:39:55 -0000
Delivered-To: apmail-incubator-connectors-commits-archive@incubator.apache.org
Received: (qmail 73078 invoked by uid 500); 27 Aug 2011 23:39:54 -0000
Mailing-List: contact connectors-commits-help@incubator.apache.org;
run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: connectors-dev@incubator.apache.org
Delivered-To: mailing list connectors-commits@incubator.apache.org
Received: (qmail 73071 invoked by uid 99); 27 Aug 2011 23:39:53 -0000
Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136)
by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Aug 2011 23:39:53 +0000
X-ASF-Spam-Status: No, hits=-2000.0 required=5.0
tests=ALL_TRUSTED
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Aug 2011 23:39:50 +0000
Received: from eris.apache.org (localhost [127.0.0.1])
by eris.apache.org (Postfix) with ESMTP id 9E8322388900;
Sat, 27 Aug 2011 23:39:30 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r1162459 - in /incubator/lcf/trunk:
framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/
site/src/documentation/content/xdocs/
Date: Sat, 27 Aug 2011 23:39:30 -0000
To: connectors-commits@incubator.apache.org
From: kwright@apache.org
X-Mailer: svnmailer-1.0.8
Message-Id: <20110827233930.9E8322388900@eris.apache.org>
Author: kwright
Date: Sat Aug 27 23:39:29 2011
New Revision: 1162459
URL: http://svn.apache.org/viewvc?rev=1162459&view=rev
Log:
Various script-engine related updates, including substantial documentation and various fixes for consistency etc.
Modified:
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java
incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java
incubator/lcf/trunk/site/src/documentation/content/xdocs/how-to-build-and-deploy.xml
incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java?rev=1162459&r1=1162458&r2=1162459&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/Variable.java Sat Aug 27 23:39:29 2011
@@ -50,8 +50,6 @@ public interface Variable
public static String ATTRIBUTE_NOTFOUNDSTATUS = "__NOTFOUND__";
/** CREATED status attribute */
public static String ATTRIBUTE_CREATEDSTATUS = "__CREATED__";
- /** RESULT attribute */
- public static String ATTRIBUTE_RESULT = "__result__";
/** Get the variable's value as a string */
public String getStringValue()
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java?rev=1162459&r1=1162458&r2=1162459&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableBoolean.java Sat Aug 27 23:39:29 2011
@@ -45,13 +45,20 @@ public class VariableBoolean extends Var
return value;
}
- /** Get the variable's value as a string */
- public String getStringValue()
+ public VariableReference doubleEquals(Variable v)
throws ScriptException
{
- if (value)
- return "true";
- return "false";
+ if (v == null)
+ throw new ScriptException("== operand cannot be null");
+ return new VariableBoolean(value == v.getBooleanValue());
+ }
+
+ public VariableReference exclamationEquals(Variable v)
+ throws ScriptException
+ {
+ if (v == null)
+ throw new ScriptException("!= operand cannot be null");
+ return new VariableBoolean(value != v.getBooleanValue());
}
public VariableReference doubleAmpersand(Variable v)
@@ -70,6 +77,22 @@ public class VariableBoolean extends Var
return new VariableBoolean(value || v.getBooleanValue());
}
+ public VariableReference ampersand(Variable v)
+ throws ScriptException
+ {
+ if (v == null)
+ throw new ScriptException("& operand cannot be null");
+ return new VariableBoolean(value && v.getBooleanValue());
+ }
+
+ public VariableReference pipe(Variable v)
+ throws ScriptException
+ {
+ if (v == null)
+ throw new ScriptException("| operand cannot be null");
+ return new VariableBoolean(value || v.getBooleanValue());
+ }
+
public VariableReference unaryExclamation()
throws ScriptException
{
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java?rev=1162459&r1=1162458&r2=1162459&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableInt.java Sat Aug 27 23:39:29 2011
@@ -72,7 +72,8 @@ public class VariableInt extends Variabl
throw new ScriptException("- operand cannot be null");
return new VariableInt(value - v.getIntValue());
}
-
+
+
public VariableReference asterisk(Variable v)
throws ScriptException
{
@@ -159,4 +160,10 @@ public class VariableInt extends Variabl
return new VariableInt(value | v.getIntValue());
}
+ public VariableReference unaryExclamation()
+ throws ScriptException
+ {
+ return new VariableInt(value ^ value);
+ }
+
}
Modified: incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java?rev=1162459&r1=1162458&r2=1162459&view=diff
==============================================================================
--- incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java (original)
+++ incubator/lcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/VariableResult.java Sat Aug 27 23:39:29 2011
@@ -57,7 +57,7 @@ public class VariableResult extends Vari
return new VariableBoolean(resultCode == 201);
else if (attributeName.equals(ATTRIBUTE_NOTFOUNDSTATUS))
return new VariableBoolean(resultCode == 404);
- else if (attributeName.equals(ATTRIBUTE_RESULT))
+ else if (attributeName.equals(ATTRIBUTE_VALUE))
return result;
else
return super.getAttribute(attributeName);
Modified: incubator/lcf/trunk/site/src/documentation/content/xdocs/how-to-build-and-deploy.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/site/src/documentation/content/xdocs/how-to-build-and-deploy.xml?rev=1162459&r1=1162458&r2=1162459&view=diff
==============================================================================
--- incubator/lcf/trunk/site/src/documentation/content/xdocs/how-to-build-and-deploy.xml (original)
+++ incubator/lcf/trunk/site/src/documentation/content/xdocs/how-to-build-and-deploy.xml Sat Aug 27 23:39:29 2011
@@ -83,6 +83,7 @@
lib
jars for all the connector plugins, which should be referenced by the appropriate clause in the ManifoldCF configuration file
wsdd
wsdd files that are needed by the included connectors in order to function
xxx-process
scripts, classpath jars, and -D switch values needed for a required connector-specific process
+
script-engine
jars and scripts for running the ManifoldCF script interpreter
example
a jetty-based example that runs in a single process (except for any connector-specific processes)
doc
javadocs for framework and all included connectors
Modified: incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml?rev=1162459&r1=1162458&r2=1162459&view=diff
==============================================================================
--- incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml (original)
+++ incubator/lcf/trunk/site/src/documentation/content/xdocs/script.xml Sat Aug 27 23:39:29 2011
@@ -53,42 +53,282 @@ java -cp ... org.apache.manifoldcf.scrip
and the ScriptParser will accordingly exit. You can also type ^Z to terminate the script.
If you use ScriptParser with a scripting file, that file will be read and interpreted. The arguments you provide will be loaded into an array
of strings, which is accessible from your script as the variable named __args__.
-
- Running the scripting language by hand
-
-
When you build ManifoldCF, the required dependent jars for the scripting language are copied to dist/script-engine/jar.
- You can run the interpreter in interactive mode by typing:
-
+
This, once again, will start the interpreter in interactive mode.
+
+
+ Script language syntax
+
+
A ManifoldCF script is not sensitive to whitespace or indenting. All comments begin with a '#' character and end with the end of that line.
+ Unquoted tokens can include alphanumeric characters, plus '_', '$', and '@'. Numeric tokens always begin with a number ('0'-'9'), and are
+ considered floating-point if they include a decimal point ('.'). Otherwise they are integers. String tokens can be quoted with either a double quote
+ ('"') or a single quote, and within strings characters can be escaped with a preceding backslash ('\').
+
A ManifoldCF script has a syntax that is readily described with a BNF grammar. See below.
Variables in the ManifoldCF scripting language determine the behavior of all aspects of expression evaluation, with the exception of operator precedence.
+ In particular, every canonical variable has the ability to support arbitrary attributes (which are named properties of the variable),
+ subscripts (children which are accessed by a numeric subscript), and all other operations, such as '+' or '=='. Not all kinds of
+ variable instance will in fact support all such features. Should you try to use a feature with a variable that does not support it, you will receive a
+ ScriptException telling you what you did wrong.
+
Since the actual operation details are bound to the variable, for binary operations the left-hand variable typically determines what actually takes place. For example:
There is, of course, a way to caste a variable to a different type. For example:
+
+print "3".__int__+7;
+ [java] 10
+
+
Here, we are using the built-in attribute __int__ to obtain the integer equivalent of the original string variable "3". See the following table for
+ a list of some of the standard attributes and their meanings:
+
+
Standard attributes
+
Attribute name
Meaning
+
__script__
Returns the script code that would create this variable
+
__string__
Returns the string value of the variable, if any
+
__int__
Returns the integer value of the variable, if any
+
__float__
Returns the floating-point value of the variable, if any
+
__boolean__
Returns the boolean value of the variable, if any
+
__size__
Returns the number of subscript children
+
__name__
Returns the 'name' of the variable
+
__value__
Returns the 'value' of the variable
+
__OK__
Returns a boolean 'true' if the variable was "OK", false otherwise
+
__NOTFOUND__
Returns a boolean 'true' if the variable was "NOTFOUND", false otherwise
+
__CREATED__
Returns a boolean 'true' if the variable was "CREATED", false otherwise
+
+
Obviously, only some variables will support each of the standard attributes. You will receive a script exception if you try to obtain a non-existent
+ attribute for a variable.
+
+ Integers
+
Integer variable types are created by non-quoted numeric values that do not have a '.' in them. For example, the character '4' will create an integer
+ variable type with a value of 4.
+
The operations supported for this variable type, and their meanings, are listed in the table below:
+
+
Integer operations
+
Operation
Meaning
Example
+
binary +
Addition, yielding an integer
4+7
+
binary -
Subtraction, yielding an integer
7-4
+
binary *
Multiplication, yielding an integer
7*4
+
binary /
Division, yielding an integer
7/4
+
unary -
Negation, yielding an integer
-4
+
binary ==
Equality comparison, yielding a boolean
7 == 4
+
binary !=
Inequality comparison, yielding a boolean
7 != 4
+
binary >=
Greater or equals comparison, yielding a boolean
7 >= 4
+
binary <=
Less or equals comparison, yielding a boolean
7 <= 4
+
binary >
Greater comparison, yielding a boolean
7 > 4
+
binary <
Less comparison, yielding a boolean
7 < 4
+
binary &
Bitwise AND, yielding an integer
7 & 4
+
binary |
Bitwise OR, yielding an integer
7 | 4
+
unary !
Bitwise NOT, yielding an integer
! 7
+
+
In addition, the standard attributes __script__, __string__, __int__, and __float__ are supported
+ by integer types.
+
+
+ Strings
+
String variable types are created by quoted sequences of characters. For example, the character '"hello world"' will create a string
+ variable type with an (unquoted) value of "hello world".
+
The operations supported for this variable type, and their meanings, are listed in the table below:
+
+
String operations
+
Operation
Meaning
Example
+
binary +
Concatenation, yielding a string
"hi" + "there"
+
binary ==
Equality comparison, yielding a boolean
"hi" == "there"
+
binary !=
Inequality comparison, yielding a boolean
"hi" != "there"
+
+
In addition, the standard attributes __script__, __string__, __int__, and __float__ are supported
+ by string types.
+
+
+ Floating-point numbers
+
Float variable types are created by non-quoted numeric values that have a '.' in them. For example, the token '4.1' will create a float
+ variable type with a value of 4.1
+
The operations supported for this variable type, and their meanings, are listed in the table below:
+
+
Float operations
+
Operation
Meaning
Example
+
binary +
Addition, yielding a float
4.0+7.0
+
binary -
Subtraction, yielding a float
7.0-4.0
+
binary *
Multiplication, yielding a float
7.0*4.0
+
binary /
Division, yielding a float
7.0/4.0
+
unary -
Negation, yielding a float
-4.0
+
binary ==
Equality comparison, yielding a boolean
7.0 == 4.0
+
binary !=
Inequality comparison, yielding a boolean
7.0 != 4.0
+
binary >=
Greater or equals comparison, yielding a boolean
7.0 >= 4.0
+
binary <=
Less or equals comparison, yielding a boolean
7.0 <= 4.0
+
binary >
Greater comparison, yielding a boolean
7.0 > 4.0
+
binary <
Less comparison, yielding a boolean
7.0 < 4.0
+
+
In addition, the standard attributes __script__, __string__, __int__, and __float__ are supported
+ by float types.
+
+
+ Booleans
+
Boolean variable types are created by the keywords 'true' and 'false'. For example, the token 'true' will create a boolean
+ variable type with a value of "true".
+
The operations supported for this variable type, and their meanings, are listed in the table below:
+
+
Boolean operations
+
Operation
Meaning
Example
+
binary ==
Equality comparison, yielding a boolean
7.0 == 4.0
+
binary !=
Inequality comparison, yielding a boolean
7.0 != 4.0
+
binary &&
AND logical operation, yielding a boolean
true && false
+
binary ||
OR logical operation, yielding a boolean
true || false
+
binary &
AND logical operation, yielding a boolean
true & false
+
binary |
OR logical operation, yielding a boolean
true | false
+
unary !
NOT logical operation, yielding a boolean
! true
+
+
In addition, the standard attributes __script__ and __boolean__ are supported
+ by boolean types.
+
+
+ Arrays
+
Array variable types are created by an initializer of the form '[' expression ',' ... expression ']'. For example, the code '[3, 4]' will create an array
+ variable type with two values, the integer "3" and the integer "4".
+
The operations supported for this variable type, and their meanings, are listed in the table below:
+
+
Array operations
+
Operation
Meaning
Example
+
subscript []
Find the specified subscript variable, yielding the variable
[3,4] [0]
+
+
In addition, the standard attributes __script__ and __size__ are supported
+ by array types.
The statements available to a ManifoldCF programmer are designed to support interaction with the ManifoldCF API. Thus, there is support for
+ all four HTTP verbs, as well as basic variable setting and control flow. The table below describes each statement type:
+
+
Statement types
+
Statement
Meaning
Example
+
'set' expression '=' expression ';'
Sets the variable described by the first expression with the value computed for the second
set myvar = 4 + 5;
+
'print' expression ';'
Prints the string value of the expression to stdout