components and architecture. page 2 building reliable component-based systems chapter 3 -...
TRANSCRIPT
Components and Architecture
Page 2Building Reliable Component-based Systems
Chapter 3 - Architecting Component-Based Systems
The Software Architecture“The software architecture of a program or computing system is the structure or structures of the system, which comprise software components [and connectors], the externally visible properties of those components [and connectors] and the relationships among them.”
Page 3Building Reliable Component-based Systems
Chapter 3 - Architecting Component-Based Systems
Architecture Design Process Can be seen as a function that:
Takes a requirement specification as input. Generates an architectural design as output. Is not an automated process, necessitating great effort
and creativity from the involved software architects.
Is comprised of three steps: Functionality-based design. Assessment of the quality attributes. Architecture Transformation.
Page 4Building Reliable Component-based Systems
Chapter 3 - Architecting Component-Based Systems
General software architecture design process
Applicationarchitecture
Requirementspecification
Requirementselection
Functionality-basedarchitectural design
(Partial)requirementspecification
Estimate qualityattributes
Architecturetransformation
QA-optimizingsolutions
MoreRequirements?
OK
OK
Yes
no
not OK
F.R.
Page 5Building Reliable Component-based Systems
Chapter 3 - Architecting Component-Based Systems
Functionality-based Design The design process starts with functionality-
based design and consists of four steps: Defining the boundaries and context of the
system. Identification of archetypes. Decomposition of the system into its main
components. The first validation of the architecture by
describing a number of system instances.
Page 6Building Reliable Component-based Systems
Chapter 3 - Architecting Component-Based Systems
Assessment of the quality attributes
The second phase is the assessment of the quality attributes in which: Each quality attribute is given an estimate. If all estimated quality attributes are as good or
better than required, the architectural design process is finished.
If not the third phase of software architecture design is entered: architecture transformation
Page 7Building Reliable Component-based Systems
Chapter 3 - Architecting Component-Based Systems
Architecture Transformation Is concerned with selecting design solutions to
improve the quality attributes while preserving the domain functionality. The design is again evaluated and the same process is
repeated if necessary. The transformations (i.e. quality attribute optimizing
solutions) generally improve one or some quality attributes while they affect others negatively.
Page 8Building Reliable Component-based Systems
Chapter 3 - Architecting Component-Based Systems
Architecture-driven Component Development
The goal for the embodiment phase of design is to either build or select components and connectors that possess the quality attributes identified during the architecting phase of development.
Three types of components: Custom built components Reusable components Commercial components
Page 9Building Reliable Component-based Systems
Chapter 3 - Architecting Component-Based Systems
Custom Components Demands both time and money. Are most likely to pay off in cases of software that are:
Very unusual Safety critical Highly secure
The component assembly will possess the quality attributes it was designed around.
Page 10Building Reliable Component-based Systems
Chapter 3 - Architecting Component-Based Systems
Pre-existing Components There are two main classes of pre-
existing components: Reusable components Commercial components
Is a fundamentally different problem than custom design. The requirements to use specific
components and component frameworks drive the architecture.
Page 11Building Reliable Component-based Systems
Chapter 3 - Architecting Component-Based Systems
Reusable Components Can exist on a wide scale of reusableness
within any organization. They must be adapted;
In most cases it will be necessary to create adaptors, often referred to as glue code.
Are developed with reuse in mind. Product line development exemplifies the
use of pre-planned reusable components.
Page 12Building Reliable Component-based Systems
Chapter 3 - Architecting Component-Based Systems
Commercial Components Introduce a large degree of uncertainty. Tend to be
Complex Idiosyncratic Unstable
Page 13Building Reliable Component-based Systems
Chapter 3 - Architecting Component-Based Systems
Component-driven Architecture Development
Constraints due to the use of pre-existing components: Design freedom is limited to component
selection. Sufficient information about how a component
will behave is not generally provided. Component properties must be verified. The framework into which components are to be
plugged influences the architecture and the process by which the system is designed.
Such components can not be optimized.
Page 14Building Reliable Component-based Systems
Chapter 3 - Architecting Component-Based Systems
Component-driven Architecture Development
It is expected that more reliable systems will be produced, with greater speed and at lower expense due to the restrictions on design freedom.
Page 15Building Reliable Component-based Systems
Chapter 4 - Component Models and Technology
Chapter 4Chapter 4
Component Models and TechnologyComponent Models and Technology
Windows purpose : moving integration between applicative functions to O.S. level
it needs effective communication mechanisms between applications
Excel-generated pie chart embedded in a Word document displayed in a PowerPoint presentation
Different applications need to share data or procedures
A little history: starting with evolution of Microsoft approach
clipboard
DDE
OLE
COM
OCX
ActiveX
DCOM
DDE (Dynamic Data Exchange)
What if spreadsheet and word processor need to share data?
Microsoft comes out with Dynamic Data Exchange (DDE), circa 1989 Lets different Windows programs share data through links Suppose some spreadsheet data were linked into word
processor When you changed data in spreadsheet, the new data
would appear in word processor Limitation: you couldn’t update the data in the word
processor; you had to invoke the spreadsheet to update the date there
Worse, links were fragile and would break if you moved data files around in file system
Object Linking and Embedding OLE (circa 1991) A way for Windows to create documents containing objects from other
programs. Embedding lets users copy a snapshot of data into word
processor and save it there• The objects are components (word processor document, spreadsheet,
picture) can be linked together and pass messages to each other according to a standard protocol, Object Linking and Embedding (OLE).
Components containers can be re-used by many applications to for E.g. place a chart from Excel and a slide from PowerPoint into a Word document
But OLE is a platform-specific solution.
OLE Technology (circa 1993)
A set of APIs to create and display a (compound) document Now possible to share code as well as data
Component Object Model (COM) COM now includes OLE as part of a larger concept
OLE becomes a set of standard COM interfaces COM protocols let components connect to origination
program: E.g. word processor can tell spreadsheet, “the user just
clicked on the spreadsheet, so start yourself up, look for data here, and let me know when you’re done.”
If the user decides to edit the embedded data, Windows activates the originating application and loads the embedded document
For example, a desktop system might include a picture in a bitmap editor using OLE
Component Object Model
The component object model (COM) provides a specification for using components produced by various vendors within a single application running under the Windows operating system.
COM objects can be created with a variety of programming languages. Object-oriented languages, such as C++, provide programming mechanisms that simplify the implementation of COM objects.
not an object-oriented language but a binary standard
Microsoft COM
COM encompasses: COM interfaces (implemented as COM objects) COM Object locations are stored in registry
a set of mechanisms for registering and passing messages between COM interfaces.
COM interfaces are defined in Microsoft Interface Description Language (MIDL).
COM components in Registry
Windows has many COM components.Registered under “\HKEY_CLASSES_ROOT\CLSID” on the registry.
OLE Extensions (OCX)
With Windows 95 came a new standard: OCX (OLE Custom eXtension component) A piece of code, smaller than application program,
but with its own user interface Let users bundle OCX controls to form customized
applications (component composition)
OCX Charting and Graphing example code for Visual Basic
• When installing the ProEssentials product, the setup program installs the ProEssentials DLL and OCX Charting interfaces into the system directory.•The setup program also registers the OCX Charts with the operating system, which prepares Visual Basic for inclusion of ProEssentials components
OCX Charting and Graphing example code for Visual Basic
the [Components] dialog and places those items selected into Visual Basic's ToolBox as shown.
ActiveX (circa 1996)
Active X, like Java Applets, supports Internet xistributed computing. ActiveX components communicate with each other via events.
Writing a program to run in the ActiveX environment creates a self-sufficient program that can run anywhere in ActiveX network
This component is known as an ActiveX control, and is often used to attach a program to a web page
Distribution option spectrum
Increasing costand effort
Server: Interaction controlData validationServicesDatabase
Client: Presentation
Server:DatabaseServer: Services
Database
Client: PresentationInteraction controlData validation
Client: PresentationInteraction controlData validationServices
The Thick client option is where the server simply provides data management and application services are implemented on the client by using ActiveX component
Thick client
ActiveX Comp
Three-tier architecture for an Internet banking system
31Chapter 18 Distributed software engineering
ActiveX - implementation
An ActiveX control can be created using one of several languages or development tools, including C++ and Visual Basic, or with scripting tools such as VBScript.
ActiveX controls originally were Windows only Other vendors later provided Mac and Unix/Linux support
for ActiveX Security issues: ActiveX controls have full file access (no
sandbox) Can be signed for authentication
Creating ActiveX Component
Creator
Creator Developer
End User
End User
Design Time Run Time
No Customization
Customization
For each component The Component Creator can enable Customization (where developer can insert code in the design time for customization) by defining
• Events (handling user interface ) ActiveX component Could be mapped to internal User Contol events by using RaiseEvent . Eg. Button Click, Mouse Down
• Properties Using Get and Let
•mapped to internal UserContol properties. E.g button Caption
•New Property
• Methods New methods
Example Creating ActiveX Component
Creating ActiveX Component
Example Mapping Events (written by creator)
Creating ActiveX Component
Get: just returns the current string found in the Caption property of the command button Let: takes a new string and just assigns it to the Caption property of the command button
Example Mapping Propriety
Using ActiveX Component
Using ActiveX Component
At design time developer could write the following code to customize the Bitton Component
nn= Bitton1.Caption .. This will call the Get sub in to nn
Bitton1.Caption = “ok” …. This will call the Set subPrivate Sub Bitton1_Click ()
Msgbox (“hello world”)End Sub
Private Sub Bitton1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y)
Msgbox (“I am moving”)
End Sub
Tax Components
For this SC what are the events, properties, methods For no customization (using it as it is created) For customization
Enter Amount
Enter Tax %
Result
Show Result Clear
Tax Components
(not customizable) Events such as Show Result , Clear event are internal
Private Sub Command1_click ()
TextField3.value = TaxTotal()
End Sub
Private Sub Command2_click ()
TextField3.text = “ “
End Sub
Enter Amount
Enter Tax %
Result
Show Result Clear
Tax Components
(simple customizable) Mapping property Properties ResultColor done by creator
Property Get ResultColor ()ResultColor = TextField.color
End Properity
Property Let ResultColor (cc)TextField.color = cc
End Properity Using this Property by simply done by designer
TaxComponent1. ResultColor = “red”
Enter Amount
Enter Tax %
Result
Show Result Clear
Tax Components
(advanced customizable) Events such as button click
Private Sub Command3_click ()
RaiseEvent Click
End Sub
Enter Amount
Result
Show Result Clear
Special Function
Tax Components
(advanced customizable) Properties Such as caption
Property Get caption ()
caption = button3.caption
End Property
Property Let caption ()
button3.caption = tt
End Property
Enter Amount
Result
Show Result Clear
Special Function
Tax Components
(advanced customizable) At design time a designer wants to add new
function AmountAfterTax to button 3
TaxComponent1.Caption = “ Amount After Tax”
Private Sub TaxComponent1_Click()AmountAfterTax=Textfield1.value*TaxPer/100)
Result = AmountAfterTax
End Sub
Enter Amount
Result
Show Result Clear
Special Function
Tax Components
At Run time
Enter Amount
Result
Show Result Clear
Amount After Tax
233
Microsoft Visual Studio (clothes ordering)
Using at Design Time
Business Component
Order
For Customization:
LOGO, Address, Title, colors, font, etc
GUI Component
Grid entry table
For customization:
Number of rows, columns, header’s captions, borders, etc
Order Form
The JavaBeans API
JavaBeans API makes it possible to write component software in Java Components are self-contained, reusable software units that can be
visually composed into composite components, applets, applications, and servlets using visual application builder tools.
A Java Bean component may have a visual representation, for example, a user-interface component, or may be non-visual, for example, a database connectivity component .
Java Bean components communicate with each other by sending events.. Components have properties which can be set by the programmer to achieve some customisation.
Enterprise JavaBeans (EJB) is an extension of the Java Bean model that provides a mechanism for encapsulating a Java Bean component
Features of JavaBeans Support for introspection
Allows development tools to query a component to determine member variables, methods, and interfaces
Support for customization so that when using an application builder a user can customize
the appearance and behavior of a bean Support for events (when beans want to intercommunicate)
Notification of a change in state User activities (typing, mouse actions, …)
Support for properties both for customization and for programmatic use Properties can be customized at design-time using property editor
Support for Methods Invoked to execute component code
Support for persistence so that a bean can be customized in an application builder and
then have its customized state saved away and reloaded later implement Serializable or Externalizable
e.g. public class Button implements java.io.Serializable { ... }
Background: What Are Beans?
• Java classes that follow certain conventions
– Must have a zero-argument (empty) constructor
– Should have no public instance variables (fields): use accessor methods instead of allowing direct access to fields
– Persistent values should be accessed through methods called getXxx and setXxx
Why You Should Use Accessors, Not Public Fields
You can put constraints on values
public void setSpeed(double newSpeed) {
if (newSpeed < 0) {
sendErrorMessage(...);
newSpeed = Math.abs(newSpeed);
}
speed = newSpeed;
}
– If users of your class accessed the fields directly, then
they would each be responsible for checking constraints
Visually Manipulated, Builder Tools (BDK...)
Property Sheet
Method Tracer
BeanBoxToolBox
Support Multi-tiered Application Model
Client tier Web clients,
Applets, Applications
Web tier Business tier EIS-tier
J2EE Architecture
JSP Using Beans: Basic Tasks• jsp:useBean<jsp:useBean id="beanName“ class="package.Class" />
e.g<jsp:useBean id="book1" class="coreservlets.Book" />
• jsp:getProperty– This element reads and outputs the value of a bean property. <jsp:getProperty name="beanName“ property="propertyName" />
e.g. <jsp:getProperty name="book1" property="title" />is equivalent to the following JSP expression<%= book1.getTitle() %>
jsp:setProperty– This element modifies a bean property. It is normally used as follows:<jsp:setProperty name="beanName“ property="propertyName"e.g.
<jsp:setProperty name="book1“ property="title“ value="Core Servlets and JavaServer Pages" />
is equivalent to the following scriptlet<% book1.setTitle("Core Servlets and JavaServer Pages"); %>
UserInfo
Component DiagramWeb
Page
Userinfo javabean example
Client
HomeInterface
HomeStub
RemoteInterface
EJBStub
EJB Server
EJB Container
Home Interface
EJBHome
Remote Interface
EJB Object
Bean Class
Any enterprise bean must define two interfaces 1- Home interface – The Home Stubs extends EJBHome which defines a
bean’s “life cycle” methods, eg. create bean, remove bean, find bean, etc.
• Initially A client initiate interacts with its server object via a container interface: the container calls the bean’s life cycle methods to create bean instance .
Client
HomeInterface
HomeStub
RemoteInterface
EJBStub
EJB Server
EJB Container
Home Interface
EJBHome
Remote Interface
EJB Object
Bean Class
2- Remote interface- defines a bean’s external interface- EJB Stub extend EJBObject (which in turn extends
java.rmi.Remote)•Clients never interact directly with a bean class, they use EJB stubs (which connect to “containers” which call the bean class interface using RMI)
Client
HomeInterface
HomeStub
RemoteInterface
EJBStub
EJB Server
EJB Container
Home Interface
EJBHome
Remote Interface
EJB Object
Bean Class
- Bean ClassThe java class that actually implements the bean’s external interface, e.g. the bean class provides implementations for the bean’s “business methods”
CORBA• The Common Object Requesting Broker Architecture
(CORBA) is a standard defined by the (Object Management Group OMG); that enables software components written in multiple computer languages and running on multiple computers to work together.
• It forms part of a larger model, Object Management Architecture (OMA) that defines at a high level of abstraction
A CORBA component provides functionality via an interface defined in the CORBA Interface Definition Language, and interacts with other components only via that interface.
It is a system software that provides interoperability services for applications, such as distributed object computing, and hides some aspects of hardware and operating system differences in heterogeneous, distributed environment
CORBA architecture
Interface Definition Language (IDL) Similar to interfaces in Java or C++ abstract
classes Defines protocol to be used between devices Allows “wrappers” for legacy systems
Object Request Broker (ORB) Middleware establishing client/server
relationship Allows transparent invocation of methods Intercepts calls, and deals with them
1- Servant object publish its interfaces using DSI to ORB2- ORB install locally at client machine all its interfaces {run-time library}, at IDL STUB3- The {client} calls (using DII) the - 'IDL-stub to perform some task 4- The stub transmits parameters over the network5- Once the request is reconstructed by 'ORB', it has to interpret it 6. 'ORB‘ will Find an object that can implement the request, pass it the parameters, invoke its
method to the object’s {server- skeleton} 6- the skeleton (server-side interpreter, it need to know the method signature: a. the method name, and
b. the type of input.. 7- The proxies and skeletons provide the object-specific information needed8- the skeleton returns the results to the caller in a reverse manner so that the IDL stub can read the
result and pass it to the client object
.
1. Facets: Facets are interfaces that a component provides. For instance, the Stock_Quote interface provides a stock price
2- Receptacles:. Receptacles provide a standard way to specify interfaces required for the component to function correctly. The Stock_Exchange component uses the SEC (Securities and Exchange Commission) interface to function correctly.
Example: CORPA component
3- Event sources/sinks: Components can also interact by monitoring asynchronous events. These loosely coupled interactions, are commonly used in distributed applications. A component declares its interest to publish or subscribe to events by specifying event sources and event sinks in its definition (subscribe ). For example, the Stock_Exchange component can be an event sink that processes Buy_Offers and Sell_Offers events and it can be an event source that publishes Price_Change events.
The COM Programming ModelA scalable programming model
ClientClient ComponentComponentCOMCOM
Client ProcessClient Process ServerServer ProcessProcess On the same machine On the same machine (component – (component – component)component) Fast, secure LPCFast, secure LPC
DCOM extends COM to support communication among objects on different computers
What is DCOM?
Com Object Creation
Proxy & Stub
COM server
Three ways in which a client can access COM objects provided by a server:
• In-Process Server (if COM object has been previously activated at the client machine)
• Local Object Proxy (if COM object resides at the client machine)
• Remote Object Proxy (if COM object resides at a server machine)
How DCOM Works: Example
Client on Windows machine Server (CustServer) on Solaris
UNIX machine Client needs to call ChangeAddress
method of the server’s ICustInfo interface/class
Both client and server are C++ modules
How DCOM Works: ExampleStep 1: Client Initiation
COMCOMLibraryLibraryCOMCOM
LibraryLibrary
CLSID_CustServerIID_ICustInfo
ClientClientClientClient
CoInitializeCoCreateInstanceEx
Call Stack
Description of Slide:COM Library - Collection of routines (API) implemented by COM. Routines typically begin with Co…
Process:The first thing any COM client or server calls is CoInitialize. To connect to the server (client side), the client then calls CoCreateInstanceEx, passing the CLSID of the server it wishes to call plus all of the desired Interface IDs.
Description of Slide:COM Library - Collection of routines (API) implemented by COM. Routines typically begin with Co…
Process:The first thing any COM client or server calls is CoInitialize. To connect to the server (client side), the client then calls CoCreateInstanceEx, passing the CLSID of the server it wishes to call plus all of the desired Interface IDs.
How DCOM Works: ExampleStep 2a: Server Activation (Client Side)
ClientClientClientClient
CoInitializeCoCreateInstanceEx
Call Stack
COMCOMLibraryLibraryCOMCOM
LibraryLibrary SCMSCMSCMSCM
CLSID_CustServerCLSID_CustServer
ProxyProxyProxyProxy
IUnknownIUnknown
ClassClassTableTable
RegistryRegistry
Process:•The CoCreateInstanceEx call is relayed to the local SCM (Service Control Manager ) , • which first checks the Class Table to see if the requested object is already running. •If not, it looks in the registry, using the CLSID_CustServer, to find out whether the server is local or remote. •If it is remote, it gets the name of the server machine to contact.•A “default” proxy is loaded which exports the IUnknown interface.
Process:•The CoCreateInstanceEx call is relayed to the local SCM (Service Control Manager ) , • which first checks the Class Table to see if the requested object is already running. •If not, it looks in the registry, using the CLSID_CustServer, to find out whether the server is local or remote. •If it is remote, it gets the name of the server machine to contact.•A “default” proxy is loaded which exports the IUnknown interface.
How DCOM Works: ExampleStep 2b: Server Activation (Server Side)
ClientClientClientClient
CoInitializeCoCreateInstanceEx
Call Stack
COMCOMLibraryLibraryCOMCOM
LibraryLibrary SCMSCMSCMSCM SCMSCMSCMSCM
CoInitializeCoRegisterClassObject
Call Stack
CLSID_CustServerCLSID_CustServer
ServerServerServerServer
ClassFactory
IUnknownIUnknown
IClassFactoryIClassFactory
ProxyProxyProxyProxy
IUnknownIUnknown
StubStubStubStub
COMCOMLibraryLibraryCOMCOM
LibraryLibrary
ClassClassTableTable
RegistryRegistry
ClassClassTableTable
RegistryRegistryProcess:On the remote machine, the SCM repeats the process of checking in the Class Table and Registry. If the object is already running, it skips to the next step. If not, it finds out the name of the executable from the registry, and starts that module.The class and the pointer to the ClassFactory are entered in the Class Table.A “default” stub is loaded into the server’s process which will facilitate communication to the client.
Process:On the remote machine, the SCM repeats the process of checking in the Class Table and Registry. If the object is already running, it skips to the next step. If not, it finds out the name of the executable from the registry, and starts that module.The class and the pointer to the ClassFactory are entered in the Class Table.A “default” stub is loaded into the server’s process which will facilitate communication to the client.
How DCOM Works: ExampleStep 3: The Class Factory
ClientClientClientClient
CoInitializeCoCreateInstanceEx
Call Stack
COMCOMLibraryLibraryCOMCOM
LibraryLibrary SCMSCMSCMSCM SCMSCMSCMSCM
ServerServerServerServer
CoInitializeCoRegisterClassObject
Call Stack
IUnknownIUnknown
IClassFactoryIClassFactory
ICustInfoICustInfo
IID_IUnknown
ClassFactory
ProxyProxyProxyProxy
IUnknownIUnknown
StubStubStubStub CCustInfo
COMCOMLibraryLibraryCOMCOM
LibraryLibrary
ClassClassTableTable
RegistryRegistry
ClassClassTableTable
RegistryRegistry
Process:Once the server has started, the system calls a method on the IClassFactory interface called CreateInstance. This method creates a new instance of the CCustInfo class, so that it is ready to accept later calls.
Process:Once the server has started, the system calls a method on the IClassFactory interface called CreateInstance. This method creates a new instance of the CCustInfo class, so that it is ready to accept later calls.
How DCOM Works: ExampleStep 4: Multiple QueryInterface
CoInitializeCoCreateInstanceEx
Call Stack
COMCOMLibraryLibraryCOMCOM
LibraryLibrary SCMSCMSCMSCM SCMSCMSCMSCM
CoInitializeCoRegisterClassObject
Call Stack
IID_ICustInfo
ClientClientClientClientProxyProxyProxyProxy
IUnknownIUnknown
StubStubStubStubServerServerServerServer
IUnknownIUnknown
IClassFactoryIClassFactory
ICustInfoICustInfo
ClassFactory
CCustInfo
COMCOMLibraryLibraryCOMCOM
LibraryLibrary
ClassClassTableTable
RegistryRegistry
ClassClassTableTable
RegistryRegistry
Process:Once the server has started and the Class Factory has created a new instance for us, the system will call the QueryInterface function of the server object for all of the Interface IDs (IIDs) supplied in the CoCreateInstanceEx call. QueryInterface will either return interface pointers or errors if the interface requested is not supported.
Process:Once the server has started and the Class Factory has created a new instance for us, the system will call the QueryInterface function of the server object for all of the Interface IDs (IIDs) supplied in the CoCreateInstanceEx call. QueryInterface will either return interface pointers or errors if the interface requested is not supported.
Step 5: Proxy/Stub loading
CoInitializeCoCreateInstanceEx
Call Stack
COMCOMLibraryLibraryCOMCOM
LibraryLibrary SCMSCMSCMSCM SCMSCMSCMSCM
CoInitializeCoRegisterClassObject
Call Stack
pCustInfoClientClientClientClient
ProxyProxyProxyProxy
IUnknownIUnknown
StubStubStubStubServerServerServerServer
IUnknownIUnknown
IClassFactoryIClassFactory
ICustInfoICustInfo
ClassFactory
CCustInfo
COMCOMLibraryLibraryCOMCOM
LibraryLibrary
ICustInfo_ProxyICustInfo_ProxyICustInfoICustInfo
ICustInfo_StubICustInfo_Stub
ClassClassTableTable
RegistryRegistry
ClassClassTableTable
RegistryRegistry
IID_ICustInfoIID_ICustInfoIID_ICustInfoIID_ICustInfo
Process:Once an interface pointer has been located, it must be “marshalled” over to the client side. At this time, using the IID as a key to the registry, the system loads a special pair of modules to act as proxy and stub for future calls. And register it
Process:Once an interface pointer has been located, it must be “marshalled” over to the client side. At this time, using the IID as a key to the registry, the system loads a special pair of modules to act as proxy and stub for future calls. And register it
How DCOM Works: ExampleStep 6: Method Call
CoInitializeCoCreateInstanceExpCustInfo->ChangeAddress
Call Stack
COMCOMLibraryLibraryCOMCOM
LibraryLibrary SCMSCMSCMSCM SCMSCMSCMSCM
CoInitializeCoRegisterClassObject
Call Stack
ClientClientClientClientProxyProxyProxyProxy
IUnknownIUnknown
StubStubStubStubServerServerServerServer
IUnknownIUnknown
IClassFactoryIClassFactory
ICustInfoICustInfo
ClassFactory
CCustInfo
COMCOMLibraryLibraryCOMCOM
LibraryLibrary
ICustInfo_ProxyICustInfo_ProxyICustInfoICustInfo
ICustInfo_StubICustInfo_Stub
ClassClassTableTable
RegistryRegistry
ClassClassTableTable
RegistryRegistry
Process:Once a pointer to the ICustInfo interface has been obtained, the program can call methods as though the server module is local. The client simply calls the ChangeAddress method of the ICustInfo interface (referenced by pCustInfo), passing all of the necessary parameters.
Process:Once a pointer to the ICustInfo interface has been obtained, the program can call methods as though the server module is local. The client simply calls the ChangeAddress method of the ICustInfo interface (referenced by pCustInfo), passing all of the necessary parameters.
Location Transparency
COM Object locations are stored in registry Applications make calls using the globally
unique CLSID. Path to COM server, or remote computer to
run DCOM server is not needed by the application. Location transparent –server and client can be
anywhere since they share the same network protocol
Language Neutrality
Various languages can be used to create components. VB, Delphi for rapid development VC++, Java for advanced development E.g. A component build in VB can be imported to
VC++ Even more languages can be used to use
COM components Additionally scripting languages like VB Script,
JScript
Connection Management Low Bandwidth
Header is 28 bytes over DCE-RPC Keep-Alive Messages bundled for all connections between
Machines
COM employs an efficient pinging protocol to detect if clients are active
COM uses reference counting mechanism to do garbage collection Internal component’s reference counter –increments
when client establishes connection with component Decrements counter –if client releases its connection If counter reaches zero –component can free itself
preferred transport protocol : UDP
Platform Neutrality
DCOM run-time is available for various platforms Win32 platforms, Solaris, DEC UNIX, HPUX,
Linux, MVS, VMS, Mac Cross-Platform Interoperability Standard
Per-Platform binary standard Unlike java, DCOM can utilize powerful platform-
specific services and optimizations Less abstraction layers prevents additional
overheads
Security by Configuration
1) DCOM obtains user name
2) Authenticate user
3) Is user in the list?
4) Fail or allow call
Weaknesses of COM/DCOM
COM/DCOM is hard to use COM is not robust enough for enterprise
deployments
• COM/DCOM are best supported on Windows 95 and NT platforms
• low cost development tools provide the ability to build and access COM components for Windows platforms, for other platforms the prices are considerably more expensive
Creating a simple COM server
ATL COM AppWizard
New ATL Object
Add New Method
Interface Definition Language
...
[
object,
uuid(79522A15-BA3D-46A5-92D6-DA4BE60646F4),
dual,
helpstring("ISimple Interface"),
pointer_default(unique)
]
interface ISimple : IDispatch
{
[id(1, helpstring("method StringLen")] HRESULT StringLen([in] BSTR str, [out,retval] long* length);
};
...
Source & Header File
Source:STDMETHODIMP CSimple::StringLen(BSTR str, long* length)
{
*length = SysStringLen(str);
return S_OK;
}
Header:...
public:
STDMETHOD(StringLen)(/*[in]*/ BSTR str, /*[out,retval]*/ long* length);
...
Creating a Simple COM Client
#include <stdio.h>#import "SimpleCom.exe"
int main(int argc, char* argv[]){
SIMPLECOMLib::ISimplePtr pSimple;long len;CoInitialize(NULL);pSimple.CreateInstance(__uuidof(SIMPLECOMLib::Simple));len = pSimple->StringLen("sample");printf("Length = %d\n", len);CoUninitialize();return 0;
}
Exception Handling
try
{
len = pSimple->StringLen("sample");
}
catch (_com_error &e)
{
printf(“%s\n”, e.Description());
}
Registering COM Objects
COM dll To register: regsvr32 mycom.dll To un-register: regsvr32 –u mycom.dll
COM exe To register: mycom.exe /regserver To un-register: mycom.exe /unregserver
Configure as DCOM
Protocols for DCOM
Comparison
A Service Oriented Architecturewhy to buy if it is cheaper to rent
Web service can be used to: tools: calendar, chat, etc Information providers: weather, news, flight information
The ultimate aim of the web services programme is to build a service-oriented architecture (SOA) with the properties (Web service can be seen as distributed component taken to extreme): Access to services is standardised (interfaces defined) Network nodes make (reusable) services available to other
nodes, independent of physical location (location transparency) The publishing of information about available services is
standardised (a service directory) SOA should be independent of implementation technology – e.g.
services can interoperate regardless of implementation environment or language (Java, C#, . . . )
E.g. Photos can be shared from sites like Flickr to social network sites like Facebook and MySpace.
Video content can be embedded on sites which are served by another host.
Advantages Easier to reuse (no setup is required) Scalability: adding more services, and users Fault tolerant Lower cost
Disadvantage: Availability (connection is lost, server down, overloading
many request) Reliability (relatively slow)
What is SOAP?
Simple Object Access Protocol (SOAP) is based on XML protocol, used for information exchange in distributed systems. SOAP establishes client-server interaction and regulates operation factors transmission and return value. To submit any information transmitted from client to server and vice versa XML is used
SOAP uses Internet Protocols
Simple Object Access Protocol (SOAP)
Developed by IBM, Lotus Development Corporation, Microsoft, DevelopMentor, and Userland Software
SOAP message Envelope
A structure describes a method call Body
Request Contains a Remote Procedure Call (RPC); request
for another machine to perform a task. It specifies the method to be invoked and any parameters
Response HTTP response document contains results from
other method call
[from What the heck is SOAP anyway by David Platt ]
HolidayReservation ServiceFront End Flight
Reservation System
HotelReservation
System
Application Servers
1
2
34
Service Composition
Service Composition
Tools using SOAP for Web Services
• Microsoft SOAP Toolkit 2.0 • Provides necessary components for both client-side and server-side, and other operations for Web Services• Available on web site: http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/msdn-files/027/001/580/msdncompositedoc.xml
• IBM Apache SOAP• Based on the IBM SOAP4J implementation.• Available on web site: http://xml.apache.org/soap/
A Component now Becomes a Service Running Outside the Consumer Boundaries
DB
CCI CCI CCI
ERP CRM
Service Service Service
Registry
11register
ConsumerConsumer
SOAP SOAP SOAP
XML XML XML
33 Communicate22
Discover/learnability
Policies
Web services with SOAP
Emerging standards support web services, all in XML:
1- discovery phase - discover What web Services that sever is hosting UDDI (Universal Description, Discovery and Integration) describes a way to publish & (directory)
2- Learning about what interfaces that service supports:WSDL (Web Service Definition Language file) describes services as a set of endpoints operating on message
3- Communication phase – placing a request for information and receive the responses•SOAP (Simple Object Access Protocol) defines the overall message structure of web service request
Example
1- a RoomService web Services project that contain multiple services, such as ReservationService, RateQuoateService, etc2- the actual UDDI file RoomService.vsdisco3- For Discovery the client application request information
http://servername/roomservice/roomservice.vsdisco
4- the Server send back this XML part (document reference that contain all the services names)
< docRef = “/roomService1.asmx” 5- the Learnability client request the WSDL from a web Service
http://servername/roomservice/roomService1/ ReservationService.asmx?WSDL
Input - Output
Name = “RoomNum”, Type = “int”
Name = “AvailabilityResult”, Type = “Boolean”
Implementation Web Service Example in C#
ReservationService.asmxReservationService.asmx
<%@ WebService Language="C#" %><%@ WebService Language="C#" %>using System;using System;using System.Web.Services;using System.Web.Services;
public class public class ReservationInterfaceReservationInterface{{ [WebMethod][WebMethod] public string public string opCheckAvaliabilityopCheckAvaliability(int (int RoomRoomNum)Num) {{ //// Implementation hereImplementation here, check database, etc, check database, etc }}}}
<%@ WebService Language="C#" %><%@ WebService Language="C#" %>using System;using System;using System.Web.Services;using System.Web.Services;
public class public class ReservationInterfaceReservationInterface{{ [WebMethod][WebMethod] public string public string opCheckAvaliabilityopCheckAvaliability(int (int RoomRoomNum)Num) {{ //// Implementation hereImplementation here, check database, etc, check database, etc }}}}
Microsoft SOAP toolkit
129
Another ASP.NET Web Services example
Links to Web
service methods
Link to service description
1 <%@ WebService Language="JScript" Class="NumberService" %>
2
3 // Fig. 23.38: number.asmx
4 // A simple Web Service
5
6 import System;
7 import System.Web.Services;
8
9 public class NumberService extends WebService
10 {
11 // Determines whether all the characters in a String are digits
12 WebMethod public function isNum( number : String ) : Boolean
13 {
14 var digitArray : char[];
15 digitArray = number.ToCharArray();
16
17 for ( var i : int = 0; i < digitArray.Length ; i++ )
18 {
19 if ( !Char.IsDigit( digitArray[ i ] ) )
20 {
21 return false;
22 }
23 }
24
25 return true;
26 } // end isNum
27
28 WebMethod public function Add( a : float, b : float) : float {
29 return a + b;
30 }
31 } // end class NumberService
ASP.NET Web Services
ASP.NET Web Services
Invoking a method of a Web service from a Web browser.
Results of invoking a Web-service method from a Web browser.
Assignment 3
Build your project using one of the components frameworks
Compositional Forms we identify two kinds of entities that are
com-posed: components and frameworks. Given this, there are three major classes of interactions that arise in component-based systems:
•
Component–Component (C–C):
composition that enables interaction among compo-nents. These interactions deliver application functionality, and so the contracts that spec-ify these interactions might be classified as application-level contracts.
Framework–Component (F–C):
• A composition that enables interactions between a com-ponent framework and its components. These interactions enable frameworks to manage component resources, and so the contracts that specify these interactions might be classi-fied as system-level contracts.
Framework–Framework (F–F):
A composition that enables interactions between frame-works. These interactions enable composition of components that are deployed in het-erogeneous frameworks, and so these contracts might be classified as interoperation con-tracts.
..\CBSE-2012-2013[1]\Technical Concepts of Component-Based Software Engineering,.pdf