Created
November 9, 2009 19:24
-
-
Save bluescreen303/230193 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/build.xml b/build.xml | |
index 8979d97..87ac1d6 100644 | |
--- a/build.xml | |
+++ b/build.xml | |
@@ -211,17 +211,26 @@ | |
<jar destfile="${jar.outfile-server}"> | |
<fileset dir="${staging}"> | |
<include name="META-INF/services/*" /> | |
+ <include name="builtin/**/*" /> | |
+ <include name="com/dutchcoastsoftware/tsunami/**/*" /> | |
<include name="com/google/common/**/*" /> | |
<include name="com/google/inject/**/*" /> | |
<include name="com/google/protobuf/**/*" /> | |
+ <include name="com/kenai/constantine/**/*" /> | |
+ <include name="com/sun/jna/**/*" /> | |
<include name="gnu/inet/**/*" /> | |
<include name="javax/inject/**/*" /> | |
<include name="javax/xml/**/*" /> | |
+ <include name="jruby/**/*" /> | |
<include name="org/aopalliance/**/*" /> | |
<include name="org/apache/commons/cli/**/*" /> | |
<include name="org/apache/commons/codec/**/*" /> | |
<include name="org/dom4j/**/*" /> | |
+ <include name="org/jcodings/**/*" /> | |
<include name="org/jivesoftware/**/*" /> | |
+ <include name="org/joda/time/**/*" /> | |
+ <include name="org/joni/**/*" /> | |
+ <include name="org/jruby/**/*" /> | |
<include name="org/waveprotocol/**/*" /> | |
<include name="org/xmlpull/**/*" /> | |
<include name="org/xmpp/**/*" /> | |
diff --git a/ruby_src/init.rb b/ruby_src/init.rb | |
new file mode 100644 | |
index 0000000..e081a95 | |
--- /dev/null | |
+++ b/ruby_src/init.rb | |
@@ -0,0 +1,65 @@ | |
+require 'jruby/core_ext' | |
+ | |
+module Com | |
+ module Dutchcoastsoftware | |
+ module Tsunami | |
+ module Server | |
+ class ClientFrontend | |
+ include org.waveprotocol.wave.examples.fedone.waveserver.ClientFrontend | |
+ | |
+ def initialize(provider) | |
+ @provider = provider | |
+ end | |
+ | |
+ def submitRequest(waveletName, delta, listener) | |
+ puts "submitted" | |
+ puts waveletName.java_class | |
+ puts waveletName | |
+ puts delta.java_class | |
+ puts delta | |
+ puts listener.java_class | |
+ puts listener | |
+ nil | |
+ end | |
+ | |
+ def openRequest(participant, waveId, waveletIdPrefixes, maximumInitialWavelets, openListener) | |
+ puts "opened" | |
+ puts participant.java_class | |
+ puts participant | |
+ puts waveId.java_class | |
+ puts waveId | |
+ puts waveletIdPrefixes.java_class | |
+ puts waveletIdPrefixes | |
+ puts maximumInitialWavelets | |
+ puts openListener.java_class | |
+ puts openListener | |
+ nil | |
+ end | |
+ | |
+ def waveletUpdate(waveletName, newDeltas, resultingVersion, documentState) | |
+ puts "updated" | |
+ nil | |
+ end | |
+ | |
+ def waveletCommitted(waveletName, version) | |
+ puts "committed" | |
+ nil | |
+ end | |
+ end | |
+ | |
+ ClientFrontend.add_method_annotation("initialize", com.google.inject.Inject => {}) | |
+ ClientFrontend.add_method_signature("initialize", [java.lang.Void::TYPE, org.waveprotocol.wave.examples.fedone.waveserver.WaveletProvider]) | |
+ ClientFrontend.add_method_signature("submitRequest", [java.lang.Void::TYPE, org.waveprotocol.wave.model.id.WaveletName.java_class, org.waveprotocol.wave.protocol.common::ProtocolWaveletDelta.java_class, org.waveprotocol.wave.examples.fedone.waveserver.ClientFrontend::SubmitResultListener.java_class]) | |
+ ClientFrontend.add_method_signature("openRequest", [java.lang.Void::TYPE, org.waveprotocol.wave.model.wave.ParticipantId.java_class, org.waveprotocol.wave.model.id.WaveId.java_class, java.util.Set.java_class, java.lang.Integer::TYPE, org.waveprotocol.wave.examples.fedone.waveserver.ClientFrontend::OpenListener.java_class]) | |
+ ClientFrontend.add_method_signature("waveletUpdate", [java.lang.Void::TYPE, org.waveprotocol.wave.model.id.WaveletName.java_class, java.util.List.java_class, org.waveprotocol.wave.protocol.common::ProtocolHashedVersion.java_class, java.util.Map.java_class]) | |
+ ClientFrontend.add_method_signature("waveletCommitted", [java.lang.Void::TYPE, org.waveprotocol.wave.model.id.WaveletName.java_class, org.waveprotocol.wave.protocol.common::ProtocolHashedVersion.java_class]) | |
+ ClientFrontend.become_java! | |
+ | |
+ # hand the created class back to java | |
+ com.dutchcoastsoftware.tsunami.server.TsunamiServerRubyInit.clientFrontend = ClientFrontend.java_class | |
+ | |
+ end | |
+ end | |
+ end | |
+end | |
+ | |
diff --git a/src/com/dutchcoastsoftware/tsunami/server/TsunamiServerRubyInit.java b/src/com/dutchcoastsoftware/tsunami/server/TsunamiServerRubyInit.java | |
new file mode 100644 | |
index 0000000..ac5cdfd | |
--- /dev/null | |
+++ b/src/com/dutchcoastsoftware/tsunami/server/TsunamiServerRubyInit.java | |
@@ -0,0 +1,21 @@ | |
+package com.dutchcoastsoftware.tsunami.server; | |
+ | |
+import java.io.FileReader; | |
+import javax.script.*; | |
+import org.waveprotocol.wave.examples.fedone.waveserver.ClientFrontend; | |
+ | |
+public final class TsunamiServerRubyInit { | |
+ | |
+ public static Class<? extends ClientFrontend> clientFrontend; | |
+ | |
+ public static void init() throws Exception { | |
+ ScriptEngineManager factory = new ScriptEngineManager(); | |
+ ScriptEngine engine = factory.getEngineByName("jruby"); | |
+ FileReader reader = new FileReader("ruby_src/init.rb"); | |
+ try { | |
+ engine.eval(reader); | |
+ } catch (ScriptException exception) { | |
+ exception.printStackTrace(); | |
+ } | |
+ } | |
+} | |
diff --git a/src/org/waveprotocol/wave/examples/fedone/ServerMain.java b/src/org/waveprotocol/wave/examples/fedone/ServerMain.java | |
index c12c78d..6acbba0 100644 | |
--- a/src/org/waveprotocol/wave/examples/fedone/ServerMain.java | |
+++ b/src/org/waveprotocol/wave/examples/fedone/ServerMain.java | |
@@ -17,6 +17,7 @@ | |
package org.waveprotocol.wave.examples.fedone; | |
+import com.dutchcoastsoftware.tsunami.server.TsunamiServerRubyInit; | |
import com.google.inject.Guice; | |
import com.google.inject.Inject; | |
import com.google.inject.Injector; | |
@@ -57,6 +58,15 @@ public class ServerMain { | |
public static void run(Module flags) | |
throws IOException { | |
+ LOG.info("initializing jruby classes..."); | |
+ try { | |
+ TsunamiServerRubyInit.init(); | |
+ LOG.info("jruby initialized"); | |
+ } catch (Exception e1) { | |
+ LOG.severe("jruby could not be started"); | |
+ e1.printStackTrace(); | |
+ } | |
+ | |
Injector injector = Guice.createInjector(new ServerModule(), flags); | |
WaveXmppComponent wxComponent = injector.getInstance(WaveXmppComponent.class); | |
ServerRpcProvider server = new ServerRpcProvider(injector.getInstance( | |
diff --git a/src/org/waveprotocol/wave/examples/fedone/waveserver/WaveServerModule.java b/src/org/waveprotocol/wave/examples/fedone/waveserver/WaveServerModule.java | |
index a4aae8b..3373798 100644 | |
--- a/src/org/waveprotocol/wave/examples/fedone/waveserver/WaveServerModule.java | |
+++ b/src/org/waveprotocol/wave/examples/fedone/waveserver/WaveServerModule.java | |
@@ -17,6 +17,7 @@ | |
package org.waveprotocol.wave.examples.fedone.waveserver; | |
+import com.dutchcoastsoftware.tsunami.server.TsunamiServerRubyInit; | |
import com.google.inject.AbstractModule; | |
import com.google.inject.Provides; | |
import com.google.inject.Singleton; | |
@@ -79,7 +80,8 @@ public class WaveServerModule extends AbstractModule { | |
bind(CertificateManager.class).to(CertificateManagerImpl.class).in(Singleton.class); | |
bind(WaveletProvider.class).to(WaveServer.class); | |
bind(WaveServer.class).to(WaveServerImpl.class).in(Singleton.class); | |
- bind(ClientFrontend.class).to(ClientFrontendImpl.class).in(Singleton.class); | |
+// bind(ClientFrontend.class).to(ClientFrontendImpl.class).in(Singleton.class); | |
+ bind(ClientFrontend.class).to(TsunamiServerRubyInit.clientFrontend).in(Singleton.class); | |
bind(ProtocolWaveClientRpc.Interface.class).to(WaveClientRpcImpl.class).in(Singleton.class); | |
bind(LocalWaveletContainer.Factory.class).to(LocalWaveletContainerFactory.class) | |
.in(Singleton.class); | |
diff --git a/third_party/runtime/jruby/jruby-1.4.0.jar b/third_party/runtime/jruby/jruby-1.4.0.jar | |
new file mode 100644 | |
index 0000000..6201802 | |
Binary files /dev/null and b/third_party/runtime/jruby/jruby-1.4.0.jar differ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment