Adding a debug display project to make sure we cover our bases
diff --git a/examples/sample.js.debugdisplay/.classpath b/examples/sample.js.debugdisplay/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/examples/sample.js.debugdisplay/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/examples/sample.js.debugdisplay/.project b/examples/sample.js.debugdisplay/.project
new file mode 100644
index 0000000..961dfe8
--- /dev/null
+++ b/examples/sample.js.debugdisplay/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>sample.js.debugdisplay</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/examples/sample.js.debugdisplay/.settings/org.eclipse.jdt.core.prefs b/examples/sample.js.debugdisplay/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..9466dda
--- /dev/null
+++ b/examples/sample.js.debugdisplay/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Wed Aug 26 11:01:39 EDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/examples/sample.js.debugdisplay/.settings/org.eclipse.pde.core.prefs b/examples/sample.js.debugdisplay/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 0000000..7aca589
--- /dev/null
+++ b/examples/sample.js.debugdisplay/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,4 @@
+#Wed Aug 26 11:01:39 EDT 2009
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/examples/sample.js.debugdisplay/META-INF/MANIFEST.MF b/examples/sample.js.debugdisplay/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..3882a7f
--- /dev/null
+++ b/examples/sample.js.debugdisplay/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Debug Sample
+Bundle-SymbolicName: sample.js.debugdisplay
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: sample.js.debugdisplay.Activator
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Import-Package: org.eclipse.e4.internal.languages.javascript,
+ org.eclipse.e4.languages.javascript,
+ org.mozilla.javascript,
+ org.osgi.framework;version="1.3.0",
+ org.osgi.util.tracker;version="1.4.2"
diff --git a/examples/sample.js.debugdisplay/build.properties b/examples/sample.js.debugdisplay/build.properties
new file mode 100644
index 0000000..34d2e4d
--- /dev/null
+++ b/examples/sample.js.debugdisplay/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/examples/sample.js.debugdisplay/scripts/bundle.json b/examples/sample.js.debugdisplay/scripts/bundle.json
new file mode 100644
index 0000000..a16a1d6
--- /dev/null
+++ b/examples/sample.js.debugdisplay/scripts/bundle.json
@@ -0,0 +1,5 @@
+{
+"Bundle-SymbolicName":"sample.js.debugdisplay",
+"Bundle-Version":"1.0",
+"Bundle-ScriptPath":"script.js"
+}
\ No newline at end of file
diff --git a/examples/sample.js.debugdisplay/scripts/script.js b/examples/sample.js.debugdisplay/scripts/script.js
new file mode 100644
index 0000000..f1fba29
--- /dev/null
+++ b/examples/sample.js.debugdisplay/scripts/script.js
@@ -0,0 +1,13 @@
+var anInteger = 42;
+var aFloat = 6.66;
+var aBoolean = true;
+var aString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur volutpat enim nec orci rhoncus id fringilla arcu lacinia. Integer nec purus eu est rutrum pharetra non non nulla.";
+var aNull = null;
+var anUndefined = undefined;
+var aNaN = 1/undefined;
+var anObject = {x: 5, y: 25};
+var aPrintableObject = {x: 5, y: 25};
+var aMap = {};
+var anArray = [];
+var anArguments = arguments;
+debugger;
diff --git a/examples/sample.js.debugdisplay/src/sample/js/debugdisplay/Activator.java b/examples/sample.js.debugdisplay/src/sample/js/debugdisplay/Activator.java
new file mode 100644
index 0000000..d48b245
--- /dev/null
+++ b/examples/sample.js.debugdisplay/src/sample/js/debugdisplay/Activator.java
@@ -0,0 +1,93 @@
+package sample.js.debugdisplay;
+
+import java.net.URL;
+import org.eclipse.e4.internal.languages.javascript.JSFrameworkImpl;
+import org.eclipse.e4.languages.javascript.JSBundle;
+import org.eclipse.e4.languages.javascript.JSBundleException;
+import org.eclipse.e4.languages.javascript.JSFramework;
+import org.mozilla.javascript.Callable;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ContextAction;
+import org.mozilla.javascript.Scriptable;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+public class Activator implements BundleActivator, ServiceTrackerCustomizer {
+
+ public static final String TEST = "test";
+
+ private BundleContext context;
+ private ServiceTracker frameworkTracker;
+ private JSFramework framework;
+
+ private JSBundle jsBundle;
+
+ public void start(BundleContext bundleContext) throws Exception {
+ this.context = bundleContext;
+
+ frameworkTracker = new ServiceTracker(context, JSFramework.class.getName(), this);
+ frameworkTracker.open();
+
+
+ }
+
+ public void stop(BundleContext bundleContext) throws Exception {
+ frameworkTracker.close();
+ frameworkTracker = null;
+ context = null;
+ }
+
+ public Object addingService(ServiceReference reference) {
+ framework = (JSFramework) context.getService(reference);
+
+ Bundle bundle = context.getBundle();
+ URL jsBundleEntry = bundle.getEntry("scripts/bundle.json");
+ if (jsBundleEntry == null)
+ return null;
+
+
+ try {
+ jsBundle =((JSFrameworkImpl)framework).installBundle(jsBundleEntry.toString(), bundle);
+ } catch (JSBundleException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ framework.resolve();
+ try {
+ testDebugSanityInstallResolveBundle();
+ } catch (JSBundleException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return framework;
+ }
+
+ public void modifiedService(ServiceReference reference, Object service) {
+ }
+
+ public void removedService(ServiceReference reference, Object service) {
+ jsBundle.uninstall();
+ framework.resolve();
+ }
+
+ public void testDebugSanityInstallResolveBundle() throws JSBundleException {
+
+ final Scriptable scope = jsBundle.getScope();
+ Object obj = scope.get("test2", scope);
+ final Callable test = (Callable) obj;
+
+ jsBundle.call(new ContextAction() {
+ public Object run(Context cx) {
+ Object result = test.call(cx, scope, scope, new Object[0]);
+ Object javaResult = Context.jsToJava(result, String.class);
+ return javaResult;
+ }
+ });
+ }
+
+}