POLYGENE-29 - Updated documentation and added more languages.

Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/f78110d9
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/f78110d9
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/f78110d9

Branch: refs/heads/develop
Commit: f78110d98670bce9ad51dd50f9e863b5e7e84d44
Parents: f9add57
Author: niclas <[email protected]>
Authored: Sun Apr 9 11:41:31 2017 +0800
Committer: niclas <[email protected]>
Committed: Sun Apr 9 11:41:31 2017 +0800

----------------------------------------------------------------------
 libraries/lang-groovy/src/docs/lang-groovy.txt  | 109 -------------------
 .../src/docs/lang-javascript.txt                |  55 ----------
 libraries/scripting/build.gradle                |   7 ++
 libraries/scripting/dev-status.xml              |   4 +-
 libraries/scripting/src/docs/groovy.txt         |  77 +++++++++++++
 libraries/scripting/src/docs/javascript.txt     |  41 +++++++
 libraries/scripting/src/docs/scripting.txt      | 100 +++++++++++++++++
 .../polygene/library/scripting/ScriptMixin.java |   4 +
 .../polygene/library/scripting/Scripting.java   |  26 ++++-
 .../library/scripting/HelloSpeaker.java         |   2 +-
 .../library/scripting/HelloSpeakerMixin.groovy  |  31 ++++++
 .../library/scripting/HelloSpeakerTest.java     |  76 +++++++++++++
 .../library/scripting/ScriptMixinTest.java      |  17 +++
 .../library/scripting/HelloSpeaker.groovy       |  26 +++++
 .../polygene/library/scripting/HelloSpeaker.js  |  25 +++++
 manual/src/docs/userguide/libraries.txt         |   6 +-
 settings.gradle                                 |   2 -
 17 files changed, 431 insertions(+), 177 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/lang-groovy/src/docs/lang-groovy.txt
----------------------------------------------------------------------
diff --git a/libraries/lang-groovy/src/docs/lang-groovy.txt 
b/libraries/lang-groovy/src/docs/lang-groovy.txt
deleted file mode 100644
index 029f241..0000000
--- a/libraries/lang-groovy/src/docs/lang-groovy.txt
+++ /dev/null
@@ -1,109 +0,0 @@
-///////////////////////////////////////////////////////////////
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
-///////////////////////////////////////////////////////////////
-
-[[lang-groovy, Groovy Scripting Library]]
-= Groovy Scripting =
-
-[devstatus]
---------------
-source=libraries/lang-groovy/dev-status.xml
---------------
-
-Groovy Scripting Library
-
-include::../../build/docs/buildinfo/artifact.txt[]
-
-The Groovy Scripting Library is a Generic mixin that implements interfaces by 
delegating to Groovy code from classpath resources.
-
-But before looking at how to use the Scripting library we'll see that *you 
don't need this library at all if you simply need to use Groovy classes as 
Fragments*.
-Then we'll see how to use Groovy class scripts and method scripts.
-
-All examples below are based on this type:
-
-[snippet,java]
-----
-source=libraries/lang-groovy/src/test/groovy/org/apache/polygene/library/groovy/HelloSpeaker.java
-tag=speaker
-----
-
-
-== Using compiled Groovy classes ==
-
-To directly use compiled Groovy classes as Fragments you don't need this 
library at all.
-
-Having this Groovy class compiled ;
-
-.HelloSpeakerMixin.groovy
-[snippet,groovy]
-----
-source=libraries/lang-groovy/src/test/groovy/org/apache/polygene/library/groovy/HelloSpeakerMixin.groovy
-tag=direct
-----
-
-assemble it directly:
-
-[snippet,java]
-----
-source=libraries/lang-groovy/src/test/groovy/org/apache/polygene/library/groovy/HelloSpeakerTest.java
-tag=direct
-----
-
-
-== Using Groovy class scripts ==
-
-Declare a Groovy class in a classpath resource file located in the same 
package as the implemented type with the name +<type>.groovy+:
-
-.HelloSpeaker.groovy
-[snippet,groovy]
-----
-source=libraries/lang-groovy/src/test/resources/org/apache/polygene/library/groovy/HelloSpeaker.groovy
-tag=script
-----
-
-Then assemble it with the +GroovyMixin+:
-
-[snippet,java]
-----
-source=libraries/lang-groovy/src/test/groovy/org/apache/polygene/library/groovy/HelloSpeakerTest.java
-tag=script
-----
-
-Groovy class scripts get +@This+ injection in a +This+ property if present.
-
-
-== Using Groovy method scripts ==
-
-Implement single composites methods, each in a classpath resource file located 
in the same package as the implemented type with the name 
+<type>.<method>.groovy+:
-
-.HelloSpeaker.sayHello.groovy
-[snippet,groovy]
-----
-source=libraries/lang-groovy/src/test/resources/org/apache/polygene/library/groovy/HelloSpeaker.sayHello.groovy
-tag=script
-----
-
-Then assemble it with the +GroovyMixin+:
-
-[snippet,java]
-----
-source=libraries/lang-groovy/src/test/groovy/org/apache/polygene/library/groovy/HelloSpeakerTest.java
-tag=script
-----
-
-Groovy method scripts get +@This+ injection as +This+ property and the methods 
arguments array as +args+.

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/lang-javascript/src/docs/lang-javascript.txt
----------------------------------------------------------------------
diff --git a/libraries/lang-javascript/src/docs/lang-javascript.txt 
b/libraries/lang-javascript/src/docs/lang-javascript.txt
deleted file mode 100644
index d50fda5..0000000
--- a/libraries/lang-javascript/src/docs/lang-javascript.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-///////////////////////////////////////////////////////////////
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
-///////////////////////////////////////////////////////////////
-
-[[lang-javascript, Javascript Scripting Library]]
-= Javascript Scripting =
-
-[devstatus]
---------------
-source=libraries/lang-javascript/dev-status.xml
---------------
-
-The Javascript Scripting Library allows Mixin methods to be implemented in 
Javascript and loaded dynamically on first use.
-
-include::../../build/docs/buildinfo/artifact.txt[]
-
-The Javascript Scripting Library is a Generic mixin class that implements 
-Composite interfaces by delegating to JavaScript functions using Rhino. Each 
-method in an interface is declared as a JS function in a file located in 
-classpath with the name "<interface>.<method>.js", where the interface name 
-includes the package, and has "." replaced with "/".
-
-Example: 
-
-    org/apache/polygene/samples/hello/domain/HelloWorldSpeaker.say.js
-
-That means that the HelloWorldSpeaker.say.js file may be co-located with the 
-class files in the same package. It is currently not supported to place the 
-Javascript implementation of the mixin in a different package than the 
-interface it implements.
-
-To use Javascript to implement the Mixin functionality for a given interface, 
-simply declare the +JavaScriptMixin+ like any other mixin, either in the 
-interface or at assembly time.
-
-[snippet,java]
-----
-source=libraries/lang-javascript/src/test/java/org/apache/polygene/library/javascript/HelloSpeaker.java
-tag=mixin
-----

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/scripting/build.gradle
----------------------------------------------------------------------
diff --git a/libraries/scripting/build.gradle b/libraries/scripting/build.gradle
index c5b3df8..bacd28e 100644
--- a/libraries/scripting/build.gradle
+++ b/libraries/scripting/build.gradle
@@ -24,10 +24,17 @@ description = "Apache Polygene™ Common Scripting Library 
contains common class
 
 jar { manifest { name = "Apache Polygene™ Library - Scripting - Common" } }
 
+apply plugin: 'groovy'
+
 dependencies {
+  api polygene.core.api
   api polygene.core.bootstrap
 
+  implementation libraries.groovy
+
   runtimeOnly polygene.core.runtime
 
   testImplementation polygene.core.testsupport
+
+  testRuntimeOnly libraries.logback
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/scripting/dev-status.xml
----------------------------------------------------------------------
diff --git a/libraries/scripting/dev-status.xml 
b/libraries/scripting/dev-status.xml
index 5ce55f5..d72e9f9 100644
--- a/libraries/scripting/dev-status.xml
+++ b/libraries/scripting/dev-status.xml
@@ -27,10 +27,10 @@
     <codebase>stable</codebase>
 
     <!-- none, brief, good, complete -->
-    <documentation>none</documentation>
+    <documentation>good</documentation>
 
     <!-- none, some, good, complete -->
-    <unittests>complete</unittests>
+    <unittests>good</unittests>
   </status>
   <licenses>
     <license>ALv2</license>

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/scripting/src/docs/groovy.txt
----------------------------------------------------------------------
diff --git a/libraries/scripting/src/docs/groovy.txt 
b/libraries/scripting/src/docs/groovy.txt
new file mode 100644
index 0000000..a277bc3
--- /dev/null
+++ b/libraries/scripting/src/docs/groovy.txt
@@ -0,0 +1,77 @@
+///////////////////////////////////////////////////////////////
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+///////////////////////////////////////////////////////////////
+
+[[groovy, Scripting with Groovy]]
+== Groovy ==
+
+The Groovy Scripting Library is a Generic mixin that implements interfaces by 
delegating to Groovy code from classpath resources.
+
+But before looking at how to use the Scripting library we'll see that *you 
don't need Scripting library at all if you
+simply need to use Groovy classes as Fragments*. Groovy is a fully Java 
compatible language and can be used directly,
+similarly to Scala.
+
+Then we'll see how to use Groovy class scripts and method scripts.
+
+All examples below are based on this type:
+
+[snippet,java]
+----
+source=libraries/lang-groovy/src/test/groovy/org/apache/polygene/library/groovy/HelloSpeaker.java
+tag=speaker
+----
+
+== Using compiled Groovy classes ==
+
+To directly use compiled Groovy classes as Fragments you don't need this 
library at all.
+
+Having this Groovy class compiled ;
+
+.HelloSpeakerMixin.groovy
+[snippet,groovy]
+----
+source=libraries/lang-groovy/src/test/groovy/org/apache/polygene/library/groovy/HelloSpeakerMixin.groovy
+tag=direct
+----
+
+assemble it directly:
+
+[snippet,java]
+----
+source=libraries/lang-groovy/src/test/groovy/org/apache/polygene/library/groovy/HelloSpeakerTest.java
+tag=direct
+----
+
+== Using Groovy function scripts ==
+
+Declare a Groovy function in a resource file located in the same package as 
the implemented type with the name +<type>.groovy+:
+
+.HelloSpeaker.groovy
+[snippet,groovy]
+----
+source=libraries/lang-groovy/src/test/resources/org/apache/polygene/library/groovy/HelloSpeaker.groovy
+tag=script
+----
+
+Then assemble it with the normal +ScriptMixin+:
+
+[snippet,java]
+----
+source=libraries/lang-groovy/src/test/groovy/org/apache/polygene/library/groovy/HelloSpeakerTest.java
+tag=script
+----

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/scripting/src/docs/javascript.txt
----------------------------------------------------------------------
diff --git a/libraries/scripting/src/docs/javascript.txt 
b/libraries/scripting/src/docs/javascript.txt
new file mode 100644
index 0000000..7568dfb
--- /dev/null
+++ b/libraries/scripting/src/docs/javascript.txt
@@ -0,0 +1,41 @@
+///////////////////////////////////////////////////////////////
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+///////////////////////////////////////////////////////////////
+
+[[javascript, Scripting with JavaScript]]
+== Javascript ==
+
+In Javascript, we map directly to JS functions with the same name.
+
+For the following Polygene composite type,
+
+[snippet,java]
+----
+source=libraries/scripting/src/test/java/org/apache/polygene/library/javascript/HelloSpeaker.java
+tag=mixin
+----
+
+
+we need a implementation that looks like this;
+
+[snippet,javascript]
+----
+source=libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeaker.js
+tag=script
+----
+

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/scripting/src/docs/scripting.txt
----------------------------------------------------------------------
diff --git a/libraries/scripting/src/docs/scripting.txt 
b/libraries/scripting/src/docs/scripting.txt
new file mode 100644
index 0000000..5ae5099
--- /dev/null
+++ b/libraries/scripting/src/docs/scripting.txt
@@ -0,0 +1,100 @@
+///////////////////////////////////////////////////////////////
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+///////////////////////////////////////////////////////////////
+
+[[scripting, Scripting Library]]
+= Scripting =
+
+[devstatus]
+--------------
+source=libraries/scripting/dev-status.xml
+--------------
+
+The Scripting Library allows Mixin methods to be implemented in any JSR-223 
scripting language, loaded dynamically on
+first use and allowing reloading of the script in runtime.
+
+include::../../build/docs/buildinfo/artifact.txt[]
+
+The Scripting Library is a Generic mixin class that implements
+Composite interfaces by delegating to script functions using Java Scripting 
API. All Java Scripting API (JSR-223)
+implementations that support
+
+[code,java]
+----
+    ((javax.script.Invocable) scriptEngine).invokeFunction( functionName, 
arguments );
+----
+
+should be supported. On Java.Net there is a 
https://java.net/projects/scripting/sources/svn/show/trunk/engines[list of Java 
Scripting API languages].
+
+
+It is important to understand that the ScriptEngines must be present on the 
classpath, or they will not be available,
+with the exception of JavaScript which uses the built-in Nashorn engine and 
Groovy that is an explicit dependency of
+this library.
+
+We welcome additional information and samples of languages that has been tried 
and tested.
+
+.Language Support
+[options="header"]
+|=======
+| Language | Supported | Tested | Implementation
+| JavaScript | Yes | Yes | | Nashorn, built-in Java 8 and later
+| Groovy | Yes | Yes | Apache | Apache Groovy, dependency exist from this 
library
+| Ruby | Yes | No |  | JRuby
+| Python | Yes | No | | Jython, must use jython-standalone
+| Kotlin | Yes | No |  | Jetbrains
+| Lua | Yes | No | MIT | luaj.org,
+| Clojure | Yes | No | CPL | https://github.com/pmf/clojure-jsr223
+|=======
+
+The following languages may or may not be supported, and was found at 
https://java.net/projects/scripting/sources/svn/show/trunk/engines[Java.Net 
Scripting project]
+
+.Potential Languages
+[options="header"]
+|=======
+| Language | Location | License
+|beanshell
+|ejs
+|freemarker
+|jacl
+|jaskell
+|jawk
+|jelly
+|jep
+|jexl
+|jst
+|judo
+|juel
+|ognl
+|pnuts
+|scheme
+|velocity
+|xpath
+|xslt
+|=======
+
+.Not Compatible Languages
+[options="header"]
+|=======
+| Language | Comment
+| Java | Implementation exists at https://github.com/nickman/javax-scripting/ 
which is forked from https://java.net/projects/scripting. It doesn't support 
Invocable, and additional work on ScriptMixin is required to support this. 
Althernatively, fork the ScriptEngine implementation and support Invocable in 
it.
+|=======
+
+include::../../../../libraries/scripting/src/docs/javascript.txt[]
+
+include::../../../../libraries/scripting/src/docs/groovy.txt[]
+

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/scripting/src/main/java/org/apache/polygene/library/scripting/ScriptMixin.java
----------------------------------------------------------------------
diff --git 
a/libraries/scripting/src/main/java/org/apache/polygene/library/scripting/ScriptMixin.java
 
b/libraries/scripting/src/main/java/org/apache/polygene/library/scripting/ScriptMixin.java
index a66f387..61c033b 100644
--- 
a/libraries/scripting/src/main/java/org/apache/polygene/library/scripting/ScriptMixin.java
+++ 
b/libraries/scripting/src/main/java/org/apache/polygene/library/scripting/ScriptMixin.java
@@ -105,6 +105,10 @@ public class ScriptMixin
         {
             engine = manager.getEngineByExtension( scripting.extension() );
         }
+        if( engine == null )
+        {
+            throw new ScriptException( "Engine " + scripting + " is not 
available. Perhaps missing implementation on the classpath." );
+        }
         return engine;
     }
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/scripting/src/main/java/org/apache/polygene/library/scripting/Scripting.java
----------------------------------------------------------------------
diff --git 
a/libraries/scripting/src/main/java/org/apache/polygene/library/scripting/Scripting.java
 
b/libraries/scripting/src/main/java/org/apache/polygene/library/scripting/Scripting.java
index b2e8464..119b8a1 100644
--- 
a/libraries/scripting/src/main/java/org/apache/polygene/library/scripting/Scripting.java
+++ 
b/libraries/scripting/src/main/java/org/apache/polygene/library/scripting/Scripting.java
@@ -19,14 +19,19 @@
  */
 package org.apache.polygene.library.scripting;
 
+import javax.script.ScriptEngineManager;
+
+// START SNIPPET: supported
 public class Scripting
 {
-    public static final Scripting JAVASCRIPT = new Scripting( "nashorn", ".js" 
);
     public static final Scripting ECMASCRIPT = new Scripting( "nashorn", ".js" 
);
     public static final Scripting GROOVY = new Scripting( "groovy", ".groovy" 
);
-    public static final Scripting RUBY = new Scripting( "jruby", ".rb" );
-    public static final Scripting PYTHON = new Scripting( "python", ".py" );
+    public static final Scripting JAVASCRIPT = new Scripting( "nashorn", ".js" 
);
     public static final Scripting KOTLIN = new Scripting( "kotlin", ".kt" );
+    public static final Scripting LUA = new Scripting( "lua", ".lua" );
+    public static final Scripting PYTHON = new Scripting( "python", ".py" );
+    public static final Scripting RUBY = new Scripting( "jruby", ".rb" );
+    // END SNIPPET: supported
 
     private String scriptEngine;
     private String extension;
@@ -51,4 +56,19 @@ public class Scripting
     {
         return extension;
     }
+
+    @Override
+    public String toString()
+    {
+        if( scriptEngine == null )
+        {
+            return "for script extension '" + extension + "'";
+        }
+        return "'" + scriptEngine + "'";
+    }
+
+    public static void main( String[] args )
+    {
+        new ScriptEngineManager().getEngineFactories().forEach( factory -> 
System.out.println(factory));
+    }
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeaker.java
----------------------------------------------------------------------
diff --git 
a/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeaker.java
 
b/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeaker.java
index 68cbc47..967332b 100644
--- 
a/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeaker.java
+++ 
b/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeaker.java
@@ -26,6 +26,6 @@ import org.apache.polygene.api.mixin.Mixins;
 @Mixins(ScriptMixin.class)
 public interface HelloSpeaker
 {
-    void sayHello();
+    String sayHello();
 }
 // END SNIPPET: mixin

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeakerMixin.groovy
----------------------------------------------------------------------
diff --git 
a/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeakerMixin.groovy
 
b/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeakerMixin.groovy
new file mode 100644
index 0000000..ad3113b
--- /dev/null
+++ 
b/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeakerMixin.groovy
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.scripting;
+
+// START SNIPPET: direct
+class HelloSpeakerMixin
+    implements HelloSpeaker
+{
+
+    String sayHello() {
+        "Hello there, Groovy"
+    }
+}
+// END SNIPPET: direct

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeakerTest.java
----------------------------------------------------------------------
diff --git 
a/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeakerTest.java
 
b/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeakerTest.java
new file mode 100644
index 0000000..de03c4c
--- /dev/null
+++ 
b/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/HelloSpeakerTest.java
@@ -0,0 +1,76 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.scripting;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.apache.polygene.bootstrap.AssemblyException;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.test.AbstractPolygeneTest;
+import org.apache.polygene.bootstrap.SingletonAssembler;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+public class HelloSpeakerTest extends AbstractPolygeneTest
+{
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+    }
+
+    @Test
+    public void testGroovyScriptResourceMixin()
+        throws Exception
+    {
+        // START SNIPPET: script
+        SingletonAssembler assembler = new SingletonAssembler()
+        {
+            @Override
+            public void assemble( ModuleAssembly module )
+                throws AssemblyException
+            {
+                module.transients( HelloSpeaker.class ).setMetaInfo( 
Scripting.GROOVY ).withMixins( ScriptMixin.class );
+            }
+        };
+        HelloSpeaker speaker = assembler.module().newTransient( 
HelloSpeaker.class );
+        assertThat( speaker.sayHello(), equalTo("Hello, Groovy") );
+        // END SNIPPET: script
+    }
+
+    @Test
+    public void testGroovyClassMixin()
+        throws Exception
+    {
+        // START SNIPPET: direct
+        SingletonAssembler assembler = new SingletonAssembler()
+        {
+            @Override
+            public void assemble( ModuleAssembly module )
+                throws AssemblyException
+            {
+                module.transients( HelloSpeaker.class ).withMixins( 
HelloSpeakerMixin.class );
+            }
+        };
+        HelloSpeaker speaker = assembler.module().newTransient( 
HelloSpeaker.class );
+        assertThat( speaker.sayHello(), equalTo("Hello there, Groovy") );
+        // END SNIPPET: direct
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/ScriptMixinTest.java
----------------------------------------------------------------------
diff --git 
a/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/ScriptMixinTest.java
 
b/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/ScriptMixinTest.java
index 501949c..75b6085 100644
--- 
a/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/ScriptMixinTest.java
+++ 
b/libraries/scripting/src/test/java/org/apache/polygene/library/scripting/ScriptMixinTest.java
@@ -52,6 +52,8 @@ public class ScriptMixinTest
         LayerAssembly layer = module.layer();
         layer.application().setName( "Script Test" );
         module.transients( DomainType.class ).setMetaInfo( 
Scripting.JAVASCRIPT ).withMixins( ScriptMixin.class );
+        module.transients( HelloSpeaker.class ).setMetaInfo( Scripting.GROOVY 
).withMixins( ScriptMixin.class );
+        module.values( HelloSpeaker.class ).setMetaInfo( Scripting.JAVASCRIPT 
).withMixins( ScriptMixin.class );
     }
 
     @Test
@@ -61,6 +63,7 @@ public class ScriptMixinTest
         assertThat(domain1.do1("her message"), equalTo("[her message]") );
     }
 
+    @Test
     public void testIsolation() throws Throwable
     {
         DomainType domain1 = transientBuilderFactory.newTransient( 
DomainType.class );
@@ -119,6 +122,20 @@ public class ScriptMixinTest
 
         TypeLookup lookup = domain.whatIsTypeLookup( );
         assertThat( lookup, notNullValue());
+    }
+
 
+    @Test
+    public void testJavascriptInvoke() throws Exception
+    {
+        HelloSpeaker speaker = valueBuilderFactory.newValue( 
HelloSpeaker.class );
+        assertThat(speaker.sayHello(), equalTo("Hello, JavaScript"));
+    }
+
+    @Test
+    public void testGroovyInvoke() throws Exception
+    {
+        HelloSpeaker speaker = transientBuilderFactory.newTransient( 
HelloSpeaker.class );
+        assertThat(speaker.sayHello(), equalTo("Hello, Groovy"));
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/scripting/src/test/resources/org/apache/polygene/library/scripting/HelloSpeaker.groovy
----------------------------------------------------------------------
diff --git 
a/libraries/scripting/src/test/resources/org/apache/polygene/library/scripting/HelloSpeaker.groovy
 
b/libraries/scripting/src/test/resources/org/apache/polygene/library/scripting/HelloSpeaker.groovy
new file mode 100644
index 0000000..1c0b7a8
--- /dev/null
+++ 
b/libraries/scripting/src/test/resources/org/apache/polygene/library/scripting/HelloSpeaker.groovy
@@ -0,0 +1,26 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.library.groovy
+
+// START SNIPPET: script
+def sayHello() {
+    "Hello, Groovy"
+}
+// END SNIPPET: script

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/libraries/scripting/src/test/resources/org/apache/polygene/library/scripting/HelloSpeaker.js
----------------------------------------------------------------------
diff --git 
a/libraries/scripting/src/test/resources/org/apache/polygene/library/scripting/HelloSpeaker.js
 
b/libraries/scripting/src/test/resources/org/apache/polygene/library/scripting/HelloSpeaker.js
new file mode 100644
index 0000000..f5e29cf
--- /dev/null
+++ 
b/libraries/scripting/src/test/resources/org/apache/polygene/library/scripting/HelloSpeaker.js
@@ -0,0 +1,25 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+
+// START SNIPPET: script
+function sayHello() {
+    return "Hello, JavaScript";
+}
+// END SNIPPET: script

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/manual/src/docs/userguide/libraries.txt
----------------------------------------------------------------------
diff --git a/manual/src/docs/userguide/libraries.txt 
b/manual/src/docs/userguide/libraries.txt
index 585ab3f..b4bcce6 100644
--- a/manual/src/docs/userguide/libraries.txt
+++ b/manual/src/docs/userguide/libraries.txt
@@ -31,11 +31,7 @@ for our users.
 
 :leveloffset: 2
 
-include::../../../../libraries/lang-groovy/src/docs/lang-groovy.txt[]
-
-:leveloffset: 2
-
-include::../../../../libraries/lang-javascript/src/docs/lang-javascript.txt[]
+include::../../../../libraries/scripting/src/docs/scripting.txt[]
 
 :leveloffset: 2
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f78110d9/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
index d63bdb6..808f937 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -31,8 +31,6 @@ include 'core:api',
         'libraries:fileconfig',
         'libraries:http',
         'libraries:invocation-cache',
-        'libraries:lang-groovy',
-        'libraries:lang-javascript',
         'libraries:jmx',
         'libraries:locking',
         'libraries:logging',

Reply via email to