it pro dev_birbilis_20101127_en
DESCRIPTION
Life after Java - Reusing Code and Skills in a .NET world / presentation at ITProDevConnections 2010 - http://www.itprodevconnections.grTRANSCRIPT
Life after Java
Reusing code and skills in a .NET world
Agenda• Java - OOP language vs platform• Java vs C#• Components & Controls vs
JavaBeans• PME (Property – Method – Event)
model• JUMP & J#• Java – COM bridges• IKVM.net • Web Services• WSRP : Web Services for Remote
Portlets
Java as an OOP language
• Inheritance, Polymorphism, Dynamic Class Loading, Exceptions...
• Great esteem and proved record at academia
• Multitude of related libraries and software, mainly OpenSource
• Lots of new programmers introduced to the Java language during their studies
Java as a platform
• Java 1.x – command line, AWT and Applets
• Java 1.2, 1.3, … = Java 2 (JFC/Swing, …)– JavaSE (= Standard Edition –
Desktops)– JavaEE (= Enterprise Edition –
Servers)– JavaME (= Micro Edition – Mobiles)
• (Re)focus JavaFX (Java vs JavaScript)
The future of Java?
• Change in priorities– Sun Microsystems Oracle– JDeveloper vs NetBeans IDE– Java Cloud, Java.net Kenai
Java.net
• Copyright issues– Sun vs Microsoft (MSJVM)–Oracle vs Google (Android Dalvik
VM)
• No standardization by established international organisations (ISO pull-out)
Economics & work conditions:• Competitive• Fluctuating Worker mobility
Reuse:• Code• Skills Flexibility = invaluable ally
Java vs C#
Anders Hejlsberg • original author of Turbo Pascal• chief architect of Delphi• J++, WFC (Windows Foundation
Classes)• lead architect of C#• LINQ (Language Integrated
Query)
C# = Java + Object Pascal (Delphi) + VB ++
Components
Unstructured Data
Record = Structured, Addressable (Name, Pos) Data
Object = Record + Methods to manipulate its data
Component = Object + PME + Resources (Packaging)
Agent = Component + (Internal) Logic / Program Loop
Controls / Widgets
Control / Widget = User Interface Component
JavaBeans:• Components (non visible)• Controls (usually JFC/Swing /
Model-ViewController [M-VC])• Enterprise JavaBeans “similar”
to COM+ components (not much related to typical JavaBeans) for J2EE
PME (Property-Method-Event)
• Properties (get/set accessors, metadata)
• Methods (OOP)• Events– Java: initially tightly-coupled (base
classes / abstract methods), later on callback interfaces
– VB: method signatures (WithEvents)
–Object Pascal / Delphi: method variables
– C#: delegates
JUMP & J# (Microsoft)
• JUMP– Import Java “projects” from Visual
Studio– Convert Java code to C#
• J#– Java compiler IL code, not Java
bytecode– Java datatype boxing– Java 1.x class library, Swing &
Collections API
• Up until Visual Studio 2005
• JACOB (OpenSource)COM Automation from Java via JNI wrappers
• jacoZoomActiveX Controls / Servers ([D]COM / Automation)
• J-Integra .COMDCOM wire protocol (ORPC) to pure Java
• J-Integra .NET.NET Remoting wire protocol to pure Java, Visual Studio & Eclipse plugins
Java – COM/.NET bridges (1)
• COMConnectJava COM/.NET – stateful TCP, low latency
• Jni4net (OpenSource)intra-process, object oriented, JNI implementation
• JNBridgeProVisual Studio & Eclipse plugins, shared memory, sockets, network binary protocol, HTTP/SOAP• EZ JComJavaCOM/.NET, drag-drop Swing components
Java – COM/.NET bridges (2)
• Java Plug-in (JavaBeans Bridge for ActiveX)
Sun/Oracle Java VM, Web Browser integration, JavaBeans ActiveX controls (typelibrary)
• Java C# Bridge (OpenSource)Serlializing/Deserlializing Java - C# objects, manual author C# object or use generic JavaObject and dynamic query• Caffeine (OpenSource)Hosting JVM in .NET Runtime, JNI OOP wrapper• R-JAX (pioneering, RMI/HTTP,
obsolete)
Java – COM/.NET bridges (3)
JNBridgePro – Call Java from .NET
JNBridgePro – Call Java from .NET (1)
JNBridgePro – Call Java from .NET (2)Start Proxy Generator
JNBridgePro – Call Java from .NET (3)Edit Classpath
JNBridgePro – Call Java from .NET (4)Class Path Entries
JNBridgePro – Call Java from .NET (5)Load Classes
JNBridgePro – Call Java from .NET (6)Load Classes Progress
JNBridgePro – Call Java from .NET (7)Choose Proxies
JNBridgePro – Call Java from .NET (8)Generate Proxies
JNBridgePro – Call Java from .NET (9)Use the Proxies
JNBridgePro – Call Java from .NET (10)Call Java Methods
JNBridgePro – Call Java from .NET (11)Run the Program
JNBridgePro – Call Java from .NET
1. Visually generate proxies: allow .Net access Java classes
2. Link .NET proxy assembly to .NET development project (Add Reference)
3. Write .NET code to access Java classes (with IntelliSense)
4. Edit configuration - specify communications mechanism (from in-process on same machine to cross-network)
5. Run integrated .NET and Java code (managed lifecycles)
JNBridgePro – Call .NET from Java
JNBridgePro – Call .NET from Java (1)
JNBridgePro – Call .NET from Java (2)Start Proxy Generator
JNBridgePro – Call .NET from Java (3)Add Assembly
JNBridgePro – Call .NET from Java (4)Assembly List Entries
JNBridgePro – Call .NET from Java (5)Load Classes
JNBridgePro – Call .NET from Java (6)Load Class Progress
JNBridgePro – Call .NET from Java (7)Choose Proxies
JNBridgePro – Call .NET from Java (8)Generate Proxies
JNBridgePro – Call .NET from Java (9)
Use the Proxies
JNBridgePro – Call .NET from Java (10)Call .NET Objects
JNBridgePro – Call .NET from Java (11)Run the Program
JNBridgePro – Call .NET from Java
1. Visually generate proxies: allow Java access .NET classes
2. Reference Java proxy .JAR file from Java development project (place in build CLASSPATH)
3. Write Java code to access .NET classes
4. Edit configuration - specify communications mechanism (from in-process on same machine to cross-network)
5. Run integrated .NET and Java code (managed lifecycles)
JNBridgePro – Visual Studio plugin
JNBridgePro – Eclipse plugin
JNBridgePro – Communications
IKVM.net (Jeroen Frijters)
Java Virtual Machine (JVM) implementation:• Microsoft .NET Framework• Mono
Components:• Java Virtual Machine in .NET• Java class libraries in .NET• Java - .NET interoperability tools
IKVM.net – usage scenarios
• Use as typical Java Virtual Machine (JVM)
• Use Java libraries in .ΝΕΤ applications
• Develop .NET applications in Java language
IKVM.net – usage scenarios
Use as typical Java Virtual Machine (JVM)
Drop-in replacement:java -jar myapp.jar
ikvm -jar myapp.jar
IKVM.net – usage scenarios
Use Java libraries in .ΝΕΤ applications
ikvmc = Java bytecode .NET IL
ikvmc -target:library mylib.jar
mylib.dll
π.χ. Apache FOP = XSL-FO processor (XML PDF)
IKVM.net – usage scenarios
Develop .NET applications in Java language
ikvmc = Java bytecode .NET IL
ikvmc -target:exe myapp.jar
myapp.exe
IKVM.net
Call .NET API from Java (in IKVM.net JVM)
ikvmstub = Java stubs from .NET
API
ikvmstub mscorlib.dll
mscorlib.jar
ikvmstub c:\lib\mylib.dll
IKVM.net – integration / tools
• Mono (OpenSource .NET by Novell)
• MonoDevelop (IDE)
• Ant (task for ikvmc)
• Jar2ikvmc (folder of dependent JARs)
IKVM.net integrationAnt task for ikvmc
<ikvmc target="exe" out="hello.exe" home="c:/ikvm-0.36.0.11" version="1.0.0.0“ debug="true“ main="net.sf.ant-ikvmc.Hello"> <fileset dir="${build}"> <include name="**/*.class"/> </fileset> <fileset dir="${lib}"> <include name="**/*.jar"/> </fileset></ikvmc>
IKVM.net integrationJar2ikvmc (folder of dependent JARs)jar2ikvmc.exe JFreeChart JFreeChart2Net.cmd
ikvmc swtgraphics2d.jar -target:library ikvmc servlet.jar -target:library ikvmc junit.jar -target:library ikvmc jcommon-1.0.10.jar -target:library ikvmc gnujaxp.jar -target:library ikvmc itext-2.0.2.jar -target:library -r:gnujaxp.dllikvmc jfreechart-1.0.6.jar -target:library -r:jcommon-1.0.10.dll → -r:servlet.dll -r:gnujaxp.dll...
• Restlet (Java web framework)Expose/Consume RESTful web APIs
• Java Web Services Stack (Metro)– JAX-WS (Java API for XML Web
Services)– JAXB (Java Architecture for XML
Binding)–WSIT (Web Services Interoperability
Technologies [aka Project Tango])–WSIT (Tango) corresponds to WCF
(Indigo)
Web Services
• Portlet = interactive application component, produces markup segments, aggregated and presented in portals
• WSRP = interactive web services focused to presentation
content & apps: discoverable & pluggable
Web Services for Remote Portlets
Why WSRP instead of simple Web Services?
• Localization
• Mime types
• Portlet modes (edit, help, view,
custom)
• Window states (minimized,
maximized, solo, normal)
Web Services for Remote Portlets
Why remote portlets?
• Ease of configuration
• Platform independence
• Scalability
Web Services for Remote Portlets
WSRP Producer
• Web Service
• Provides 1 or more Portlets
• Implements WSRP
interfaces/operations
• Can provide runtime (container)
for deploying/management of >1
portlet
Web Services for Remote Portlets
WSRP Consumer
• Web Service client
• Usually a portal
• Calls producer WSRP web
services
• Provides environment to interact
with portlets the Producers
provide
Web Services for Remote Portlets
• Producers (.NET WSRP)
–NetUnity SharePoint WSRP
Producer
–Oracle WebCenter .NET Accelerator
• Consumers (WSRP .NET)
–Microsoft WSRP Toolkit - SharePoint
2007
–NetUnity WSRP Consumer for
SharePoint
–NetUnity WSRP .NET Consumer
Web Services for Remote Portlets
• C# and Java comparison (Wikipedia)
o http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java
• Anders Hejlsberg (Wikipedia)o http://en.wikipedia.org/wiki/Anders_Heljsberg
• Java ISO pull-out (ECMA fast track to ISO)
o http://www.crn.com/news/channel-programs/18806978/sun-drops-iso-java-standards-effort-for-good.htm
• Oracle vs Google Android (Dalvik VM)
o http://www.businessweek.com/news/2010-08-13/oracle-says-google-android-violates-its-java-patents.html
References (1)
• Java Native Interface (JNI)o http://
download.oracle.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html
• JACOBo http://sourceforge.net/projects/jacob-project
• jacoZoomo http://www.infozoom.de/en_jacoZoom.shtml
• J-Integrao http://j-integra.intrinsyc.com
References (2)
• COMConnecto http://sourceforge.net/projects/comconnect
• jni4neto http://jni4net.sourceforge.net
• JNBridgeProo http://www.jnbridge.como http://www.jnbridge.com/jnbpro.htm
• EZ JComo http://www.ezjcom.como http://www.ezjcom.com/java.net.html
References (3)
• Java Plug-in (JavaBeans Bridge for ActiveX)
o http://www.oracle.com/technetwork/java/index-jsp-141438.html
o http://download.oracle.com/javase/1.4.2/docs/guide/beans/axbridge/developerguide/index.html
o http://download.oracle.com/javase/1.4.2/docs/guide/beans/axbridge/developerguide/examples.html
• Java C# Bridgeo http://java-cs-bridge.sourceforge.net
• Caffeineo http://caffeine.berlios.de/siteo http://
www.codeproject.com/KB/dotnet/Espresso.aspxo http://lsd.luminis.nl/java-net-interoperability/
References (4)
• IKVM.neto http://www.ikvm.neto http://sourceforge.net/apps/mediawiki/ikvmo http://ant-ikvmc.sourceforge.neto http://code.google.com/p/jar2ikvmc
• JDK, JavaFX SDK & NetBeans IDEo http://
www.oracle.com/technetwork/java/index.html
o http://www.java.com (Java Runtime)
References (5)
• .NET Framework & Visual Studio IDE
o http://www.microsoft.com/neto http://msdn.microsoft.com/en-us/vstudio/default.asp
xo http://www.microsoft.com/expresso http://
msdn.microsoft.com/en-us/library/ff649514.aspx
• Mono & MonoDevelop IDE• http://www.mono-project.com• http://monodevelop.com
• Eclipse Platform & IDEo http://www.eclipse.org
References (6)
• Restlet (RESTful web framework for Java)
o http://www.restlet.org
• Java Web Services Stack (Metro)• http://
www.oracle.com/technetwork/java/index-jsp-137004.html
• http://jax-ws.java.net (JAX-WS / JSR 224)• https://jaxb.dev.java.net (JAXB / JSR 222)• http://wsit.java.net (WSIT)• http://policy.dev.java.net (WS-Policy)• http://xwss.dev.java.net (WS-Security)• http://
netbeans.org/images_www/articles/interviews/wsit-netbeans-plugin.html
• Java Portlet Specificationo http://en.wikipedia.org/wiki/JSR_168 /
References (7)
• WSRP (Web Services for Remote Portlets)
o http://en.wikipedia.org/wiki/Web_Services_for_Remote_Portlets
o http://www.ibm.com/developerworks/webservices/library/ws-wsrp
o https://wsrp.dev.java.neto http://
www.oasis-open.org/committees/tc_home.php?wg_abbrev=wsrp
o http://www.oasis-open.org/committees/download.php/3343/oasis-200304-wsrp-specification-1.0.pdf
o http://www.oasis-open.org/committees/download.php/21178/wsrp-primer-1.0.html
o http://www.oasis-open.org/committees/download.php/11774/wsrp-faq-draft-0.30.html
References (8)
• WSRP Toolkit for SharePoint 2007
• http://code.msdn.microsoft.com/WSRPToolkit
• NetUnity SharePoint & .NET WSRP Consumers
o http://www.netunitysoftware.com/Home.aspx
o Oracle WebCenter .NET Accelerator
o http://blogs.oracle.com/fusionecm/2010/05/webcenter_net_accelerator_-_mi.html
References (9)