2006 05 11 integrating java and dotnet
TRANSCRIPT
-
8/8/2019 2006 05 11 Integrating Java and DotNet
1/26
Integrating OpenROADwith Java and .NET
1
David Tondreau
Architect
1
-
8/8/2019 2006 05 11 Integrating Java and DotNet
2/26
Agenda
OpenROAD Server Primer
OpenROAD Servers COM Interface
OpenROAD and the Java Wrapper
2
OpenROAD and the C# Wrapper
-
8/8/2019 2006 05 11 Integrating Java and DotNet
3/26
The OpenROAD Server
Middle Tier Component
Business logic written in OpenROAD
SQL built into the language
Access multiple databases via gateways
3
-
Allows multiple thin clients
Communication via DCOM (even from OpenROAD clients!)
Business logic accessed using remote procedure calls (RPC)
Applications become highly scalable because databaseresources are shared (i.e, 1 db connection = many clients)
-
8/8/2019 2006 05 11 Integrating Java and DotNet
4/26
Partitioning OpenROAD Applications
Separation of business logic
OpenROAD user classes and 4GL procedures which contain businesslogic are placed in a separate application
May need to separate business logic from user interface logic!
Creation of remote procedure calls
4
4GL procedures (called Service Call Procedures or SCPs) are createdmanually or generated
SCPs allow methods of server-based user classes to be called remotely
Deployment
The server application is imaged
The application is registered in the server as a logically named resource
VASA stores registration information in the Windows registry
-
8/8/2019 2006 05 11 Integrating Java and DotNet
5/26
Client Access to the OpenROAD Server
Support OpenROAD
and COM clients
All clients follow threeOpenROAD Server Pooler
DCOM
OpenROAD Server
Client
DCOM
5
Connection using theName Server
One or more SCP calls
Release of connection
OpenROAD4GL Server
OpenROAD4GL Server
OpenROAD4GL Server
4GL4GL4GL
Ingres/Net
IngresDBMS
OpenROADNameServer
Registry
-
8/8/2019 2006 05 11 Integrating Java and DotNet
6/26
OpenROAD Client Access to the Server
Uc_Name_Server_Client 4GL Class
Provides the functions to connect and disconnect to the server Connect() and Disconnect()
Global instance (ASONameServer) declared in the runtime
RemoteServer System Class
6
Holds the connection to the to the server Provides the function to call server SCPs
Call4GL()
Provides low level means to connect (not recommended!) Initiate()
Global instance (CurRemoteServer) declared in the runtime Handles parameters to remote calls automatically
-
8/8/2019 2006 05 11 Integrating Java and DotNet
7/26
Simple Example
OpenROAD User Class
Class: EmployeeObject
Attributes
EmpID, FirstName, LastName, HireDate,
7
Methods GetEmployeeData()
METHOD GetEmployeeData () =METHOD GetEmployeeData () =METHOD GetEmployeeData () =METHOD GetEmployeeData () ={{{{
SELECT :CurObject.FirstName = First_Name,SELECT :CurObject.FirstName = First_Name,SELECT :CurObject.FirstName = First_Name,SELECT :CurObject.FirstName = First_Name,:CurObject.LastName = Last_Name,:CurObject.LastName = Last_Name,:CurObject.LastName = Last_Name,:CurObject.LastName = Last_Name,:CurObject.HireDate = Hire_Date:CurObject.HireDate = Hire_Date:CurObject.HireDate = Hire_Date:CurObject.HireDate = Hire_Date
FROM EmployeeFROM EmployeeFROM EmployeeFROM EmployeeWHERE Emp_ID = :CurObject.EmpID;WHERE Emp_ID = :CurObject.EmpID;WHERE Emp_ID = :CurObject.EmpID;WHERE Emp_ID = :CurObject.EmpID;
}}}}
-
8/8/2019 2006 05 11 Integrating Java and DotNet
8/26
Simple Example
OpenROAD Fat Client
EmployeeObject EmployeeEmployeeObject EmployeeEmployeeObject EmployeeEmployeeObject Employee
On Click GoButtonOn Click GoButtonOn Click GoButtonOn Click GoButton
8
{{{{Employee.GetEmployeeData();Employee.GetEmployeeData();Employee.GetEmployeeData();Employee.GetEmployeeData();FIELD(Employee).UpdField();FIELD(Employee).UpdField();FIELD(Employee).UpdField();FIELD(Employee).UpdField();
}}}}
-
8/8/2019 2006 05 11 Integrating Java and DotNet
9/26
Simple Example
Create a new application for the server Needs to include the business objects like the EmployeeObject
Create a Service Call Procedure
Procedure EmployeeObject_GetEmployeeDataProcedure EmployeeObject_GetEmployeeDataProcedure EmployeeObject_GetEmployeeDataProcedure EmployeeObject_GetEmployeeData((((
Employee = EmployeeObject;Employee = EmployeeObject;Employee = EmployeeObject;Employee = EmployeeObject;====
9
{{{{
Employee.GetEmployeeData();Employee.GetEmployeeData();Employee.GetEmployeeData();Employee.GetEmployeeData();}}}}
Create a starting ghost framefor the application
Image the server application
Register the applicationusing VASA
-
8/8/2019 2006 05 11 Integrating Java and DotNet
10/26
Simple Example
10
-
8/8/2019 2006 05 11 Integrating Java and DotNet
11/26
Simple Example
OpenROAD Thin Client
EmployeeObject EmployeeEmployeeObject EmployeeEmployeeObject EmployeeEmployeeObject Employee
Initialize () =Initialize () =Initialize () =Initialize () ={{{{
ASONameServer.Connect(ASONameServer.Connect(ASONameServer.Connect(ASONameServer.Connect(P_V_Name = HumanResources,P_V_Name = HumanResources,P_V_Name = HumanResources,P_V_Name = HumanResources,
11
_ __ __ __ _
}}}}On Click GoButton =On Click GoButton =On Click GoButton =On Click GoButton ={{{{
CurRemoteServer.Call4GL(EmployeeObject_GetEmployeeData,CurRemoteServer.Call4GL(EmployeeObject_GetEmployeeData,CurRemoteServer.Call4GL(EmployeeObject_GetEmployeeData,CurRemoteServer.Call4GL(EmployeeObject_GetEmployeeData,Employee = BYREF(Employee))Employee = BYREF(Employee))Employee = BYREF(Employee))Employee = BYREF(Employee))
FIELD(Employee).UpdField();FIELD(Employee).UpdField();FIELD(Employee).UpdField();FIELD(Employee).UpdField();}}}}
On WindowClose =On WindowClose =On WindowClose =On WindowClose ={{{{
CurRemoteServer.Release();CurRemoteServer.Release();CurRemoteServer.Release();CurRemoteServer.Release();}}}}
-
8/8/2019 2006 05 11 Integrating Java and DotNet
12/26
COM Client Access to the Server
ASOSession Class Provides the functions to connect and disconnect from the server
Connect() and Disconnect()
Provides the function to call the server using PM CallProc()
RemoteServer Class
12
Holds the connection to the to the server Provides low level means to connect (not recommeded!)
Initiate()
Provides the function to call server SCPs Call4GL()
ParameterData Provides the functions to pack and unpack SCP parameter data
getXXX() and setXXX()
-
8/8/2019 2006 05 11 Integrating Java and DotNet
13/26
-
8/8/2019 2006 05 11 Integrating Java and DotNet
14/26
Benefits/Drawbacks of the COM Interface
Benefits
Use Microsoft Office as a client
Use ASP web server as client
14
Have to declare parameter descriptions
Have to pack/repack parameter data
COM clients mostly Windows not Unix
-
8/8/2019 2006 05 11 Integrating Java and DotNet
15/26
OpenROAD Java Wrapper
Mirrors COM components
Uses the Java Native Interface (JNI)
Same method functionality as COM components
15
Conforms to Java naming standards
Errors raise COMExceptions
Available on Unix and Windows
-
8/8/2019 2006 05 11 Integrating Java and DotNet
16/26
Java Interface Classes
com.ingres.openroad.ASOSession
Wraps an instance of the OpenROAD.RemoteServer COM class.
com.ingres.openroad.RemoteServer
Wraps an instance of the OpenROAD.RemoteServer COM class.
16
com.ingres.openroad.ParameterData Wraps an instance of the OpenROAD.ParameterData COM class
com.ingres.openroad.COMException
Class that represents COM errors
Includes a getHRESULT method so that client code can examinethe COM HRESULT value without parsing error message text.
-
8/8/2019 2006 05 11 Integrating Java and DotNet
17/26
OpenROAD vs Java Datatypes
PDO has getXXX and setXXX methods
Five basic type conversions
SmallInt/Integer ..Integer
17
.
Varchar/StringObject..String
Date...Date
LongByteObject...Byte[ ]
Data
-
8/8/2019 2006 05 11 Integrating Java and DotNet
18/26
Proxies
Classes which represent OpenROAD classes
Written in another language (e.g., Java or C#)
Same attribute names
Used for passing data to/from appserver
18
Methods to pack/unpack themselves into ParameterData
SCPs are called from an SCPCoverClass
Methods perform calls to the OpenROAD server
-
8/8/2019 2006 05 11 Integrating Java and DotNet
19/26
19
-
8/8/2019 2006 05 11 Integrating Java and DotNet
20/26
-
8/8/2019 2006 05 11 Integrating Java and DotNet
21/26
.NET Interface Classes
Ingres.OpenROAD.ParameterData
Wraps an instance of the OpenROAD.ParameterDataCOM class
The default constructor takes no arguments and creates an
21
.
An optional constructor takes a string of attributedeclarations and implicitly does the DeclareAttr calls.
Declaration string is simply a whitespace-delimited list of attrNameattrType pairs
-
8/8/2019 2006 05 11 Integrating Java and DotNet
22/26
OpenROAD vs .NET Datatypes
Unlike Java, the .NET runtime treats all types as objects
Including the basic value types, like integer or double.
.NET PDO data access methods take and return objects
No type-specific get/set methods as in Java
Caller must cast the returned object to the relevant subtype before using
22
it.
Null values
In Java, a null object reference maps to the VT_NULL VARIANT
Null OpenROAD values are represented as null Java object references.
The .NET to COM interface maps null object references to VT_EMPTY VT_NULL is mapped to a special object type of class System.DBNull.
-
8/8/2019 2006 05 11 Integrating Java and DotNet
23/26
Exception Handling
In Java, all failures from the COM interface are reportedby throwing a com.ingres.openroad.COMException will
contain the HRESULT value
The .NET COM interface is similar Uses the System.Runtime.InteropServices.COMException class.
23
However, it uses that exception class only as a last resort!!
If a .NET exception class exists that represents the meaning of aparticular HRESULT, .NET throws the .NET exception instead ofa COMException.
E.g., HRESULT 0x80070005 Access Denied is reported asSystem.UnauthorizedAccessException.
Therefore, a single catch clause for COMException will not pickup all possible HRESULT failures.
-
8/8/2019 2006 05 11 Integrating Java and DotNet
24/26
IDisposable Interface
.NET classes implement the IDisposable
interface Provides a Dispose method to release unmanaged
resources owned by the object instance
-
24
.NET. The release method provides the equivalent functionality
in the Java classes.
Requirement to call Dispose when finished using an object
instance is similar to the requirement to call release in theJava classes.
-
8/8/2019 2006 05 11 Integrating Java and DotNet
25/26
25
-
8/8/2019 2006 05 11 Integrating Java and DotNet
26/26
Proxy Generator (Java Example)
26