it pro dev_birbilis_20101127_en

68
Life after Java Reusing code and skills in a .NET world

Upload: george-birbilis

Post on 29-Nov-2014

1.199 views

Category:

Technology


8 download

DESCRIPTION

Life after Java - Reusing Code and Skills in a .NET world / presentation at ITProDevConnections 2010 - http://www.itprodevconnections.gr

TRANSCRIPT

Page 1: It pro dev_birbilis_20101127_en

Life after Java

Reusing code and skills in a .NET world

Page 2: It pro dev_birbilis_20101127_en

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

Page 3: It pro dev_birbilis_20101127_en

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

Page 4: It pro dev_birbilis_20101127_en

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)

Page 5: It pro dev_birbilis_20101127_en

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)

Page 6: It pro dev_birbilis_20101127_en

Economics & work conditions:• Competitive• Fluctuating Worker mobility

Reuse:• Code• Skills Flexibility = invaluable ally

Page 7: It pro dev_birbilis_20101127_en

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 ++

Page 8: It pro dev_birbilis_20101127_en

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

Page 9: It pro dev_birbilis_20101127_en

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

Page 10: It pro dev_birbilis_20101127_en

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

Page 11: It pro dev_birbilis_20101127_en

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

Page 12: It pro dev_birbilis_20101127_en

• 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)

Page 13: It pro dev_birbilis_20101127_en

• 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)

Page 14: It pro dev_birbilis_20101127_en

• 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)

Page 15: It pro dev_birbilis_20101127_en

JNBridgePro – Call Java from .NET

Page 16: It pro dev_birbilis_20101127_en

JNBridgePro – Call Java from .NET (1)

Page 17: It pro dev_birbilis_20101127_en

JNBridgePro – Call Java from .NET (2)Start Proxy Generator

Page 18: It pro dev_birbilis_20101127_en

JNBridgePro – Call Java from .NET (3)Edit Classpath

Page 19: It pro dev_birbilis_20101127_en

JNBridgePro – Call Java from .NET (4)Class Path Entries

Page 20: It pro dev_birbilis_20101127_en

JNBridgePro – Call Java from .NET (5)Load Classes

Page 21: It pro dev_birbilis_20101127_en

JNBridgePro – Call Java from .NET (6)Load Classes Progress

Page 22: It pro dev_birbilis_20101127_en

JNBridgePro – Call Java from .NET (7)Choose Proxies

Page 23: It pro dev_birbilis_20101127_en

JNBridgePro – Call Java from .NET (8)Generate Proxies

Page 24: It pro dev_birbilis_20101127_en

JNBridgePro – Call Java from .NET (9)Use the Proxies

Page 25: It pro dev_birbilis_20101127_en

JNBridgePro – Call Java from .NET (10)Call Java Methods

Page 26: It pro dev_birbilis_20101127_en

JNBridgePro – Call Java from .NET (11)Run the Program

Page 27: It pro dev_birbilis_20101127_en

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)

Page 28: It pro dev_birbilis_20101127_en

JNBridgePro – Call .NET from Java

Page 29: It pro dev_birbilis_20101127_en

JNBridgePro – Call .NET from Java (1)

Page 30: It pro dev_birbilis_20101127_en

JNBridgePro – Call .NET from Java (2)Start Proxy Generator

Page 31: It pro dev_birbilis_20101127_en

JNBridgePro – Call .NET from Java (3)Add Assembly

Page 32: It pro dev_birbilis_20101127_en

JNBridgePro – Call .NET from Java (4)Assembly List Entries

Page 33: It pro dev_birbilis_20101127_en

JNBridgePro – Call .NET from Java (5)Load Classes

Page 34: It pro dev_birbilis_20101127_en

JNBridgePro – Call .NET from Java (6)Load Class Progress

Page 35: It pro dev_birbilis_20101127_en

JNBridgePro – Call .NET from Java (7)Choose Proxies

Page 36: It pro dev_birbilis_20101127_en

JNBridgePro – Call .NET from Java (8)Generate Proxies

Page 37: It pro dev_birbilis_20101127_en

JNBridgePro – Call .NET from Java (9)

Use the Proxies

Page 38: It pro dev_birbilis_20101127_en

JNBridgePro – Call .NET from Java (10)Call .NET Objects

Page 39: It pro dev_birbilis_20101127_en

JNBridgePro – Call .NET from Java (11)Run the Program

Page 40: It pro dev_birbilis_20101127_en

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)

Page 41: It pro dev_birbilis_20101127_en

JNBridgePro – Visual Studio plugin

Page 42: It pro dev_birbilis_20101127_en

JNBridgePro – Eclipse plugin

Page 43: It pro dev_birbilis_20101127_en

JNBridgePro – Communications

Page 44: It pro dev_birbilis_20101127_en

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

Page 45: It pro dev_birbilis_20101127_en

IKVM.net – usage scenarios

• Use as typical Java Virtual Machine (JVM)

• Use Java libraries in .ΝΕΤ applications

• Develop .NET applications in Java language

Page 46: It pro dev_birbilis_20101127_en

IKVM.net – usage scenarios

Use as typical Java Virtual Machine (JVM)

Drop-in replacement:java -jar myapp.jar

ikvm -jar myapp.jar

Page 47: It pro dev_birbilis_20101127_en

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)

Page 48: It pro dev_birbilis_20101127_en

IKVM.net – usage scenarios

Develop .NET applications in Java language

ikvmc = Java bytecode .NET IL

ikvmc -target:exe myapp.jar

myapp.exe

Page 49: It pro dev_birbilis_20101127_en

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

Page 50: It pro dev_birbilis_20101127_en

IKVM.net – integration / tools

• Mono (OpenSource .NET by Novell)

• MonoDevelop (IDE)

• Ant (task for ikvmc)

• Jar2ikvmc (folder of dependent JARs)

Page 51: It pro dev_birbilis_20101127_en

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>

Page 52: It pro dev_birbilis_20101127_en

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...

Page 53: It pro dev_birbilis_20101127_en

• 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

Page 54: It pro dev_birbilis_20101127_en

• 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

Page 55: It pro dev_birbilis_20101127_en

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

Page 56: It pro dev_birbilis_20101127_en

Why remote portlets?

• Ease of configuration

• Platform independence

• Scalability

Web Services for Remote Portlets

Page 57: It pro dev_birbilis_20101127_en

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

Page 58: It pro dev_birbilis_20101127_en

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

Page 59: It pro dev_birbilis_20101127_en

• 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

Page 62: It pro dev_birbilis_20101127_en

• 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)

Page 63: It pro dev_birbilis_20101127_en

• 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)

Page 65: It pro dev_birbilis_20101127_en

• .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)

Page 66: It pro dev_birbilis_20101127_en

• 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)

Page 67: It pro dev_birbilis_20101127_en

• 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)

Page 68: It pro dev_birbilis_20101127_en

• 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)