java technology and .net ui interoperability: how to mix and match

28
2007 JavaOne SM Conference | Session TS-3888 | Java Technology and .NET UI Interoperability: How to Mix and Match UI Components Wayne Citrin, JNBridge Robert Bell, Microsoft TS-3888

Upload: others

Post on 03-Feb-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 |

Java™ Technology and .NET UI Interoperability: How to Mix and Match UI Components

Wayne Citrin, JNBridge

Robert Bell, Microsoft

TS-3888

Page 2: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 2

Outline

• Why Interop?• Types of Interop• .NET UI Technologies• UI Interop Using Java™ Native Interface (JNI™)• UI Interop Using Bridging• Summary and Conclusion

Page 3: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 3

What Is Interop?

• Interoperability enables communication, data exchange, or program execution among various systems in a way that requires the user to have little or no awareness of the underlying operations of those systems

ISO Information Technology

Page 4: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 4

Why Interop? Business Reasons

• Business moves quickly• Technology moves quickly• Buy for competitive parity, build for competitive

advantage, interoperate for?• Pragmatic• Cost

Page 5: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 5

Why Interop? Technical Reasons

• Most enterprises and ISVs either have or support both technologies

• Benefits• Re-use• Delivery based on technical merit

• Interop is more that Java technology and .NET• SharePoint, Office 2007, SQL Server reporting

services, BizTalk, etc.

Page 6: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 6

Types of Interop—Tiers

• Presentation• Application• Resource

• Shared database• Asynchronous• Messaging

Page 7: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 7

Types of Interop—Presentation Tier

• Web• Axis, JavaServer Pages™ (JSP™) technology,

and servlets• AJAX, ASP.NET

• Smart Client• Applet, Java application• Winforms• WPF• Silverlight

Page 8: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 8

Types of Interop—Presentation Tier

• Business requirement: To replace or extend an existing presentation tier by using the technology of a different platform, or to integrate an application written to a different platform with an existing presentation tier

• Business benefits: Allows selection of the presentation tier based on the best overall user experience, regardless of technology

Page 9: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 9

Types of Interop—Presentation Tier Web Services

JavaTechnology

.NET JavaTechnology

.NETPresentation Tier

Application Tier

Page 10: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 10

Types of Interop—.NET UI Technologies

• Windows Forms (WinForms)• Windows Presentation Foundation (WPF)• Silverlight (WPF/E)

Page 11: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 11

UI Interoperability Matrix

Host.NET Java Technology

WinForms WPF AWT Swing SWT

Embedded

.NETWinForms Y N Y

WPF ? N ?

JavaTechnology

AWT Y YSwing N NSWT ? ?

Page 12: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 12

UI Interop Using JNI Implementation

• Calling the JNI API invocation interface from .NET

• Peers and Windows handles• Cross-platform parent-child assignments• Demo: Embedding Java code in .NET

Page 13: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 13

Calling JNI API InvocationInterface From .NET

• .NET is managed, JNI implementation is unmanaged

• Call through a “hybrid” dll

C++

Unmanaged

JavaTechnology

JNI

API

Hybrid dll (C++ only)

C++

Managed

C#

Managed

Page 14: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 14

Calling Invocation InterfaceC#

Managed C++

Managed C++

Unmanaged C++

JavaCode

Page 15: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 15

Peers

What about Swing?

Java component

Win32 window

Page 16: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 16

Window Handles

HandleHandle Table

Object

Page 17: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 17

Obtaining the Peer’s Handle1) Surround Java component with Frame

Page 18: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 18

Obtaining the Peer’s HandleGet handle of frame’s drawing surface

Java Code

Unmanaged C++

Page 19: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 19

Set .NET Form as Parentof Java Component

Page 20: Java Technology and .NET UI Interoperability: How to Mix and Match

202007 JavaOneSM Conference | Session TS-3888 |

DemoJava Technology in .NET

Page 21: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 21

UI Interop Using Bridging

• Bridging• Wrappers• Demo: Java technology in .NET• Demo: .NET in Java technology

Page 22: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 22

Bridging

InternetInternetIntranetIntranet

SocketSocket--based based TCP/Binary TCP/Binary

Communications Communications ChannelChannel

JNBridgePro Runtime

Component

Java Technology Side

User Java Code

User .NETCode

SharedMemory

Communications Channel

JNBridgePro Runtime

Component

.NET Side

Process

Machine

Page 23: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 23

Wrappers: Java Technology in .NET

Proxied JavaUI component

JavaControl .NET wrapper

.NET WPF app

JavaUI component

extends UserControl

Page 24: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 24

Wrappers: .NET in Java Technology

DotNetControl or DotNetSWTControl wrapper

Extends Canvas or Composite

AWT or SWT app

.NETUI Component

Proxied .NETUI Component

Page 25: Java Technology and .NET UI Interoperability: How to Mix and Match

252007 JavaOneSM Conference | Session TS-3888 |

DemoJava Technology in .NET

Page 26: Java Technology and .NET UI Interoperability: How to Mix and Match

262007 JavaOneSM Conference | Session TS-3888 |

Demo.NET in Java Technology

Page 27: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 | 27

Summary and Conclusion

• Variety of reasons for Java technology/ .NET interop

• UI interop• Mix and match most appropriate components

for the task• Make your Java components available to .NET users

• Techniques• JNI implementation• Bridging

Page 28: Java Technology and .NET UI Interoperability: How to Mix and Match

2007 JavaOneSM Conference | Session TS-3888 |

Java™ Technology and .NET UI Interoperability: How to Mix and Match UI Components

Wayne Citrin, JNBridge

Robert Bell, Microsoft

TS-3888