page 1, june 3, 2015 cbse – graduate course an introduction to com, ejb.net and corba component...

69
Page 1, March 13, 2022 CBSE – graduate course An Introduction to COM, EJB An Introduction to COM, EJB .NET and CORBA .NET and CORBA Component Technologies Component Technologies Magnus Larsson

Post on 19-Dec-2015

224 views

Category:

Documents


3 download

TRANSCRIPT

Page 1, April 18, 2023CBSE – graduate course

An Introduction to COM, EJBAn Introduction to COM, EJB

.NET and CORBA.NET and CORBA

Component TechnologiesComponent TechnologiesMagnus Larsson

Page 2, April 18, 2023CBSE – graduate course

Different TechnologiesDifferent Technologies

COM/DCOM, COM+

EJB

.NET

CORBA/CCM

Page 3, April 18, 2023CBSE – graduate course

An Introduction to COMAn Introduction to COM

Page 4, April 18, 2023CBSE – graduate course

Key-Concepts of COMKey-Concepts of COM

COM interfaces and COM classes

Uniquely identified by GUIDs

A class may implement several interfaces

Several classes may implement the same interface

COM servers

Are either in-process (.dll) or out-of-process (.exe)

A server may implement several classes

The COM library

Used by clients to create COM objects

Page 5, April 18, 2023CBSE – graduate course

A Simple COM ObjectA Simple COM Object

A COM object has methods and state

Language independent

All Access is through the interface

Supports multiple interfaces

Each interface has a GUID

Page 6, April 18, 2023CBSE – graduate course

IUnkownIUnkown

All COM objects must implement IUnknown

AddRef

Release

QueryInterface IUnknown

Page 7, April 18, 2023CBSE – graduate course

IUnknownIUnknown

Contains only three methods

HRESULT QueryInterface(GUID iid, void **iptr);

ULONG AddRef();

ULONG Release();

QueryInterface is used for Interface Navigation

AddRef and Release is used for reference counting

A form of collaborative carbage collection

Page 8, April 18, 2023CBSE – graduate course

The COM LibraryThe COM Library

A traditional C API

Most used function is probably

HRESULT CoCreateInstance(GUID clsid, // Which classIUnknown *pOuter, // For aggregation (opt.)DWORD dwClsCtx, // Locality spec. (opt.)GUID iid, // Which interfacevoid **pi); // Returns pointer to interface

Example (simplified):

IMyObject *p = 0;CoCreateInstance(C_MyObj, 0, 0, I_MyObj, (void **) &p);

Page 9, April 18, 2023CBSE – graduate course

Specifying InterfacesSpecifying Interfaces

COM defines a binary standard for interfaces

Language independent implementation of the interfaces

Interfaces are defined in Interface Definition Language (IDL)

An interface has an GUID as an indentifier

IUnknown

IDispatch

Page 12, April 18, 2023CBSE – graduate course

Traditional Access of ServicesTraditional Access of Services

Operating System

Operating System

Library calls

IPC

Network Communication

System calls

Page 13, April 18, 2023CBSE – graduate course

Accessing Services with COM/DCOMAccessing Services with COM/DCOM

Operating System

Operating System

DCOM

COM/Win32COM

COM

Page 14, April 18, 2023CBSE – graduate course

Invocation of a methodInvocation of a method

Remote Procedure Call (RPC) is used

The RPC in DCOM is called Object RPC

Based on Microsoft RPC

Which is itself based on DCE RPC

Operating System

Operating System

DCOM

COM/Win32COM

COM

Page 15, April 18, 2023CBSE – graduate course

Creating a local objectCreating a local object

ObjectObject

Server

Client Application

Client Application

COM LibraryCOM Library

1. CoCreateInstance

3. Return pointer to interface

4. Invoke methods

2. Locate server object

CLSID_X

CLSID_Y Path to server Y

Path to server X

Registry

Page 16, April 18, 2023CBSE – graduate course

Creating a local object using a class factoryCreating a local object using a class factory

ObjectObject

Server

Client Application

Client Application

1. IClassFactory::CreateInstance

4. Invoke methods

2. Create Objectand get

interface pointer

ClassFactoryClass

Factory

3. Return pointer to interface

Page 17, April 18, 2023CBSE – graduate course

Creating a remote objectCreating a remote object

ObjectObject

Server

Client Application

Client Application

COM LibraryCOM Library1. CoCreateInstance

2. Locate server object

3. Return pointer to interface

4. Invoke methods

CLSID_X

... ...

C:\X.exe

Registry

CLSID_X

CLSID_Y D:\Y.exe

Idt.mdh.se

Registry

Idt.mdh.semrtc.mdh.se

Page 18, April 18, 2023CBSE – graduate course

ActiveXActiveX

A marketing name for a set of technologies and services, all based on COM (the model, the “ORB”, and the services)

ActiveX Controls

Are COM components with “design-time” UI

Can be written in C++, Java, VB, Delphi, ...

Self-registering

Optimized for download and execute

Page 19, April 18, 2023CBSE – graduate course

Enterprise Java BeansEnterprise Java Beans

Magnus Larsson

[email protected]

Page 20, April 18, 2023CBSE – graduate course

Two Tier Architecture Two Tier Architecture

DatabaseDatabase

Tier Boundary

BusinessLogic

BusinessLogic

DatabaseDriver

DatabaseDriver

BusinessLogic

BusinessLogic

BusinessLogic

BusinessLogic

PresentationLogic

PresentationLogic

Data Layer

Presentation / Business Layer

Page 21, April 18, 2023CBSE – graduate course

Two Tier ArchitectureTwo Tier Architecture

Deployment costs are high

Database driver switching costs are high

Business logic migration costs are high

The client have to recompile if the BL is changed

Network performance suffers

Page 22, April 18, 2023CBSE – graduate course

N-Tier Architecture N-Tier Architecture

DatabaseDatabase

Tier Boundary

BusinessLogic

BusinessLogic

DatabaseDriver

DatabaseDriver

BusinessLogic

BusinessLogic

BusinessLogic

BusinessLogic

PresentationLogic

PresentationLogic

Data Layer

Business Layer

Tier BoundaryPresentation Layer

Page 23, April 18, 2023CBSE – graduate course

N-Tier ArchitectureN-Tier Architecture

Deployment costs are low

Database switching costs are low

Business migration costs are low

A firewall can secure parts of the deployment

Each tier can vary independently

Communication performance suffers

Maintenance costs are high

Page 24, April 18, 2023CBSE – graduate course

Java BeansJava Beans

Small grained application bits

Building blocks for applications

They are development components and not deployable components

Helps to construct applications that are deployable

“A Java Bean is a reusable software component that can be manipulated visually in a builder tool.”

“A Java Bean is a reusable software component that can be manipulated visually in a builder tool.”

Page 25, April 18, 2023CBSE – graduate course

Enterprise Java BeansEnterprise Java Beans

Enterprise beans

Larger components

Can be deployed

Similar to servlets and applets

Servlets are for the web servcrRequest oriented

Applets for the browser

“Enterprise JavaBeans is a standard server-side component model for component transaction

monitors”

“Enterprise JavaBeans is a standard server-side component model for component transaction

monitors”

Page 26, April 18, 2023CBSE – graduate course

Applets, Servlets and EJBApplets, Servlets and EJB

Web server with servlet engine Java enabled web browser

Application server with component container

ServletsServlets

EnterpriseJavaBeansEnterpriseJavaBeans

AppletsApplets

Page 27, April 18, 2023CBSE – graduate course

Java Remote Method InvocationJava Remote Method Invocation

RMI is an interface used over two protocols

Java Remote Method Protocol (JRMP)

Internet Inter-ORB Protocol (IIOP)

JavaClientJavaClient

CORBAObject

CORBAObject

JavaObjectJava

Object

RMIRMI

JRMP, IIOPJRMP, IIOP

Page 28, April 18, 2023CBSE – graduate course

Interface and ImplementationInterface and Implementation

Separate the interface from the implementation

Java supports this with the interface and class keywords

Page 29, April 18, 2023CBSE – graduate course

Java-Based TechnologiesJava-Based Technologies

RMI

Remote JavaApplication

Java Bean

JavaApp. EJBEJB

Container

Machine X Machine Y

RMI

RMI

Client

Page 30, April 18, 2023CBSE – graduate course

COM-Based TechnologiesCOM-Based Technologies

COM

DCOM

RemoteServer

ActiveX

LocalServer MTSMTS

Container

Machine X Machine Y

DCOM

Client

Page 31, April 18, 2023CBSE – graduate course

CORBA-Based TechnologiesCORBA-Based Technologies

RemoteApplication

LocalApp.

Machine X Machine Y

ClientIIOP

IIOP

Page 32, April 18, 2023CBSE – graduate course

Who is creating the enterprise beans?Who is creating the enterprise beans?

EJBs are created by the EJB Object

The container is responsible for creating and destroying beans

The home object is used to create the EJB Object

Page 33, April 18, 2023CBSE – graduate course

Calling an Enterprise BeanCalling an Enterprise Bean

HomeObjectHomeObject

EJB Container/Server

Client Application

Client Application

1. Call a method

EnterpriseBean

EnterpriseBean

EJBObjectEJB

Object

2. Acquire a bean and delegate thecall to the bean

2. Acquire a bean and delegate thecall to the bean

3.Return result

4. Return to client

Page 34, April 18, 2023CBSE – graduate course

Creating the EJB ObjectCreating the EJB Object

HomeObjectHomeObject

EJB Container/Server

Client Application

Client Application 1. Create EJB Obj.

EnterpriseBean

EnterpriseBean

EJBObjectEJB

Object

2. Create EJB Object

3. Return EJB Obj. Ref.

Page 35, April 18, 2023CBSE – graduate course

1. Retrivehomeobject

2. Return reference

JNDI

Java Naming and Directory InterfaceJava Naming and Directory Interface

Client Application

Client Application

NamingServiceNamingService

Page 36, April 18, 2023CBSE – graduate course

1. Retrivehomeobject

2. Return reference

JNDI

One More TimeOne More Time

HomeObjectHomeObject

EJB Container/Server

Client Application

Client Application 3. Create EJB Obj.

EnterpriseBean

EnterpriseBean

EJBObjectEJB

Object

4. Create EJB Object

5. Return EJB Obj. Ref.

NamingServiceNamingService

6. Call a method

7. Acquire a bean and delegate thecall to the bean

7. Acquire a bean and delegate thecall to the bean

8.Return result

9. Return to client

Page 37, April 18, 2023CBSE – graduate course

Java Application Server TechnologiesJava Application Server Technologies

EJBApplications

EJBApplications

EJB

HTTPListener

HTTPListener

Windows NT, Unix,Others

DBMSDBMS

DBMSDBMS

DBMSDBMS

JSPApplications

JSPApplications

BrowserClient

BrowserClient

RichClient Rich

Client

HTTP

RMI/IIOP

VariousJavaTools

VariousJavaTools

VariousJSP ToolsVarious

JSP Tools

ServletsServlets

JDBCJDBC

JDBCJDBC

JDBCJDBC

Page 38, April 18, 2023CBSE – graduate course

Microsoft Application Server TechnologiesMicrosoft Application Server Technologies

COMApplications

COMApplications

MTS

IISIIS

Windows NT

DBMSDBMS

DBMSDBMS

DBMSDBMS

ASPApplications

ASPApplications

ADOADO

ADOADO

BrowserClient

BrowserClient

RichClient Rich

Client

HTTP

DCOM

VBVC++VJ++

VBVC++VJ++

VisualInterDevVisual

InterDev

Page 39, April 18, 2023CBSE – graduate course

Overview of the .NET FrameworkOverview of the .NET Framework

[email protected]

Page 40, April 18, 2023CBSE – graduate course

.NET Platform .NET Platform

Operating Systems

Common Language Runtime

Base Class Library

ADO.NET and XML

ASP.NET Windows Forms

Common Language Specification

VB C++ C# JScript …V

isual S

tud

io.N

ET

Page 41, April 18, 2023CBSE – graduate course

Common Language RuntimeCommon Language Runtime

Manages running code

Verifies type safety

Provides garbage collection, error handling

Code access security for semi-trusted code

Provides common type system

Value types (integer, float, user defined, etc)

Objects, Interfaces

Provides access to system resources

Native API, COM interop, etc.

Page 42, April 18, 2023CBSE – graduate course

MSIL

Compilation and ExecutionCompilation and Execution

Source Code

Source Code

Language CompilerLanguage Compiler

Compilation

Before installation or the first time each method is calledExecution

JIT Compiler

JIT Compiler

NativeCode

NativeCode

CodeCode

MetadataMetadata

Page 43, April 18, 2023CBSE – graduate course

Common Language RuntimeCommon Language Runtime

Class Loader

IL to NativeCompilers

CodeManager

GarbageCollector

Security Engine Debug Engine

Type Checker Exception Manager

Thread Support COM Marshaler

Base Class Library Support

Page 44, April 18, 2023CBSE – graduate course

Multi-Language DevelopmentMulti-Language Development

Advanced multi-language features

Cross language inheritance, exceptions

Over 20 languages currently supported

VB, C++, C#, Java, JScript, Pearl, COBOL

High leveraged tools

Debuggers, etc work with all languages

Page 45, April 18, 2023CBSE – graduate course

From COM to .NETFrom COM to .NET

COM .NET

Registration self describing components

GUIDs hierarchical namespaces

IDL files source code to metadata

HRESULTs structured exceptions

IUnknown Root object class

AddRef/Release Garbage collector

CoCreateInstance ”new” operator

QueryInterface Type.GetInterface

Page 46, April 18, 2023CBSE – graduate course

From COM to .NETFrom COM to .NET

No registration required

Code is self-describing

xcopy components to application directory

Zero-impact install

Installing one application will not affect another

Using private assemblies

Side-by-side execution

Multiple component versions can co-exist

Using shared assemblies

Page 47, April 18, 2023CBSE – graduate course

Integration with COMIntegration with COM

Deploy .NET classes as COM objects

Register with RegAsm.exe

COM objects can be imported

No ref counting or COM API needed

.Net classes utilize COM+ services

Transactions, Object pooling, etc…

Easily call system functions

No marshaling for common cases

Page 48, April 18, 2023CBSE – graduate course

ASP.NETASP.NET

Page 49, April 18, 2023CBSE – graduate course

ASP.NETASP.NET

Rich page architecture – “Web Forms”

web services support

Modular, factored architecture

The CLR does lazy downloading of external assemblies

Enhanced reliability and availability

Improved performance and scalability

Compiled server side components

Web farms

Page 50, April 18, 2023CBSE – graduate course

ASP.NET Page DevelopmentASP.NET Page Development

Server controls encapsulate behavior

Provide VB-Like Model

Support compiled languages

VB, C#, JScript, COBOL, etc.

Enable separation of code from content

Developers and designers can work independently

Support multiple clients automatically

Rich DHTML, HTML 3.2, etc…

Mobile controls for small devices

Page 51, April 18, 2023CBSE – graduate course

ASP.NET Web ServicesASP.NET Web Services

Simple Programming Model

Author .ASMX Files with Class Methods

ASP.NET compiles on demand, generates WSDL contract, exposes HTML help page

Incoming HTTP messages call methods

No special HTTP or XML knowledge needed

Supports Multiple Message Wire Formats

HTTP Get, Post, and SOAP Requests

Page 52, April 18, 2023CBSE – graduate course

ASP.NET DeploymentASP.NET Deployment

“XCOPY” deployment

No registration required

No stopping the server

Supports all web resources

Web pages, web services

Compiled components (DLL)

Configuration files

Update running applications

Applications gracefully migrated

Page 53, April 18, 2023CBSE – graduate course

Scalable and AvailableScalable and Available

Special support for multi-proc scaling

Scalable GC, multi-process applications

Web farm scalable session state

ASP.NET State Service, SQL Server

Detects and recovers from failures

Crashes, hangs, memory leaks, etc…

Page 54, April 18, 2023CBSE – graduate course

Web Services With .NETWeb Services With .NET

ProgramsPrograms

ObjectsObjects

ClassesClasses

MethodsMethods

CallsCalls

WebWeb

XMLXML

XSDXSD

WSDLWSDL

SOAPSOAP

DataData

SchemaSchema

ServicesServices

InvocationInvocation

ApplicationApplicationConceptsConcepts

The .NET framework providesThe .NET framework providesa bi-directional mappinga bi-directional mapping

Page 55, April 18, 2023CBSE – graduate course

Common Language SpecificationCommon Language Specification

Page 56, April 18, 2023CBSE – graduate course

Language InteroperabilityLanguage Interoperability

The CLR specifying and enforcing a common type system

Inherit implementation from other types implemented in other languages

Debuggers, profilers and other tools requires only to understand one environment, the MSIL

Exceptions can be thrown across languages

Page 57, April 18, 2023CBSE – graduate course

A Unified Programming ModelA Unified Programming Model

Windows APIWindows API

.NET Framework.NET Framework

Consistent API availability regardless oflanguage and programming model

ASPASP

Stateless,Code embeddedin HTML pages

MFC/ATLMFC/ATL

Subclassing,Power,

Expressiveness

VB FormsVB Forms

RAD,Composition,

Delegation

Page 58, April 18, 2023CBSE – graduate course

Programming modelProgramming model

Organization

Organized in hierarchical namespaces

Unified type system

Everything is an object

Boxing converts value types to objects No need for special variant type

Component Oriented

Properties, methods & events are 1st class

Design-time functionality

Page 59, April 18, 2023CBSE – graduate course

ExampleExample

HWND hwndMain = CreateWindowEx( 0, "MainWClass", "Main Window", WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, (HWND)NULL, (HMENU)NULL, hInstance, NULL); ShowWindow(hwndMain, SW_SHOWDEFAULT); UpdateWindow(hwndMain);

Form form = new Form();form.Text = "Main Window";form.Show();

Windows API

.NET Framework

Page 60, April 18, 2023CBSE – graduate course

Everything Is An ObjectEverything Is An Object

Traditional views of primitive types

C++, Java: They’re “magic”

Smalltalk, Lisp: They’re full-blown objects

Improved extensibility and reusability

New primitive types: Decimal, SQL…

Collections, etc., work for all types

Page 61, April 18, 2023CBSE – graduate course

Everything Is An ObjectEverything Is An Object

Boxing

Allocates box, copies value into it

Unboxing

Checks type of box, copies value out

Dim i As Integer = 123Dim o As Object = iDim j As Integer = CInt(o)

123123i

o

123123

System.Int32System.Int32

123123j

int i = 123;object o = i;int j = (int)o;

Brad Abrams
add VB code

Page 62, April 18, 2023CBSE – graduate course

Slide 1

An Introduction to CORBAAn Introduction to CORBA

Magnus [email protected]

Page 63, April 18, 2023CBSE – graduate course

CORBA (Common Object Request Broker Architecture)

CORBAapps CORBAdomains CORBAfacilities

CORBAservices

OMA OverviewOMA Overview

TransactionsTransactions EventEvent SecuritySecurity NamingNaming

Page 64, April 18, 2023CBSE – graduate course

CORBA ServicesCORBA Services

CORBA Object Services, COS or CORBAServices

Naming

Event Management

Transactions

Concurrency Control

SecurityAuthentication

Authorization

Page 65, April 18, 2023CBSE – graduate course

CORBA StatusCORBA Status

Initial revision October 1991; revised & clarified Feb 92, Apr 94.

Functionality in CORBA 2.0:

CORBA Architecture, unchanged from ver. 1.1 and 1.2

Mappings for C, C++, COBOL, Ada, Java and Smalltalk

Interoperability & Initialization extensions

Interface Repository extensions

Transaction Processing extension

Security extensions, secure IIOP & SSL

COM/CORBA Interworking

Datatype extensions

Page 66, April 18, 2023CBSE – graduate course

CORBA 3.0CORBA 3.0

Internet Integration

Firewall Specification

Interoperable Name Service

Quality of Service Control

Asynchronous Messaging and Quality of Service Control

Minimum, Fault-Tolerant, and Real-Time CORBA

The CORBAcomponent architecture

Components

Scripting

Page 67, April 18, 2023CBSE – graduate course

Characteristics of CORBA ComponentsCharacteristics of CORBA Components

Extends IDL to support the components

Introduces components to the Object Management Architecture (OMA)

Defines interfaces for navigation among multiple interfaces

XML is used to describe the run time properties

Defines a mapping to EJB

Page 68, April 18, 2023CBSE – graduate course

Object AdaptersObject Adapters

An object adapter is a pluggable entity

The OA is responsible for mapping an object reference onto an object implementation.

The OA activates the object if it is not in the memory

Basic Object Adapter

First adapter introduced

Portable Object Adapter

Flexible and defines a set of services from which other object adapters can be derived

Assure that objects are portable

Page 69, April 18, 2023CBSE – graduate course

CORBAContainer

Ap

pli

cati

on

Pro

gra

mm

ing

In

terf

ace

s

CORBA Services• persistence• transactions• security• events

CORBA POA• activation• deactivation

Java BeanJava Bean

Java BeanJava Bean

Java CodeJava Code

CORBAComponent

CORBAComponent

EnterpriseJava Bean

CORBAComponent

CORBAComponent

CORBA ComponentsCORBA Components

Page 70, April 18, 2023CBSE – graduate course

The Container ModelThe Container Model

A Framework for Server Applications

Built on the Portable Object Adaptor

Provides interfaces for CORBA Services

transactions

security

events

persistence

Uses Callbacks for instance management

Empty container for user-defined frameworks

Page 71, April 18, 2023CBSE – graduate course

Defined Container FrameworksDefined Container Frameworks

ComponentComponentComponentComponent

Con

tain

er

ORB/POA

Transaction Security Persistence Events

Callback InterfacesCallback Interfaces

Internal InterfacesInternal Interfaces

ExternalExternalInterfacesInterfaces