1.1 --- a/.hgtags Sun Sep 08 11:42:01 2013 +0200
1.2 +++ b/.hgtags Wed Sep 18 11:20:57 2013 +0200
1.3 @@ -10,3 +10,4 @@
1.4 623816269b75e53fffb4b19960df7040a3c20056 release-0.7
1.5 23572dc719bd630817d11eaabdee4565f63ef8e1 release-0.7.1
1.6 56abd247f421febd8b2c5e59d666968692e11555 release-0.7.2
1.7 +a83e16b8b825399bb21461e578c32d86982e4ed3 release-0.8
2.1 --- a/benchmarks/matrix-multiplication/pom.xml Sun Sep 08 11:42:01 2013 +0200
2.2 +++ b/benchmarks/matrix-multiplication/pom.xml Wed Sep 18 11:20:57 2013 +0200
2.3 @@ -4,12 +4,12 @@
2.4
2.5 <groupId>org.apidesign.bck2brwsr</groupId>
2.6 <artifactId>matrix.multiplication</artifactId>
2.7 - <version>0.8-SNAPSHOT</version>
2.8 + <version>0.9-SNAPSHOT</version>
2.9 <packaging>jar</packaging>
2.10 <parent>
2.11 <artifactId>benchmarks</artifactId>
2.12 <groupId>org.apidesign.bck2brwsr</groupId>
2.13 - <version>0.8-SNAPSHOT</version>
2.14 + <version>0.9-SNAPSHOT</version>
2.15 </parent>
2.16
2.17 <name>Matrix multiplication</name>
2.18 @@ -74,7 +74,7 @@
2.19 <dependency>
2.20 <groupId>org.apidesign.bck2brwsr</groupId>
2.21 <artifactId>emul.mini</artifactId>
2.22 - <version>0.8-SNAPSHOT</version>
2.23 + <version>0.9-SNAPSHOT</version>
2.24 </dependency>
2.25 <dependency>
2.26 <groupId>org.testng</groupId>
2.27 @@ -91,13 +91,13 @@
2.28 <dependency>
2.29 <groupId>org.apidesign.bck2brwsr</groupId>
2.30 <artifactId>vmtest</artifactId>
2.31 - <version>0.8-SNAPSHOT</version>
2.32 + <version>0.9-SNAPSHOT</version>
2.33 <scope>test</scope>
2.34 </dependency>
2.35 <dependency>
2.36 <groupId>org.apidesign.bck2brwsr</groupId>
2.37 <artifactId>launcher.http</artifactId>
2.38 - <version>0.8-SNAPSHOT</version>
2.39 + <version>0.9-SNAPSHOT</version>
2.40 <scope>test</scope>
2.41 </dependency>
2.42 </dependencies>
3.1 --- a/benchmarks/pom.xml Sun Sep 08 11:42:01 2013 +0200
3.2 +++ b/benchmarks/pom.xml Wed Sep 18 11:20:57 2013 +0200
3.3 @@ -4,11 +4,11 @@
3.4 <parent>
3.5 <artifactId>bck2brwsr</artifactId>
3.6 <groupId>org.apidesign</groupId>
3.7 - <version>0.8-SNAPSHOT</version>
3.8 + <version>0.9-SNAPSHOT</version>
3.9 </parent>
3.10 <groupId>org.apidesign.bck2brwsr</groupId>
3.11 <artifactId>benchmarks</artifactId>
3.12 - <version>0.8-SNAPSHOT</version>
3.13 + <version>0.9-SNAPSHOT</version>
3.14 <packaging>pom</packaging>
3.15 <name>Performance benchmarks</name>
3.16 <modules>
4.1 --- a/dew/pom.xml Sun Sep 08 11:42:01 2013 +0200
4.2 +++ b/dew/pom.xml Wed Sep 18 11:20:57 2013 +0200
4.3 @@ -4,11 +4,11 @@
4.4 <parent>
4.5 <groupId>org.apidesign</groupId>
4.6 <artifactId>bck2brwsr</artifactId>
4.7 - <version>0.8-SNAPSHOT</version>
4.8 + <version>0.9-SNAPSHOT</version>
4.9 </parent>
4.10 <groupId>org.apidesign.bck2brwsr</groupId>
4.11 <artifactId>dew</artifactId>
4.12 - <version>0.8-SNAPSHOT</version>
4.13 + <version>0.9-SNAPSHOT</version>
4.14 <name>Development Environment for Web</name>
4.15 <url>http://maven.apache.org</url>
4.16 <build>
5.1 --- a/ide/editor/pom.xml Sun Sep 08 11:42:01 2013 +0200
5.2 +++ b/ide/editor/pom.xml Wed Sep 18 11:20:57 2013 +0200
5.3 @@ -4,12 +4,12 @@
5.4 <parent>
5.5 <artifactId>ide</artifactId>
5.6 <groupId>org.apidesign.bck2brwsr</groupId>
5.7 - <version>0.8-SNAPSHOT</version>
5.8 + <version>0.9-SNAPSHOT</version>
5.9 </parent>
5.10
5.11 <groupId>org.apidesign.bck2brwsr.ide</groupId>
5.12 <artifactId>editor</artifactId>
5.13 - <version>0.8-SNAPSHOT</version>
5.14 + <version>0.9-SNAPSHOT</version>
5.15 <packaging>nbm</packaging>
5.16
5.17 <name>Editor Support for Bck2Brwsr</name>
5.18 @@ -75,7 +75,7 @@
5.19 <dependency>
5.20 <groupId>org.apidesign.bck2brwsr</groupId>
5.21 <artifactId>core</artifactId>
5.22 - <version>0.8-SNAPSHOT</version>
5.23 + <version>0.9-SNAPSHOT</version>
5.24 <type>jar</type>
5.25 <scope>test</scope>
5.26 </dependency>
6.1 --- a/ide/pom.xml Sun Sep 08 11:42:01 2013 +0200
6.2 +++ b/ide/pom.xml Wed Sep 18 11:20:57 2013 +0200
6.3 @@ -4,11 +4,11 @@
6.4 <parent>
6.5 <artifactId>bck2brwsr</artifactId>
6.6 <groupId>org.apidesign</groupId>
6.7 - <version>0.8-SNAPSHOT</version>
6.8 + <version>0.9-SNAPSHOT</version>
6.9 </parent>
6.10 <groupId>org.apidesign.bck2brwsr</groupId>
6.11 <artifactId>ide</artifactId>
6.12 - <version>0.8-SNAPSHOT</version>
6.13 + <version>0.9-SNAPSHOT</version>
6.14 <packaging>pom</packaging>
6.15 <name>IDE Support</name>
6.16 <modules>
7.1 --- a/javaquery/api/pom.xml Sun Sep 08 11:42:01 2013 +0200
7.2 +++ b/javaquery/api/pom.xml Wed Sep 18 11:20:57 2013 +0200
7.3 @@ -4,12 +4,12 @@
7.4 <parent>
7.5 <groupId>org.apidesign.bck2brwsr</groupId>
7.6 <artifactId>javaquery</artifactId>
7.7 - <version>0.8-SNAPSHOT</version>
7.8 + <version>0.9-SNAPSHOT</version>
7.9 </parent>
7.10
7.11 <groupId>org.apidesign.bck2brwsr</groupId>
7.12 <artifactId>javaquery.api</artifactId>
7.13 - <version>0.8-SNAPSHOT</version>
7.14 + <version>0.9-SNAPSHOT</version>
7.15 <name>JavaQuery API</name>
7.16
7.17 <url>http://maven.apache.org</url>
8.1 --- a/javaquery/demo-calculator-dynamic/pom.xml Sun Sep 08 11:42:01 2013 +0200
8.2 +++ b/javaquery/demo-calculator-dynamic/pom.xml Wed Sep 18 11:20:57 2013 +0200
8.3 @@ -4,7 +4,7 @@
8.4
8.5 <groupId>org.apidesign.bck2brwsr</groupId>
8.6 <artifactId>demo.calculator</artifactId>
8.7 - <version>0.8-SNAPSHOT</version>
8.8 + <version>0.9-SNAPSHOT</version>
8.9 <packaging>jar</packaging>
8.10
8.11 <name>JavaQuery Demo - Calculator</name>
9.1 --- a/javaquery/demo-calculator/pom.xml Sun Sep 08 11:42:01 2013 +0200
9.2 +++ b/javaquery/demo-calculator/pom.xml Wed Sep 18 11:20:57 2013 +0200
9.3 @@ -4,7 +4,7 @@
9.4
9.5 <groupId>org.apidesign.bck2brwsr</groupId>
9.6 <artifactId>demo.static.calculator</artifactId>
9.7 - <version>0.8-SNAPSHOT</version>
9.8 + <version>0.9-SNAPSHOT</version>
9.9 <packaging>jar</packaging>
9.10
9.11 <name>JavaQuery Demo - Calculator - Static Compilation</name>
10.1 --- a/javaquery/demo-twitter/pom.xml Sun Sep 08 11:42:01 2013 +0200
10.2 +++ b/javaquery/demo-twitter/pom.xml Wed Sep 18 11:20:57 2013 +0200
10.3 @@ -4,12 +4,12 @@
10.4 <parent>
10.5 <artifactId>javaquery</artifactId>
10.6 <groupId>org.apidesign.bck2brwsr</groupId>
10.7 - <version>0.8-SNAPSHOT</version>
10.8 + <version>0.9-SNAPSHOT</version>
10.9 </parent>
10.10
10.11 <groupId>org.apidesign.bck2brwsr</groupId>
10.12 <artifactId>demo-twitter</artifactId>
10.13 - <version>0.8-SNAPSHOT</version>
10.14 + <version>0.9-SNAPSHOT</version>
10.15 <packaging>jar</packaging>
10.16
10.17 <name>Bck2Brwsr's Twttr</name>
11.1 --- a/javaquery/pom.xml Sun Sep 08 11:42:01 2013 +0200
11.2 +++ b/javaquery/pom.xml Wed Sep 18 11:20:57 2013 +0200
11.3 @@ -4,11 +4,11 @@
11.4 <parent>
11.5 <artifactId>bck2brwsr</artifactId>
11.6 <groupId>org.apidesign</groupId>
11.7 - <version>0.8-SNAPSHOT</version>
11.8 + <version>0.9-SNAPSHOT</version>
11.9 </parent>
11.10 <groupId>org.apidesign.bck2brwsr</groupId>
11.11 <artifactId>javaquery</artifactId>
11.12 - <version>0.8-SNAPSHOT</version>
11.13 + <version>0.9-SNAPSHOT</version>
11.14 <packaging>pom</packaging>
11.15 <name>JavaQuery API and Demo</name>
11.16 <modules>
12.1 --- a/ko/archetype-test/pom.xml Sun Sep 08 11:42:01 2013 +0200
12.2 +++ b/ko/archetype-test/pom.xml Wed Sep 18 11:20:57 2013 +0200
12.3 @@ -4,11 +4,11 @@
12.4 <parent>
12.5 <groupId>org.apidesign.bck2brwsr</groupId>
12.6 <artifactId>ko</artifactId>
12.7 - <version>0.8-SNAPSHOT</version>
12.8 + <version>0.9-SNAPSHOT</version>
12.9 </parent>
12.10 <groupId>org.apidesign.bck2brwsr</groupId>
12.11 <artifactId>ko-archetype-test</artifactId>
12.12 - <version>0.8-SNAPSHOT</version>
12.13 + <version>0.9-SNAPSHOT</version>
12.14 <name>Knockout Bck2Brwsr Archetype Test</name>
12.15 <url>http://maven.apache.org</url>
12.16 <description>Verifies the Knockout & net.java.html.json archetype behaves properly.</description>
13.1 --- a/ko/archetype-test/src/test/java/org/apidesign/bck2brwsr/ko/archetype/test/VerifyArchetypeTest.java Sun Sep 08 11:42:01 2013 +0200
13.2 +++ b/ko/archetype-test/src/test/java/org/apidesign/bck2brwsr/ko/archetype/test/VerifyArchetypeTest.java Wed Sep 18 11:20:57 2013 +0200
13.3 @@ -18,11 +18,15 @@
13.4 package org.apidesign.bck2brwsr.ko.archetype.test;
13.5
13.6 import java.io.File;
13.7 +import java.io.IOException;
13.8 +import java.io.InputStream;
13.9 import java.util.Properties;
13.10 +import java.util.zip.ZipEntry;
13.11 import java.util.zip.ZipFile;
13.12 import org.apache.maven.it.Verifier;
13.13 import org.testng.annotations.Test;
13.14 import static org.testng.Assert.*;
13.15 +import org.testng.reporters.Files;
13.16
13.17 /**
13.18 *
13.19 @@ -87,9 +91,18 @@
13.20 assertTrue(zip.isFile(), "Zip file with website was created");
13.21
13.22 ZipFile zf = new ZipFile(zip);
13.23 - assertNotNull(zf.getEntry("public_html/index.html"), "index.html found");
13.24 - assertNotNull(zf.getEntry("public_html/twitterExample.css"), "css file found");
13.25 + final ZipEntry index = zf.getEntry("public_html/index.html");
13.26 + assertNotNull(index, "index.html found");
13.27
13.28 + String txt = readText(zf.getInputStream(index));
13.29 + final int beg = txt.indexOf("${");
13.30 + if (beg >= 0) {
13.31 + int end = txt.indexOf("}", beg);
13.32 + if (end < beg) {
13.33 + end = txt.length();
13.34 + }
13.35 + fail("No substitutions in index.html. Found: " + txt.substring(beg, end));
13.36 + }
13.37 }
13.38
13.39 private Verifier generateFromArchetype(final File dir, String... params) throws Exception {
13.40 @@ -113,4 +126,8 @@
13.41 v.verifyErrorFreeLog();
13.42 return v;
13.43 }
13.44 +
13.45 + private static String readText(InputStream is) throws IOException {
13.46 + return Files.readFile(is);
13.47 + }
13.48 }
14.1 --- a/ko/archetype/pom.xml Sun Sep 08 11:42:01 2013 +0200
14.2 +++ b/ko/archetype/pom.xml Wed Sep 18 11:20:57 2013 +0200
14.3 @@ -4,11 +4,11 @@
14.4 <parent>
14.5 <artifactId>ko</artifactId>
14.6 <groupId>org.apidesign.bck2brwsr</groupId>
14.7 - <version>0.8-SNAPSHOT</version>
14.8 + <version>0.9-SNAPSHOT</version>
14.9 </parent>
14.10 <groupId>org.apidesign.bck2brwsr</groupId>
14.11 <artifactId>knockout4j-archetype</artifactId>
14.12 - <version>0.8-SNAPSHOT</version>
14.13 + <version>0.9-SNAPSHOT</version>
14.14 <packaging>jar</packaging>
14.15 <name>Knockout Bck2Brwsr Maven Archetype</name>
14.16 <description>
15.1 --- a/ko/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml Sun Sep 08 11:42:01 2013 +0200
15.2 +++ b/ko/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml Wed Sep 18 11:20:57 2013 +0200
15.3 @@ -26,8 +26,8 @@
15.4 <include>**/*.java</include>
15.5 </includes>
15.6 </fileSet>
15.7 - <fileSet filtered="true" packaged="true">
15.8 - <directory>src/main/resources</directory>
15.9 + <fileSet filtered="true" packaged="false">
15.10 + <directory>src/main/webapp/pages</directory>
15.11 <includes>
15.12 <include>**/*.xhtml</include>
15.13 <include>**/*.html</include>
16.1 --- a/ko/archetype/src/main/resources/archetype-resources/pom.xml Sun Sep 08 11:42:01 2013 +0200
16.2 +++ b/ko/archetype/src/main/resources/archetype-resources/pom.xml Wed Sep 18 11:20:57 2013 +0200
16.3 @@ -42,7 +42,7 @@
16.4 <bck2brwsr.version>${project.version}</bck2brwsr.version>
16.5 <bck2brwsr.launcher.version>${project.version}</bck2brwsr.launcher.version>
16.6 <bck2brwsr.obfuscationlevel>MINIMAL</bck2brwsr.obfuscationlevel>
16.7 - <brwsr.startpage>\${package.replace('.','/')}/index.html</brwsr.startpage>
16.8 + <brwsr.startpage>pages/index.html</brwsr.startpage>
16.9 </properties>
16.10 <build>
16.11 <plugins>
16.12 @@ -58,8 +58,9 @@
16.13 </execution>
16.14 </executions>
16.15 <configuration>
16.16 - <startpage>\${brwsr.startpage}</startpage>
16.17 - <launcher>\${brwsr}</launcher>
16.18 + <directory>\${basedir}/src/main/webapp/</directory>
16.19 + <startpage>${brwsr.startpage}</startpage>
16.20 + <launcher>${brwsr}</launcher>
16.21 </configuration>
16.22 </plugin>
16.23 <plugin>
16.24 @@ -113,6 +114,12 @@
16.25 <scope>test</scope>
16.26 </dependency>
16.27 <dependency>
16.28 + <groupId>org.apidesign.bck2brwsr</groupId>
16.29 + <artifactId>launcher.http</artifactId>
16.30 + <version>\${bck2brwsr.launcher.version}</version>
16.31 + <scope>test</scope>
16.32 + </dependency>
16.33 + <dependency>
16.34 <groupId>org.apidesign.bck2brwsr</groupId>
16.35 <artifactId>vmtest</artifactId>
16.36 <version>\${bck2brwsr.version}</version>
16.37 @@ -254,12 +261,6 @@
16.38 <version>\${bck2brwsr.version}</version>
16.39 <scope>runtime</scope>
16.40 </dependency>
16.41 - <dependency>
16.42 - <groupId>org.apidesign.bck2brwsr</groupId>
16.43 - <artifactId>launcher.http</artifactId>
16.44 - <version>\${bck2brwsr.launcher.version}</version>
16.45 - <scope>test</scope>
16.46 - </dependency>
16.47 </dependencies>
16.48 </profile>
16.49 </profiles>
17.1 --- a/ko/archetype/src/main/resources/archetype-resources/src/main/assembly/bck2brwsr.xml Sun Sep 08 11:42:01 2013 +0200
17.2 +++ b/ko/archetype/src/main/resources/archetype-resources/src/main/assembly/bck2brwsr.xml Wed Sep 18 11:20:57 2013 +0200
17.3 @@ -29,6 +29,11 @@
17.4 </excludes>
17.5 <outputDirectory>/</outputDirectory>
17.6 </fileSet>
17.7 + <fileSet>
17.8 + <directory>src/main/webapp/pages</directory>
17.9 + <outputDirectory>/</outputDirectory>
17.10 + <filtered>true</filtered>
17.11 + </fileSet>
17.12 </fileSets>
17.13 <files>
17.14 <file>
18.1 --- a/ko/archetype/src/main/resources/archetype-resources/src/main/assembly/fxbrwsr.xml Sun Sep 08 11:42:01 2013 +0200
18.2 +++ b/ko/archetype/src/main/resources/archetype-resources/src/main/assembly/fxbrwsr.xml Wed Sep 18 11:20:57 2013 +0200
18.3 @@ -20,4 +20,14 @@
18.4 <outputDirectory>/</outputDirectory>
18.5 </file>
18.6 </files>
18.7 + <fileSets>
18.8 + <fileSet>
18.9 + <directory>src/main/webapp/</directory>
18.10 + <outputDirectory>/</outputDirectory>
18.11 + <includes>
18.12 + <include>pages/**</include>
18.13 + </includes>
18.14 + <filtered>true</filtered>
18.15 + </fileSet>
18.16 + </fileSets>
18.17 </assembly>
18.18 \ No newline at end of file
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
19.2 +++ b/ko/archetype/src/main/resources/archetype-resources/src/main/java/DataModel.java Wed Sep 18 11:20:57 2013 +0200
19.3 @@ -0,0 +1,31 @@
19.4 +package ${package};
19.5 +
19.6 +import net.java.html.json.ComputedProperty;
19.7 +import net.java.html.json.Function;
19.8 +import net.java.html.json.Model;
19.9 +import net.java.html.json.Property;
19.10 +
19.11 +/** Model annotation generates class Data with
19.12 + * one message property, boolean property and read only words property
19.13 + */
19.14 +@Model(className = "Data", properties = {
19.15 + @Property(name = "message", type = String.class),
19.16 + @Property(name = "on", type = boolean.class)
19.17 +})
19.18 +final class DataModel {
19.19 + @ComputedProperty static java.util.List<String> words(String message) {
19.20 + String[] arr = new String[6];
19.21 + String[] words = message == null ? new String[0] : message.split(" ", 6);
19.22 + for (int i = 0; i < 6; i++) {
19.23 + arr[i] = words.length > i ? words[i] : "!";
19.24 + }
19.25 + return java.util.Arrays.asList(arr);
19.26 + }
19.27 +
19.28 + @Function static void turnOn(Data model) {
19.29 + model.setOn(true);
19.30 + }
19.31 + @Function static void turnOff(Data model) {
19.32 + model.setOn(false);
19.33 + }
19.34 +}
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/ko/archetype/src/main/resources/archetype-resources/src/main/java/Main.java Wed Sep 18 11:20:57 2013 +0200
20.3 @@ -0,0 +1,15 @@
20.4 +package ${package};
20.5 +
20.6 +public final class Main {
20.7 + private Main() {
20.8 + }
20.9 +
20.10 + /**
20.11 + * Called when the page is ready.
20.12 + */
20.13 + static {
20.14 + Data d = new Data();
20.15 + d.setMessage("Hello World from HTML and Java!");
20.16 + d.applyBindings();
20.17 + }
20.18 +}
21.1 --- a/ko/archetype/src/main/resources/archetype-resources/src/main/java/TwitterClient.java Sun Sep 08 11:42:01 2013 +0200
21.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
21.3 @@ -1,178 +0,0 @@
21.4 -package ${package};
21.5 -
21.6 -import java.util.Arrays;
21.7 -import java.util.List;
21.8 -import net.java.html.json.ComputedProperty;
21.9 -import net.java.html.json.Function;
21.10 -import net.java.html.json.Model;
21.11 -import net.java.html.json.OnPropertyChange;
21.12 -import net.java.html.json.OnReceive;
21.13 -import net.java.html.json.Property;
21.14 -
21.15 -@Model(className="TwitterModel", properties={
21.16 - @Property(name="savedLists", type=Tweeters.class, array = true),
21.17 - @Property(name="activeTweetersName", type=String.class),
21.18 - @Property(name="activeTweeters", type=String.class, array = true),
21.19 - @Property(name="userNameToAdd", type=String.class),
21.20 - @Property(name="loading", type=boolean.class),
21.21 - @Property(name="currentTweets", type=Tweet.class, array = true)
21.22 -})
21.23 -public class TwitterClient {
21.24 - @Model(className = "Tweeters", properties = {
21.25 - @Property(name="name", type = String.class),
21.26 - @Property(name="userNames", type = String.class, array = true)
21.27 - })
21.28 - static class Twttrs {
21.29 - }
21.30 - @Model(className = "Tweet", properties = {
21.31 - @Property(name = "from_user", type = String.class),
21.32 - @Property(name = "from_user_id", type = int.class),
21.33 - @Property(name = "profile_image_url", type = String.class),
21.34 - @Property(name = "text", type = String.class),
21.35 - @Property(name = "created_at", type = String.class),
21.36 - })
21.37 - static final class Twt {
21.38 - @ComputedProperty static String html(String text) {
21.39 - StringBuilder sb = new StringBuilder(320);
21.40 - for (int pos = 0;;) {
21.41 - int http = text.indexOf("http", pos);
21.42 - if (http == -1) {
21.43 - sb.append(text.substring(pos));
21.44 - return sb.toString();
21.45 - }
21.46 - int spc = text.indexOf(' ', http);
21.47 - if (spc == -1) {
21.48 - spc = text.length();
21.49 - }
21.50 - sb.append(text.substring(pos, http));
21.51 - String url = text.substring(http, spc);
21.52 - sb.append("<a href='").append(url).append("'>").append(url).append("</a>");
21.53 - pos = spc;
21.54 - }
21.55 - }
21.56 -
21.57 - @ComputedProperty static String userUrl(String from_user) {
21.58 - return "http://twitter.com/" + from_user;
21.59 - }
21.60 - }
21.61 - @Model(className = "TwitterQuery", properties = {
21.62 - @Property(array = true, name = "results", type = Twt.class)
21.63 - })
21.64 - public static final class TwttrQr {
21.65 - }
21.66 -
21.67 - @OnReceive(url="{root}/search.json?{query}&callback={me}", jsonp="me")
21.68 - static void queryTweets(TwitterModel page, TwitterQuery q) {
21.69 - page.getCurrentTweets().clear();
21.70 - page.getCurrentTweets().addAll(q.getResults());
21.71 - page.setLoading(false);
21.72 - }
21.73 -
21.74 - @OnPropertyChange("activeTweetersName")
21.75 - static void changeTweetersList(TwitterModel model) {
21.76 - Tweeters people = findByName(model.getSavedLists(), model.getActiveTweetersName());
21.77 - model.getActiveTweeters().clear();
21.78 - model.getActiveTweeters().addAll(people.getUserNames());
21.79 - }
21.80 -
21.81 - @OnPropertyChange({ "activeTweeters", "activeTweetersCount" })
21.82 - static void refreshTweets(TwitterModel model) {
21.83 - StringBuilder sb = new StringBuilder();
21.84 - sb.append("rpp=25&q=");
21.85 - String sep = "";
21.86 - for (String p : model.getActiveTweeters()) {
21.87 - sb.append(sep);
21.88 - sb.append("from:");
21.89 - sb.append(p);
21.90 - sep = " OR ";
21.91 - }
21.92 - model.setLoading(true);
21.93 - model.queryTweets("http://search.twitter.com", sb.toString());
21.94 - }
21.95 -
21.96 - static {
21.97 - final TwitterModel model = new TwitterModel();
21.98 - final List<Tweeters> svdLst = model.getSavedLists();
21.99 - svdLst.add(newTweeters("API Design", "JaroslavTulach"));
21.100 - svdLst.add(newTweeters("Celebrities", "JohnCleese", "MCHammer", "StephenFry", "algore", "StevenSanderson"));
21.101 - svdLst.add(newTweeters("Microsoft people", "BillGates", "shanselman", "ScottGu"));
21.102 - svdLst.add(newTweeters("NetBeans", "GeertjanW","monacotoni", "NetBeans", "petrjiricka"));
21.103 - svdLst.add(newTweeters("Tech pundits", "Scobleizer", "LeoLaporte", "techcrunch", "BoingBoing", "timoreilly", "codinghorror"));
21.104 -
21.105 - model.setActiveTweetersName("NetBeans");
21.106 -
21.107 - model.applyBindings();
21.108 - }
21.109 -
21.110 - @ComputedProperty
21.111 - static boolean hasUnsavedChanges(List<String> activeTweeters, List<Tweeters> savedLists, String activeTweetersName) {
21.112 - Tweeters tw = findByName(savedLists, activeTweetersName);
21.113 - if (activeTweeters == null) {
21.114 - return false;
21.115 - }
21.116 - return !tw.getUserNames().equals(activeTweeters);
21.117 - }
21.118 -
21.119 - @ComputedProperty
21.120 - static int activeTweetersCount(List<String> activeTweeters) {
21.121 - return activeTweeters.size();
21.122 - }
21.123 -
21.124 - @ComputedProperty
21.125 - static boolean userNameToAddIsValid(
21.126 - String userNameToAdd, String activeTweetersName, List<Tweeters> savedLists, List<String> activeTweeters
21.127 - ) {
21.128 - return userNameToAdd != null &&
21.129 - userNameToAdd.matches("[a-zA-Z0-9_]{1,15}") &&
21.130 - !activeTweeters.contains(userNameToAdd);
21.131 - }
21.132 -
21.133 - @Function
21.134 - static void deleteList(TwitterModel model) {
21.135 - final List<Tweeters> sl = model.getSavedLists();
21.136 - sl.remove(findByName(sl, model.getActiveTweetersName()));
21.137 - if (sl.isEmpty()) {
21.138 - final Tweeters t = new Tweeters();
21.139 - t.setName("New");
21.140 - sl.add(t);
21.141 - }
21.142 - model.setActiveTweetersName(sl.get(0).getName());
21.143 - }
21.144 -
21.145 - @Function
21.146 - static void saveChanges(TwitterModel model) {
21.147 - Tweeters t = findByName(model.getSavedLists(), model.getActiveTweetersName());
21.148 - int indx = model.getSavedLists().indexOf(t);
21.149 - if (indx != -1) {
21.150 - t.setName(model.getActiveTweetersName());
21.151 - t.getUserNames().clear();
21.152 - t.getUserNames().addAll(model.getActiveTweeters());
21.153 - }
21.154 - }
21.155 -
21.156 - @Function
21.157 - static void addUser(TwitterModel model) {
21.158 - String n = model.getUserNameToAdd();
21.159 - model.getActiveTweeters().add(n);
21.160 - }
21.161 - @Function
21.162 - static void removeUser(String data, TwitterModel model) {
21.163 - model.getActiveTweeters().remove(data);
21.164 - }
21.165 -
21.166 - private static Tweeters findByName(List<Tweeters> list, String name) {
21.167 - for (Tweeters l : list) {
21.168 - if (l.getName() != null && l.getName().equals(name)) {
21.169 - return l;
21.170 - }
21.171 - }
21.172 - return list.isEmpty() ? new Tweeters() : list.get(0);
21.173 - }
21.174 -
21.175 - private static Tweeters newTweeters(String listName, String... userNames) {
21.176 - Tweeters t = new Tweeters();
21.177 - t.setName(listName);
21.178 - t.getUserNames().addAll(Arrays.asList(userNames));
21.179 - return t;
21.180 - }
21.181 -}
22.1 --- a/ko/archetype/src/main/resources/archetype-resources/src/main/resources/index.html Sun Sep 08 11:42:01 2013 +0200
22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
22.3 @@ -1,90 +0,0 @@
22.4 -<?xml version="1.0" encoding="UTF-8"?>
22.5 -
22.6 -<!--
22.7 - Copied from knockout.js Twitter example:
22.8 - http://knockoutjs.com/examples/twitter.html
22.9 --->
22.10 -
22.11 -<!DOCTYPE html>
22.12 -<html xmlns="http://www.w3.org/1999/xhtml">
22.13 - <head>
22.14 - <title>Bck2Brwsr's Twitter</title>
22.15 - </head>
22.16 - <body>
22.17 - <link href='twitterExample.css' rel='Stylesheet' ></link>
22.18 -
22.19 - <style type='text/css'>
22.20 - .liveExample select { height: 1.7em; }
22.21 - .liveExample button { height: 2em; }
22.22 - </style>
22.23 -
22.24 -
22.25 - <h2>Bck2Brwsr's Twitter</h2>
22.26 -
22.27 - <p>
22.28 - This code is based on original
22.29 - <a href="http://knockoutjs.com/examples/twitter.html">knockout.js
22.30 - Twitter example</a> and
22.31 - uses almost unmodified HTML page. It just changes the model. The model
22.32 - is written in Java language with the help of
22.33 - <a href="http://bck2brwsr.apidesign.org/javadoc/net.java.html.json/">
22.34 - Knockout/Java binding library
22.35 - </a>. The Java source code has about 180 lines and seems more
22.36 - dense and shorter than the original JavaScript model.
22.37 - </p>
22.38 - <p>
22.39 - The project has two profiles. Either it executes in real Java virtual
22.40 - machine and renders using JavaFX's WebView (use <code>fxbrwsr</code> profile
22.41 - - the default). It can also run directly in a browser via
22.42 - <a href="http://bck2brwsr.apidesign.org">Bck2Brwsr</a> virtual machine
22.43 - (use <code>bck2brwsr</code> profile).
22.44 - </p>
22.45 -
22.46 - <div class='liveExample'>
22.47 - <div class='configuration'>
22.48 - <div class='listChooser'>
22.49 - <button data-bind='click: deleteList, enable: activeTweetersName'>Delete</button>
22.50 - <button data-bind='click: saveChanges, enable: hasUnsavedChanges'>Save</button>
22.51 - <select data-bind='options: savedLists, optionsValue: "name", value: activeTweetersName'> </select>
22.52 - </div>
22.53 -
22.54 - <p>Currently viewing <span data-bind='text: activeTweetersCount'> </span> user(s):</p>
22.55 - <div class='currentUsers' >
22.56 - <ul data-bind='foreach: activeTweeters'>
22.57 - <li>
22.58 - <button data-bind='click: $root.removeUser'>Remove</button>
22.59 - <div data-bind='text: $data'> </div>
22.60 - </li>
22.61 - </ul>
22.62 - </div>
22.63 -
22.64 - <form data-bind='submit: addUser'>
22.65 - <label>Add user:</label>
22.66 - <input data-bind='value: userNameToAdd, valueUpdate: "keyup", css: { invalid: !userNameToAddIsValid() }' />
22.67 - <button data-bind='enable: userNameToAddIsValid' type='submit'>Add</button>
22.68 - </form>
22.69 - </div>
22.70 - <div class='tweets'>
22.71 - <div class='loadingIndicator' data-bind="visible: loading">Loading...</div>
22.72 - <table data-bind='foreach: currentTweets' width='100%'>
22.73 - <tr>
22.74 - <td><img data-bind='attr: { src: profile_image_url }' /></td>
22.75 - <td>
22.76 - <a class='twitterUser' data-bind='attr: { href: userUrl }, text: from_user'> </a>
22.77 - <span data-bind='html: html'> </span>
22.78 - <div class='tweetInfo' data-bind='text: created_at'> </div>
22.79 - </td>
22.80 - </tr>
22.81 - </table>
22.82 - </div>
22.83 - </div>
22.84 -
22.85 - <script src="bck2brwsr.js"></script>
22.86 - <script type="text/javascript">
22.87 - var vm = bck2brwsr('${artifactId}-${version}.jar');
22.88 - vm.loadClass('${package}.TwitterClient');
22.89 - </script>
22.90 -
22.91 -
22.92 - </body>
22.93 -</html>
23.1 --- a/ko/archetype/src/main/resources/archetype-resources/src/main/resources/twitterExample.css Sun Sep 08 11:42:01 2013 +0200
23.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
23.3 @@ -1,32 +0,0 @@
23.4 -/*
23.5 - Copied from knockout.js Twitter example:
23.6 - http://knockoutjs.com/examples/twitter.html
23.7 -*/
23.8 -
23.9 -.configuration, .tweets, .tweets td { font-family: Verdana; font-size: 13px; }
23.10 -.configuration { background-color: #DEDEDE; border: 2px solid gray; float:left; height: 40em; width: 40%; padding: 0.5em; border-right-width:0; }
23.11 -.tweets { width: 55%; border: 2px solid gray; height: 40em; overflow: scroll; overflow-x: hidden; background-color: Black; color: White; padding: 0.5em; position: relative; }
23.12 -.tweets table { border-width: 0;}
23.13 -.tweets tr { vertical-align: top; }
23.14 -.tweets td { padding: 0.4em 0.3em 1em 0.4em; border-width: 0; }
23.15 -.tweets img { width: 4em; }
23.16 -.tweetInfo { color: Gray; font-size: 0.9em; }
23.17 -.twitterUser { color: #77AAFF; text-decoration: none; font-size: 1.1em; font-weight: bold; }
23.18 -input.invalid { border: 1px solid red !important; background-color: #FFAAAA !important; }
23.19 -
23.20 -.listChooser select, .listChooser button { vertical-align:top; }
23.21 -.listChooser select { width: 60%; font-size:1.2em; height:1.4em; }
23.22 -.listChooser button { width: 19%; height:1.68em; float:right; }
23.23 -
23.24 -.currentUsers { height: 28em; overflow-y: auto; overflow-x: hidden; }
23.25 -.currentUsers button { float: right; height: 2.5em; margin: 0.1em; padding-left: 1em; padding-right: 1em; }
23.26 -.currentUsers ul, .configuration li { list-style: none; margin: 0; padding: 0 }
23.27 -.currentUsers li { height: 2.4em; font-size: 1.2em; background-color: #A7D0E3; border: 1px solid gray; margin-bottom: 0.3em; -webkit-border-radius: 5px; -moz-border-radius: 5px; -webkit-box-shadow: 0 0.2em 0.5em gray; -moz-box-shadow: 0 0.2em 0.5em gray; }
23.28 -.currentUsers li div { padding: 0.6em; }
23.29 -.currentUsers li:hover { background-color: #EEC; }
23.30 -
23.31 -.configuration form label { width: 25%; display: inline-block; text-align:right; overflow: hidden; }
23.32 -.configuration form input { width:40%; font-size: 1.3em; border:1px solid silver; background-color: White; padding: 0.1em; }
23.33 -.configuration form button { width: 20%; margin-left: 0.3em; height: 2em; }
23.34 -
23.35 -.loadingIndicator { position: absolute; top: 0.1em; left: 0.1em; font: 0.8em Arial; background-color: #229; color: White; padding: 0.2em 0.5em 0.2em 0.5em; }
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
24.2 +++ b/ko/archetype/src/main/resources/archetype-resources/src/main/webapp/pages/index.html Wed Sep 18 11:20:57 2013 +0200
24.3 @@ -0,0 +1,63 @@
24.4 +<!DOCTYPE html>
24.5 +<html>
24.6 + <head>
24.7 + <title></title>
24.8 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
24.9 +
24.10 + <style type="text/css">
24.11 + @-webkit-keyframes spin {
24.12 + 0% { -webkit-transform: rotate(0deg); }
24.13 + 100% { -webkit-transform: rotate(360deg); }
24.14 + }
24.15 +
24.16 + .rotate {
24.17 + -webkit-animation-name: spin;
24.18 + -webkit-animation-duration: 3s;
24.19 + -webkit-animation-iteration-count: infinite;
24.20 + -webkit-animation-direction: alternate;
24.21 + }
24.22 +
24.23 + #scene {
24.24 + position: relative;
24.25 + top: 60px;
24.26 + text-align: center;
24.27 + }
24.28 +
24.29 + #words span {
24.30 + border: 1px solid #ccc;
24.31 + background: rgba(255,255,155,0.8);
24.32 + text-align: center;
24.33 + font-size: 30px;
24.34 + -webkit-box-shadow: inset 0 0 40px rgba(0,0,0,0.4);
24.35 + position: absolute;
24.36 + }
24.37 +
24.38 + #words span:nth-child(1) { left: 45%; top: 0px; }
24.39 + #words span:nth-child(2) { left: 25%; top: 100px; }
24.40 + #words span:nth-child(3) { left: 65%; top: 100px; }
24.41 + #words span:nth-child(4) { left: 10%; top: 200px; }
24.42 + #words span:nth-child(5) { left: 45%; top: 200px; }
24.43 + #words span:nth-child(6) { left: 80%; top: 200px; }
24.44 +
24.45 + </style>
24.46 +
24.47 + </head>
24.48 + <body>
24.49 + <h1>Words Demo</h1>
24.50 + <input data-bind="value: message, valueUpdate: 'afterkeydown'" size="80">
24.51 + <br>
24.52 + <button data-bind="enable: !on(), click: $root.turnOn">Start</button>
24.53 + <button data-bind="enable: on, click: $root.turnOff">Stop</button>
24.54 +
24.55 + <div id="scene">
24.56 + <span id="words" data-bind="foreach: words">
24.57 + <span data-bind="text: $data, css: { 'rotate' : $root.on } "></span>
24.58 + </span>
24.59 + </div>
24.60 + <script type="text/javascript" src="bck2brwsr.js"></script>
24.61 + <script>
24.62 + var vm = bck2brwsr('${project.build.finalName}.jar');
24.63 + vm.loadClass('${package}.Main');
24.64 + </script>
24.65 + </body>
24.66 +</html>
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
25.2 +++ b/ko/archetype/src/main/resources/archetype-resources/src/test/java/DataModelTest.java Wed Sep 18 11:20:57 2013 +0200
25.3 @@ -0,0 +1,16 @@
25.4 +package ${package};
25.5 +
25.6 +import static org.testng.Assert.*;
25.7 +import org.testng.annotations.Test;
25.8 +
25.9 +public class DataModelTest {
25.10 + @Test public void areHelloWorldTwoWords() {
25.11 + Data model = new Data();
25.12 + model.setMessage("Hello World!");
25.13 +
25.14 + java.util.List<String> arr = model.getWords();
25.15 + assertEquals(arr.size(), 6, "Six words always");
25.16 + assertEquals("Hello", arr.get(0), "Hello is the first word");
25.17 + assertEquals("World!", arr.get(1), "World is the second word");
25.18 + }
25.19 +}
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/ko/archetype/src/main/resources/archetype-resources/src/test/java/InconsistencyTest.java Wed Sep 18 11:20:57 2013 +0200
26.3 @@ -0,0 +1,38 @@
26.4 +package ${package};
26.5 +
26.6 +import org.apidesign.bck2brwsr.vmtest.Compare;
26.7 +import org.apidesign.bck2brwsr.vmtest.VMTest;
26.8 +import org.testng.annotations.Factory;
26.9 +
26.10 +/** Bck2brwsr cares about compatibility with real Java. Whatever API is
26.11 + * supported by bck2brwsr, it needs to behave the same way as when running
26.12 + * in HotSpot VM.
26.13 + * <p>
26.14 + * There can be bugs, however. To help us fix them, we kindly ask you to
26.15 + * write an "inconsistency" test. A test that compares behavior of the API
26.16 + * between real VM and bck2brwsr VM. This class is skeleton of such test.
26.17 + */
26.18 +public class InconsistencyTest {
26.19 + /** A method to demonstrate inconsistency between bck2brwsr and HotSpot.
26.20 + * Make calls to an API that behaves strangely, return some result at
26.21 + * the end. No need to use any <code>assert</code>.
26.22 + *
26.23 + * @return value to compare between HotSpot and bck2brwsr
26.24 + */
26.25 + @Compare
26.26 + public int checkStringHashCode() throws Exception {
26.27 + return "Is string hashCode the same?".hashCode();
26.28 + }
26.29 +
26.30 + /** Factory method that creates a three tests for each method annotated with
26.31 + * {@link org.apidesign.bck2brwsr.vmtest.Compare}. One executes the code in
26.32 + * HotSpot, one in Rhino and the last one compares the results.
26.33 + *
26.34 + * @see org.apidesign.bck2brwsr.vmtest.VMTest
26.35 + */
26.36 + @Factory
26.37 + public static Object[] create() {
26.38 + return VMTest.create(InconsistencyTest.class);
26.39 + }
26.40 +
26.41 +}
27.1 --- a/ko/archetype/src/main/resources/archetype-resources/src/test/java/TwitterClientTest.java Sun Sep 08 11:42:01 2013 +0200
27.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
27.3 @@ -1,50 +0,0 @@
27.4 -package ${package};
27.5 -
27.6 -import java.util.List;
27.7 -import net.java.html.BrwsrCtx;
27.8 -import net.java.html.json.Models;
27.9 -import static org.testng.Assert.*;
27.10 -import org.testng.annotations.BeforeMethod;
27.11 -import org.testng.annotations.Test;
27.12 -
27.13 -/** We can unit test the TwitterModel smoothly.
27.14 - */
27.15 -public class TwitterClientTest {
27.16 - private TwitterModel model;
27.17 -
27.18 -
27.19 - @BeforeMethod
27.20 - public void initModel() {
27.21 - model = Models.bind(new TwitterModel(), BrwsrCtx.EMPTY);
27.22 - }
27.23 -
27.24 - @Test public void testIsValidToAdd() {
27.25 - model.setUserNameToAdd("Joe");
27.26 - Tweeters t = Models.bind(new Tweeters(), BrwsrCtx.EMPTY);
27.27 - t.setName("test");
27.28 - model.getSavedLists().add(t);
27.29 - model.setActiveTweetersName("test");
27.30 -
27.31 - assertTrue(model.isUserNameToAddIsValid(), "Joe is OK");
27.32 - TwitterClient.addUser(model);
27.33 - assertFalse(model.isUserNameToAddIsValid(), "Can't add Joe for the 2nd time");
27.34 - assertEquals(t.getUserNames().size(), 0, "Original tweeters list remains empty");
27.35 -
27.36 - List<String> mod = model.getActiveTweeters();
27.37 - assertTrue(model.isHasUnsavedChanges(), "We have modifications");
27.38 - assertEquals(mod.size(), 1, "One element in the list");
27.39 - assertEquals(mod.get(0), "Joe", "Its name is Joe");
27.40 -
27.41 - assertSame(model.getActiveTweeters(), mod, "Editing list is the modified one");
27.42 -
27.43 - TwitterClient.saveChanges(model);
27.44 - assertFalse(model.isHasUnsavedChanges(), "Does not have anything to save");
27.45 -
27.46 - assertSame(model.getActiveTweeters(), mod, "Still editing the old modified one");
27.47 - }
27.48 -
27.49 - @Test public void httpAtTheEnd() {
27.50 - String res = TwitterClient.Twt.html("Ahoj http://kuk");
27.51 - assertEquals(res, "Ahoj <a href='http://kuk'>http://kuk</a>");
27.52 - }
27.53 -}
28.1 --- a/ko/archetype/src/main/resources/archetype-resources/src/test/java/TwitterProtocolTest.java Sun Sep 08 11:42:01 2013 +0200
28.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
28.3 @@ -1,73 +0,0 @@
28.4 -package ${package};
28.5 -
28.6 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
28.7 -import org.apidesign.bck2brwsr.vmtest.Http;
28.8 -import org.apidesign.bck2brwsr.vmtest.VMTest;
28.9 -import org.testng.annotations.Factory;
28.10 -
28.11 -public class TwitterProtocolTest {
28.12 - private TwitterModel page;
28.13 - @Http(@Http.Resource(
28.14 - path = "/search.json",
28.15 - mimeType = "application/json",
28.16 - parameters = {"callback"},
28.17 - content = "$0({\"completed_in\":0.04,\"max_id\":320055706885689344,\"max_id_str\""
28.18 - + ":\"320055706885689344\",\"page\":1,\"query\":\"from%3AJaroslavTulach\",\"refresh_url\":"
28.19 - + "\"?since_id=320055706885689344&q=from%3AJaroslavTulach\","
28.20 - + "\"results\":[{\"created_at\":\"Fri, 05 Apr 2013 06:10:01 +0000\","
28.21 - + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
28.22 - + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":320055706885689344,"
28.23 - + "\"id_str\":\"320055706885689344\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
28.24 - + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
28.25 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
28.26 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
28.27 - + "\"@tom_enebo Amzng! Not that I would like #ruby, but I am really glad you guys stabilized the plugin + "
28.28 - + "made it work in #netbeans 7.3! Gd wrk.\",\"to_user\":\"tom_enebo\",\"to_user_id\":14498747,"
28.29 - + "\"to_user_id_str\":\"14498747\",\"to_user_name\":\"tom_enebo\",\"in_reply_to_status_id\":319832359509839872,"
28.30 - + "\"in_reply_to_status_id_str\":\"319832359509839872\"},{\"created_at\":\"Thu, 04 Apr 2013 07:33:06 +0000\","
28.31 - + "\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,\"from_user_id_str\":"
28.32 - + "\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,\"id\":319714227088678913,"
28.33 - + "\"id_str\":\"319714227088678913\",\"iso_language_code\":\"en\",\"metadata\":{\"result_type\":"
28.34 - + "\"recent\"},\"profile_image_url\":\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
28.35 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
28.36 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
28.37 - + "\"RT @drkrab: At #erlangfactory @joerl: Frameworks grow in complexity until nobody can use them.\"},"
28.38 - + "{\"created_at\":\"Tue, 02 Apr 2013 07:44:34 +0000\",\"from_user\":\"JaroslavTulach\","
28.39 - + "\"from_user_id\":420944648,\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\","
28.40 - + "\"geo\":null,\"id\":318992336145248256,\"id_str\":\"318992336145248256\",\"iso_language_code\":\"en\","
28.41 - + "\"metadata\":{\"result_type\":\"recent\"},\"profile_image_url\":"
28.42 - + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
28.43 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
28.44 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
28.45 - + "\"Twitter renamed to twttr http:\\/\\/t.co\\/tqaN4T1xlZ - good, I don't have to rename #bck2brwsr!\"},"
28.46 - + "{\"created_at\":\"Sun, 31 Mar 2013 03:52:04 +0000\",\"from_user\":\"JaroslavTulach\",\"from_user_id\":420944648,"
28.47 - + "\"from_user_id_str\":\"420944648\",\"from_user_name\":\"Jaroslav Tulach\",\"geo\":null,"
28.48 - + "\"id\":318209051223789568,\"id_str\":\"318209051223789568\",\"iso_language_code\":\"en\",\"metadata\":"
28.49 - + "{\"result_type\":\"recent\"},\"profile_image_url\":"
28.50 - + "\"http:\\/\\/a0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
28.51 - + "\"profile_image_url_https\":\"https:\\/\\/si0.twimg.com\\/profile_images\\/1656828312\\/jst_normal.gif\","
28.52 - + "\"source\":\"<a href="http:\\/\\/twitter.com\\/">web<\\/a>\",\"text\":"
28.53 - + "\"Math proofs without words. Ingenious: http:\\/\\/t.co\\/sz7yVbfpGw\"}],\"results_per_page\":100,"
28.54 - + "\"since_id\":0,\"since_id_str\":\"0\"})"
28.55 - ))
28.56 - @BrwsrTest public void readFromTwttr() throws InterruptedException {
28.57 - if (page == null) {
28.58 - page = new TwitterModel();
28.59 - page.applyBindings();
28.60 - page.queryTweets("", "q=xyz");
28.61 - }
28.62 -
28.63 - if (page.getCurrentTweets().isEmpty()) {
28.64 - throw new InterruptedException();
28.65 - }
28.66 -
28.67 - assert 4 == page.getCurrentTweets().size() : "Four tweets: " + page.getCurrentTweets();
28.68 -
28.69 - String firstDate = page.getCurrentTweets().get(0).getCreated_at();
28.70 - assert "Fri, 05 Apr 2013 06:10:01 +0000".equals(firstDate) : "Date is OK: " + firstDate;
28.71 - }
28.72 -
28.73 - @Factory public static Object[] create() {
28.74 - return VMTest.create(TwitterProtocolTest.class);
28.75 - }
28.76 -}
29.1 --- a/ko/bck2brwsr/pom.xml Sun Sep 08 11:42:01 2013 +0200
29.2 +++ b/ko/bck2brwsr/pom.xml Wed Sep 18 11:20:57 2013 +0200
29.3 @@ -4,11 +4,11 @@
29.4 <parent>
29.5 <groupId>org.apidesign.bck2brwsr</groupId>
29.6 <artifactId>ko</artifactId>
29.7 - <version>0.8-SNAPSHOT</version>
29.8 + <version>0.9-SNAPSHOT</version>
29.9 </parent>
29.10 <groupId>org.apidesign.bck2brwsr</groupId>
29.11 <artifactId>ko-bck2brwsr</artifactId>
29.12 - <version>0.8-SNAPSHOT</version>
29.13 + <version>0.9-SNAPSHOT</version>
29.14 <name>Knockout.b2b</name>
29.15 <url>http://maven.apache.org</url>
29.16 <build>
30.1 --- a/ko/bck2brwsr/src/main/java/org/apidesign/bck2brwsr/ko2brwsr/BrwsrCtxPrvdr.java Sun Sep 08 11:42:01 2013 +0200
30.2 +++ b/ko/bck2brwsr/src/main/java/org/apidesign/bck2brwsr/ko2brwsr/BrwsrCtxPrvdr.java Wed Sep 18 11:20:57 2013 +0200
30.3 @@ -21,6 +21,7 @@
30.4 import org.apidesign.html.context.spi.Contexts;
30.5 import org.apidesign.html.json.spi.Technology;
30.6 import org.apidesign.html.json.spi.Transfer;
30.7 +import org.apidesign.html.json.spi.WSTransfer;
30.8 import org.openide.util.lookup.ServiceProvider;
30.9
30.10 /** This is an implementation package - just
30.11 @@ -40,7 +41,8 @@
30.12 public void fillContext(Contexts.Builder context, Class<?> requestor) {
30.13 if (bck2BrwsrVM()) {
30.14 context.register(Technology.class, BrwsrCtxImpl.DEFAULT, 50).
30.15 - register(Transfer.class, BrwsrCtxImpl.DEFAULT, 50);
30.16 + register(Transfer.class, BrwsrCtxImpl.DEFAULT, 50).
30.17 + register(WSTransfer.class, BrwsrCtxImpl.DEFAULT, 50);
30.18 }
30.19 }
30.20
31.1 --- a/ko/fx/pom.xml Sun Sep 08 11:42:01 2013 +0200
31.2 +++ b/ko/fx/pom.xml Wed Sep 18 11:20:57 2013 +0200
31.3 @@ -4,15 +4,14 @@
31.4 <parent>
31.5 <groupId>org.apidesign.bck2brwsr</groupId>
31.6 <artifactId>ko</artifactId>
31.7 - <version>0.8-SNAPSHOT</version>
31.8 + <version>0.9-SNAPSHOT</version>
31.9 </parent>
31.10 <groupId>org.apidesign.bck2brwsr</groupId>
31.11 <artifactId>ko-fx</artifactId>
31.12 - <version>0.8-SNAPSHOT</version>
31.13 + <version>0.9-SNAPSHOT</version>
31.14 <name>Knockout.fx in Brwsr</name>
31.15 <url>http://maven.apache.org</url>
31.16 <properties>
31.17 - <jfxrt.jar>${java.home}/lib/jfxrt.jar</jfxrt.jar>
31.18 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
31.19 </properties>
31.20 <build>
32.1 --- a/ko/fx/src/test/java/org/apidesign/bck2brwsr/kofx/KnockoutFXTest.java Sun Sep 08 11:42:01 2013 +0200
32.2 +++ b/ko/fx/src/test/java/org/apidesign/bck2brwsr/kofx/KnockoutFXTest.java Wed Sep 18 11:20:57 2013 +0200
32.3 @@ -28,6 +28,7 @@
32.4 import net.java.html.BrwsrCtx;
32.5 import net.java.html.js.JavaScriptBody;
32.6 import org.apidesign.bck2brwsr.vmtest.VMTest;
32.7 +import org.apidesign.html.boot.impl.FnUtils;
32.8 import org.apidesign.html.context.spi.Contexts;
32.9 import org.apidesign.html.json.spi.Technology;
32.10 import org.apidesign.html.json.spi.Transfer;
32.11 @@ -59,7 +60,7 @@
32.12
32.13 @Override
32.14 public BrwsrCtx createContext() {
32.15 - FXContext fx = new FXContext();
32.16 + FXContext fx = new FXContext(FnUtils.currentPresenter());
32.17 TyrusContext tc = new TyrusContext();
32.18 Contexts.Builder b = Contexts.newBuilder().
32.19 register(Technology.class, fx, 10).
33.1 --- a/ko/pom.xml Sun Sep 08 11:42:01 2013 +0200
33.2 +++ b/ko/pom.xml Wed Sep 18 11:20:57 2013 +0200
33.3 @@ -3,13 +3,13 @@
33.4 <modelVersion>4.0.0</modelVersion>
33.5 <groupId>org.apidesign.bck2brwsr</groupId>
33.6 <artifactId>ko</artifactId>
33.7 - <version>0.8-SNAPSHOT</version>
33.8 + <version>0.9-SNAPSHOT</version>
33.9 <packaging>pom</packaging>
33.10 <name>Bck2Brwsr Knockout Support</name>
33.11 <parent>
33.12 <groupId>org.apidesign</groupId>
33.13 <artifactId>bck2brwsr</artifactId>
33.14 - <version>0.8-SNAPSHOT</version>
33.15 + <version>0.9-SNAPSHOT</version>
33.16 </parent>
33.17 <modules>
33.18 <module>archetype</module>
34.1 --- a/launcher/api/pom.xml Sun Sep 08 11:42:01 2013 +0200
34.2 +++ b/launcher/api/pom.xml Wed Sep 18 11:20:57 2013 +0200
34.3 @@ -4,11 +4,11 @@
34.4 <parent>
34.5 <groupId>org.apidesign.bck2brwsr</groupId>
34.6 <artifactId>launcher-pom</artifactId>
34.7 - <version>0.8-SNAPSHOT</version>
34.8 + <version>0.9-SNAPSHOT</version>
34.9 </parent>
34.10 <groupId>org.apidesign.bck2brwsr</groupId>
34.11 <artifactId>launcher</artifactId>
34.12 - <version>0.8-SNAPSHOT</version>
34.13 + <version>0.9-SNAPSHOT</version>
34.14 <name>Launcher API</name>
34.15 <url>http://maven.apache.org</url>
34.16 <properties>
35.1 --- a/launcher/api/src/main/java/org/apidesign/bck2brwsr/launcher/Launcher.java Sun Sep 08 11:42:01 2013 +0200
35.2 +++ b/launcher/api/src/main/java/org/apidesign/bck2brwsr/launcher/Launcher.java Wed Sep 18 11:20:57 2013 +0200
35.3 @@ -135,14 +135,34 @@
35.4 * The <code>startpage</code> should be relative location inside the root
35.5 * directory. Opens a browser with URL showing the start page.
35.6 *
35.7 + * @param brwsr type of the browser to use
35.8 + * @param directory the root directory on disk
35.9 + * @param classes additional classloader with access to classes or <code>null</code>
35.10 + * @param startpage relative path from the root to the page
35.11 + * @return instance of server that can be closed
35.12 + * @exception IOException if something goes wrong.
35.13 + * @since 0.8
35.14 + */
35.15 + public static Closeable showDir(String brwsr, File directory, ClassLoader classes, String startpage) throws IOException {
35.16 + Launcher l = createBrowser(brwsr);
35.17 + if (classes != null) {
35.18 + l.addClassLoader(classes);
35.19 + }
35.20 + l.showDirectory(directory, startpage, classes != null);
35.21 + return (Closeable) l;
35.22 + }
35.23 +
35.24 + /** Starts an HTTP server which provides access to certain directory.
35.25 + * The <code>startpage</code> should be relative location inside the root
35.26 + * directory. Opens a browser with URL showing the start page.
35.27 + *
35.28 * @param directory the root directory on disk
35.29 * @param startpage relative path from the root to the page
35.30 + * @return instance of server that can be closed
35.31 * @exception IOException if something goes wrong.
35.32 */
35.33 public static Closeable showDir(File directory, String startpage) throws IOException {
35.34 - Launcher l = createBrowser(null);
35.35 - l.showDirectory(directory, startpage);
35.36 - return (Closeable) l;
35.37 + return showDir(null, directory, null, startpage);
35.38 }
35.39
35.40 abstract InvocationContext runMethod(InvocationContext c) throws IOException;
35.41 @@ -152,7 +172,7 @@
35.42 return Launcher.class.getClassLoader().loadClass(cn);
35.43 }
35.44
35.45 - void showDirectory(File directory, String startpage) throws IOException {
35.46 + void showDirectory(File directory, String startpage, boolean addClasses) throws IOException {
35.47 throw new UnsupportedOperationException();
35.48 }
35.49
36.1 --- a/launcher/fx/pom.xml Sun Sep 08 11:42:01 2013 +0200
36.2 +++ b/launcher/fx/pom.xml Wed Sep 18 11:20:57 2013 +0200
36.3 @@ -4,11 +4,11 @@
36.4 <parent>
36.5 <groupId>org.apidesign.bck2brwsr</groupId>
36.6 <artifactId>launcher-pom</artifactId>
36.7 - <version>0.8-SNAPSHOT</version>
36.8 + <version>0.9-SNAPSHOT</version>
36.9 </parent>
36.10 <groupId>org.apidesign.bck2brwsr</groupId>
36.11 <artifactId>launcher.fx</artifactId>
36.12 - <version>0.8-SNAPSHOT</version>
36.13 + <version>0.9-SNAPSHOT</version>
36.14 <name>FXBrwsr Launcher</name>
36.15 <url>http://maven.apache.org</url>
36.16 <build>
36.17 @@ -33,7 +33,6 @@
36.18 </plugins>
36.19 </build>
36.20 <properties>
36.21 - <jfxrt.jar>${java.home}/lib/jfxrt.jar</jfxrt.jar>
36.22 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36.23 </properties>
36.24 <dependencies>
37.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Sun Sep 08 11:42:01 2013 +0200
37.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Wed Sep 18 11:20:57 2013 +0200
37.3 @@ -52,6 +52,7 @@
37.4 import org.glassfish.grizzly.http.server.Request;
37.5 import org.glassfish.grizzly.http.server.Response;
37.6 import org.glassfish.grizzly.http.server.ServerConfiguration;
37.7 +import org.glassfish.grizzly.http.server.StaticHttpHandler;
37.8 import org.glassfish.grizzly.http.util.HttpStatus;
37.9 import org.glassfish.grizzly.threadpool.ThreadPoolConfig;
37.10 import org.glassfish.grizzly.websockets.WebSocket;
37.11 @@ -111,7 +112,7 @@
37.12 if (!startpage.startsWith("/")) {
37.13 startpage = "/" + startpage;
37.14 }
37.15 - HttpServer s = initServer(".", true);
37.16 + HttpServer s = initServer(".", true, "");
37.17 int last = startpage.lastIndexOf('/');
37.18 String prefix = startpage.substring(0, last);
37.19 String simpleName = startpage.substring(last);
37.20 @@ -124,11 +125,16 @@
37.21 }
37.22 }
37.23
37.24 - void showDirectory(File dir, String startpage) throws IOException {
37.25 + void showDirectory(File dir, String startpage, boolean addClasses) throws IOException {
37.26 if (!startpage.startsWith("/")) {
37.27 startpage = "/" + startpage;
37.28 }
37.29 - HttpServer s = initServer(dir.getPath(), false);
37.30 + String prefix = "";
37.31 + int last = startpage.lastIndexOf('/');
37.32 + if (last >= 0) {
37.33 + prefix = startpage.substring(0, last);
37.34 + }
37.35 + HttpServer s = initServer(dir.getPath(), addClasses, prefix);
37.36 try {
37.37 launchServerAndBrwsr(s, startpage);
37.38 } catch (Exception ex) {
37.39 @@ -155,8 +161,8 @@
37.40 }
37.41 }
37.42
37.43 - private HttpServer initServer(String path, boolean addClasses) throws IOException {
37.44 - HttpServer s = HttpServer.createSimpleServer(path, new PortRange(8080, 65535));
37.45 + private HttpServer initServer(String path, boolean addClasses, String vmPrefix) throws IOException {
37.46 + HttpServer s = HttpServer.createSimpleServer(null, new PortRange(8080, 65535));
37.47 /*
37.48 ThreadPoolConfig fewThreads = ThreadPoolConfig.defaultConfig().copy().
37.49 setPoolName("Fx/Bck2 Brwsr").
37.50 @@ -172,8 +178,15 @@
37.51 }
37.52 */
37.53 final ServerConfiguration conf = s.getServerConfiguration();
37.54 + VMAndPages vm = new VMAndPages();
37.55 + conf.addHttpHandler(vm, "/");
37.56 + if (vmPrefix != null) {
37.57 + vm.registerVM(vmPrefix + "/bck2brwsr.js");
37.58 + }
37.59 + if (path != null) {
37.60 + vm.addDocRoot(path);
37.61 + }
37.62 if (addClasses) {
37.63 - conf.addHttpHandler(new VM(), "/bck2brwsr.js");
37.64 conf.addHttpHandler(new Classes(resources), "/classes/");
37.65 }
37.66 final WebSocketAddOn addon = new WebSocketAddOn();
37.67 @@ -185,7 +198,7 @@
37.68
37.69 private void executeInBrowser() throws InterruptedException, URISyntaxException, IOException {
37.70 wait = new CountDownLatch(1);
37.71 - server = initServer(".", true);
37.72 + server = initServer(".", true, "");
37.73 final ServerConfiguration conf = server.getServerConfiguration();
37.74
37.75 class DynamicResourceHandler extends HttpHandler {
37.76 @@ -642,14 +655,28 @@
37.77
37.78 }
37.79
37.80 - private class VM extends HttpHandler {
37.81 + private class VMAndPages extends StaticHttpHandler {
37.82 + private String vmResource;
37.83 +
37.84 + public VMAndPages() {
37.85 + super((String[]) null);
37.86 + }
37.87 +
37.88 @Override
37.89 public void service(Request request, Response response) throws Exception {
37.90 - response.setCharacterEncoding("UTF-8");
37.91 - response.setContentType("text/javascript");
37.92 - StringBuilder sb = new StringBuilder();
37.93 - generateBck2BrwsrJS(sb, BaseHTTPLauncher.this.resources);
37.94 - response.getWriter().write(sb.toString());
37.95 + if (request.getRequestURI().equals(vmResource)) {
37.96 + response.setCharacterEncoding("UTF-8");
37.97 + response.setContentType("text/javascript");
37.98 + StringBuilder sb = new StringBuilder();
37.99 + generateBck2BrwsrJS(sb, BaseHTTPLauncher.this.resources);
37.100 + response.getWriter().write(sb.toString());
37.101 + } else {
37.102 + super.service(request, response);
37.103 + }
37.104 + }
37.105 +
37.106 + private void registerVM(String vmResource) {
37.107 + this.vmResource = vmResource;
37.108 }
37.109 }
37.110
38.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/FXBrwsrLauncher.java Sun Sep 08 11:42:01 2013 +0200
38.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/FXBrwsrLauncher.java Wed Sep 18 11:20:57 2013 +0200
38.3 @@ -17,11 +17,14 @@
38.4 */
38.5 package org.apidesign.bck2brwsr.launcher;
38.6
38.7 +import java.io.File;
38.8 import org.apidesign.bck2brwsr.launcher.fximpl.FXBrwsr;
38.9 import java.io.IOException;
38.10 import java.io.InputStream;
38.11 import java.lang.reflect.Method;
38.12 +import java.net.JarURLConnection;
38.13 import java.net.URI;
38.14 +import java.net.URISyntaxException;
38.15 import java.net.URL;
38.16 import java.net.URLClassLoader;
38.17 import java.util.ArrayList;
38.18 @@ -34,6 +37,7 @@
38.19 import java.util.logging.Logger;
38.20 import javafx.application.Platform;
38.21 import org.apidesign.bck2brwsr.launcher.fximpl.JVMBridge;
38.22 +import org.openide.util.Exceptions;
38.23
38.24 /**
38.25 *
38.26 @@ -116,15 +120,29 @@
38.27 String startPage = null;
38.28
38.29 final ClassLoader cl = FXBrwsrLauncher.class.getClassLoader();
38.30 - startPage = findStartPage(cl, startPage);
38.31 + URL[] manifestURL = { null };
38.32 + startPage = findStartPage(cl, startPage, manifestURL);
38.33 if (startPage == null) {
38.34 throw new NullPointerException("Can't find StartPage tag in manifests!");
38.35 }
38.36
38.37 - Launcher.showURL("fxbrwsr", cl, startPage);
38.38 + File dir = new File(".");
38.39 + if (manifestURL[0].getProtocol().equals("jar")) {
38.40 + try {
38.41 + dir = new File(
38.42 + ((JarURLConnection)manifestURL[0].openConnection()).getJarFileURL().toURI()
38.43 + ).getParentFile();
38.44 + } catch (URISyntaxException ex) {
38.45 + LOG.log(Level.WARNING, "Can't find root directory", ex);
38.46 + }
38.47 + }
38.48 +
38.49 + Launcher.showDir("fxbrwsr", dir, cl, startPage);
38.50 }
38.51
38.52 - private static String findStartPage(final ClassLoader cl, String startPage) throws IOException {
38.53 + private static String findStartPage(
38.54 + final ClassLoader cl, String startPage, URL[] startURL
38.55 + ) throws IOException {
38.56 Enumeration<URL> en = cl.getResources("META-INF/MANIFEST.MF");
38.57 while (en.hasMoreElements()) {
38.58 URL url = en.nextElement();
38.59 @@ -139,6 +157,9 @@
38.60 String sp = mf.getMainAttributes().getValue("StartPage");
38.61 if (sp != null) {
38.62 startPage = sp;
38.63 + if (startURL != null) {
38.64 + startURL[0] = url;
38.65 + }
38.66 break;
38.67 }
38.68 }
39.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/BrowserToolbar.java Sun Sep 08 11:42:01 2013 +0200
39.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/BrowserToolbar.java Wed Sep 18 11:20:57 2013 +0200
39.3 @@ -45,7 +45,7 @@
39.4 private final ToggleGroup resizeGroup = new ToggleGroup();
39.5 private final ComboBox<String> comboZoom = new ComboBox<String>();
39.6
39.7 - BrowserToolbar(WebView webView, Pane container, boolean useFirebug, final WebDebug webDebug) {
39.8 + BrowserToolbar(WebView webView, Pane container, boolean useFirebug) {
39.9 this.webView = webView;
39.10 this.container = container;
39.11
39.12 @@ -104,19 +104,6 @@
39.13 });
39.14 getItems().add(firebug);
39.15 }
39.16 -
39.17 - if (webDebug != null) {
39.18 - final ToggleButton btnSelMode = new ToggleButton(null, new ImageView(
39.19 - new Image(BrowserToolbar.class.getResourceAsStream("selectionMode.png"))));
39.20 - btnSelMode.setTooltip(new Tooltip("Toggle selection mode"));
39.21 - btnSelMode.selectedProperty().addListener(new InvalidationListener() {
39.22 - @Override
39.23 - public void invalidated(Observable o) {
39.24 - toggleSelectionMode(webDebug, btnSelMode.isSelected());
39.25 - }
39.26 - });
39.27 - getItems().add(btnSelMode);
39.28 - }
39.29 }
39.30
39.31 private String zoom( String zoomFactor ) {
39.32 @@ -181,11 +168,6 @@
39.33 webView.autosize();
39.34 }
39.35
39.36 - private void toggleSelectionMode(WebDebug dbg, boolean selMode) {
39.37 - // "inspect"
39.38 - dbg.call("{\"message\":\"selection_mode\",\"selectionMode\":" + selMode + "}");
39.39 - }
39.40 -
39.41 final void toggleFireBug(boolean enable) {
39.42 WebEngine eng = webView.getEngine();
39.43 Object installed = eng.executeScript("window.Firebug");
40.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/FXBrwsr.java Sun Sep 08 11:42:01 2013 +0200
40.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/FXBrwsr.java Wed Sep 18 11:20:57 2013 +0200
40.3 @@ -55,8 +55,9 @@
40.4 @Override
40.5 public void start(Stage primaryStage) throws Exception {
40.6 WebView view = new WebView();
40.7 - final String nbUserDir = this.getParameters().getNamed().get("userdir"); // NOI18N
40.8 - WebController wc = new WebController(view, nbUserDir, getParameters().getUnnamed());
40.9 + WebController wc = new WebController(view, getParameters().getUnnamed());
40.10 +
40.11 + FXInspect.initialize(view.getEngine());
40.12
40.13 final VBox vbox = new VBox();
40.14 vbox.setAlignment( Pos.CENTER );
40.15 @@ -73,7 +74,7 @@
40.16 final boolean showToolbar = "true".equals(this.getParameters().getNamed().get("toolbar")); // NOI18N
40.17 final boolean useFirebug = "true".equals(this.getParameters().getNamed().get("firebug")); // NOI18N
40.18 if (showToolbar) {
40.19 - final ToolBar toolbar = new BrowserToolbar(view, vbox, useFirebug, wc.dbg);
40.20 + final ToolBar toolbar = new BrowserToolbar(view, vbox, useFirebug);
40.21 root.setTop( toolbar );
40.22 }
40.23 root.setCenter(hbox);
40.24 @@ -90,12 +91,9 @@
40.25 */
40.26 private static class WebController {
40.27 private final JVMBridge bridge;
40.28 - private final WebDebug dbg;
40.29 - private final String ud;
40.30
40.31 - public WebController(WebView view, String ud, List<String> params) {
40.32 + public WebController(WebView view, List<String> params) {
40.33 this.bridge = new JVMBridge(view.getEngine());
40.34 - this.ud = ud;
40.35 LOG.log(Level.INFO, "Initializing WebView with {0}", params);
40.36 final WebEngine eng = view.getEngine();
40.37 try {
40.38 @@ -138,15 +136,6 @@
40.39 dialogStage.showAndWait();
40.40 }
40.41 });
40.42 - WebDebug wd = null;
40.43 - try {
40.44 - if (ud != null) {
40.45 - wd = WebDebug.create(eng.impl_getDebugger(), ud);
40.46 - }
40.47 - } catch (Exception ex) {
40.48 - LOG.log(Level.WARNING, null, ex);
40.49 - }
40.50 - this.dbg = wd;
40.51 }
40.52
40.53 boolean initBck2Brwsr(WebEngine webEngine) {
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
41.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/FXInspect.java Wed Sep 18 11:20:57 2013 +0200
41.3 @@ -0,0 +1,112 @@
41.4 +/**
41.5 + * Back 2 Browser Bytecode Translator
41.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
41.7 + *
41.8 + * This program is free software: you can redistribute it and/or modify
41.9 + * it under the terms of the GNU General Public License as published by
41.10 + * the Free Software Foundation, version 2 of the License.
41.11 + *
41.12 + * This program is distributed in the hope that it will be useful,
41.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
41.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41.15 + * GNU General Public License for more details.
41.16 + *
41.17 + * You should have received a copy of the GNU General Public License
41.18 + * along with this program. Look for COPYING file in the top folder.
41.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
41.20 + */
41.21 +package org.apidesign.bck2brwsr.launcher.fximpl;
41.22 +
41.23 +import com.sun.javafx.scene.web.Debugger;
41.24 +import java.io.IOException;
41.25 +import java.io.ObjectInputStream;
41.26 +import java.io.ObjectOutputStream;
41.27 +import java.net.InetAddress;
41.28 +import java.net.Socket;
41.29 +import java.nio.charset.StandardCharsets;
41.30 +import java.util.logging.Level;
41.31 +import java.util.logging.Logger;
41.32 +import javafx.application.Platform;
41.33 +import javafx.scene.web.WebEngine;
41.34 +import javafx.util.Callback;
41.35 +import org.openide.util.Exceptions;
41.36 +
41.37 +/**
41.38 + *
41.39 + * @author Jaroslav Tulach <jtulach@netbeans.org>
41.40 + */
41.41 +final class FXInspect implements Runnable {
41.42 + private static final Logger LOG = Logger.getLogger(FXInspect.class.getName());
41.43 +
41.44 +
41.45 + private final WebEngine engine;
41.46 + private final ObjectInputStream input;
41.47 +
41.48 + private FXInspect(WebEngine engine, int port) throws IOException {
41.49 + this.engine = engine;
41.50 +
41.51 + Socket socket = new Socket(InetAddress.getByName(null), port);
41.52 + ObjectOutputStream output = new ObjectOutputStream(socket.getOutputStream());
41.53 + this.input = new ObjectInputStream(socket.getInputStream());
41.54 + initializeDebugger(output);
41.55 + }
41.56 +
41.57 + static boolean initialize(WebEngine engine) {
41.58 + final int inspectPort = Integer.getInteger("netbeans.inspect.port", -1); // NOI18N
41.59 + if (inspectPort != -1) {
41.60 + try {
41.61 + FXInspect inspector = new FXInspect(engine, inspectPort);
41.62 + Thread t = new Thread(inspector, "FX<->NetBeans Inspector");
41.63 + t.start();
41.64 + return true;
41.65 + } catch (IOException ex) {
41.66 + LOG.log(Level.INFO, "Cannot connect to NetBeans IDE to port " + inspectPort, ex); // NOI18N
41.67 + }
41.68 + }
41.69 + return false;
41.70 + }
41.71 +
41.72 + private void initializeDebugger(final ObjectOutputStream output) {
41.73 + Platform.runLater(new Runnable() {
41.74 + @Override
41.75 + public void run() {
41.76 + Debugger debugger = engine.impl_getDebugger();
41.77 + debugger.setEnabled(true);
41.78 + debugger.setMessageCallback(new Callback<String,Void>() {
41.79 + @Override
41.80 + public Void call(String message) {
41.81 + try {
41.82 + byte[] bytes = message.getBytes(StandardCharsets.UTF_8);
41.83 + output.writeInt(bytes.length);
41.84 + output.write(bytes);
41.85 + output.flush();
41.86 + } catch (IOException ioex) {
41.87 + ioex.printStackTrace();
41.88 + }
41.89 + return null;
41.90 + }
41.91 + });
41.92 + }
41.93 + });
41.94 + }
41.95 +
41.96 + @Override
41.97 + public void run() {
41.98 + try {
41.99 + while (true) {
41.100 + int length = input.readInt();
41.101 + byte[] bytes = new byte[length];
41.102 + input.readFully(bytes);
41.103 + final String message = new String(bytes, StandardCharsets.UTF_8);
41.104 + Platform.runLater(new Runnable() {
41.105 + @Override
41.106 + public void run() {
41.107 + engine.impl_getDebugger().sendMessage(message);
41.108 + }
41.109 + });
41.110 + }
41.111 + } catch (IOException ioex) {
41.112 + ioex.printStackTrace();
41.113 + }
41.114 + }
41.115 +}
42.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/JVMBridge.java Sun Sep 08 11:42:01 2013 +0200
42.2 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/JVMBridge.java Wed Sep 18 11:20:57 2013 +0200
42.3 @@ -39,6 +39,7 @@
42.4 public final class JVMBridge {
42.5 private final WebEngine engine;
42.6 private final ClassLoader cl;
42.7 + private final WebPresenter presenter;
42.8
42.9 private static ClassLoader[] ldrs;
42.10 private static ChangeListener<Void> onBck2BrwsrLoad;
42.11 @@ -46,8 +47,8 @@
42.12 JVMBridge(WebEngine eng) {
42.13 this.engine = eng;
42.14 final ClassLoader p = JVMBridge.class.getClassLoader().getParent();
42.15 - WebClassLoader wcl = new WebClassLoader();
42.16 - this.cl = FnUtils.newLoader(wcl, wcl, p);
42.17 + this.presenter = new WebPresenter();
42.18 + this.cl = FnUtils.newLoader(presenter, presenter, p);
42.19 }
42.20
42.21 public static void registerClassLoaders(ClassLoader[] loaders) {
42.22 @@ -69,10 +70,11 @@
42.23 }
42.24
42.25 public Class<?> loadClass(String name) throws ClassNotFoundException {
42.26 + FnUtils.currentPresenter(presenter);
42.27 return Class.forName(name, true, cl);
42.28 }
42.29
42.30 - private final class WebClassLoader implements FindResources, Fn.Presenter {
42.31 + private final class WebPresenter implements FindResources, Fn.Presenter {
42.32 @Override
42.33 public void findResources(String name, Collection<? super URL> results, boolean oneIsEnough) {
42.34 if (ldrs != null) for (ClassLoader l : ldrs) {
42.35 @@ -99,7 +101,7 @@
42.36 sb.append("})()");
42.37
42.38 JSObject x = (JSObject) engine.executeScript(sb.toString());
42.39 - return new JSFn(x);
42.40 + return new JSFn(this, x);
42.41 }
42.42
42.43 @Override
42.44 @@ -125,10 +127,11 @@
42.45 private static final class JSFn extends Fn {
42.46 private final JSObject fn;
42.47
42.48 - public JSFn(JSObject fn) {
42.49 + private JSFn(WebPresenter cl, JSObject fn) {
42.50 + super(cl);
42.51 this.fn = fn;
42.52 }
42.53 -
42.54 +
42.55 @Override
42.56 public Object invoke(Object thiz, Object... args) throws Exception {
42.57 try {
43.1 --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/fximpl/WebDebug.java Sun Sep 08 11:42:01 2013 +0200
43.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
43.3 @@ -1,189 +0,0 @@
43.4 -/**
43.5 - * Back 2 Browser Bytecode Translator
43.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
43.7 - *
43.8 - * This program is free software: you can redistribute it and/or modify
43.9 - * it under the terms of the GNU General Public License as published by
43.10 - * the Free Software Foundation, version 2 of the License.
43.11 - *
43.12 - * This program is distributed in the hope that it will be useful,
43.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
43.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43.15 - * GNU General Public License for more details.
43.16 - *
43.17 - * You should have received a copy of the GNU General Public License
43.18 - * along with this program. Look for COPYING file in the top folder.
43.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
43.20 - */
43.21 -package org.apidesign.bck2brwsr.launcher.fximpl;
43.22 -
43.23 -import com.sun.javafx.scene.web.Debugger;
43.24 -import java.io.File;
43.25 -import java.io.IOException;
43.26 -import java.io.InputStream;
43.27 -import java.io.InterruptedIOException;
43.28 -import java.io.OutputStream;
43.29 -import java.io.UnsupportedEncodingException;
43.30 -import java.lang.reflect.Method;
43.31 -import java.util.concurrent.ArrayBlockingQueue;
43.32 -import java.util.concurrent.Executors;
43.33 -import java.util.concurrent.TimeUnit;
43.34 -import java.util.concurrent.atomic.AtomicReference;
43.35 -import java.util.logging.Level;
43.36 -import java.util.logging.Logger;
43.37 -import javafx.application.Platform;
43.38 -import javafx.util.Callback;
43.39 -
43.40 -/** Simulates WebKit protocol over WebSockets.
43.41 - *
43.42 - * @author Jaroslav Tulach
43.43 - */
43.44 -abstract class WebDebug extends OutputStream
43.45 -implements Callback<String, Void>, Runnable {
43.46 - private static final Logger LOG = Logger.getLogger(WebDebug.class.getName());
43.47 -
43.48 - private final Debugger debug;
43.49 - private final StringBuilder cmd = new StringBuilder();
43.50 - private final ToDbgInputStream toDbg;
43.51 - private final String ud;
43.52 -
43.53 - WebDebug(Debugger debug, String ud) throws Exception {
43.54 - this.debug = debug;
43.55 - this.ud = ud;
43.56 - toDbg = new ToDbgInputStream();
43.57 - debug.setEnabled(true);
43.58 - debug.setMessageCallback(this);
43.59 - }
43.60 -
43.61 - static WebDebug create(Debugger debug, String ud) throws Exception {
43.62 - WebDebug web = new WebDebug(debug, ud) {};
43.63 -
43.64 - Executors.newFixedThreadPool(1).execute(web);
43.65 -
43.66 - return web;
43.67 - }
43.68 -
43.69 - @Override
43.70 - public void run() {
43.71 - try {
43.72 - String p = System.getProperty("startpage.file");
43.73 - File f;
43.74 - if (p != null && (f = new File(p)).exists()) {
43.75 - String[] args = {"--livehtml", f.getAbsolutePath()};
43.76 - File dir = f.getParentFile();
43.77 - cliHandler(args, toDbg, this, System.err, dir);
43.78 - }
43.79 - } catch (Exception ex) {
43.80 - LOG.log(Level.SEVERE, null, ex);
43.81 - }
43.82 - }
43.83 -
43.84 - @Override
43.85 - public void close() {
43.86 - try {
43.87 - toDbg.close();
43.88 - } catch (IOException ex) {
43.89 - LOG.log(Level.SEVERE, null, ex);
43.90 - }
43.91 - }
43.92 -
43.93 - @Override
43.94 - public Void call(String p) {
43.95 - assert p.indexOf('\n') == -1 : "No new line: " + p;
43.96 - LOG.log(Level.INFO, "toDbgr: {0}", p);
43.97 - toDbg.pushMsg(p);
43.98 - return null;
43.99 - }
43.100 -
43.101 - @Override
43.102 - public void write(int b) throws IOException {
43.103 - if (b == '\n') {
43.104 - final String msg = cmd.toString();
43.105 - Platform.runLater(new Runnable() {
43.106 - @Override
43.107 - public void run() {
43.108 - LOG.log(Level.INFO, "toView: {0}", msg);
43.109 - debug.sendMessage(msg);
43.110 - }
43.111 - });
43.112 - cmd.setLength(0);
43.113 - } else {
43.114 - if (cmd.length() > 100000) {
43.115 - LOG.log(Level.WARNING, "Too big:\n{0}", cmd);
43.116 - }
43.117 - cmd.append((char)b);
43.118 - }
43.119 - }
43.120 -
43.121 - private void cliHandler(
43.122 - String[] args, InputStream is, OutputStream os, OutputStream err, File dir
43.123 - ) {
43.124 - try {
43.125 - Class<?> main = Class.forName("org.netbeans.MainImpl");
43.126 - Method m = main.getDeclaredMethod("execute", String[].class, InputStream.class,
43.127 - OutputStream.class, OutputStream.class, AtomicReference.class
43.128 - );
43.129 - m.setAccessible(true);
43.130 - System.setProperty("netbeans.user", ud);
43.131 - int ret = (Integer)m.invoke(null, args, is, os, err, null);
43.132 - LOG.log(Level.INFO, "Return value: {0}", ret);
43.133 - } catch (Exception ex) {
43.134 - LOG.log(Level.SEVERE, null, ex);
43.135 - } finally {
43.136 - LOG.info("Communication is over");
43.137 - }
43.138 -
43.139 - }
43.140 -
43.141 - private class ToDbgInputStream extends InputStream {
43.142 - private byte[] current;
43.143 - private int currentPos;
43.144 - private final ArrayBlockingQueue<byte[]> pending = new ArrayBlockingQueue<byte[]>(64);
43.145 -
43.146 - public ToDbgInputStream() {
43.147 - }
43.148 -
43.149 - @Override
43.150 - public int read() throws IOException {
43.151 - return read(null, 0, 1);
43.152 - }
43.153 -
43.154 - @Override
43.155 - public int read(byte[] arr, int offset, int len) throws IOException {
43.156 - if (current == null || current.length <= currentPos) {
43.157 - for (;;) {
43.158 - WebDebug.this.flush();
43.159 - try {
43.160 - current = pending.poll(5, TimeUnit.MILLISECONDS);
43.161 - if (current == null) {
43.162 - return 0;
43.163 - }
43.164 - break;
43.165 - } catch (InterruptedException ex) {
43.166 - throw (InterruptedIOException)new InterruptedIOException().initCause(ex);
43.167 - }
43.168 - }
43.169 - LOG.info("Will return: " + new String(current));
43.170 - currentPos = 0;
43.171 - }
43.172 - int cnt = 0;
43.173 - while (len-- > 0 && currentPos < current.length) {
43.174 - final byte nextByte = current[currentPos++];
43.175 - if (arr == null) {
43.176 - return nextByte;
43.177 - }
43.178 - arr[offset + cnt++] = nextByte;
43.179 - }
43.180 - LOG.log(Level.INFO, "read returns: {0}", new String(arr, offset, cnt));
43.181 - return cnt;
43.182 - }
43.183 -
43.184 - private void pushMsg(String p) {
43.185 - try {
43.186 - pending.offer((p + '\n').getBytes("UTF-8"));
43.187 - } catch (UnsupportedEncodingException ex) {
43.188 - throw new IllegalStateException(ex);
43.189 - }
43.190 - }
43.191 - }
43.192 -}
44.1 --- a/launcher/fx/src/test/java/org/apidesign/bck2brwsr/launcher/fximpl/JsClassLoaderTest.java Sun Sep 08 11:42:01 2013 +0200
44.2 +++ b/launcher/fx/src/test/java/org/apidesign/bck2brwsr/launcher/fximpl/JsClassLoaderTest.java Wed Sep 18 11:20:57 2013 +0200
44.3 @@ -35,6 +35,7 @@
44.4 import org.apidesign.html.boot.impl.FnUtils;
44.5 import static org.testng.Assert.*;
44.6 import org.testng.annotations.BeforeClass;
44.7 +import org.testng.annotations.BeforeMethod;
44.8 import org.testng.annotations.Test;
44.9
44.10 /**
44.11 @@ -44,6 +45,7 @@
44.12 public class JsClassLoaderTest {
44.13 private static ClassLoader loader;
44.14 private static Class<?> methodClass;
44.15 + private static Fn.Presenter presenter;
44.16
44.17 public JsClassLoaderTest() {
44.18 }
44.19 @@ -82,7 +84,7 @@
44.20 sb.append("})()");
44.21 try {
44.22 final Object val = eng.eval(sb.toString());
44.23 - return new Fn() {
44.24 + return new Fn(this) {
44.25 @Override
44.26 public Object invoke(Object thiz, Object... args) throws Exception {
44.27 List<Object> all = new ArrayList<Object>(args.length + 1);
44.28 @@ -109,10 +111,16 @@
44.29 }
44.30 }
44.31
44.32 - loader = FnUtils.newLoader(new Fr(), new Fr(), parent);
44.33 + Fr fr = new Fr();
44.34 + presenter = fr;
44.35 + loader = FnUtils.newLoader(fr, fr, parent);
44.36 methodClass = loader.loadClass(JsMethods.class.getName());
44.37 }
44.38
44.39 + @BeforeMethod public void registerPresenter() {
44.40 + FnUtils.currentPresenter(presenter);
44.41 + }
44.42 +
44.43 @Test public void noParamMethod() throws Throwable {
44.44 Method plus = methodClass.getMethod("fortyTwo");
44.45 try {
45.1 --- a/launcher/http/pom.xml Sun Sep 08 11:42:01 2013 +0200
45.2 +++ b/launcher/http/pom.xml Wed Sep 18 11:20:57 2013 +0200
45.3 @@ -4,11 +4,11 @@
45.4 <parent>
45.5 <groupId>org.apidesign.bck2brwsr</groupId>
45.6 <artifactId>launcher-pom</artifactId>
45.7 - <version>0.8-SNAPSHOT</version>
45.8 + <version>0.9-SNAPSHOT</version>
45.9 </parent>
45.10 <groupId>org.apidesign.bck2brwsr</groupId>
45.11 <artifactId>launcher.http</artifactId>
45.12 - <version>0.8-SNAPSHOT</version>
45.13 + <version>0.9-SNAPSHOT</version>
45.14 <name>Bck2Brwsr Launcher</name>
45.15 <url>http://maven.apache.org</url>
45.16 <build>
46.1 --- a/launcher/pom.xml Sun Sep 08 11:42:01 2013 +0200
46.2 +++ b/launcher/pom.xml Wed Sep 18 11:20:57 2013 +0200
46.3 @@ -4,11 +4,11 @@
46.4 <parent>
46.5 <artifactId>bck2brwsr</artifactId>
46.6 <groupId>org.apidesign</groupId>
46.7 - <version>0.8-SNAPSHOT</version>
46.8 + <version>0.9-SNAPSHOT</version>
46.9 </parent>
46.10 <groupId>org.apidesign.bck2brwsr</groupId>
46.11 <artifactId>launcher-pom</artifactId>
46.12 - <version>0.8-SNAPSHOT</version>
46.13 + <version>0.9-SNAPSHOT</version>
46.14 <packaging>pom</packaging>
46.15 <name>Launchers</name>
46.16 <properties>
47.1 --- a/pom.xml Sun Sep 08 11:42:01 2013 +0200
47.2 +++ b/pom.xml Wed Sep 18 11:20:57 2013 +0200
47.3 @@ -3,7 +3,7 @@
47.4 <modelVersion>4.0.0</modelVersion>
47.5 <groupId>org.apidesign</groupId>
47.6 <artifactId>bck2brwsr</artifactId>
47.7 - <version>0.8-SNAPSHOT</version>
47.8 + <version>0.9-SNAPSHOT</version>
47.9 <packaging>pom</packaging>
47.10 <name>Back 2 Browser</name>
47.11 <parent>
47.12 @@ -15,7 +15,7 @@
47.13 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
47.14 <netbeans.version>RELEASE73</netbeans.version>
47.15 <license>COPYING</license>
47.16 - <net.java.html.version>0.5</net.java.html.version>
47.17 + <net.java.html.version>0.6</net.java.html.version>
47.18 </properties>
47.19 <modules>
47.20 <module>dew</module>
47.21 @@ -264,4 +264,28 @@
47.22 </dependency>
47.23 </dependencies>
47.24 </dependencyManagement>
47.25 + <profiles>
47.26 + <profile>
47.27 + <id>jdk8</id>
47.28 + <activation>
47.29 + <file>
47.30 + <exists>${java.home}/lib/ext/jfxrt.jar</exists>
47.31 + </file>
47.32 + </activation>
47.33 + <properties>
47.34 + <jfxrt.jar>${java.home}/lib/ext/jfxrt.jar</jfxrt.jar>
47.35 + </properties>
47.36 + </profile>
47.37 + <profile>
47.38 + <id>jdk7</id>
47.39 + <activation>
47.40 + <file>
47.41 + <exists>${java.home}/lib/jfxrt.jar</exists>
47.42 + </file>
47.43 + </activation>
47.44 + <properties>
47.45 + <jfxrt.jar>${java.home}/lib/jfxrt.jar</jfxrt.jar>
47.46 + </properties>
47.47 + </profile>
47.48 + </profiles>
47.49 </project>
48.1 --- a/rt/archetype/pom.xml Sun Sep 08 11:42:01 2013 +0200
48.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
48.3 @@ -1,87 +0,0 @@
48.4 -<?xml version="1.0" encoding="UTF-8"?>
48.5 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
48.6 - <modelVersion>4.0.0</modelVersion>
48.7 - <parent>
48.8 - <artifactId>rt</artifactId>
48.9 - <groupId>org.apidesign.bck2brwsr</groupId>
48.10 - <version>0.8-SNAPSHOT</version>
48.11 - </parent>
48.12 - <groupId>org.apidesign.bck2brwsr</groupId>
48.13 - <artifactId>bck2brwsr-archetype-html-sample</artifactId>
48.14 - <version>0.8-SNAPSHOT</version>
48.15 - <packaging>jar</packaging>
48.16 - <name>Bck2Brwsr Maven Archetype</name>
48.17 - <description>
48.18 - Creates a skeletal HTML page and associated Java controller class.
48.19 - Runs in any browser (even without Java plugin) with the help of Bck2Brwsr
48.20 - virtual machine.
48.21 - </description>
48.22 - <build>
48.23 - <resources>
48.24 - <resource>
48.25 - <directory>src/main/resources</directory>
48.26 - <filtering>true</filtering>
48.27 - <includes>
48.28 - <include>**/pom.xml</include>
48.29 - </includes>
48.30 - </resource>
48.31 - <resource>
48.32 - <directory>src/main/resources</directory>
48.33 - <filtering>false</filtering>
48.34 - <excludes>
48.35 - <exclude>**/pom.xml</exclude>
48.36 - </excludes>
48.37 - </resource>
48.38 - </resources>
48.39 - <plugins>
48.40 - <plugin>
48.41 - <groupId>org.apache.maven.plugins</groupId>
48.42 - <artifactId>maven-compiler-plugin</artifactId>
48.43 - <version>2.3.2</version>
48.44 - <configuration>
48.45 - <source>1.6</source>
48.46 - <target>1.6</target>
48.47 - </configuration>
48.48 - </plugin>
48.49 - <plugin>
48.50 - <groupId>org.apache.maven.plugins</groupId>
48.51 - <artifactId>maven-resources-plugin</artifactId>
48.52 - <version>2.6</version>
48.53 - <configuration>
48.54 - <escapeString>\</escapeString>
48.55 - <target>1.6</target>
48.56 - </configuration>
48.57 - </plugin>
48.58 - <plugin>
48.59 - <groupId>org.apache.maven.plugins</groupId>
48.60 - <artifactId>maven-surefire-plugin</artifactId>
48.61 - <configuration>
48.62 - <skipTests>true</skipTests>
48.63 - </configuration>
48.64 - <executions>
48.65 - <execution>
48.66 - <id>test</id>
48.67 - <goals>
48.68 - <goal>test</goal>
48.69 - </goals>
48.70 - <phase>integration-test</phase>
48.71 - <configuration>
48.72 - <additionalClasspathElements>
48.73 - <additionalClasspathElement>${project.build.directory}/bck2brwsr-archetype-html-sample-${project.version}.jar</additionalClasspathElement>
48.74 - </additionalClasspathElements>
48.75 - <skipTests>false</skipTests>
48.76 - </configuration>
48.77 - </execution>
48.78 -
48.79 - </executions>
48.80 - </plugin>
48.81 - </plugins>
48.82 - </build>
48.83 - <dependencies>
48.84 - <dependency>
48.85 - <groupId>org.testng</groupId>
48.86 - <artifactId>testng</artifactId>
48.87 - <scope>test</scope>
48.88 - </dependency>
48.89 - </dependencies>
48.90 -</project>
49.1 --- a/rt/archetype/src/main/java/org/apidesign/bck2brwsr/archetype/package-info.java Sun Sep 08 11:42:01 2013 +0200
49.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
49.3 @@ -1,18 +0,0 @@
49.4 -/**
49.5 - * Back 2 Browser Bytecode Translator
49.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
49.7 - *
49.8 - * This program is free software: you can redistribute it and/or modify
49.9 - * it under the terms of the GNU General Public License as published by
49.10 - * the Free Software Foundation, version 2 of the License.
49.11 - *
49.12 - * This program is distributed in the hope that it will be useful,
49.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
49.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49.15 - * GNU General Public License for more details.
49.16 - *
49.17 - * You should have received a copy of the GNU General Public License
49.18 - * along with this program. Look for COPYING file in the top folder.
49.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
49.20 - */
49.21 -package org.apidesign.bck2brwsr.archetype;
50.1 --- a/rt/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml Sun Sep 08 11:42:01 2013 +0200
50.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
50.3 @@ -1,55 +0,0 @@
50.4 -<?xml version="1.0" encoding="UTF-8"?>
50.5 -<!--
50.6 -
50.7 - Back 2 Browser Bytecode Translator
50.8 - Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
50.9 -
50.10 - This program is free software: you can redistribute it and/or modify
50.11 - it under the terms of the GNU General Public License as published by
50.12 - the Free Software Foundation, version 2 of the License.
50.13 -
50.14 - This program is distributed in the hope that it will be useful,
50.15 - but WITHOUT ANY WARRANTY; without even the implied warranty of
50.16 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50.17 - GNU General Public License for more details.
50.18 -
50.19 - You should have received a copy of the GNU General Public License
50.20 - along with this program. Look for COPYING file in the top folder.
50.21 - If not, see http://opensource.org/licenses/GPL-2.0.
50.22 -
50.23 --->
50.24 -<archetype-descriptor name="Get Java Bck2Brwsr!">
50.25 - <fileSets>
50.26 - <fileSet filtered="true" packaged="true">
50.27 - <directory>src/main/java</directory>
50.28 - <includes>
50.29 - <include>**/App.java</include>
50.30 - </includes>
50.31 - </fileSet>
50.32 - <fileSet filtered="true" packaged="true">
50.33 - <directory>src/main/resources</directory>
50.34 - <includes>
50.35 - <include>**/*.xhtml</include>
50.36 - <include>**/*.html</include>
50.37 - </includes>
50.38 - </fileSet>
50.39 - <fileSet filtered="true" packaged="true">
50.40 - <directory>src/test/java</directory>
50.41 - <includes>
50.42 - <include>**/*Test.java</include>
50.43 - </includes>
50.44 - </fileSet>
50.45 - <fileSet filtered="false" packaged="false">
50.46 - <directory></directory>
50.47 - <includes>
50.48 - <include>nbactions.xml</include>
50.49 - </includes>
50.50 - </fileSet>
50.51 - <fileSet filtered="true" packaged="false">
50.52 - <directory></directory>
50.53 - <includes>
50.54 - <include>bck2brwsr-assembly.xml</include>
50.55 - </includes>
50.56 - </fileSet>
50.57 - </fileSets>
50.58 -</archetype-descriptor>
50.59 \ No newline at end of file
51.1 --- a/rt/archetype/src/main/resources/archetype-resources/bck2brwsr-assembly.xml Sun Sep 08 11:42:01 2013 +0200
51.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
51.3 @@ -1,61 +0,0 @@
51.4 -<?xml version="1.0"?>
51.5 -<!--
51.6 -
51.7 - Back 2 Browser Bytecode Translator
51.8 - Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
51.9 -
51.10 - This program is free software: you can redistribute it and/or modify
51.11 - it under the terms of the GNU General Public License as published by
51.12 - the Free Software Foundation, version 2 of the License.
51.13 -
51.14 - This program is distributed in the hope that it will be useful,
51.15 - but WITHOUT ANY WARRANTY; without even the implied warranty of
51.16 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51.17 - GNU General Public License for more details.
51.18 -
51.19 - You should have received a copy of the GNU General Public License
51.20 - along with this program. Look for COPYING file in the top folder.
51.21 - If not, see http://opensource.org/licenses/GPL-2.0.
51.22 -
51.23 --->
51.24 -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
51.25 - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
51.26 -
51.27 - <id>bck2brwsr</id>
51.28 - <formats>
51.29 - <format>zip</format>
51.30 - </formats>
51.31 - <baseDirectory>public_html</baseDirectory>
51.32 - <dependencySets>
51.33 - <dependencySet>
51.34 - <useProjectArtifact>false</useProjectArtifact>
51.35 - <scope>runtime</scope>
51.36 - <outputDirectory>lib</outputDirectory>
51.37 - <includes>
51.38 - <include>*:jar</include>
51.39 - <include>*:rt</include>
51.40 - </includes>
51.41 - </dependencySet>
51.42 - <dependencySet>
51.43 - <useProjectArtifact>false</useProjectArtifact>
51.44 - <scope>provided</scope>
51.45 - <includes>
51.46 - <include>*:js</include>
51.47 - </includes>
51.48 - <unpack>true</unpack>
51.49 - <outputDirectory>/</outputDirectory>
51.50 - </dependencySet>
51.51 - </dependencySets>
51.52 - <files>
51.53 - <file>
51.54 - <source>${project.build.directory}/${project.build.finalName}.jar</source>
51.55 - <outputDirectory>/</outputDirectory>
51.56 - </file>
51.57 - <file>
51.58 - <source>${project.build.directory}/classes/${package.replace('.','/')}/index.html</source>
51.59 - <outputDirectory>/</outputDirectory>
51.60 - <destName>index.html</destName>
51.61 - </file>
51.62 - </files>
51.63 -
51.64 -</assembly>
51.65 \ No newline at end of file
52.1 --- a/rt/archetype/src/main/resources/archetype-resources/nbactions.xml Sun Sep 08 11:42:01 2013 +0200
52.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
52.3 @@ -1,10 +0,0 @@
52.4 -<?xml version="1.0" encoding="UTF-8"?>
52.5 -<actions>
52.6 - <action>
52.7 - <actionName>run</actionName>
52.8 - <goals>
52.9 - <goal>process-classes</goal>
52.10 - <goal>bck2brwsr:brwsr</goal>
52.11 - </goals>
52.12 - </action>
52.13 -</actions>
53.1 --- a/rt/archetype/src/main/resources/archetype-resources/pom.xml Sun Sep 08 11:42:01 2013 +0200
53.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
53.3 @@ -1,141 +0,0 @@
53.4 -<?xml version="1.0"?>
53.5 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
53.6 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
53.7 - <modelVersion>4.0.0</modelVersion>
53.8 -
53.9 - <groupId>\${groupId}</groupId>
53.10 - <artifactId>\${artifactId}</artifactId>
53.11 - <version>\${version}</version>
53.12 - <packaging>jar</packaging>
53.13 -
53.14 - <name>\${artifactId}</name>
53.15 -
53.16 - <repositories>
53.17 - <repository>
53.18 - <id>java.net</id>
53.19 - <name>Java.net</name>
53.20 - <url>https://maven.java.net/content/repositories/releases/</url>
53.21 - <snapshots>
53.22 - <enabled>true</enabled>
53.23 - </snapshots>
53.24 - </repository>
53.25 - <repository>
53.26 - <id>netbeans</id>
53.27 - <name>NetBeans</name>
53.28 - <url>http://bits.netbeans.org/maven2/</url>
53.29 - </repository>
53.30 - </repositories>
53.31 - <pluginRepositories>
53.32 - <pluginRepository>
53.33 - <id>java.net</id>
53.34 - <name>Java.net</name>
53.35 - <url>https://maven.java.net/content/repositories/releases/</url>
53.36 - <snapshots>
53.37 - <enabled>true</enabled>
53.38 - </snapshots>
53.39 - </pluginRepository>
53.40 - </pluginRepositories>
53.41 -
53.42 - <properties>
53.43 - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
53.44 - </properties>
53.45 - <build>
53.46 - <plugins>
53.47 - <plugin>
53.48 - <groupId>org.apidesign.bck2brwsr</groupId>
53.49 - <artifactId>bck2brwsr-maven-plugin</artifactId>
53.50 - <version>${project.version}</version>
53.51 - <executions>
53.52 - <execution>
53.53 - <goals>
53.54 - <goal>brwsr</goal>
53.55 - </goals>
53.56 - </execution>
53.57 - </executions>
53.58 - <configuration>
53.59 - <startpage>\${package.replace('.','/')}/index.html</startpage>
53.60 - </configuration>
53.61 - </plugin>
53.62 - <plugin>
53.63 - <groupId>org.apache.maven.plugins</groupId>
53.64 - <artifactId>maven-compiler-plugin</artifactId>
53.65 - <version>2.3.2</version>
53.66 - <configuration>
53.67 - <source>1.7</source>
53.68 - <target>1.7</target>
53.69 - </configuration>
53.70 - </plugin>
53.71 - <plugin>
53.72 - <groupId>org.apache.maven.plugins</groupId>
53.73 - <artifactId>maven-jar-plugin</artifactId>
53.74 - <version>2.4</version>
53.75 - <configuration>
53.76 - <archive>
53.77 - <manifest>
53.78 - <addClasspath>true</addClasspath>
53.79 - <classpathPrefix>lib/</classpathPrefix>
53.80 - </manifest>
53.81 - </archive>
53.82 - </configuration>
53.83 - </plugin>
53.84 - <plugin>
53.85 - <artifactId>maven-assembly-plugin</artifactId>
53.86 - <version>2.4</version>
53.87 - <executions>
53.88 - <execution>
53.89 - <id>distro-assembly</id>
53.90 - <phase>package</phase>
53.91 - <goals>
53.92 - <goal>single</goal>
53.93 - </goals>
53.94 - <configuration>
53.95 - <descriptors>
53.96 - <descriptor>bck2brwsr-assembly.xml</descriptor>
53.97 - </descriptors>
53.98 - </configuration>
53.99 - </execution>
53.100 - </executions>
53.101 - </plugin>
53.102 - </plugins>
53.103 - </build>
53.104 -
53.105 - <dependencies>
53.106 - <dependency>
53.107 - <groupId>org.apidesign.bck2brwsr</groupId>
53.108 - <artifactId>emul</artifactId>
53.109 - <version>${project.version}</version>
53.110 - <classifier>rt</classifier>
53.111 - </dependency>
53.112 - <dependency>
53.113 - <groupId>org.apidesign.bck2brwsr</groupId>
53.114 - <artifactId>javaquery.api</artifactId>
53.115 - <version>${project.version}</version>
53.116 - </dependency>
53.117 - <dependency>
53.118 - <groupId>org.testng</groupId>
53.119 - <artifactId>testng</artifactId>
53.120 - <version>6.5.2</version>
53.121 - <scope>test</scope>
53.122 - </dependency>
53.123 - <dependency>
53.124 - <groupId>org.apidesign.bck2brwsr</groupId>
53.125 - <artifactId>vm4brwsr</artifactId>
53.126 - <classifier>js</classifier>
53.127 - <type>zip</type>
53.128 - <version>${project.version}</version>
53.129 - <scope>provided</scope>
53.130 - </dependency>
53.131 - <dependency>
53.132 - <groupId>org.apidesign.bck2brwsr</groupId>
53.133 - <artifactId>vmtest</artifactId>
53.134 - <version>${project.version}</version>
53.135 - <scope>test</scope>
53.136 - </dependency>
53.137 - <dependency>
53.138 - <artifactId>canvas</artifactId>
53.139 - <groupId>net.java.html</groupId>
53.140 - <type>jar</type>
53.141 - <version>${project.version}</version>
53.142 - </dependency>
53.143 - </dependencies>
53.144 -</project>
54.1 --- a/rt/archetype/src/main/resources/archetype-resources/src/main/resources/index.html Sun Sep 08 11:42:01 2013 +0200
54.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
54.3 @@ -1,31 +0,0 @@
54.4 -<?xml version="1.0" encoding="UTF-8"?>
54.5 -<!DOCTYPE html>
54.6 -<html xmlns="http://www.w3.org/1999/xhtml">
54.7 - <head>
54.8 - <title>Bck2Brwsr's Hello World</title>
54.9 - </head>
54.10 - <body>
54.11 - <h1 data-bind="text: helloMessage">Loading Bck2Brwsr's Hello World...</h1>
54.12 - Your name: <input id='input' data-bind="value: name, valueUpdate: 'afterkeydown'"></input>
54.13 - <button id="hello">Say Hello!</button>
54.14 - <p>
54.15 - <canvas id="canvas" width="300" height="50">
54.16 - </canvas>
54.17 - </p>
54.18 -
54.19 -
54.20 - <div data-bind="if: noMessages">No message displayed yet.</div>
54.21 - <ul data-bind="foreach: messages">
54.22 - <li>
54.23 - <a href="#" data-bind="text: $data, click: $root.display"></a>
54.24 - (<a href="#" data-bind="click: $root.remove">delete</a>)
54.25 - </li>
54.26 - </ul>
54.27 -
54.28 - <script src="bck2brwsr.js"></script>
54.29 - <script type="text/javascript">
54.30 - var vm = bck2brwsr('${artifactId}-${version}.jar');
54.31 - vm.loadClass('${package}.App');
54.32 - </script>
54.33 - </body>
54.34 -</html>
55.1 --- a/rt/archetype/src/main/resources/archetype-resources/src/test/java/AppTest.java Sun Sep 08 11:42:01 2013 +0200
55.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
55.3 @@ -1,26 +0,0 @@
55.4 -package ${package};
55.5 -
55.6 -import static org.testng.Assert.*;
55.7 -import org.testng.annotations.BeforeMethod;
55.8 -import org.testng.annotations.Test;
55.9 -
55.10 -/** Demonstrating POJO testing of HTML page model. Runs in good old HotSpot
55.11 - * as it does not reference any HTML elements or browser functionality. Just
55.12 - * operates on the page model.
55.13 - *
55.14 - * @author Jaroslav Tulach <jtulach@netbeans.org>
55.15 - */
55.16 -public class AppTest {
55.17 - private Index model;
55.18 -
55.19 -
55.20 - @BeforeMethod
55.21 - public void initModel() {
55.22 - model = new Index().applyBindings();
55.23 - }
55.24 -
55.25 - @Test public void testHelloMessage() {
55.26 - model.setName("Joe");
55.27 - assertEquals(model.getHelloMessage(), "Hello Joe!", "Cleared after pressing +");
55.28 - }
55.29 -}
56.1 --- a/rt/archetype/src/main/resources/archetype-resources/src/test/java/InconsistencyTest.java Sun Sep 08 11:42:01 2013 +0200
56.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
56.3 @@ -1,40 +0,0 @@
56.4 -package ${package};
56.5 -
56.6 -import org.apidesign.bck2brwsr.vmtest.Compare;
56.7 -import org.apidesign.bck2brwsr.vmtest.VMTest;
56.8 -import org.testng.annotations.Factory;
56.9 -
56.10 -/** Bck2brwsr cares about compatibility with real Java. Whatever API is
56.11 - * supported by bck2brwsr, it needs to behave the same way as when running
56.12 - * in HotSpot VM.
56.13 - * <p>
56.14 - * There can be bugs, however. To help us fix them, we kindly ask you to
56.15 - * write an "inconsistency" test. A test that compares behavior of the API
56.16 - * between real VM and bck2brwsr VM. This class is skeleton of such test.
56.17 - *
56.18 - * @author Jaroslav Tulach <jtulach@netbeans.org>
56.19 - */
56.20 -public class InconsistencyTest {
56.21 - /** A method to demonstrate inconsistency between bck2brwsr and HotSpot.
56.22 - * Make calls to an API that behaves strangely, return some result at
56.23 - * the end. No need to use any <code>assert</code>.
56.24 - *
56.25 - * @return value to compare between HotSpot and bck2brwsr
56.26 - */
56.27 - @Compare
56.28 - public int checkStringHashCode() throws Exception {
56.29 - return "Is string hashCode the same?".hashCode();
56.30 - }
56.31 -
56.32 - /** Factory method that creates a three tests for each method annotated with
56.33 - * {@link org.apidesign.bck2brwsr.vmtest.Compare}. One executes the code in
56.34 - * HotSpot, one in Rhino and the last one compares the results.
56.35 - *
56.36 - * @see org.apidesign.bck2brwsr.vmtest.VMTest
56.37 - */
56.38 - @Factory
56.39 - public static Object[] create() {
56.40 - return VMTest.create(InconsistencyTest.class);
56.41 - }
56.42 -
56.43 -}
57.1 --- a/rt/archetype/src/main/resources/archetype-resources/src/test/java/IntegrationTest.java Sun Sep 08 11:42:01 2013 +0200
57.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
57.3 @@ -1,46 +0,0 @@
57.4 -package ${package};
57.5 -
57.6 -import org.apidesign.bck2brwsr.htmlpage.api.OnEvent;
57.7 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
57.8 -import org.apidesign.bck2brwsr.vmtest.HtmlFragment;
57.9 -import org.apidesign.bck2brwsr.vmtest.VMTest;
57.10 -import org.testng.annotations.Factory;
57.11 -
57.12 -/** Sometimes it is useful to run tests inside of the real browser.
57.13 - * To do that just annotate your method with {@link org.apidesign.bck2brwsr.vmtest.BrwsrTest}
57.14 - * and that is it. If your code references elements on the HTML page,
57.15 - * you can pass in an {@link org.apidesign.bck2brwsr.vmtest.HtmlFragment} which
57.16 - * will be made available on the page before your test starts.
57.17 - *
57.18 - * @author Jaroslav Tulach <jtulach@netbeans.org>
57.19 - */
57.20 -public class IntegrationTest {
57.21 -
57.22 - /** Write to testing code here. Use <code>assert</code> (but not TestNG's
57.23 - * Assert, as TestNG is not compiled with target 1.6 yet).
57.24 - */
57.25 - @HtmlFragment(
57.26 - "<h1 data-bind=\"text: helloMessage\">Loading Bck2Brwsr's Hello World...</h1>\n" +
57.27 - "Your name: <input id='input' data-bind=\"value: name, valueUpdate: 'afterkeydown'\"></input>\n" +
57.28 - "<button id=\"hello\">Say Hello!</button>\n" +
57.29 - "<p>\n" +
57.30 - " <canvas id=\"canvas\" width=\"300\" height=\"50\"></canvas>\n" +
57.31 - "</p>\n"
57.32 - )
57.33 - @BrwsrTest
57.34 - public void modifyValueAssertChangeInModel() {
57.35 - Index m = new Index();
57.36 - m.setName("Joe Hacker");
57.37 - m.applyBindings();
57.38 - assert "Joe Hacker".equals(m.input.getValue()) : "Value is really Joe Hacker: " + m.input.getValue();
57.39 - m.input.setValue("Happy Joe");
57.40 - m.triggerEvent(m.input, OnEvent.CHANGE);
57.41 - assert "Happy Joe".equals(m.getName()) : "Name property updated to Happy Joe: " + m.getName();
57.42 - }
57.43 -
57.44 - @Factory
57.45 - public static Object[] create() {
57.46 - return VMTest.create(IntegrationTest.class);
57.47 - }
57.48 -
57.49 -}
58.1 --- a/rt/archetype/src/test/java/org/apidesign/bck2brwsr/archetype/ArchetypeVersionTest.java Sun Sep 08 11:42:01 2013 +0200
58.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
58.3 @@ -1,101 +0,0 @@
58.4 -/**
58.5 - * Back 2 Browser Bytecode Translator
58.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
58.7 - *
58.8 - * This program is free software: you can redistribute it and/or modify
58.9 - * it under the terms of the GNU General Public License as published by
58.10 - * the Free Software Foundation, version 2 of the License.
58.11 - *
58.12 - * This program is distributed in the hope that it will be useful,
58.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
58.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58.15 - * GNU General Public License for more details.
58.16 - *
58.17 - * You should have received a copy of the GNU General Public License
58.18 - * along with this program. Look for COPYING file in the top folder.
58.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
58.20 - */
58.21 -package org.apidesign.bck2brwsr.archetype;
58.22 -
58.23 -import java.net.URL;
58.24 -import javax.xml.XMLConstants;
58.25 -import javax.xml.parsers.DocumentBuilderFactory;
58.26 -import javax.xml.xpath.XPathConstants;
58.27 -import javax.xml.xpath.XPathExpression;
58.28 -import javax.xml.xpath.XPathFactory;
58.29 -import org.testng.annotations.Test;
58.30 -import static org.testng.Assert.*;
58.31 -import org.testng.annotations.BeforeClass;
58.32 -import org.w3c.dom.Document;
58.33 -import org.w3c.dom.NodeList;
58.34 -
58.35 -/**
58.36 - *
58.37 - * @author Jaroslav Tulach <jtulach@netbeans.org>
58.38 - */
58.39 -public class ArchetypeVersionTest {
58.40 - private String version;
58.41 -
58.42 - public ArchetypeVersionTest() {
58.43 - }
58.44 -
58.45 - @BeforeClass public void readCurrentVersion() throws Exception {
58.46 - final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
58.47 - URL u = l.getResource("META-INF/maven/org.apidesign.bck2brwsr/bck2brwsr-archetype-html-sample/pom.xml");
58.48 - assertNotNull(u, "Own pom found: " + System.getProperty("java.class.path"));
58.49 -
58.50 - final XPathFactory fact = XPathFactory.newInstance();
58.51 - fact.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
58.52 -
58.53 - XPathExpression xp = fact.newXPath().compile("project/version/text()");
58.54 -
58.55 - Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(u.openStream());
58.56 - version = xp.evaluate(dom);
58.57 -
58.58 - assertFalse(version.isEmpty(), "There should be some version string");
58.59 - }
58.60 -
58.61 -
58.62 - @Test public void testComparePomDepsVersions() throws Exception {
58.63 - final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
58.64 - URL r = l.getResource("archetype-resources/pom.xml");
58.65 - assertNotNull(r, "Archetype pom found");
58.66 -
58.67 - final XPathFactory fact = XPathFactory.newInstance();
58.68 - XPathExpression xp2 = fact.newXPath().compile(
58.69 - "//version[../groupId/text() = 'org.apidesign.bck2brwsr']/text()"
58.70 - );
58.71 -
58.72 - Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream());
58.73 - NodeList arch = (NodeList) xp2.evaluate(dom, XPathConstants.NODESET);
58.74 -
58.75 - if (arch.getLength() < 3) {
58.76 - fail("There should be at least three dependencies to bck2brwsr APIs: " + arch.getLength());
58.77 - }
58.78 -
58.79 - for (int i = 0; i < arch.getLength(); i++) {
58.80 - assertEquals(arch.item(i).getTextContent(), version, i + "th dependency needs to be on latest version of bck2brwsr");
58.81 - }
58.82 - }
58.83 -
58.84 - @Test public void testNbActions() throws Exception {
58.85 - final ClassLoader l = ArchetypeVersionTest.class.getClassLoader();
58.86 - URL r = l.getResource("archetype-resources/nbactions.xml");
58.87 - assertNotNull(r, "Archetype nb file found");
58.88 -
58.89 - final XPathFactory fact = XPathFactory.newInstance();
58.90 - XPathExpression xp2 = fact.newXPath().compile(
58.91 - "//goal/text()"
58.92 - );
58.93 -
58.94 - Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(r.openStream());
58.95 - NodeList goals = (NodeList) xp2.evaluate(dom, XPathConstants.NODESET);
58.96 -
58.97 - for (int i = 0; i < goals.getLength(); i++) {
58.98 - String s = goals.item(i).getTextContent();
58.99 - if (s.contains("bck2brwsr")) {
58.100 - assertFalse(s.matches(".*bck2brwsr.*[0-9].*"), "No numbers: " + s);
58.101 - }
58.102 - }
58.103 - }
58.104 -}
59.1 --- a/rt/core/pom.xml Sun Sep 08 11:42:01 2013 +0200
59.2 +++ b/rt/core/pom.xml Wed Sep 18 11:20:57 2013 +0200
59.3 @@ -4,11 +4,11 @@
59.4 <parent>
59.5 <groupId>org.apidesign.bck2brwsr</groupId>
59.6 <artifactId>rt</artifactId>
59.7 - <version>0.8-SNAPSHOT</version>
59.8 + <version>0.9-SNAPSHOT</version>
59.9 </parent>
59.10 <groupId>org.apidesign.bck2brwsr</groupId>
59.11 <artifactId>core</artifactId>
59.12 - <version>0.8-SNAPSHOT</version>
59.13 + <version>0.9-SNAPSHOT</version>
59.14 <name>Bck2Brwsr Native Annotations</name>
59.15 <url>http://maven.apache.org</url>
59.16 <build>
60.1 --- a/rt/emul/brwsrtest/pom.xml Sun Sep 08 11:42:01 2013 +0200
60.2 +++ b/rt/emul/brwsrtest/pom.xml Wed Sep 18 11:20:57 2013 +0200
60.3 @@ -4,11 +4,11 @@
60.4 <parent>
60.5 <groupId>org.apidesign.bck2brwsr</groupId>
60.6 <artifactId>emul.pom</artifactId>
60.7 - <version>0.8-SNAPSHOT</version>
60.8 + <version>0.9-SNAPSHOT</version>
60.9 </parent>
60.10 <groupId>org.apidesign.bck2brwsr</groupId>
60.11 <artifactId>brwsrtest</artifactId>
60.12 - <version>0.8-SNAPSHOT</version>
60.13 + <version>0.9-SNAPSHOT</version>
60.14 <name>Tests Inside Real Browser</name>
60.15 <url>http://maven.apache.org</url>
60.16 <properties>
61.1 --- a/rt/emul/compact/pom.xml Sun Sep 08 11:42:01 2013 +0200
61.2 +++ b/rt/emul/compact/pom.xml Wed Sep 18 11:20:57 2013 +0200
61.3 @@ -4,11 +4,11 @@
61.4 <parent>
61.5 <groupId>org.apidesign.bck2brwsr</groupId>
61.6 <artifactId>emul.pom</artifactId>
61.7 - <version>0.8-SNAPSHOT</version>
61.8 + <version>0.9-SNAPSHOT</version>
61.9 </parent>
61.10 <groupId>org.apidesign.bck2brwsr</groupId>
61.11 <artifactId>emul</artifactId>
61.12 - <version>0.8-SNAPSHOT</version>
61.13 + <version>0.9-SNAPSHOT</version>
61.14 <name>Bck2Brwsr API Profile</name>
61.15 <url>http://maven.apache.org</url>
61.16 <properties>
62.1 --- a/rt/emul/compact/src/main/java/java/lang/System.java Sun Sep 08 11:42:01 2013 +0200
62.2 +++ b/rt/emul/compact/src/main/java/java/lang/System.java Wed Sep 18 11:20:57 2013 +0200
62.3 @@ -17,6 +17,8 @@
62.4 */
62.5 package java.lang;
62.6
62.7 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
62.8 +
62.9 /** Poor man's re-implementation of most important System methods.
62.10 *
62.11 * @author Jaroslav Tulach <jtulach@netbeans.org>
62.12 @@ -33,6 +35,10 @@
62.13 return org.apidesign.bck2brwsr.emul.lang.System.currentTimeMillis();
62.14 }
62.15
62.16 + public static long nanoTime() {
62.17 + return org.apidesign.bck2brwsr.emul.lang.System.nanoTime();
62.18 + }
62.19 +
62.20 public static int identityHashCode(Object obj) {
62.21 return obj.defaultHashCode();
62.22 }
62.23 @@ -56,8 +62,8 @@
62.24 public static String lineSeparator() {
62.25 return "\n";
62.26 }
62.27 -
62.28 - public static long nanoTime() {
62.29 - return org.apidesign.bck2brwsr.emul.lang.System.nanoTime();
62.30 +
62.31 + @JavaScriptBody(args = { "exitCode" }, body = "window.close();")
62.32 + public static void exit(int exitCode) {
62.33 }
62.34 }
63.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
63.2 +++ b/rt/emul/compact/src/main/java/java/lang/ThreadLocal.java Wed Sep 18 11:20:57 2013 +0200
63.3 @@ -0,0 +1,157 @@
63.4 +/*
63.5 + * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
63.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
63.7 + *
63.8 + * This code is free software; you can redistribute it and/or modify it
63.9 + * under the terms of the GNU General Public License version 2 only, as
63.10 + * published by the Free Software Foundation. Oracle designates this
63.11 + * particular file as subject to the "Classpath" exception as provided
63.12 + * by Oracle in the LICENSE file that accompanied this code.
63.13 + *
63.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
63.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
63.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
63.17 + * version 2 for more details (a copy is included in the LICENSE file that
63.18 + * accompanied this code).
63.19 + *
63.20 + * You should have received a copy of the GNU General Public License version
63.21 + * 2 along with this work; if not, write to the Free Software Foundation,
63.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
63.23 + *
63.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
63.25 + * or visit www.oracle.com if you need additional information or have any
63.26 + * questions.
63.27 + */
63.28 +
63.29 +package java.lang;
63.30 +
63.31 +/**
63.32 + * This class provides thread-local variables. These variables differ from
63.33 + * their normal counterparts in that each thread that accesses one (via its
63.34 + * <tt>get</tt> or <tt>set</tt> method) has its own, independently initialized
63.35 + * copy of the variable. <tt>ThreadLocal</tt> instances are typically private
63.36 + * static fields in classes that wish to associate state with a thread (e.g.,
63.37 + * a user ID or Transaction ID).
63.38 + *
63.39 + * <p>For example, the class below generates unique identifiers local to each
63.40 + * thread.
63.41 + * A thread's id is assigned the first time it invokes <tt>ThreadId.get()</tt>
63.42 + * and remains unchanged on subsequent calls.
63.43 + * <pre>
63.44 + * import java.util.concurrent.atomic.AtomicInteger;
63.45 + *
63.46 + * public class ThreadId {
63.47 + * // Atomic integer containing the next thread ID to be assigned
63.48 + * private static final AtomicInteger nextId = new AtomicInteger(0);
63.49 + *
63.50 + * // Thread local variable containing each thread's ID
63.51 + * private static final ThreadLocal<Integer> threadId =
63.52 + * new ThreadLocal<Integer>() {
63.53 + * @Override protected Integer initialValue() {
63.54 + * return nextId.getAndIncrement();
63.55 + * }
63.56 + * };
63.57 + *
63.58 + * // Returns the current thread's unique ID, assigning it if necessary
63.59 + * public static int get() {
63.60 + * return threadId.get();
63.61 + * }
63.62 + * }
63.63 + * </pre>
63.64 + * <p>Each thread holds an implicit reference to its copy of a thread-local
63.65 + * variable as long as the thread is alive and the <tt>ThreadLocal</tt>
63.66 + * instance is accessible; after a thread goes away, all of its copies of
63.67 + * thread-local instances are subject to garbage collection (unless other
63.68 + * references to these copies exist).
63.69 + *
63.70 + * @author Josh Bloch and Doug Lea
63.71 + * @since 1.2
63.72 + */
63.73 +public class ThreadLocal<T> {
63.74 + private static final Object NONE = new Object();
63.75 + private Object value = NONE;
63.76 +
63.77 + /**
63.78 + * Returns the current thread's "initial value" for this
63.79 + * thread-local variable. This method will be invoked the first
63.80 + * time a thread accesses the variable with the {@link #get}
63.81 + * method, unless the thread previously invoked the {@link #set}
63.82 + * method, in which case the <tt>initialValue</tt> method will not
63.83 + * be invoked for the thread. Normally, this method is invoked at
63.84 + * most once per thread, but it may be invoked again in case of
63.85 + * subsequent invocations of {@link #remove} followed by {@link #get}.
63.86 + *
63.87 + * <p>This implementation simply returns <tt>null</tt>; if the
63.88 + * programmer desires thread-local variables to have an initial
63.89 + * value other than <tt>null</tt>, <tt>ThreadLocal</tt> must be
63.90 + * subclassed, and this method overridden. Typically, an
63.91 + * anonymous inner class will be used.
63.92 + *
63.93 + * @return the initial value for this thread-local
63.94 + */
63.95 + protected T initialValue() {
63.96 + return null;
63.97 + }
63.98 +
63.99 + /**
63.100 + * Creates a thread local variable.
63.101 + */
63.102 + public ThreadLocal() {
63.103 + }
63.104 +
63.105 + /**
63.106 + * Returns the value in the current thread's copy of this
63.107 + * thread-local variable. If the variable has no value for the
63.108 + * current thread, it is first initialized to the value returned
63.109 + * by an invocation of the {@link #initialValue} method.
63.110 + *
63.111 + * @return the current thread's value of this thread-local
63.112 + */
63.113 + public T get() {
63.114 + if (value == NONE) {
63.115 + return setInitialValue();
63.116 + } else {
63.117 + return (T)value;
63.118 + }
63.119 + }
63.120 +
63.121 + /**
63.122 + * Variant of set() to establish initialValue. Used instead
63.123 + * of set() in case user has overridden the set() method.
63.124 + *
63.125 + * @return the initial value
63.126 + */
63.127 + private T setInitialValue() {
63.128 + T v = initialValue();
63.129 + this.value = v;
63.130 + return v;
63.131 + }
63.132 +
63.133 + /**
63.134 + * Sets the current thread's copy of this thread-local variable
63.135 + * to the specified value. Most subclasses will have no need to
63.136 + * override this method, relying solely on the {@link #initialValue}
63.137 + * method to set the values of thread-locals.
63.138 + *
63.139 + * @param value the value to be stored in the current thread's copy of
63.140 + * this thread-local.
63.141 + */
63.142 + public void set(T value) {
63.143 + this.value = value;
63.144 + }
63.145 +
63.146 + /**
63.147 + * Removes the current thread's value for this thread-local
63.148 + * variable. If this thread-local variable is subsequently
63.149 + * {@linkplain #get read} by the current thread, its value will be
63.150 + * reinitialized by invoking its {@link #initialValue} method,
63.151 + * unless its value is {@linkplain #set set} by the current thread
63.152 + * in the interim. This may result in multiple invocations of the
63.153 + * <tt>initialValue</tt> method in the current thread.
63.154 + *
63.155 + * @since 1.5
63.156 + */
63.157 + public void remove() {
63.158 + this.value = NONE;
63.159 + }
63.160 +}
64.1 --- a/rt/emul/compact/src/main/java/java/util/logging/Logger.java Sun Sep 08 11:42:01 2013 +0200
64.2 +++ b/rt/emul/compact/src/main/java/java/util/logging/Logger.java Wed Sep 18 11:20:57 2013 +0200
64.3 @@ -449,9 +449,17 @@
64.4 if (record.getLevel().intValue() < levelValue) {
64.5 return;
64.6 }
64.7 +
64.8 + String method;
64.9 + switch (record.getLevel().toString()) {
64.10 + case "INFO": method = "info"; break;
64.11 + case "SEVERE": method = "error"; break;
64.12 + case "WARNING": method = "warn"; break;
64.13 + default: method = "log"; break;
64.14 + }
64.15
64.16 consoleLog(
64.17 - record.getLevel().toString(),
64.18 + method,
64.19 record.getLoggerName(),
64.20 record.getMessage()
64.21 );
65.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
65.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/NotifyWaitTest.java Wed Sep 18 11:20:57 2013 +0200
65.3 @@ -0,0 +1,62 @@
65.4 +/**
65.5 + * Back 2 Browser Bytecode Translator
65.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
65.7 + *
65.8 + * This program is free software: you can redistribute it and/or modify
65.9 + * it under the terms of the GNU General Public License as published by
65.10 + * the Free Software Foundation, version 2 of the License.
65.11 + *
65.12 + * This program is distributed in the hope that it will be useful,
65.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
65.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
65.15 + * GNU General Public License for more details.
65.16 + *
65.17 + * You should have received a copy of the GNU General Public License
65.18 + * along with this program. Look for COPYING file in the top folder.
65.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
65.20 + */
65.21 +package org.apidesign.bck2brwsr.tck;
65.22 +
65.23 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
65.24 +import org.apidesign.bck2brwsr.vmtest.Compare;
65.25 +import org.apidesign.bck2brwsr.vmtest.VMTest;
65.26 +import org.testng.annotations.Factory;
65.27 +
65.28 +/**
65.29 + *
65.30 + * @author Jaroslav Tulach <jtulach@netbeans.org>
65.31 + */
65.32 +public class NotifyWaitTest {
65.33 +
65.34 + @Compare public synchronized String canCallNotify() throws Exception {
65.35 + notify();
65.36 + return "OK";
65.37 + }
65.38 +
65.39 + @Compare public synchronized String canCallNotifyAll() throws Exception {
65.40 + notifyAll();
65.41 + return "OK";
65.42 + }
65.43 +
65.44 + @BrwsrTest public synchronized String throwsInterruptedException() {
65.45 + try {
65.46 + wait();
65.47 + throw new IllegalStateException();
65.48 + } catch (InterruptedException ex) {
65.49 + return "OK";
65.50 + }
65.51 + }
65.52 +
65.53 + @BrwsrTest public synchronized String waitMsThrowsInterruptedException() {
65.54 + try {
65.55 + wait(32);
65.56 + throw new IllegalStateException();
65.57 + } catch (InterruptedException ex) {
65.58 + return "OK";
65.59 + }
65.60 + }
65.61 +
65.62 + @Factory public static Object[] create() {
65.63 + return VMTest.create(NotifyWaitTest.class);
65.64 + }
65.65 +}
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
66.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/RegExpSplitTest.java Wed Sep 18 11:20:57 2013 +0200
66.3 @@ -0,0 +1,50 @@
66.4 +/**
66.5 + * Back 2 Browser Bytecode Translator
66.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
66.7 + *
66.8 + * This program is free software: you can redistribute it and/or modify
66.9 + * it under the terms of the GNU General Public License as published by
66.10 + * the Free Software Foundation, version 2 of the License.
66.11 + *
66.12 + * This program is distributed in the hope that it will be useful,
66.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
66.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66.15 + * GNU General Public License for more details.
66.16 + *
66.17 + * You should have received a copy of the GNU General Public License
66.18 + * along with this program. Look for COPYING file in the top folder.
66.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
66.20 + */
66.21 +package org.apidesign.bck2brwsr.tck;
66.22 +
66.23 +import java.util.Arrays;
66.24 +import org.apidesign.bck2brwsr.vmtest.Compare;
66.25 +import org.apidesign.bck2brwsr.vmtest.VMTest;
66.26 +import org.testng.annotations.Factory;
66.27 +
66.28 +/**
66.29 + *
66.30 + * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
66.31 + */
66.32 +public class RegExpSplitTest {
66.33 +
66.34 + public @Compare Object splitSpace() {
66.35 + return Arrays.asList("How are you today?".split(" "));
66.36 + }
66.37 +
66.38 + public @Compare Object splitSpaceTrimMinusOne() {
66.39 + return Arrays.asList(" How are you today? ".split(" ", -1));
66.40 + }
66.41 +
66.42 + public @Compare Object splitSpaceTrimZero() {
66.43 + return Arrays.asList(" How are you today? ".split(" ", 0));
66.44 + }
66.45 +
66.46 + public @Compare Object splitSpaceLimit2() {
66.47 + return Arrays.asList("How are you today?".split(" ", 2));
66.48 + }
66.49 +
66.50 + @Factory public static Object[] create() {
66.51 + return VMTest.create(RegExpSplitTest.class);
66.52 + }
66.53 +}
67.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
67.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotations.java Wed Sep 18 11:20:57 2013 +0200
67.3 @@ -0,0 +1,86 @@
67.4 +/**
67.5 + * Back 2 Browser Bytecode Translator
67.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
67.7 + *
67.8 + * This program is free software: you can redistribute it and/or modify
67.9 + * it under the terms of the GNU General Public License as published by
67.10 + * the Free Software Foundation, version 2 of the License.
67.11 + *
67.12 + * This program is distributed in the hope that it will be useful,
67.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
67.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67.15 + * GNU General Public License for more details.
67.16 + *
67.17 + * You should have received a copy of the GNU General Public License
67.18 + * along with this program. Look for COPYING file in the top folder.
67.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
67.20 + */
67.21 +package org.apidesign.bck2brwsr.vmtest.impl;
67.22 +
67.23 +import net.java.html.js.JavaScriptBody;
67.24 +import net.java.html.js.JavaScriptResource;
67.25 +
67.26 +/**
67.27 + *
67.28 + * @author Jaroslav Tulach <jtulach@netbeans.org>
67.29 + */
67.30 +@JavaScriptResource("htmlannotations.js")
67.31 +public class HtmlAnnotations {
67.32 + private Object callback;
67.33 +
67.34 +
67.35 + @JavaScriptBody(args = {}, body = "return 42;")
67.36 + public static int fourtyTwo() {
67.37 + return -1;
67.38 + }
67.39 +
67.40 + @JavaScriptBody(args = { "x", "y" }, body = "return mul(x, y);")
67.41 + public static native int useExternalMul(int x, int y);
67.42 +
67.43 + public static int callback() {
67.44 + final int[] arr = { 0 };
67.45 + callback(new Runnable() {
67.46 + @Override
67.47 + public void run() {
67.48 + arr[0]++;
67.49 + }
67.50 + });
67.51 + return arr[0];
67.52 + }
67.53 +
67.54 + @JavaScriptBody(args = { "r" }, javacall=true, body = "r.@java.lang.Runnable::run()()")
67.55 + private static native void callback(Runnable r);
67.56 +
67.57 + @JavaScriptBody(args = { }, javacall = true, body = "return @org.apidesign.bck2brwsr.vmtest.impl.HtmlAnnotations::callback()();")
67.58 + public static native int staticCallback();
67.59 +
67.60 +
67.61 + protected long chooseLong(boolean takeFirst, boolean takeSecond, long first, long second) {
67.62 + long l = 0;
67.63 + if (takeFirst) l += first;
67.64 + if (takeSecond) l += second;
67.65 + return l;
67.66 + }
67.67 +
67.68 + protected void onError(Object obj) throws Exception {
67.69 + callback = obj;
67.70 + }
67.71 +
67.72 + Object getError() {
67.73 + return callback;
67.74 + }
67.75 +
67.76 + public static Object create() {
67.77 + return new HtmlAnnotations();
67.78 + }
67.79 + @JavaScriptBody(args = { "impl", "a", "b" }, javacall = true, body =
67.80 + "return impl.@org.apidesign.bck2brwsr.vmtest.impl.HtmlAnnotations::chooseLong(ZZJJ)(true, false, a, b);"
67.81 + )
67.82 + public static native long first(Object impl, long a, long b);
67.83 +
67.84 + @JavaScriptBody(args = { "impl", "d" }, javacall = true, body =
67.85 + "impl.@org.apidesign.bck2brwsr.vmtest.impl.HtmlAnnotations::onError(Ljava/lang/Object;)(d);" +
67.86 + "return impl.@org.apidesign.bck2brwsr.vmtest.impl.HtmlAnnotations::getError()();"
67.87 + )
67.88 + public static native Double onError(Object impl, Double d);
67.89 +}
68.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
68.2 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotationsTest.java Wed Sep 18 11:20:57 2013 +0200
68.3 @@ -0,0 +1,71 @@
68.4 +/**
68.5 + * Back 2 Browser Bytecode Translator
68.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
68.7 + *
68.8 + * This program is free software: you can redistribute it and/or modify
68.9 + * it under the terms of the GNU General Public License as published by
68.10 + * the Free Software Foundation, version 2 of the License.
68.11 + *
68.12 + * This program is distributed in the hope that it will be useful,
68.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
68.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
68.15 + * GNU General Public License for more details.
68.16 + *
68.17 + * You should have received a copy of the GNU General Public License
68.18 + * along with this program. Look for COPYING file in the top folder.
68.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
68.20 + */
68.21 +package org.apidesign.bck2brwsr.vmtest.impl;
68.22 +
68.23 +import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
68.24 +import org.apidesign.bck2brwsr.vmtest.VMTest;
68.25 +import org.testng.annotations.Factory;
68.26 +
68.27 +/** Verify cooperation with net.java.html.js annotations.
68.28 + *
68.29 + * @author Jaroslav Tulach <jtulach@netbeans.org>
68.30 + */
68.31 +public class HtmlAnnotationsTest {
68.32 + @BrwsrTest public void fourtyTwo() throws Exception {
68.33 + assertEquals(HtmlAnnotations.fourtyTwo(), 42);
68.34 + }
68.35 +
68.36 + @BrwsrTest public void externalMul() throws Exception {
68.37 + assertEquals(HtmlAnnotations.useExternalMul(7, 6), 42);
68.38 + }
68.39 +
68.40 + @BrwsrTest public void callRunnableFromJS() throws Exception {
68.41 + assertEquals(HtmlAnnotations.callback(), 1);
68.42 + }
68.43 +
68.44 + @BrwsrTest public void callStaticMethodFromJS() throws Exception {
68.45 + assertEquals(HtmlAnnotations.staticCallback(), 1);
68.46 + }
68.47 +
68.48 + @BrwsrTest public void callbackWithFourParamsAndReturnType() throws Exception {
68.49 + Object instance = HtmlAnnotations.create();
68.50 + assertNotNull(instance, "Instance created");
68.51 + assertEquals(HtmlAnnotations.first(instance, 42, 31), 42);
68.52 + }
68.53 +
68.54 + @BrwsrTest public void callbackWithObjectParamsAndReturnType() throws Exception {
68.55 + Object instance = HtmlAnnotations.create();
68.56 + assertNotNull(instance, "Instance created");
68.57 + assertEquals(HtmlAnnotations.onError(instance, 42.0), 42.0);
68.58 + }
68.59 +
68.60 + private static void assertEquals(double real, double exp) {
68.61 + if (real - exp < 0.01) {
68.62 + return;
68.63 + }
68.64 + assert false : "Expecting " + exp + " but was " + real;
68.65 + }
68.66 +
68.67 + private static void assertNotNull(Object obj, String msg) {
68.68 + assert obj != null : msg;
68.69 + }
68.70 +
68.71 + @Factory public static Object[] create() {
68.72 + return VMTest.create(HtmlAnnotationsTest.class);
68.73 + }
68.74 +}
69.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
69.2 +++ b/rt/emul/compact/src/test/resources/org/apidesign/bck2brwsr/vmtest/impl/htmlannotations.js Wed Sep 18 11:20:57 2013 +0200
69.3 @@ -0,0 +1,20 @@
69.4 +/*
69.5 + * Back 2 Browser Bytecode Translator
69.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
69.7 + *
69.8 + * This program is free software: you can redistribute it and/or modify
69.9 + * it under the terms of the GNU General Public License as published by
69.10 + * the Free Software Foundation, version 2 of the License.
69.11 + *
69.12 + * This program is distributed in the hope that it will be useful,
69.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
69.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69.15 + * GNU General Public License for more details.
69.16 + *
69.17 + * You should have received a copy of the GNU General Public License
69.18 + * along with this program. Look for COPYING file in the top folder.
69.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
69.20 + */
69.21 +
69.22 +function mul(x, y) { return x * y; }
69.23 +window.mul = mul;
70.1 --- a/rt/emul/mini/pom.xml Sun Sep 08 11:42:01 2013 +0200
70.2 +++ b/rt/emul/mini/pom.xml Wed Sep 18 11:20:57 2013 +0200
70.3 @@ -4,11 +4,11 @@
70.4 <parent>
70.5 <groupId>org.apidesign.bck2brwsr</groupId>
70.6 <artifactId>emul.pom</artifactId>
70.7 - <version>0.8-SNAPSHOT</version>
70.8 + <version>0.9-SNAPSHOT</version>
70.9 </parent>
70.10 <groupId>org.apidesign.bck2brwsr</groupId>
70.11 <artifactId>emul.mini</artifactId>
70.12 - <version>0.8-SNAPSHOT</version>
70.13 + <version>0.9-SNAPSHOT</version>
70.14 <name>Minimal API Profile</name>
70.15 <url>http://maven.apache.org</url>
70.16 <properties>
70.17 @@ -18,7 +18,7 @@
70.18 <dependency>
70.19 <groupId>org.apidesign.bck2brwsr</groupId>
70.20 <artifactId>core</artifactId>
70.21 - <version>0.8-SNAPSHOT</version>
70.22 + <version>0.9-SNAPSHOT</version>
70.23 <type>jar</type>
70.24 </dependency>
70.25 <dependency>
71.1 --- a/rt/emul/mini/src/main/java/java/lang/Object.java Sun Sep 08 11:42:01 2013 +0200
71.2 +++ b/rt/emul/mini/src/main/java/java/lang/Object.java Wed Sep 18 11:20:57 2013 +0200
71.3 @@ -328,7 +328,8 @@
71.4 * @see java.lang.Object#notifyAll()
71.5 * @see java.lang.Object#wait()
71.6 */
71.7 - public final native void notify();
71.8 + public final void notify() {
71.9 + }
71.10
71.11 /**
71.12 * Wakes up all threads that are waiting on this object's monitor. A
71.13 @@ -352,7 +353,8 @@
71.14 * @see java.lang.Object#notify()
71.15 * @see java.lang.Object#wait()
71.16 */
71.17 - public final native void notifyAll();
71.18 + public final void notifyAll() {
71.19 + }
71.20
71.21 /**
71.22 * Causes the current thread to wait until either another thread invokes the
71.23 @@ -439,7 +441,9 @@
71.24 * @see java.lang.Object#notify()
71.25 * @see java.lang.Object#notifyAll()
71.26 */
71.27 - public final native void wait(long timeout) throws InterruptedException;
71.28 + public final void wait(long timeout) throws InterruptedException {
71.29 + throw new InterruptedException();
71.30 + }
71.31
71.32 /**
71.33 * Causes the current thread to wait until another thread invokes the
71.34 @@ -504,20 +508,7 @@
71.35 * this exception is thrown.
71.36 */
71.37 public final void wait(long timeout, int nanos) throws InterruptedException {
71.38 - if (timeout < 0) {
71.39 - throw new IllegalArgumentException("timeout value is negative");
71.40 - }
71.41 -
71.42 - if (nanos < 0 || nanos > 999999) {
71.43 - throw new IllegalArgumentException(
71.44 - "nanosecond timeout value out of range");
71.45 - }
71.46 -
71.47 - if (nanos >= 500000 || (nanos != 0 && timeout == 0)) {
71.48 - timeout++;
71.49 - }
71.50 -
71.51 - wait(timeout);
71.52 + throw new InterruptedException();
71.53 }
71.54
71.55 /**
71.56 @@ -559,7 +550,7 @@
71.57 * @see java.lang.Object#notifyAll()
71.58 */
71.59 public final void wait() throws InterruptedException {
71.60 - wait(0);
71.61 + throw new InterruptedException();
71.62 }
71.63
71.64 /**
72.1 --- a/rt/emul/mini/src/main/java/java/lang/String.java Sun Sep 08 11:42:01 2013 +0200
72.2 +++ b/rt/emul/mini/src/main/java/java/lang/String.java Wed Sep 18 11:20:57 2013 +0200
72.3 @@ -2315,8 +2315,35 @@
72.4 * @spec JSR-51
72.5 */
72.6 public String[] split(String regex, int limit) {
72.7 - throw new UnsupportedOperationException("Needs regexp");
72.8 + if (limit <= 0) {
72.9 + Object[] arr = splitImpl(this, regex, Integer.MAX_VALUE);
72.10 + int to = arr.length;
72.11 + if (limit == 0) {
72.12 + while (to > 1 && ((String)arr[--to]).isEmpty()) {
72.13 + }
72.14 + to++;
72.15 + }
72.16 + String[] ret = new String[to];
72.17 + System.arraycopy(arr, 0, ret, 0, to);
72.18 + return ret;
72.19 + } else {
72.20 + Object[] arr = splitImpl(this, regex, limit);
72.21 + String[] ret = new String[arr.length];
72.22 + int pos = 0;
72.23 + for (int i = 0; i < arr.length; i++) {
72.24 + final String s = (String)arr[i];
72.25 + ret[i] = s;
72.26 + pos = indexOf(s, pos) + s.length();
72.27 + }
72.28 + ret[arr.length - 1] += substring(pos);
72.29 + return ret;
72.30 + }
72.31 }
72.32 +
72.33 + @JavaScriptBody(args = { "str", "regex", "limit"}, body =
72.34 + "return str.split(new RegExp(regex), limit);"
72.35 + )
72.36 + private static native Object[] splitImpl(String str, String regex, int limit);
72.37
72.38 /**
72.39 * Splits this string around matches of the given <a
73.1 --- a/rt/emul/pom.xml Sun Sep 08 11:42:01 2013 +0200
73.2 +++ b/rt/emul/pom.xml Wed Sep 18 11:20:57 2013 +0200
73.3 @@ -4,11 +4,11 @@
73.4 <parent>
73.5 <groupId>org.apidesign.bck2brwsr</groupId>
73.6 <artifactId>rt</artifactId>
73.7 - <version>0.8-SNAPSHOT</version>
73.8 + <version>0.9-SNAPSHOT</version>
73.9 </parent>
73.10 <groupId>org.apidesign.bck2brwsr</groupId>
73.11 <artifactId>emul.pom</artifactId>
73.12 - <version>0.8-SNAPSHOT</version>
73.13 + <version>0.9-SNAPSHOT</version>
73.14 <packaging>pom</packaging>
73.15 <name>Emulation of Core Libraries</name>
73.16 <modules>
74.1 --- a/rt/mojo/pom.xml Sun Sep 08 11:42:01 2013 +0200
74.2 +++ b/rt/mojo/pom.xml Wed Sep 18 11:20:57 2013 +0200
74.3 @@ -4,11 +4,11 @@
74.4 <parent>
74.5 <groupId>org.apidesign.bck2brwsr</groupId>
74.6 <artifactId>rt</artifactId>
74.7 - <version>0.8-SNAPSHOT</version>
74.8 + <version>0.9-SNAPSHOT</version>
74.9 </parent>
74.10 <groupId>org.apidesign.bck2brwsr</groupId>
74.11 <artifactId>bck2brwsr-maven-plugin</artifactId>
74.12 - <version>0.8-SNAPSHOT</version>
74.13 + <version>0.9-SNAPSHOT</version>
74.14 <packaging>maven-plugin</packaging>
74.15 <name>Bck2Brwsr Maven Plugin</name>
74.16 <url>http://bck2brwsr.apidesign.org/</url>
75.1 --- a/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/BrwsrMojo.java Sun Sep 08 11:42:01 2013 +0200
75.2 +++ b/rt/mojo/src/main/java/org/apidesign/bck2brwsr/mojo/BrwsrMojo.java Wed Sep 18 11:20:57 2013 +0200
75.3 @@ -79,7 +79,8 @@
75.4 try {
75.5 Closeable httpServer;
75.6 if (directory != null) {
75.7 - httpServer = Launcher.showDir(directory, startpage);
75.8 + URLClassLoader url = buildClassLoader(classes, prj.getArtifacts());
75.9 + httpServer = Launcher.showDir(launcher, directory, url, startpage);
75.10 } else {
75.11 URLClassLoader url = buildClassLoader(classes, prj.getArtifacts());
75.12 try {
76.1 --- a/rt/pom.xml Sun Sep 08 11:42:01 2013 +0200
76.2 +++ b/rt/pom.xml Wed Sep 18 11:20:57 2013 +0200
76.3 @@ -3,18 +3,17 @@
76.4 <modelVersion>4.0.0</modelVersion>
76.5 <groupId>org.apidesign.bck2brwsr</groupId>
76.6 <artifactId>rt</artifactId>
76.7 - <version>0.8-SNAPSHOT</version>
76.8 + <version>0.9-SNAPSHOT</version>
76.9 <packaging>pom</packaging>
76.10 <name>Bck2Brwsr Runtime</name>
76.11 <parent>
76.12 <groupId>org.apidesign</groupId>
76.13 <artifactId>bck2brwsr</artifactId>
76.14 - <version>0.8-SNAPSHOT</version>
76.15 + <version>0.9-SNAPSHOT</version>
76.16 </parent>
76.17 <modules>
76.18 <module>core</module>
76.19 <module>emul</module>
76.20 - <module>archetype</module>
76.21 <module>mojo</module>
76.22 <module>vm</module>
76.23 <module>vmtest</module>
77.1 --- a/rt/vm/pom.xml Sun Sep 08 11:42:01 2013 +0200
77.2 +++ b/rt/vm/pom.xml Wed Sep 18 11:20:57 2013 +0200
77.3 @@ -3,12 +3,12 @@
77.4 <parent>
77.5 <groupId>org.apidesign.bck2brwsr</groupId>
77.6 <artifactId>rt</artifactId>
77.7 - <version>0.8-SNAPSHOT</version>
77.8 + <version>0.9-SNAPSHOT</version>
77.9 </parent>
77.10
77.11 <groupId>org.apidesign.bck2brwsr</groupId>
77.12 <artifactId>vm4brwsr</artifactId>
77.13 - <version>0.8-SNAPSHOT</version>
77.14 + <version>0.9-SNAPSHOT</version>
77.15 <packaging>jar</packaging>
77.16
77.17 <name>Virtual Machine for Browser</name>
78.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/VMLazy.java Sun Sep 08 11:42:01 2013 +0200
78.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/VMLazy.java Wed Sep 18 11:20:57 2013 +0200
78.3 @@ -130,6 +130,14 @@
78.4
78.5 @Override
78.6 protected void requireScript(String resourcePath) throws IOException {
78.7 + if (!resourcePath.startsWith("/")) {
78.8 + resourcePath = "/" + resourcePath;
78.9 + }
78.10 + String code = readCode(resourcePath);
78.11 + applyCode(lazy.loader, null, code, false);
78.12 + }
78.13 +
78.14 + private String readCode(String resourcePath) throws IOException {
78.15 InputStream is = getClass().getResourceAsStream(resourcePath);
78.16 StringBuilder sb = new StringBuilder();
78.17 for (;;) {
78.18 @@ -139,7 +147,7 @@
78.19 }
78.20 sb.append((char)ch);
78.21 }
78.22 - applyCode(lazy.loader, null, sb.toString(), false);
78.23 + return sb.toString();
78.24 }
78.25
78.26 @Override
79.1 --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/HtmlAnnotations.java Sun Sep 08 11:42:01 2013 +0200
79.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
79.3 @@ -1,86 +0,0 @@
79.4 -/**
79.5 - * Back 2 Browser Bytecode Translator
79.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
79.7 - *
79.8 - * This program is free software: you can redistribute it and/or modify
79.9 - * it under the terms of the GNU General Public License as published by
79.10 - * the Free Software Foundation, version 2 of the License.
79.11 - *
79.12 - * This program is distributed in the hope that it will be useful,
79.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
79.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
79.15 - * GNU General Public License for more details.
79.16 - *
79.17 - * You should have received a copy of the GNU General Public License
79.18 - * along with this program. Look for COPYING file in the top folder.
79.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
79.20 - */
79.21 -package org.apidesign.vm4brwsr;
79.22 -
79.23 -import net.java.html.js.JavaScriptBody;
79.24 -import net.java.html.js.JavaScriptResource;
79.25 -
79.26 -/**
79.27 - *
79.28 - * @author Jaroslav Tulach <jtulach@netbeans.org>
79.29 - */
79.30 -@JavaScriptResource("htmlannotations.js")
79.31 -public class HtmlAnnotations {
79.32 - private Object callback;
79.33 -
79.34 -
79.35 - @JavaScriptBody(args = {}, body = "return 42;")
79.36 - public static int fourtyTwo() {
79.37 - return -1;
79.38 - }
79.39 -
79.40 - @JavaScriptBody(args = { "x", "y" }, body = "return mul(x, y);")
79.41 - public static native int useExternalMul(int x, int y);
79.42 -
79.43 - public static int callback() {
79.44 - final int[] arr = { 0 };
79.45 - callback(new Runnable() {
79.46 - @Override
79.47 - public void run() {
79.48 - arr[0]++;
79.49 - }
79.50 - });
79.51 - return arr[0];
79.52 - }
79.53 -
79.54 - @JavaScriptBody(args = { "r" }, javacall=true, body = "r.@java.lang.Runnable::run()()")
79.55 - private static native void callback(Runnable r);
79.56 -
79.57 - @JavaScriptBody(args = { }, javacall = true, body = "return @org.apidesign.vm4brwsr.HtmlAnnotations::callback()();")
79.58 - public static native int staticCallback();
79.59 -
79.60 -
79.61 - protected long chooseLong(boolean takeFirst, boolean takeSecond, long first, long second) {
79.62 - long l = 0;
79.63 - if (takeFirst) l += first;
79.64 - if (takeSecond) l += second;
79.65 - return l;
79.66 - }
79.67 -
79.68 - protected void onError(Object obj) throws Exception {
79.69 - callback = obj;
79.70 - }
79.71 -
79.72 - Object getError() {
79.73 - return callback;
79.74 - }
79.75 -
79.76 - public static Object create() {
79.77 - return new HtmlAnnotations();
79.78 - }
79.79 - @JavaScriptBody(args = { "impl", "a", "b" }, javacall = true, body =
79.80 - "return impl.@org.apidesign.vm4brwsr.HtmlAnnotations::chooseLong(ZZJJ)(true, false, a, b);"
79.81 - )
79.82 - public static native long first(Object impl, long a, long b);
79.83 -
79.84 - @JavaScriptBody(args = { "impl", "d" }, javacall = true, body =
79.85 - "impl.@org.apidesign.vm4brwsr.HtmlAnnotations::onError(Ljava/lang/Object;)(d);" +
79.86 - "return impl.@org.apidesign.vm4brwsr.HtmlAnnotations::getError()();"
79.87 - )
79.88 - public static native Double onError(Object impl, Double d);
79.89 -}
80.1 --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/HtmlAnnotationsTest.java Sun Sep 08 11:42:01 2013 +0200
80.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
80.3 @@ -1,91 +0,0 @@
80.4 -/**
80.5 - * Back 2 Browser Bytecode Translator
80.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
80.7 - *
80.8 - * This program is free software: you can redistribute it and/or modify
80.9 - * it under the terms of the GNU General Public License as published by
80.10 - * the Free Software Foundation, version 2 of the License.
80.11 - *
80.12 - * This program is distributed in the hope that it will be useful,
80.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
80.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80.15 - * GNU General Public License for more details.
80.16 - *
80.17 - * You should have received a copy of the GNU General Public License
80.18 - * along with this program. Look for COPYING file in the top folder.
80.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
80.20 - */
80.21 -package org.apidesign.vm4brwsr;
80.22 -
80.23 -import static org.testng.Assert.assertNotNull;
80.24 -import org.testng.annotations.AfterClass;
80.25 -import org.testng.annotations.BeforeClass;
80.26 -import org.testng.annotations.Test;
80.27 -
80.28 -/** Verify cooperation with net.java.html.js annotations.
80.29 - *
80.30 - * @author Jaroslav Tulach <jtulach@netbeans.org>
80.31 - */
80.32 -public class HtmlAnnotationsTest {
80.33 - @Test public void fourtyTwo() throws Exception {
80.34 - assertExec("Annotation used", HtmlAnnotations.class,
80.35 - "fourtyTwo__I",
80.36 - Double.valueOf(42)
80.37 - );
80.38 - }
80.39 -
80.40 - @Test public void externalMul() throws Exception {
80.41 - assertExec("mul function is loaded", HtmlAnnotations.class,
80.42 - "useExternalMul__III",
80.43 - Double.valueOf(42),
80.44 - 7, 6
80.45 - );
80.46 - }
80.47 -
80.48 - @Test public void callRunnableFromJS() throws Exception {
80.49 - assertExec("runnable called", HtmlAnnotations.class,
80.50 - "callback__I",
80.51 - Double.valueOf(1)
80.52 - );
80.53 - }
80.54 -
80.55 - @Test public void callStaticMethodFromJS() throws Exception {
80.56 - assertExec("runnable called", HtmlAnnotations.class,
80.57 - "staticCallback__I",
80.58 - Double.valueOf(1)
80.59 - );
80.60 - }
80.61 -
80.62 - @Test public void callbackWithFourParamsAndReturnType() throws Exception {
80.63 - Object instance = code.execCode("Get an HtmlAnnotations instance", HtmlAnnotations.class, "create__Ljava_lang_Object_2", null);
80.64 - assertNotNull(instance, "Instance created");
80.65 - assertExec("runnable called", HtmlAnnotations.class,
80.66 - "first__JLjava_lang_Object_2JJ",
80.67 - Double.valueOf(42), instance, 42, 31
80.68 - );
80.69 - }
80.70 -
80.71 - @Test public void callbackWithObjectParamsAndReturnType() throws Exception {
80.72 - Object instance = code.execCode("Get an HtmlAnnotations instance", HtmlAnnotations.class, "create__Ljava_lang_Object_2", null);
80.73 - assertNotNull(instance, "Instance created");
80.74 - assertExec("called back and forth", HtmlAnnotations.class,
80.75 - "onError__Ljava_lang_Double_2Ljava_lang_Object_2Ljava_lang_Double_2",
80.76 - Double.valueOf(42), instance, 42
80.77 - );
80.78 - }
80.79 -
80.80 - private static TestVM code;
80.81 -
80.82 - @BeforeClass
80.83 - public void compileTheCode() throws Exception {
80.84 - code = TestVM.compileClass("org/apidesign/vm4brwsr/HtmlAnnotations");
80.85 - }
80.86 - @AfterClass
80.87 - public static void releaseTheCode() {
80.88 - code = null;
80.89 - }
80.90 - private static void assertExec(String msg, Class clazz, String method, Object expRes, Object... args) throws Exception {
80.91 - code.assertExec(msg, clazz, method, expRes, args);
80.92 - }
80.93 -
80.94 -}
81.1 --- a/rt/vm/src/test/resources/org/apidesign/vm4brwsr/htmlannotations.js Sun Sep 08 11:42:01 2013 +0200
81.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
81.3 @@ -1,19 +0,0 @@
81.4 -/*
81.5 - * Back 2 Browser Bytecode Translator
81.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
81.7 - *
81.8 - * This program is free software: you can redistribute it and/or modify
81.9 - * it under the terms of the GNU General Public License as published by
81.10 - * the Free Software Foundation, version 2 of the License.
81.11 - *
81.12 - * This program is distributed in the hope that it will be useful,
81.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
81.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81.15 - * GNU General Public License for more details.
81.16 - *
81.17 - * You should have received a copy of the GNU General Public License
81.18 - * along with this program. Look for COPYING file in the top folder.
81.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
81.20 - */
81.21 -
81.22 -function mul(x, y) { return x * y; }
82.1 --- a/rt/vmtest/pom.xml Sun Sep 08 11:42:01 2013 +0200
82.2 +++ b/rt/vmtest/pom.xml Wed Sep 18 11:20:57 2013 +0200
82.3 @@ -4,11 +4,11 @@
82.4 <parent>
82.5 <groupId>org.apidesign.bck2brwsr</groupId>
82.6 <artifactId>rt</artifactId>
82.7 - <version>0.8-SNAPSHOT</version>
82.8 + <version>0.9-SNAPSHOT</version>
82.9 </parent>
82.10 <groupId>org.apidesign.bck2brwsr</groupId>
82.11 <artifactId>vmtest</artifactId>
82.12 - <version>0.8-SNAPSHOT</version>
82.13 + <version>0.9-SNAPSHOT</version>
82.14
82.15 <name>VM Testing APIs</name>
82.16 <url>http://bck2brwsr.apidesign.org</url>