java technology and .net ui interoperability: how to mix and match
TRANSCRIPT
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
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
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
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
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.
2007 JavaOneSM Conference | Session TS-3888 | 6
Types of Interop—Tiers
• Presentation• Application• Resource
• Shared database• Asynchronous• Messaging
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
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
2007 JavaOneSM Conference | Session TS-3888 | 9
Types of Interop—Presentation Tier Web Services
JavaTechnology
.NET JavaTechnology
.NETPresentation Tier
Application Tier
2007 JavaOneSM Conference | Session TS-3888 | 10
Types of Interop—.NET UI Technologies
• Windows Forms (WinForms)• Windows Presentation Foundation (WPF)• Silverlight (WPF/E)
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 ? ?
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
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
2007 JavaOneSM Conference | Session TS-3888 | 14
Calling Invocation InterfaceC#
Managed C++
Managed C++
Unmanaged C++
JavaCode
2007 JavaOneSM Conference | Session TS-3888 | 15
Peers
What about Swing?
Java component
Win32 window
2007 JavaOneSM Conference | Session TS-3888 | 16
Window Handles
…
HandleHandle Table
Object
2007 JavaOneSM Conference | Session TS-3888 | 17
Obtaining the Peer’s Handle1) Surround Java component with Frame
2007 JavaOneSM Conference | Session TS-3888 | 18
Obtaining the Peer’s HandleGet handle of frame’s drawing surface
Java Code
Unmanaged C++
2007 JavaOneSM Conference | Session TS-3888 | 19
Set .NET Form as Parentof Java Component
202007 JavaOneSM Conference | Session TS-3888 |
DemoJava Technology in .NET
2007 JavaOneSM Conference | Session TS-3888 | 21
UI Interop Using Bridging
• Bridging• Wrappers• Demo: Java technology in .NET• Demo: .NET in Java technology
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
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
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
252007 JavaOneSM Conference | Session TS-3888 |
DemoJava Technology in .NET
262007 JavaOneSM Conference | Session TS-3888 |
Demo.NET in Java Technology
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
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