SlideShare uma empresa Scribd logo
1 de 70
Presentation Outline of Commercial Systems
• Bahman
Part A: Java Beans
Part B: Enterprise Java Beans
• John
Corba
OLE
ActiveX
• Andrew
COM
DCOM
COM+
Java Beans & Enterprise Java Beans
Component-Based Design
Bahman Kalali
Computer Systems Group
bkalali@csg.uwaterloo.ca
Spring 2002
Outline (Part A)
 Introduction to JavaBeans
 A Bean's Public Interface
 Bean Properties
 Bean Events
 Bean Methods
 Reflection API
 Bean Distribution
 Summary
Java Bean is a reusable platform-neutral software component that
can be visually manipulated in a visual application builder tool.
This definition has two distinct parts:
 A bean is a software component.
 A bean can be visually manipulated in a tool.
Introduction
Construction from Components
 Properties
 Methods
 Events
A Bean's Public Interface
At the source code level, a bean's property is nothing more than a
private attribute of a class that is supported by public getter and/or setter
methods.
Type of Properties
 Simple
 Boolean
 Index
 Bound
 Constrained
Bean’s Properties
Sample Account Property Balance
 Naming convention to expose a simple property:
public void setXxx (<type> arg)
public <type> getXxx()
 Example for Account's balance property:
public void setBalance( int amount )
public int getBalance()
By applying a naming pattern to the set/get Balance methods above,
the visual builder tool will expose a read/write "balance" property that
has the type int.
Exposing Simple Properties
 Naming convention to expose a boolean property:
public void setXxx (boolean arg)
public boolean isXxx()
 Example for overdrawn property:
public void setOverdrawn( boolean overdrawn )
public boolean isOverdrawn()
Boolean properties may be exposed by using the isXxx naming convention.
Exposing Boolean Properties
 Naming convention to expose an indexed property:
public void setXxx ( <type> [] arg)
public <type>[] getXxx()
public void setXxx (int index, <type> arg)
public <type> getXxx (int index)
 Example for an Account owner property:
public void setOwner(String[] owners)
public String getOwner()
public void setOwner(int index, String owner)
public String getOwner(int index)
Exposing Indexed Properties
// Account Class - non visual Java Bean
public class Account extends Object {
int balance = 0;
public Account() { // constructor }
public void setBalance ( int newBalance ) { balance = newBalance; }
public int getBalance() { return balance; }
public void deposit ( int pennies ) { setBalance ( getBalance() + pennies ); }
public void withdraw ( int pennies ) { setBalance ( getBalance() - pennies ); }
}
// end of class Account
Account Bean with a balance Property
Bound Properties
• A Bean properties changes, another Bean may want to be notified of the
change and react to the change.
• Whenever a bound properties changes, notification of change is sent to
interested listeners.
• It is up to the source Bean to keep track of listeners.
Account Bean with a Balance Property
• PropertyChangeSupport object constructs a PropertyChangeEvent object
and passes it to the Listener chain.
• Listener objects will interrogate the property that is changing and process
accordingly.
Constrained Properties
1) setBalance called
2) Account notifies the VetoableChangeListeners
of pending change request
3) Listeners can optionally throw exception
4) balance is updated if no exception is thrown
Bean Custom Events
• Bound and constrained properties fire events when properties are changed.
• Java Beans can also fire other kind of events (custom events).
• The application developer can wire up to these events without writing code.
 Naming conventions are used
public void addXxxListener ( XxxListener listener)
public void removeXxxListener ( XxxListener listener)
 Example for exposing an OverdrawEvent
public void addOverdrawListener ( OverdrawListener listener)
public void removeOverdrawListener ( OverdrawListener listener)
 In addition to these methods, the source object also provides:
1) OverdrawEvent class
2) OverdrawListener interface
3) code to fire the event
4) code to manage the listener chain
Exposing Bean Custom Events
Bean Methods
• To expose a method in the Bean’s public interface, simply make the method
public.
How does a visual Builder tool determines
a Bean’s public interface?
• At development time the visual builder tool is able to
interrogate beans, and figure out what's in there.
• How does it do that?  The Java Reflection API
In Java 1.1 and higher, anyone can inspect a class using the
Reflection API
Account account = new Account();
Class classObject = account.getClass();
Method [] methodsArray = classObject.getDeclaredMethods();
methodsArray now contains an array of Method objects for the class
Account
A method objects contain information about a method's:
 Method name
 Return type
 Argument list
 Access type
Reflection API
 Beans can be distributed in a JAR file (basically a ZIP file).
 The JAR utility that comes with the JDK can be used to create JAR files.
 JAR files can contain any type of file, not just Java bytecodes,
image,sound and text.
 A manifest file describes the contents of the JAR.
Bean Distribution
 Beans
 are software components
 are usable by programming tools
 are packaged in JAR files
 use a standard naming convention
 have a public interface
 A Bean's Public Interface composed of:
 Properties
 Simple
 Indexed
 Boolean
 Bound
 Constrained
 Events
 Signalled by changing properties
 Signalled for custom state change
 Methods
 Default is any public method
Summary
 Introduction to Enterprise Java Beans
 Three-Tiered Architecture
 JBoss Application Server
 Enterprise Java Beans
 Accessing a Business Method
 Case Study: Distributed Shoe Web Application
 Demonstration of application lifecycle
 Summary
23
Outline (Part B)
 EJB specification defines an architecture for the development
and deployment of transactional, distributed object applications-
based, server-side software components.
 Case Study
 Shoe Retailer Company
24
ShoeCollection
Shoe
brand
branch
name
id
quantities
25 Running Montreal Nike 50
Introduction
 Client Layer
 Presentation Layer
 Business Logic Layer
 Data Layer
Client Layer
Presentation
Layer
Business Logic
Layer
Data Layer
Logical Layers Typical Web
Implementation
Browser
Database
Application Server
Web Server
Lower Tier
Upper Tier
Middle Tier
25
Three-Tiered Architecture
EJB
Java Beans
 JBoss is an application server written in Java that can host EJB
component.
 JBoss provides a container.
 An EJB container implicitly manages resources for EJB:
 Threads
 Socket
 Database connections
 Remote accessibility
 Mutliclient support
 Persistence management
26
JBoss Application Server
Bean Types
 Session Beans => models business processes
 Entity Beans => models business data
Application Server
EJB Container
Session Bean
Entity Bean
JSP/Java Beans Servlet
Browser
DB
Web Server
Presentation
Layer
Business Logic
Layer
Enterprise Java Beans
EJB
Home Object
EJB
Object Bean Class
Home
Interface
Remote
Interface
Client
EJB
Home Object
EJB
Object
EJB Container
JBoss Application Server
Client
Enterprise Java Beans (contd.)
Enterprise Bean Components composed of:
 (1) Bean Class ( i.e. ShoeBean.java)
 (5) Home Interface ( i.e. ShoeHome.java)
 (3) Remote Interface ( i.e. Shoe.java)
 (2) EJB Object
 (4) EJB Home Object( Responsibility: Create, Find, Remove EJB object)
 (6) Deployment Descriptor( i.e ejb-jar.xml)
Retrieval of the Home object reference and generation of
remote EJB object reference.
EJB Object
Remote Interface
Home Interface
EJB Container
Client Code
Enterprise Bean
JNDI
Home Object
1: Retrieve
reference
2: Return Home
Object reference
3: Request new
EJB object
Home Object
5: Return EJB object reference
4: Create EJB object
Directory Service
29
Accessing a Business Method
 Handling a client request to a business method.
EJB Object
Remote Interface
Home Interface
EJB Container
EJB Object
EJB Object
Home Object
Client Code
1:Call a Method
4: Return
value to client
Enterprise Bean
2: Acquire a Bean, and delegate
the method to the Bean
3:Method Returns
30
Accessing a Business Method (cont’d.)
Presentation
Layer
Business Logic
Layer
Client Layer
Data Layer
JspShoeBrowse
Java Bean
JSP Pages
ShoeCollection
Session Bean
Shoe
Entity Bean
Web Browser
Tomcat Web Server
JBoss Application Server
<<HTTP>>
<<RMI>>
EJB Container
Servlet Container
Hypersonic database
31
Shoe Distributed Web Application
 Build
 Package
 Deploy
 Run
cs854-WebServer
WEB-INF
classes
lib
JspShoeBrowse.class
browse.jsp
prev.jsp
mext.jsp
search.jsp
header.html
footer.html
shoe.jar
web.xml
shoe.war
cs854-ApplicationServer
shoe
Shoe.class
ShoeHOME.class
ShoeBean.class
ShoeCollection.class
ShoeCollectionHome.class
ShoeCollectionBean.class
shoecollection
utils
ShoeExistsException.class
jboss.xml
ejb-jar.xml
META-INF
shoe.jar
32
Demonstration of application lifecycle
33
JavaBeans Enterprise JavaBeans
JavaBeans may be visible or
nonvisible at runtime.
An EJB is a non-visual, remote object.
JavaBeans are intended to be local to a
single process and are primarily
intended to run on the client side.
EJBs are remotely executable
components or business objects that
can be deployed only on the server.
JavaBeans is a component technology
to create generic Java components that
can be composed together into applets
and applications.
Even though EJB is a component
technology, it neither builds upon nor
extends the original JavaBean
specification.
JavaBeans are not typed. EJBs are of two types—session beans
and entity beans.
No explicit support exists for
transactions in JavaBeans.
EJBs may be transactional and the EJB
Servers provide transactional support.
Summary
CORBA Key Concepts
• Com+mon Object Request Broker Architecture
• Location Transparency
• Objects
• Portable
• Standard
Simplified Architecture
• Interface Definition Language(IDL)
• Application Programming Interface(API)
• Object Request Broker(ORB)
CORBAArchitecture
Dyn.
Inter-
face
IDL
Stub
ORB
Interface
IDL
Skeleton
Object
Adapter
Object Implementation
Client
Object Services: naming, events, life cycle, persistence, transactions,
concurrency, relationships, externalization, object licensing,
properties, object query.
ORB
OS Kernel OS Kernel
Network
IDL Interface for Quoter
interface Stock {
double price ();
readonly attribute string symbol;
readonly attribute string full_name;
};
interface Stock_Factory {
Stock get_stock (in string stock_symbol)
raises (Invalid_Stock_Symbol);
};
In client.cpp:
int main (int argc, char* argv[])
{
try {
// First initialize the ORB, that will remove some arguments...
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv,
"" /* the ORB name, it can be anything! */);
// Get Reference to desired object
// call methods to access object
orb->destroy ();
}
catch (CORBA::Exception &ex) {
std::cerr << "CORBA exception raised!" << std::endl;
}
return 0;
}
Client - Manage ORB in Stock Quoter
Client.cpp
Client - Get Quoter
Object R
In client.cpp:
#include "QuoterC.h”
CORBA::Object_var factory_object = orb->string_to_object(argv[1]);
Quoter::Stock_Factory_var factory =
Quoter::Stock_Factory::_narrow (factory_object.in ());
for (int i = 2; i != argc; ++i)
{
try {
// Get the stock object
Quoter::Stock_var stock = factory->get_stock (argv[i]);
Client.cpp
ef
Implement Get_Stock
Method
In stock_factory_i.cpp
// Return Object Reference
Quoter::Stock_ptr Quoter_Stock_Factory_i::get_stock
(const char *symbol)
throw (Quoter::Invalid_Stock_Symbol)
{
if (strcmp (symbol, "RHAT") == 0)
{ return this->rhat_._this(); }
else if (strcmp (symbol, "MSFT") == 0)
{ return this->msft_._this (); }
throw Quoter::Invalid_Stock_Symbol ();
}
Stock_
Factory_i.cpp
Implementing Stock Interface
In stock_i.cpp
// Access object
class Quoter_Stock_i : public POA_Quoter::Stock
{
public:
Quoter_Stock_i (const char *symbol, const char*full_name,
CORBA::Double price);
private:
std::string symbol_;
std::string full_name_;
CORBA::Double price_;
};
Stock_i.cpp
Stock Operations
and Attributes
In stock_i.cpp:
// Access object
class Quoter_Stock_i : public POA_Quoter::Stock
{
public: // some details omitted
char *symbol () throw (CORBA::SystemException);
char *full_name () throw (CORBA::SystemException);
CORBA::Double price () throw (CORBA::SystemException);
};
// In the .cpp file:
char * Quoter_Stock_i::symbol () throw
(CORBA::SystemException)
{ return CORBA::string_dup (this->symbol_.c_str ());
}
Stock_i.cpp
Implement
Server
int main (int argc, char* argv[])
{
try
{ // First initialize the ORB, that will remove some arguments…
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "" /* the ORB name, it
can be anything! */);
CORBA::Object_var poa_object =
orb->resolve_initial_references ("RootPOA");
PortableServer::POA_var poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager =
poa->the_POAManager ();
poa_manager->activate ();
// The application code goes here!
// Destroy the POA, waiting until the destruction terminates
poa->destroy (1, 1); orb->destroy ();
}
catch (CORBA::Exception &ex) { std::cerr << "CORBA exception raised!" <<
std::endl; } return 0; }
Server.cpp
•CORBA provides a communication
infrastructure for a heterogeneous, distributed
collection of collaborating objects
•Analogous to “hardware bus”
Software Bus
OLE Overview
• Object Linking and Embedding
• Microsoft 's technology for supporting compound documents
• A way for Windows to create documents containing objects from
other programs.
• Components can be re-used by many applications (referred to
as component containers).
OLE Example
• Pie chart generated by Excel
embedded in a word
document being displayed in
a PowerPoint presentation..
OLE Technology
• A set of APIs to create and display a (compound) document
• The Component Object Model (COM) now takes in OLE as part
of a larger concept. It has become a set of standard COM
interfaces
• Embedded documents retain all their original properties. If the
user decides to edit the embedded data, Windows activates the
originating application and loads the embedded document.
OLE Extensions
• Automation is an OLE technology, which enables third party
applications to remotely control Office applications.
• e.g. Puppeteer invokes Automation interfaces to modify
application behavior when executing on bandwidth limited
platforms.
• using Automation interfaces, Puppeteer can act as a buffer for a
large PowerPoint presentation, loading slides while the user
presents.
ActiveX - Overview
• A loosely-defined set of technologies developed by Microsoft, ActiveX is
an outgrowth of two other Microsoft technologies called OLE (Object
Linking and Embedding) and COM (Component Object Model). ActiveX
applies to a whole set of COM-based technologies.
• ActiveX control is Microsoft 's answer to the Java technology from
. An ActiveX control is roughly equivalent to a applet, but is
known as an ActiveX control.
• Writing a program to run in the ActiveX environment creates a self-
sufficient program that can be run anywhere in your ActiveX network
• This component is known as an ActiveX control, and is often used to
attach a program to a web page.
ActiveX - Implementation
• An ActiveX control can be created using one of several
languages or development tools, including C++ and Visual
Basic, or PowerBuilder, or with scripting tools such as VBScript.
• Currently, ActiveX controls run in 95/98/NT/2000 and in
. Microsoft plans to support ActiveX controls for
UNIX.
• Similar (but different) security issues as applets
Example
Sub
()
Resp = Window.Confirm "Use the MS Agent?"
If Resp Then
Window.Alert "Loading ActiveX Controls."
Document.WriteLn "<OBJECT ID='Agent' width=0 height=0"
Document.WriteLn "CLASSID='CLSID:F5BE8BD2-7DE6-11D0-91FE-
00C04FD701A5'"
Document.WriteLn " CODEBASE='http://activex.microsoft.com/" & _
"controls/agent/msagent.exe#VERSION=1,5,1,0'>"
Document.WriteLn "<" & Chr(47) & "OBJECT>"
Document.WriteLn "<OBJECT ID='TruVoice' width=0 height=0"
Document.WriteLn " CLASSID='CLSID:B8F2846E-CE36-11D0-AC83-
00C04FD97575'"
Document.WriteLn " CODEBASE='http://activex.microsoft.com/" & _
"controls/agent/cgram.exe#VERSION=1,5,0,0'>"
Document.WriteLn "<" & Chr(47) & "OBJECT>"
End If
End Sub
Commercial Products :
Microsoft COM/DCOM/COM+
Andrew Trevors
Software Architecture Group
adtrevor@uwaterloo.ca
Overview
• What is COM / DCOM / COM+?
• COM
– Client/Server Model
– Objects & Interfaces
– COM Servers
– COM Clients
– COM Library
– COM Example
• DCOM
• COM+
What is COM / DCOM / COM+?
• COM (Component Object Model)
– software architecture which allows components from multiple
vendors to be combined in a variety of applications
– binary standard for component interoperability
– platform and language independent, distributed, object-oriented.
– is the foundation technology for Microsoft's OLE and ActiveX®
technologies, as well as others.
• DCOM (Distributed Component Object Model)
– enables software components to communicate directly over a
network in a reliable, secure, and efficient manner.
– is designed for use across multiple network transports.
– based on the OSF's DCE-RPC specification.
What is COM / DCOM / COM+?
• COM+ (Component Services)
– upgrade of the original COM
– Adds
• Transaction processing from Microsoft Transaction Manager
• Queued components
• Object pooling
• Publish-subscribe event service
• much, much, more.
Client/Server Model
Client
Application
COM
Server
Object
(1) “Create
Object” (2) Locate
implementation
(3) Get object
interface pointer,
return to Client
(4) Call interface
members
Objects & Interfaces
• Interface
– a set of member functions that a client can call to access that object
implementation.
– all interfaces start with an ‘I”, followed by a descriptive label
identifying what services they provide.
– all interfaces have a IID (interface identifier) which uniquely
identifies them.
• Object
– an implementation of one or more interfaces
– If object wishes to allow COM to locate and launch its
implementation then it needs to have a CLSID (class identifier)
– at very least, objects must implement IUnknown interface
• QueryInterface(), AddRef(), Release()
COM Servers
• Servers come in three varieties:
– In-process
• Server loaded into the clients process space
• loaded as a Dynamic Linked Library (DLL)
– Local
• Server that runs as a separate process on the same machine as
the client
• run as an executable (EXE) application
– Remote
• Server that runs as a separate process on another machine
• DLL or EXE
COM Servers
• Servers have four responsibilities
– Allocate a CLSID for each supported class and provide a mapping
between CLSID and server module (registry)
– Implement a class factory object with the IClassFactory interface
(CreateInstance & LockServer) for each CLSID
– Expose the class factory so the COM Library can find it once it is
loaded (CoRegisterClassObject or DllGetClassOjbect)
– Provide for unloading the factory if is serving no objects and no
locks are in place
COM Clients
• Any application which uses COM to instantiate objects
• Object usage involves:
– Using CLSID through COM Library or class factory to get an
interface pointer
• Interface pointer is actually a pointer to a pointer to a table of
function pointers
– Using interface pointer to call member functions or to obtain other
interfaces
– Calling Release() function when done with object.
COM Library
• COM Library provides :
– A small number of API functions that facilitate the creation of COM
applications
• clients (object creation).
• servers (object exposure).
– Implementation locator services
• COM determines, from a class identifier, which server
implements that class and where that server is located
(registry).
– Transparent remote procedure calls when an object is running in a
local or remote server
COM Example
class StockQuote : public IUnknown {
public:
HRESULT QueryInterface( IID & iid, void** ppvObj );
ULONG AddRef();
ULONG Release();
HRESULT getSymbol( char** symbol );
HRESULT getLongName( char** name );
HRESULT getPrice( int* price )
private:
int _price;
char* _symbol;
char* _name
};
COM Example
HRESULT StockQuote::QueryInterface( IID & iid, void** ppvObj ) {
HRESULT retVal = S_OK;
if( IsEqualID( iid, IID_IUnknown )
*ppvObj = ( IUnknown*) this;
else {
*ppvObj = NULL;
retVal = E_NOINTERFACE;
}
return retVal;
}
COM Example
hRes = CoCreateInstance(&CLSID_STOCK, NULL,
CLSCTX_SERVER,
&IID_IUnknown, &pStock);
if (SUCCEEDED(hRes)) {
// do something with pStock
}
else {
// report error
}
DCOM
• Extends COM to support object communication across
networks.
• DCOM protocol, Object RPC, extends DCE RPC
– Uses RPC packets with extra information such as interface pointer
identifiers
– Programmers generally write an IDL and use an IDL compiler
(MIDL) to generate proxies/stubs
• Pinging for garbage collection
DCOM
In-Process
Object
Client
Application
Local
Object
Proxy
Remote
Object
Proxy
In-Process Server
COM
Client Process
RPC
RPC
Local
Object
Local Server
Stub
COM
Local Server Process
Remote
Object
Remote Server
Stub
COM
Remote Server Process
Remote Machine
COM+
• Transactions
– Coordination between COM+ and DTC (Distributed
Transaction Coordinator) to ensure ACID properties.
• Queued Components
– Provides asynchronous component invocation and execution
through the use of Microsoft Message Queuing Service
• Object Pooling
– Automatic service provided by COM+ which allows
components to have instances of itself kept active in a pool
• Stateless
• No thread affinity
• Aggregatable
COM+
• COM+ Events

Mais conteúdo relacionado

Semelhante a CommercialSystemsBahman.ppt

EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)Montreal JUG
 
JSF basics
JSF basicsJSF basics
JSF basicsairbo
 
Spring training
Spring trainingSpring training
Spring trainingshah_d_p
 
2-0. Spring ecosytem.pdf
2-0. Spring ecosytem.pdf2-0. Spring ecosytem.pdf
2-0. Spring ecosytem.pdfDeoDuaNaoHet
 
EJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkEJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkBill Lyons
 
Prairie DevCon 2015 - Crafting Evolvable API Responses
Prairie DevCon 2015 - Crafting Evolvable API ResponsesPrairie DevCon 2015 - Crafting Evolvable API Responses
Prairie DevCon 2015 - Crafting Evolvable API Responsesdarrelmiller71
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlJava Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlArjun Thakur
 
Building a web application with ontinuation monads
Building a web application with ontinuation monadsBuilding a web application with ontinuation monads
Building a web application with ontinuation monadsSeitaro Yuuki
 
KOIN for dependency Injection
KOIN for dependency InjectionKOIN for dependency Injection
KOIN for dependency InjectionKirill Rozov
 
InterConnect 2016 Java EE 7 Overview (PEJ-5296)
InterConnect 2016 Java EE 7 Overview (PEJ-5296)InterConnect 2016 Java EE 7 Overview (PEJ-5296)
InterConnect 2016 Java EE 7 Overview (PEJ-5296)Kevin Sutter
 
Lecture 8 Enterprise Java Beans (EJB)
Lecture 8  Enterprise Java Beans (EJB)Lecture 8  Enterprise Java Beans (EJB)
Lecture 8 Enterprise Java Beans (EJB)Fahad Golra
 

Semelhante a CommercialSystemsBahman.ppt (20)

EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)EJB et WS (Montreal JUG - 12 mai 2011)
EJB et WS (Montreal JUG - 12 mai 2011)
 
JSF basics
JSF basicsJSF basics
JSF basics
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
Introduction to EJB
Introduction to EJBIntroduction to EJB
Introduction to EJB
 
Ejb3 Presentation
Ejb3 PresentationEjb3 Presentation
Ejb3 Presentation
 
Java beans
Java beansJava beans
Java beans
 
Spring training
Spring trainingSpring training
Spring training
 
Javabean1
Javabean1Javabean1
Javabean1
 
2-0. Spring ecosytem.pdf
2-0. Spring ecosytem.pdf2-0. Spring ecosytem.pdf
2-0. Spring ecosytem.pdf
 
EJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkEJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLink
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
 
Prairie DevCon 2015 - Crafting Evolvable API Responses
Prairie DevCon 2015 - Crafting Evolvable API ResponsesPrairie DevCon 2015 - Crafting Evolvable API Responses
Prairie DevCon 2015 - Crafting Evolvable API Responses
 
P20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptxP20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptx
 
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of ControlJava Spring framework, Dependency Injection, DI, IoC, Inversion of Control
Java Spring framework, Dependency Injection, DI, IoC, Inversion of Control
 
Building a web application with ontinuation monads
Building a web application with ontinuation monadsBuilding a web application with ontinuation monads
Building a web application with ontinuation monads
 
KOIN for dependency Injection
KOIN for dependency InjectionKOIN for dependency Injection
KOIN for dependency Injection
 
InterConnect 2016 Java EE 7 Overview (PEJ-5296)
InterConnect 2016 Java EE 7 Overview (PEJ-5296)InterConnect 2016 Java EE 7 Overview (PEJ-5296)
InterConnect 2016 Java EE 7 Overview (PEJ-5296)
 
Spring Basics
Spring BasicsSpring Basics
Spring Basics
 
Lecture 8 Enterprise Java Beans (EJB)
Lecture 8  Enterprise Java Beans (EJB)Lecture 8  Enterprise Java Beans (EJB)
Lecture 8 Enterprise Java Beans (EJB)
 
Cognos Software Development Kit
Cognos Software Development KitCognos Software Development Kit
Cognos Software Development Kit
 

Mais de KalsoomTahir2

Mais de KalsoomTahir2 (20)

005813616.pdf
005813616.pdf005813616.pdf
005813616.pdf
 
009576860.pdf
009576860.pdf009576860.pdf
009576860.pdf
 
005813185.pdf
005813185.pdf005813185.pdf
005813185.pdf
 
HASH FUNCTIONS.pdf
HASH FUNCTIONS.pdfHASH FUNCTIONS.pdf
HASH FUNCTIONS.pdf
 
6. McCall's Model.pptx
6. McCall's Model.pptx6. McCall's Model.pptx
6. McCall's Model.pptx
 
ch02-Database System Concepts and Architecture.ppt
ch02-Database System Concepts and Architecture.pptch02-Database System Concepts and Architecture.ppt
ch02-Database System Concepts and Architecture.ppt
 
9223301.ppt
9223301.ppt9223301.ppt
9223301.ppt
 
11885558.ppt
11885558.ppt11885558.ppt
11885558.ppt
 
Indexing.ppt
Indexing.pptIndexing.ppt
Indexing.ppt
 
chap05-info366.ppt
chap05-info366.pptchap05-info366.ppt
chap05-info366.ppt
 
1650607.ppt
1650607.ppt1650607.ppt
1650607.ppt
 
005281271.pdf
005281271.pdf005281271.pdf
005281271.pdf
 
soa_and_jra.ppt
soa_and_jra.pptsoa_and_jra.ppt
soa_and_jra.ppt
 
ERP_Up_Down.ppt
ERP_Up_Down.pptERP_Up_Down.ppt
ERP_Up_Down.ppt
 
Topic1CourseIntroduction.ppt
Topic1CourseIntroduction.pptTopic1CourseIntroduction.ppt
Topic1CourseIntroduction.ppt
 
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.pptLecture 19 - Dynamic Web - JAVA - Part 1.ppt
Lecture 19 - Dynamic Web - JAVA - Part 1.ppt
 
EJBDetailsFeb25.ppt
EJBDetailsFeb25.pptEJBDetailsFeb25.ppt
EJBDetailsFeb25.ppt
 
jan28EAI.ppt
jan28EAI.pptjan28EAI.ppt
jan28EAI.ppt
 
005428052.pdf
005428052.pdf005428052.pdf
005428052.pdf
 
jini-1.ppt
jini-1.pptjini-1.ppt
jini-1.ppt
 

Último

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 

Último (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 

CommercialSystemsBahman.ppt

  • 1. Presentation Outline of Commercial Systems • Bahman Part A: Java Beans Part B: Enterprise Java Beans • John Corba OLE ActiveX • Andrew COM DCOM COM+
  • 2. Java Beans & Enterprise Java Beans Component-Based Design Bahman Kalali Computer Systems Group bkalali@csg.uwaterloo.ca Spring 2002
  • 3. Outline (Part A)  Introduction to JavaBeans  A Bean's Public Interface  Bean Properties  Bean Events  Bean Methods  Reflection API  Bean Distribution  Summary
  • 4. Java Bean is a reusable platform-neutral software component that can be visually manipulated in a visual application builder tool. This definition has two distinct parts:  A bean is a software component.  A bean can be visually manipulated in a tool. Introduction
  • 6.  Properties  Methods  Events A Bean's Public Interface
  • 7. At the source code level, a bean's property is nothing more than a private attribute of a class that is supported by public getter and/or setter methods. Type of Properties  Simple  Boolean  Index  Bound  Constrained Bean’s Properties
  • 9.  Naming convention to expose a simple property: public void setXxx (<type> arg) public <type> getXxx()  Example for Account's balance property: public void setBalance( int amount ) public int getBalance() By applying a naming pattern to the set/get Balance methods above, the visual builder tool will expose a read/write "balance" property that has the type int. Exposing Simple Properties
  • 10.  Naming convention to expose a boolean property: public void setXxx (boolean arg) public boolean isXxx()  Example for overdrawn property: public void setOverdrawn( boolean overdrawn ) public boolean isOverdrawn() Boolean properties may be exposed by using the isXxx naming convention. Exposing Boolean Properties
  • 11.  Naming convention to expose an indexed property: public void setXxx ( <type> [] arg) public <type>[] getXxx() public void setXxx (int index, <type> arg) public <type> getXxx (int index)  Example for an Account owner property: public void setOwner(String[] owners) public String getOwner() public void setOwner(int index, String owner) public String getOwner(int index) Exposing Indexed Properties
  • 12. // Account Class - non visual Java Bean public class Account extends Object { int balance = 0; public Account() { // constructor } public void setBalance ( int newBalance ) { balance = newBalance; } public int getBalance() { return balance; } public void deposit ( int pennies ) { setBalance ( getBalance() + pennies ); } public void withdraw ( int pennies ) { setBalance ( getBalance() - pennies ); } } // end of class Account Account Bean with a balance Property
  • 13. Bound Properties • A Bean properties changes, another Bean may want to be notified of the change and react to the change. • Whenever a bound properties changes, notification of change is sent to interested listeners. • It is up to the source Bean to keep track of listeners.
  • 14. Account Bean with a Balance Property • PropertyChangeSupport object constructs a PropertyChangeEvent object and passes it to the Listener chain. • Listener objects will interrogate the property that is changing and process accordingly.
  • 15. Constrained Properties 1) setBalance called 2) Account notifies the VetoableChangeListeners of pending change request 3) Listeners can optionally throw exception 4) balance is updated if no exception is thrown
  • 16. Bean Custom Events • Bound and constrained properties fire events when properties are changed. • Java Beans can also fire other kind of events (custom events). • The application developer can wire up to these events without writing code.
  • 17.  Naming conventions are used public void addXxxListener ( XxxListener listener) public void removeXxxListener ( XxxListener listener)  Example for exposing an OverdrawEvent public void addOverdrawListener ( OverdrawListener listener) public void removeOverdrawListener ( OverdrawListener listener)  In addition to these methods, the source object also provides: 1) OverdrawEvent class 2) OverdrawListener interface 3) code to fire the event 4) code to manage the listener chain Exposing Bean Custom Events
  • 18. Bean Methods • To expose a method in the Bean’s public interface, simply make the method public.
  • 19. How does a visual Builder tool determines a Bean’s public interface? • At development time the visual builder tool is able to interrogate beans, and figure out what's in there. • How does it do that?  The Java Reflection API
  • 20. In Java 1.1 and higher, anyone can inspect a class using the Reflection API Account account = new Account(); Class classObject = account.getClass(); Method [] methodsArray = classObject.getDeclaredMethods(); methodsArray now contains an array of Method objects for the class Account A method objects contain information about a method's:  Method name  Return type  Argument list  Access type Reflection API
  • 21.  Beans can be distributed in a JAR file (basically a ZIP file).  The JAR utility that comes with the JDK can be used to create JAR files.  JAR files can contain any type of file, not just Java bytecodes, image,sound and text.  A manifest file describes the contents of the JAR. Bean Distribution
  • 22.  Beans  are software components  are usable by programming tools  are packaged in JAR files  use a standard naming convention  have a public interface  A Bean's Public Interface composed of:  Properties  Simple  Indexed  Boolean  Bound  Constrained  Events  Signalled by changing properties  Signalled for custom state change  Methods  Default is any public method Summary
  • 23.  Introduction to Enterprise Java Beans  Three-Tiered Architecture  JBoss Application Server  Enterprise Java Beans  Accessing a Business Method  Case Study: Distributed Shoe Web Application  Demonstration of application lifecycle  Summary 23 Outline (Part B)
  • 24.  EJB specification defines an architecture for the development and deployment of transactional, distributed object applications- based, server-side software components.  Case Study  Shoe Retailer Company 24 ShoeCollection Shoe brand branch name id quantities 25 Running Montreal Nike 50 Introduction
  • 25.  Client Layer  Presentation Layer  Business Logic Layer  Data Layer Client Layer Presentation Layer Business Logic Layer Data Layer Logical Layers Typical Web Implementation Browser Database Application Server Web Server Lower Tier Upper Tier Middle Tier 25 Three-Tiered Architecture EJB Java Beans
  • 26.  JBoss is an application server written in Java that can host EJB component.  JBoss provides a container.  An EJB container implicitly manages resources for EJB:  Threads  Socket  Database connections  Remote accessibility  Mutliclient support  Persistence management 26 JBoss Application Server
  • 27. Bean Types  Session Beans => models business processes  Entity Beans => models business data Application Server EJB Container Session Bean Entity Bean JSP/Java Beans Servlet Browser DB Web Server Presentation Layer Business Logic Layer Enterprise Java Beans
  • 28. EJB Home Object EJB Object Bean Class Home Interface Remote Interface Client EJB Home Object EJB Object EJB Container JBoss Application Server Client Enterprise Java Beans (contd.) Enterprise Bean Components composed of:  (1) Bean Class ( i.e. ShoeBean.java)  (5) Home Interface ( i.e. ShoeHome.java)  (3) Remote Interface ( i.e. Shoe.java)  (2) EJB Object  (4) EJB Home Object( Responsibility: Create, Find, Remove EJB object)  (6) Deployment Descriptor( i.e ejb-jar.xml)
  • 29. Retrieval of the Home object reference and generation of remote EJB object reference. EJB Object Remote Interface Home Interface EJB Container Client Code Enterprise Bean JNDI Home Object 1: Retrieve reference 2: Return Home Object reference 3: Request new EJB object Home Object 5: Return EJB object reference 4: Create EJB object Directory Service 29 Accessing a Business Method
  • 30.  Handling a client request to a business method. EJB Object Remote Interface Home Interface EJB Container EJB Object EJB Object Home Object Client Code 1:Call a Method 4: Return value to client Enterprise Bean 2: Acquire a Bean, and delegate the method to the Bean 3:Method Returns 30 Accessing a Business Method (cont’d.)
  • 31. Presentation Layer Business Logic Layer Client Layer Data Layer JspShoeBrowse Java Bean JSP Pages ShoeCollection Session Bean Shoe Entity Bean Web Browser Tomcat Web Server JBoss Application Server <<HTTP>> <<RMI>> EJB Container Servlet Container Hypersonic database 31 Shoe Distributed Web Application
  • 32.  Build  Package  Deploy  Run cs854-WebServer WEB-INF classes lib JspShoeBrowse.class browse.jsp prev.jsp mext.jsp search.jsp header.html footer.html shoe.jar web.xml shoe.war cs854-ApplicationServer shoe Shoe.class ShoeHOME.class ShoeBean.class ShoeCollection.class ShoeCollectionHome.class ShoeCollectionBean.class shoecollection utils ShoeExistsException.class jboss.xml ejb-jar.xml META-INF shoe.jar 32 Demonstration of application lifecycle
  • 33. 33 JavaBeans Enterprise JavaBeans JavaBeans may be visible or nonvisible at runtime. An EJB is a non-visual, remote object. JavaBeans are intended to be local to a single process and are primarily intended to run on the client side. EJBs are remotely executable components or business objects that can be deployed only on the server. JavaBeans is a component technology to create generic Java components that can be composed together into applets and applications. Even though EJB is a component technology, it neither builds upon nor extends the original JavaBean specification. JavaBeans are not typed. EJBs are of two types—session beans and entity beans. No explicit support exists for transactions in JavaBeans. EJBs may be transactional and the EJB Servers provide transactional support. Summary
  • 34. CORBA Key Concepts • Com+mon Object Request Broker Architecture • Location Transparency • Objects • Portable • Standard
  • 35. Simplified Architecture • Interface Definition Language(IDL) • Application Programming Interface(API) • Object Request Broker(ORB)
  • 36. CORBAArchitecture Dyn. Inter- face IDL Stub ORB Interface IDL Skeleton Object Adapter Object Implementation Client Object Services: naming, events, life cycle, persistence, transactions, concurrency, relationships, externalization, object licensing, properties, object query. ORB OS Kernel OS Kernel Network
  • 37. IDL Interface for Quoter interface Stock { double price (); readonly attribute string symbol; readonly attribute string full_name; }; interface Stock_Factory { Stock get_stock (in string stock_symbol) raises (Invalid_Stock_Symbol); };
  • 38. In client.cpp: int main (int argc, char* argv[]) { try { // First initialize the ORB, that will remove some arguments... CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "" /* the ORB name, it can be anything! */); // Get Reference to desired object // call methods to access object orb->destroy (); } catch (CORBA::Exception &ex) { std::cerr << "CORBA exception raised!" << std::endl; } return 0; } Client - Manage ORB in Stock Quoter Client.cpp
  • 39. Client - Get Quoter Object R In client.cpp: #include "QuoterC.h” CORBA::Object_var factory_object = orb->string_to_object(argv[1]); Quoter::Stock_Factory_var factory = Quoter::Stock_Factory::_narrow (factory_object.in ()); for (int i = 2; i != argc; ++i) { try { // Get the stock object Quoter::Stock_var stock = factory->get_stock (argv[i]); Client.cpp
  • 40. ef
  • 41. Implement Get_Stock Method In stock_factory_i.cpp // Return Object Reference Quoter::Stock_ptr Quoter_Stock_Factory_i::get_stock (const char *symbol) throw (Quoter::Invalid_Stock_Symbol) { if (strcmp (symbol, "RHAT") == 0) { return this->rhat_._this(); } else if (strcmp (symbol, "MSFT") == 0) { return this->msft_._this (); } throw Quoter::Invalid_Stock_Symbol (); } Stock_ Factory_i.cpp
  • 42. Implementing Stock Interface In stock_i.cpp // Access object class Quoter_Stock_i : public POA_Quoter::Stock { public: Quoter_Stock_i (const char *symbol, const char*full_name, CORBA::Double price); private: std::string symbol_; std::string full_name_; CORBA::Double price_; }; Stock_i.cpp
  • 43. Stock Operations and Attributes In stock_i.cpp: // Access object class Quoter_Stock_i : public POA_Quoter::Stock { public: // some details omitted char *symbol () throw (CORBA::SystemException); char *full_name () throw (CORBA::SystemException); CORBA::Double price () throw (CORBA::SystemException); }; // In the .cpp file: char * Quoter_Stock_i::symbol () throw (CORBA::SystemException) { return CORBA::string_dup (this->symbol_.c_str ()); } Stock_i.cpp
  • 44. Implement Server int main (int argc, char* argv[]) { try { // First initialize the ORB, that will remove some arguments… CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "" /* the ORB name, it can be anything! */); CORBA::Object_var poa_object = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = poa->the_POAManager (); poa_manager->activate (); // The application code goes here! // Destroy the POA, waiting until the destruction terminates poa->destroy (1, 1); orb->destroy (); } catch (CORBA::Exception &ex) { std::cerr << "CORBA exception raised!" << std::endl; } return 0; } Server.cpp
  • 45. •CORBA provides a communication infrastructure for a heterogeneous, distributed collection of collaborating objects •Analogous to “hardware bus” Software Bus
  • 46.
  • 47. OLE Overview • Object Linking and Embedding • Microsoft 's technology for supporting compound documents • A way for Windows to create documents containing objects from other programs. • Components can be re-used by many applications (referred to as component containers).
  • 48. OLE Example • Pie chart generated by Excel embedded in a word document being displayed in a PowerPoint presentation..
  • 49. OLE Technology • A set of APIs to create and display a (compound) document • The Component Object Model (COM) now takes in OLE as part of a larger concept. It has become a set of standard COM interfaces • Embedded documents retain all their original properties. If the user decides to edit the embedded data, Windows activates the originating application and loads the embedded document.
  • 50. OLE Extensions • Automation is an OLE technology, which enables third party applications to remotely control Office applications. • e.g. Puppeteer invokes Automation interfaces to modify application behavior when executing on bandwidth limited platforms. • using Automation interfaces, Puppeteer can act as a buffer for a large PowerPoint presentation, loading slides while the user presents.
  • 51. ActiveX - Overview • A loosely-defined set of technologies developed by Microsoft, ActiveX is an outgrowth of two other Microsoft technologies called OLE (Object Linking and Embedding) and COM (Component Object Model). ActiveX applies to a whole set of COM-based technologies. • ActiveX control is Microsoft 's answer to the Java technology from . An ActiveX control is roughly equivalent to a applet, but is known as an ActiveX control. • Writing a program to run in the ActiveX environment creates a self- sufficient program that can be run anywhere in your ActiveX network • This component is known as an ActiveX control, and is often used to attach a program to a web page.
  • 52. ActiveX - Implementation • An ActiveX control can be created using one of several languages or development tools, including C++ and Visual Basic, or PowerBuilder, or with scripting tools such as VBScript. • Currently, ActiveX controls run in 95/98/NT/2000 and in . Microsoft plans to support ActiveX controls for UNIX. • Similar (but different) security issues as applets
  • 53. Example Sub () Resp = Window.Confirm "Use the MS Agent?" If Resp Then Window.Alert "Loading ActiveX Controls." Document.WriteLn "<OBJECT ID='Agent' width=0 height=0" Document.WriteLn "CLASSID='CLSID:F5BE8BD2-7DE6-11D0-91FE- 00C04FD701A5'" Document.WriteLn " CODEBASE='http://activex.microsoft.com/" & _ "controls/agent/msagent.exe#VERSION=1,5,1,0'>" Document.WriteLn "<" & Chr(47) & "OBJECT>" Document.WriteLn "<OBJECT ID='TruVoice' width=0 height=0" Document.WriteLn " CLASSID='CLSID:B8F2846E-CE36-11D0-AC83- 00C04FD97575'" Document.WriteLn " CODEBASE='http://activex.microsoft.com/" & _ "controls/agent/cgram.exe#VERSION=1,5,0,0'>" Document.WriteLn "<" & Chr(47) & "OBJECT>" End If End Sub
  • 54. Commercial Products : Microsoft COM/DCOM/COM+ Andrew Trevors Software Architecture Group adtrevor@uwaterloo.ca
  • 55. Overview • What is COM / DCOM / COM+? • COM – Client/Server Model – Objects & Interfaces – COM Servers – COM Clients – COM Library – COM Example • DCOM • COM+
  • 56. What is COM / DCOM / COM+? • COM (Component Object Model) – software architecture which allows components from multiple vendors to be combined in a variety of applications – binary standard for component interoperability – platform and language independent, distributed, object-oriented. – is the foundation technology for Microsoft's OLE and ActiveX® technologies, as well as others. • DCOM (Distributed Component Object Model) – enables software components to communicate directly over a network in a reliable, secure, and efficient manner. – is designed for use across multiple network transports. – based on the OSF's DCE-RPC specification.
  • 57. What is COM / DCOM / COM+? • COM+ (Component Services) – upgrade of the original COM – Adds • Transaction processing from Microsoft Transaction Manager • Queued components • Object pooling • Publish-subscribe event service • much, much, more.
  • 58. Client/Server Model Client Application COM Server Object (1) “Create Object” (2) Locate implementation (3) Get object interface pointer, return to Client (4) Call interface members
  • 59. Objects & Interfaces • Interface – a set of member functions that a client can call to access that object implementation. – all interfaces start with an ‘I”, followed by a descriptive label identifying what services they provide. – all interfaces have a IID (interface identifier) which uniquely identifies them. • Object – an implementation of one or more interfaces – If object wishes to allow COM to locate and launch its implementation then it needs to have a CLSID (class identifier) – at very least, objects must implement IUnknown interface • QueryInterface(), AddRef(), Release()
  • 60. COM Servers • Servers come in three varieties: – In-process • Server loaded into the clients process space • loaded as a Dynamic Linked Library (DLL) – Local • Server that runs as a separate process on the same machine as the client • run as an executable (EXE) application – Remote • Server that runs as a separate process on another machine • DLL or EXE
  • 61. COM Servers • Servers have four responsibilities – Allocate a CLSID for each supported class and provide a mapping between CLSID and server module (registry) – Implement a class factory object with the IClassFactory interface (CreateInstance & LockServer) for each CLSID – Expose the class factory so the COM Library can find it once it is loaded (CoRegisterClassObject or DllGetClassOjbect) – Provide for unloading the factory if is serving no objects and no locks are in place
  • 62. COM Clients • Any application which uses COM to instantiate objects • Object usage involves: – Using CLSID through COM Library or class factory to get an interface pointer • Interface pointer is actually a pointer to a pointer to a table of function pointers – Using interface pointer to call member functions or to obtain other interfaces – Calling Release() function when done with object.
  • 63. COM Library • COM Library provides : – A small number of API functions that facilitate the creation of COM applications • clients (object creation). • servers (object exposure). – Implementation locator services • COM determines, from a class identifier, which server implements that class and where that server is located (registry). – Transparent remote procedure calls when an object is running in a local or remote server
  • 64. COM Example class StockQuote : public IUnknown { public: HRESULT QueryInterface( IID & iid, void** ppvObj ); ULONG AddRef(); ULONG Release(); HRESULT getSymbol( char** symbol ); HRESULT getLongName( char** name ); HRESULT getPrice( int* price ) private: int _price; char* _symbol; char* _name };
  • 65. COM Example HRESULT StockQuote::QueryInterface( IID & iid, void** ppvObj ) { HRESULT retVal = S_OK; if( IsEqualID( iid, IID_IUnknown ) *ppvObj = ( IUnknown*) this; else { *ppvObj = NULL; retVal = E_NOINTERFACE; } return retVal; }
  • 66. COM Example hRes = CoCreateInstance(&CLSID_STOCK, NULL, CLSCTX_SERVER, &IID_IUnknown, &pStock); if (SUCCEEDED(hRes)) { // do something with pStock } else { // report error }
  • 67. DCOM • Extends COM to support object communication across networks. • DCOM protocol, Object RPC, extends DCE RPC – Uses RPC packets with extra information such as interface pointer identifiers – Programmers generally write an IDL and use an IDL compiler (MIDL) to generate proxies/stubs • Pinging for garbage collection
  • 68. DCOM In-Process Object Client Application Local Object Proxy Remote Object Proxy In-Process Server COM Client Process RPC RPC Local Object Local Server Stub COM Local Server Process Remote Object Remote Server Stub COM Remote Server Process Remote Machine
  • 69. COM+ • Transactions – Coordination between COM+ and DTC (Distributed Transaction Coordinator) to ensure ACID properties. • Queued Components – Provides asynchronous component invocation and execution through the use of Microsoft Message Queuing Service • Object Pooling – Automatic service provided by COM+ which allows components to have instances of itself kept active in a pool • Stateless • No thread affinity • Aggregatable