510 likes | 591 Vues
33rd Degree Conference Kraków, 7 April , 2011. Java, .N ET , Ruby and PHP integration. Matthias Hryniszak. The following presentation is intended for informational purposes only .
E N D
33rd DegreeConference Kraków, 7 April, 2011 Java, .NET, Ruby and PHP integration Matthias Hryniszak
The following presentation is intended for informational purposes only. There’s no part of it that you should consider either a guideline, viable option or production-ready set of instructions that could solve your problem If you use any concepts of what you see here it is entirely up to you to make sure it works for you.
The story so far…
section .text global _start ;must be declared for linker (ld) _start: ;tell linker entry point movedx,len ;message length movecx,msg ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel section .data msg db 'Hello, world!',0xa ;our dear string lenequ $ - msg ;length of our dear string
#include <stdio.h> • #include <stdlib.h> intmain() { println("Hello, world!"); } • #include <iostream> • int main(){ • std::cout << "Hello World!" << std::endl; • }
│ pom.xml • │ • └───src • ├───main • │ ├───java • │ │└───com • │ │└───aplaline • │ │└───example • │ ││MyApplicationModule.java • │ ││ServletConfig.java • │ ││ • │ │├───components • │ ││TextLabel.java • │ ││ • │ │└───views • │ │FrontView.java • │ │RootView.java • │ │ • │ ├───resources • │ │└───com • │ │└───aplaline • │ │└───example • │ │├───components • │ ││TextLabel.xsl • │ ││ • │ │└───views • │ │FrontView.xsl • │ │RootView.xsl • │ │ • │ └───webapp • │ │main.css • │ │ • │ ├───gfx • │ │pageheader.png • │ │ • │ ├───scripts • │ │contextfw.js • │ │jquery.js • │ │json.js • │ │ • │ └───WEB-INF • │ web.xml • │ • └───test • └───java • └───com • └───aplaline • └───example • WebStart.java
using System; • class Pogram { • public staticvoidMain() { • Console.WriteLine("Hello, world!"); • } • }
AgendaTheno-brainers • PHP – thedynamiclanguage for masses • Whywouldyouevencare? • How to integratewith PHP code • Ruby – thenewwave • What’s Ruby reallygoodat? • How to integratewith Ruby code 整合
AgendaTheevil, but coolside of life • .NET– theeviltwinfrom Microsoft • Whywouldyouevencare? • Thelameside of integration… • Howcoolkids do it? 整合
Howabout… Java integration 整合
Wiki in 2 minutes! MediaWiki 整合
Blogin 2 minutes! Wordpress 整合
Forum in 2 minutes! PhpBB 整合
Ruby as a scriptinglanguageJSR 223 ScriptEngineManagersem = newScriptEngineManager(); ScriptEnginese = sem.getEngineByExtension("rb"); InputStreamis = ClassLoader.getSystemResourceAsStream("hello.rb"); InputStreamReaderscript = newInputStreamReader(is); try { Objectresult = se.eval(script); System.out.println("Result: " + result); } catch (Exception e) { System.out.println( "Errorwhileexecutingscript\n" + e.getMessage() ); } 整合
Ruby as a scriptinglanguageJSR 223 require'java' Calculator = com.aplaline.example.Calculator calc = Calculator.new calc.add(2.0,3.0) 整合
Ruby as a scriptinglanguageJSR 223 require'java' Calculator = com.aplaline.example.Calculator calc = Calculator.new calc.add(2.0,3.0) 整合
Ruby as a language for testsJtestR - regular class HashMapTests < Test::Unit::TestCase def setup @map = java.util.HashMap.new end def test_that_map_is_empty assert @map.isEmpty end end 整合
Ruby as a language for testsJtestR - RSpec import java.util.HashMap describe "An empty", HashMap do before :each do @hash_map = HashMap.new end it "should be able to add an entry to it" do @hash_map.put "foo", "bar" @hash_map.get("foo").should == "bar" end end 整合
Whyevenbother? • Learnfromother’smistakes • Becomeawarethat Java is not theonlychoice • Make sureyouunderstandtherisksinvolved • To haveplenty of fun! 整合
Howwouldyouintegratewithit?TheIKVM-way IKVM.NET 整合
What’sinthebox? • ikvmc.exe • thebinarycompiler • jar-to-dll/execonverter • ikvm.exe • the JVM implementation on .NET • ikvmstub.exe • dll-to-jarconverter • OpenJDKinassembly form 整合
Java on .NET ??? Demo Groovy + OSGi 整合
Whatruns on IKVM? Eclipse 整合
Whatruns on IKVM? Apache Tomcat 整合