Permalink
Browse files

Initial JavaScript/Rhino support

  • Loading branch information...
1 parent 2d5163b commit 07045f9b37114a1579eb47a7a1ef7e6b0f8b0665 @jannehietamaki committed Oct 31, 2010
View
@@ -31,6 +31,13 @@
<groupId>com.theoryinpractise</groupId>
<artifactId>clojure-maven-plugin</artifactId>
<version>1.3.1</version>
+ <configuration>
+ <warnOnReflection>true</warnOnReflection>
+ <testDeclaredNamespaceOnly>true</testDeclaredNamespaceOnly>
+ <namespaces>
+ <namespace>mungbean_test</namespace>
+ </namespaces>
+ </configuration>
<executions>
<execution>
<id>test-clojure</id>
View
@@ -1,20 +1,18 @@
-<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
- <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
- <classpathentry excluding="**/*.java|**/*.java" including="**/*" kind="src" path="src/main/resources"/>
- <classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar" sourcepath="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/clojure/clojure/1.2.0/clojure-1.2.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/com/github/mpeltonen/jdave-core/1.2-beta2/jdave-core-1.2-beta2.jar" sourcepath="M2_REPO/com/github/mpeltonen/jdave-core/1.2-beta2/jdave-core-1.2-beta2-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/com/github/mpeltonen/jdave-junit4/1.2-beta2/jdave-junit4-1.2-beta2.jar" sourcepath="M2_REPO/com/github/mpeltonen/jdave-junit4/1.2-beta2/jdave-junit4-1.2-beta2-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.4.0/jmock-2.4.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jmock/jmock-legacy/2.4.0/jmock-legacy-2.4.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/junit/junit-dep/4.5/junit-dep-4.5.jar" sourcepath="M2_REPO/junit/junit-dep/4.5/junit-dep-4.5-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/objenesis/objenesis/1.2/objenesis-1.2.jar" sourcepath="M2_REPO/org/objenesis/objenesis/1.2/objenesis-1.2-sources.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="var" path="M2_REPO"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+ <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
+ <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
+ <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
+ <classpathentry kind="src" path="src/main/resources" including="**/*" excluding="**/*.java|**/*.java"/>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar" sourcepath="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/clojure/clojure/1.2.0/clojure-1.2.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/com/github/mpeltonen/jdave-core/1.2-beta2/jdave-core-1.2-beta2.jar" sourcepath="M2_REPO/com/github/mpeltonen/jdave-core/1.2-beta2/jdave-core-1.2-beta2-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/com/github/mpeltonen/jdave-junit4/1.2-beta2/jdave-junit4-1.2-beta2.jar" sourcepath="M2_REPO/com/github/mpeltonen/jdave-junit4/1.2-beta2/jdave-junit4-1.2-beta2-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.4.0/jmock-2.4.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jmock/jmock-legacy/2.4.0/jmock-legacy-2.4.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit-dep/4.5/junit-dep-4.5.jar" sourcepath="M2_REPO/junit/junit-dep/4.5/junit-dep-4.5-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/objenesis/objenesis/1.2/objenesis-1.2.jar" sourcepath="M2_REPO/org/objenesis/objenesis/1.2/objenesis-1.2-sources.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+</classpath>
View
@@ -0,0 +1,16 @@
+<classpath>
+ <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3.jar" sourcepath="M2_REPO/cglib/cglib-nodep/2.1_3/cglib-nodep-2.1_3-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/com/github/mpeltonen/jdave-core/1.2-beta2/jdave-core-1.2-beta2.jar" sourcepath="M2_REPO/com/github/mpeltonen/jdave-core/1.2-beta2/jdave-core-1.2-beta2-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/com/github/mpeltonen/jdave-junit4/1.2-beta2/jdave-junit4-1.2-beta2.jar" sourcepath="M2_REPO/com/github/mpeltonen/jdave-junit4/1.2-beta2/jdave-junit4-1.2-beta2-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jmock/jmock/2.4.0/jmock-2.4.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jmock/jmock-legacy/2.4.0/jmock-legacy-2.4.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/rhino/js/1.7R2/js-1.7R2.jar" sourcepath="M2_REPO/rhino/js/1.7R2/js-1.7R2-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit-dep/4.5/junit-dep-4.5.jar" sourcepath="M2_REPO/junit/junit-dep/4.5/junit-dep-4.5-sources.jar"/>
+ <classpathentry kind="src" path="/mungbean-java"/>
+ <classpathentry kind="var" path="M2_REPO/org/objenesis/objenesis/1.2/objenesis-1.2.jar" sourcepath="M2_REPO/org/objenesis/objenesis/1.2/objenesis-1.2-sources.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+</classpath>
@@ -0,0 +1 @@
+target
View
@@ -0,0 +1,15 @@
+<projectDescription>
+ <name>mungbean-rhino</name>
+ <comment/>
+ <projects>
+ <project>mungbean-java</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,5 @@
+#Sun Oct 31 16:54:04 EET 2010
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
View
@@ -0,0 +1,104 @@
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>mungbean</groupId>
+ <artifactId>mungbean</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <groupId>mungbean</groupId>
+ <artifactId>mungbean-rhino</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>com.github.mpeltonen</groupId>
+ <artifactId>jdave-core</artifactId>
+ <version>1.2-beta2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.github.mpeltonen</groupId>
+ <artifactId>jdave-junit4</artifactId>
+ <version>1.2-beta2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.objenesis</groupId>
+ <artifactId>objenesis</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.7R2</version>
+ </dependency>
+ <dependency>
+ <groupId>mungbean</groupId>
+ <artifactId>mungbean-java</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <repositories>
+ <repository>
+ <id>laughingpanda-maven2</id>
+ <name>Laughing Panda Maven 2 Repository</name>
+ <url>http://www.laughingpanda.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>laughingpanda-maven2-plugins</id>
+ <name>Laughing Panda Maven 2 Repository</name>
+ <url>http://www.laughingpanda.org/maven2/</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <build>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>${basedir}/src/main/java</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ <resource>
+ <filtering>false</filtering>
+ <directory>${basedir}/src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <encoding>UTF-8</encoding>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <includes>
+ <include>**/*Spec.java</include>
+ <include>**/*IntegrationTest.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
@@ -0,0 +1,34 @@
+package mungbean.rhino;
+
+import java.util.Map;
+
+import org.mozilla.javascript.ScriptableObject;
+
+public class MapWrapper extends ScriptableObject {
+ private final Map<String, Object> map;
+
+ public MapWrapper(Map<String, Object> map) {
+ this.map = map;
+ }
+
+ @Override
+ public String getClassName() {
+ return "Array";
+ }
+
+ public void put(String name, org.mozilla.javascript.Scriptable start, Object value) {
+ map.put(name, value);
+ }
+
+ public Object get(String name, org.mozilla.javascript.Scriptable start) {
+ return map.get(name);
+ }
+
+ public boolean has(String name, org.mozilla.javascript.Scriptable start) {
+ return map.containsKey(name);
+ }
+
+ public Object[] getIds() {
+ return map.keySet().toArray();
+ }
+}
@@ -0,0 +1,24 @@
+package mungbean.rhino;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import mungbean.Authentication;
+import mungbean.DBOperationExecutor;
+import mungbean.Server;
+import mungbean.Settings;
+import mungbean.SingleNodeDbOperationExecutor;
+
+public class MungbeanConfiguration {
+ private final DBOperationExecutor executor;
+
+ public MungbeanConfiguration(String host, int port) {
+ List<Authentication> auths = new ArrayList<Authentication>();
+ Settings settings = new Settings();
+ executor = new SingleNodeDbOperationExecutor(settings, new Server(host, port, auths.toArray(new Authentication[auths.size()])));
+ }
+
+ public DBOperationExecutor executor() {
+ return executor;
+ }
+}
Oops, something went wrong.

0 comments on commit 07045f9

Please sign in to comment.