Component Object Model Tutorial
Component Object Model Tutorial
Tutorial
Contributors
J. Scott Evans - CPI - [email protected]
Diego Sevilla Ruiz - [email protected]
Raphaël Marvie - LIFL – [email protected]
OMG PSDL
Persistent state definition OMG extends
i.e. [abstract] storage types and homes PSDL
Output
OMG IDL 3.0 files
Client-side OMG IDL mapping
Client-side stubs
Interface Repository entries
Output
Local server-side OMG IDL mapping
Component skeletons
Component metadata as XML descriptors
Output
Component binaries
XML component descriptors enriched
XML
Client-side refers to Component describes Binary
OMG IDL Descriptor Component
Component Component
Client Packager
designers implementer
Programming
IDL/CIDL File User's Code Home Properties Component Properties
Language
Tools
IDL/CIDL
Default Properties
Compiler
CORBA
Stubs, Skeletons Implementation Component
Package
Generated files
Wednesday, April 24th, 2002 CORBA Component Model Tutorial 23
Next Tutorial Steps
Defining CORBA component types
Abstract Component Model and OMG IDL 3.0 extensions
Programming CORBA component clients
Client-side OMG IDL mapping
Implementing CORBA components
Component Implementation Framework (CIF)
Local server-side OMG IDL mapping
Component Implementation Definition Language (CIDL)
Putting CORBA containers to work
Packaging CORBA components
Associated XML DTDs
Deploying CORBA component applications
Component deployment objects and “basic” process
Facets
Receptacles
REQUIRED
OFFERED
My
Business
Component
Event Event
sinks sources
Attributes
Wednesday, April 24th, 2002 CORBA Component Model Tutorial 29
Building CCM Applications =
Assembling CORBA Component Instances
Could be configured
By visual property sheet mechanisms in assembly or
deployment environments
By homes or during implementation initialization
Potentially readonly thereafter
Wednesday, April 24th, 2002 CORBA Component Model Tutorial 31
Component Facets
Home interface
MyBusinessHome
c1
cN
Kant
Fork Thinking
Hungry
Fork Starving
Eating
Dead
Aristotle
Fork
Philosopher
Fork
name = Descartes
Philosopher
name = Aristotle
Observer
module DiningPhilosophers
{
// Sets the prefix of all these OMG IDL definitions.
// Prefix generated Java mapping classes.
typeprefix DiningPhilosophers "omg.org";
. . .
};
enum PhilosopherState
{
EATING, THINKING, HUNGRY, Philosopher
STARVING, DEAD
}; name = XXX
eventtype StatusInfo
{
public string name;
public PhilosopherState state;
public unsigned long ticks_since_last_meal;
public boolean has_left_fork;
public boolean has_right_fork;
};
component Philosopher
{
attribute string name; Philosopher
component Philosopher
{
Philosopher
attribute string name;
// The left fork receptacle.
name = XXX
uses Fork left;
// The right fork receptacle.
uses Fork right;
// The status info event source.
publishes StatusInfo info;
};
component Philosopher
{
attribute string name;
Philosopher
component Philosopher
{
attribute string name;
Philosopher
Observer
component Observer
{
// The status info sink port.
consumes StatusInfo info;
};
Observer
component Observer
{
// The status info sink port.
consumes StatusInfo info;
};
Observer
component Observer
{
// The status info sink port.
consumes StatusInfo info;
};
uses
OMG IDL
Client-side 3.0
OMG IDL 2.x Compiler
implemented by
Client Component
Stub ORB
interface ForkManager :
::Components::CCMObject
{
Fork provide_the_fork();
};
home ForkHome
manages ForkManager {}; Fork
Is mapped to Manager
interface ForkHomeExplicit :
::Components::CCMHome {};
interface ForkHomeImplicit :
::Components::KeylessCCMHome {
ForkManager create();
};
interface ForkHome :
ForkHomeExplicit,
ForkHomeImplicit {};
Wednesday, April 24th, 2002 CORBA Component Model Tutorial 64
Client-Side Mapping for
StatusInfo Event Type
eventtype StatusInfo {. . .};
Is mapped to
valuetype StatusInfo :
::Components::EventBase { . . . };
interface StatusInfoConsumer :
::Components::EventConsumerBase {
void push_StatusInfo(in StatusInfo
the_StatusInfo);
};
Wednesday, April 24th, 2002 CORBA Component Model Tutorial 65
Client-Side Mapping
for Observer Component
Is mapped to
interface Observer :
::Components::CCMObject {
StatusInfoConsumer get_consumer_info();
};
interface ObserverHomeExplicit :
::Components::CCMHome {};
interface ObserverHomeImplicit :
::Components::KeylessCCMHome {
Observer create();
};
interface ObserverHome :
ObserverHomeExplicit,
ObserverHomeImplicit {};
interface Philosopher :
::Components::CCMObject {
attribute string name;
.../...
Wednesday, April 24th, 2002 CORBA Component Model Tutorial 68
Client-Side Mapping
for Philosopher Component Philosopher
name = XXX
fork.release()
Philosopher
Skeletons managing
ports, life cycle,
persistency, etc.
Compiling + GIOP/IIOP
for CIF/Java
Component container
Component
Monolithic executor specific
context
Container context
Component container
Main segment
Component
Seg2 Seg3 Seg4 specific
context
Container context
ExecutorLocator
uses implemented by
OMG IDL
Client-side Local
3.0
OMG IDL 2.x server-side
Compiler
OMG IDL 2.x
implemented by delegates to
User written
Compiler Client Component
Stub ORB Skeleton
Generated files
Wednesday, April 24th, 2002 CORBA Component Model Tutorial 83
Main Server-Side OMG IDL Mapping Rules
A component type is mapped to three local interfaces
The main component executor interface
Inheriting from Components::EnterpriseComponent
The monolithic component executor interface
Operations to obtain facet executors and receive events
The component specific context interface
Operations to access component receptacles and event sources
Fork
Manager
local interface CCM_ForkHomeExplicit :
::Components::HomeExecutorBase {
// Empty as no user-defined home operations.
};
local interface CCM_ForkHomeImplicit {
::Components::EnterpriseComponent
create() raises(::Components::CreateFailure);
};
local interface CCM_ForkHome :
CCM_ForkHomeExplicit,
CCM_ForkHomeImplicit {};
Observer
local interface
CCM_ObserverHomeExplicit :
::Components::HomeExecutorBase {};
Observer
public class ObserverHomeImpl
extends org.omg.CORBA.LocalObject
implements CCM_ObserverHome
{
// Required by CCM_ObserverHome interface.
public org.omg.Components.EnterpriseComponent
create()
{ return new ObserverImpl(); }
name = XXX
name = XXX
name = XXX
public class PhilosopherImpl
extends org.omg.CORBA.LocalObject
implements CCM_Philosopher,
SessionComponent,
java.lang.Runnable
{ // Constructor.
public PhilosopherImpl(String n) { name_ = n; }
// Transient state.
private String name_;
// Required by the CCM_Philosopher_Executor interface.
public void name(String n) { name_ = n; }
public String name() { return name_; }
interface Fork {
void get () raises (InUse);
void release ();
};
component ForkManager {
provides Fork the_fork;
};
public:
ForkManager_2_impl () {
the_fork_ = new Fork_impl;
}
CCM_Fork_ptr get_the_fork () {
return CCM_Fork::_duplicate (the_fork_);
}
};
class ForkManager_3_Locator_impl :
virtual public Components::ExecutorLocator
{
CCM_ForkManager_Executor_var _executor;
CCM_Fork_var _the_fork;
public:
ForkManager_3_Locator_impl ()
{
_executor = new ForkManager_3_Executor_impl;
_the_fork = new Fork_impl;
}
CORBA::Object_ptr
obtain_executor (const char * name) {
if (strcmp (name, “ForkManager”) == 0)
return CORBA::Object::_duplicate (_executor);
else
return CORBA::Object::_duplicate (_the_fork);
}
void configuration_complete ()
{ /* empty */ }
};
Fork
local interface CCM_ForkHomeExplicit : Manager
::Components::HomeExecutorBase {
// Empty
};
local interface CCM_ForkHomeImplicit {
::Components::EnterpriseComponent
create () raises(::Components::CreateFailure);
};
local interface CCM_ForkHome :
CCM_ForkHomeExplicit,
CCM_ForkHomeImplicit {};
class ForkHome_impl :
virtual public CCM_ForkHome Fork
{ Manager
// from the implicit interface
Components::EnterpriseComponent_ptr create ()
{
return new ForkManager_1_impl;
// or: return new ForkManager_2_impl;
// or: return new ForkManager_3_Locator_impl;
};
extern “C” {
Components::HomeExecutorBase_ptr
create_ForkHome ()
{ return new ForkHome_impl; }
}
component Observer {
consumes StatusInfo info;
};
class Observer_impl :
virtual public MyObserver
{
public:
// receive StatusInfo event
void set_session_context
(Components::SessionContext_ptr ctx)
{ /* empty */ }
void ccm_activate ()
{ … display GUI … }
void ccm_passivate ()
{ … hide GUI … }
void ccm_remove ()
{ … free GUI … }
};
Observer
local interface
CCM_ObserverHomeExplicit :
::Components::HomeExecutorBase {};
class ObserverHome_impl :
Observer
virtual public CCM_ObserverHome
{
// from the implicit interface
Components::EnterpriseComponent_ptr create ()
{
return new Observer_impl;
}
};
extern “C” {
Components::HomeExecutorBase_ptr
create_ObserverHome ()
{ return new ObserverHome_impl; }
}
name
component Philosopher {
attribute string name;
uses Fork left;
uses Fork right;
publishes StatusInfo info;
};
home PhilosopherHome manages Philosopher {
factory new (in string name);
};
local interface MyPhilosopher :
CCM_Philosopher,
Components::SessionComponent
{};
name
name
name
class Philosopher_impl :
virtual public MyPhilosopher
{
CCM_Philosopher_Context_var _ctx;
CORBA::String_var _name;
public:
// Philosopher interface
Philosopher_impl (const char * nn) {
_name = nn;
}
void name (const char * nn) { _name = nn; }
char * name () { return CORBA::string_dup (_name); }
name
// from SessionComponent interface
void set_session_context
(Components::SessionContext_ptr ctx)
{ _ctx = CCM_Philosopher_Context::_narrow (ctx); }
void ccm_activate ()
{ … start philosopher, start timer … }
void ccm_passivate ()
{ … deep-freeze philosopher, stop timer … }
void ccm_remove ()
{ … kill philosopher … }
name
// timer callback
void timer ()
{
// not the real code
Fork_var left = _ctx->get_connection_left ();
Fork_var right = _ctx->get_connection_right ();
left->get (); // acquire left fork
right->get (); // acquire right fork
StatusInfo_var info = new StatusInfo_impl;
// set event contents
_ctx->push_info (info);
right->release (); // release right fork
left->release (); // release left fork
}
};
Philosopher
local interface
CCM_PhilosopherHomeExplicit : name
::Components::HomeExecutorBase {
::Components::EnterpriseComponent
new (in string name);
};
local interface CCM_PhilosopherHomeImplicit {
::Components::EnterpriseComponent
create () raises(Components::CreateFailure);
};
local interface CCM_PhilosopherHome :
CCM_PhilosopherHomeExplicit,
CCM_PhilosopherHomeImplicit {};
Components::EnterpriseComponent_ptr
_cxx_new (const char * name)
{ return new Philosopher_impl (name); }
};
extern “C” {
Components::HomeExecutorBase_ptr
create_PhilosopherHome ()
{ return new PhilosopherHome_impl; }
}
Component
OMG IDL OMG CIDL
includes Executor
3.0
imports
delegates to
partially User written
implemented Component
Component Compiler
Skeleton Executor
Generated files
Skeleton
Wednesday, April 24th, 2002 CORBA Component Model Tutorial 140
Advanced CIDL Composition Features
Associated abstract storage home type for
component persistency
Multiple executor segments
Implement a subset of the component’s facets
Could have an associated abstract storage home
Proxy homes
Component
OMG PSDL OMG CIDL
includes Executor
Storage
Stub uses Component
User written
Executor
Skeleton Compiler
Database Generated files
C Home
l Extended
i OMG IDL
external
e API Callback
CORBA
n API
Component
t
POA
Internal
API Container
ORB
Container Manager
Entity Session EJB Other
Container Container Container Container
ORB
A component is specified
OMG IDL 3.0, PSDL, and CIDL
A component is implemented
Component Implementation Framework
A component must be packaged
A component may be assembled with other
components
Components and assemblies are be deployed
policies
Property File Descriptor (.cpf) defining default attribute values
Software Package Descriptor (.csd) describing package contents
I D L / C ID L F ile U s e r 's C o d e P r o g r a m m in g
Language
T o o ls
ID L /C ID L D e f a u lt P r o p e r t ie s H o m e P r o p e r t ie s C o m p o n e n t P r o p e r t ie s
C o m p ile r
C O R BA
S tu b s , S k e le t o n s I m p le m e n ta t io n C om ponent
P ackage
C O R B A C om ponent
P a c k a g in g A s s e m b ly
C om ponent A s s e m b ly
Tool Tool
P ackage P ackage
C om ponent
D e s c rip to r
s o ftp k g A s s e m b ly
D e s c r ip t o r D e s c r ip to r
C O R BA
D e p lo y m e n t
C om ponent
Tool
P ackage
I D L / C I D L F ile U s e r 's C o d e P r o g r a m m in g
Language
T o o ls
ID L /C ID L D e f a u lt P r o p e r t ie s H o m e P r o p e r t ie s C o m p o n e n t P r o p e r t ie s
C o m p ile r
C O R BA
S tu b s , S k e le to n s I m p le m e n t a t io n C om ponent
P ackage
C O R BA C om ponent
P a c k a g in g A s s e m b ly
C om ponent A s s e m b ly
Tool Tool
P ackage P ackage
C om ponent
D e s c r ip to r
s o ftp k g A s s e m b ly
D e s c r ip t o r D e s c r ip to r
C O R BA
D e p lo y m e n t
C om ponent
Tool
P ackage
Component
* Property
File
Descriptor
valueentrypoint="DiningPhilosophers.StatusInfoDefaultFactory.create"
factoryentrypoint="DiningPhilosophers.StatusInfoDefaultFactory">
<fileinarchive
name="DiningPhilosophers/StatusInfoDefaultFactory.class"/>
</valuetypefactory>
</dependency>
<corbacomponent>
<corbaversion>3.0</corbaversion>
<componentrepid repid=
"IDL:DiningPhilosophers/Philosopher:1.0"/>
<homerepid repid=
"IDL:DiningPhilosophers/PhilosopherHome:1.0"/>
<componentkind>
<process><servant lifetime="container" /></process>
</componentkind>
<security rightsfamily="CORBA“
rightscombinator="secanyrights" />
<threading policy="multithread" />
<configurationcomplete set="true" />
I D L / C I D L F ile U s e r 's C o d e P r o g ra m m in g
Language
T o o ls
ID L /C ID L D e f a u lt P r o p e r t ie s H o m e P r o p e rtie s C o m p o n e n t P r o p e r t ie s
C o m p ile r
C O R BA
S tu b s , S k e le to n s I m p le m e n t a t io n C om ponent
P ackage
C O R BA C om ponent
P a c k a g in g A s s e m b ly
C om ponent A s s e m b ly
Tool Tool
P ackage P ackage
C om ponent
D e s c r ip t o r
s o ftp k g A s s e m b ly
D e s c rip to r D e s c r ip t o r
C O R BA
D e p lo y m e n t
C om ponent
Tool
P ackage
<properties>
<simple name="name" type="string">
<description>Philosopher name</description>
<value>Kant</value>
<defaultvalue>Unknown</defaultvalue>
</simple>
</properties>
Fork
Philosopher
Fork
name = Descartes
Philosopher
name = Aristotle
Observer
<componentassembly id="demophilo">
<description>Dinner assembly descriptor</description>
<componentfiles>
<componentfile id="PhilosopherComponent">
<fileinarchive name="philosopher.csd"/>
</componentfile>
<componentfile id="ObserverComponent">
<fileinarchive name="observer.csd"/>
</componentfile>
<componentfile id="ForkManagerComponent">
<fileinarchive name="forkmanager.csd"/>
</componentfile>
</componentfiles>
<homeplacement id="ForkHome">
<componentfileref idref="ForkManagerComponent"/>
<componentinstantiation id="ForkManager1"/>
<componentinstantiation id="ForkManager2"/>
<componentinstantiation id="ForkManager3"/>
<registerwithhomefinder name="ForkHome"/>
</homeplacement>
<usesport>
<usesidentifier>left</usesidentifier>
<componentinstantiationref idref="Kant"/>
</usesport>
<providesport>
<providesidentifier>the_fork</providesidentifier>
<componentinstantiationref idref="ForkManager1"/>
</providesport>
</connectinterface>
Philosopher
<connectevent> name = Kant Observer
<publishesport>
<publishesidentifier>info</publishesidentifier>
<componentinstantiationref idref="Kant"/>
</publishesport>
<consumesport>
<consumesidentifier>info</consumesidentifier>
<componentinstantiationref idref="Freud"/>
</consumesport>
</connectevent>
User
IDL Compiler
Code
Generated
Code Shared
IDL/CIDL Library or
Compiler Executable
Component
Descriptor
Component
Packaging
Package
Tool
.zip
Default
Properties
Instance Port
Creation Connections
Component
Package
Component Assembly
Assembly
Package Archive
Tool
.aar (ZIP)
Component
Package
DeploymentT
Properties
ool
...
I n s t a ll
P ro c e s s o r O b je ct
P ro c e s s o r
ZIP D e p lo y m e n t A p p
A s se m b ly F i le
OMG IDL I n s ta ll
O b je c t
P ro ce ss o r
S t a g in g A r e a
I n st a ll
O b je c t
P ro c e s s o r
P ro c e s s o r
ServerActivator
«instantiates»
Container
«instantiates»
CCMHome
«instantiates»
ComponentInstallation
CCMObject
Wednesday, April 24th, 2002 CORBA Component Model Tutorial 200
Deployment API: Assembly
module Components {
enum AssemblyState {
INACTIVE, INSERVICE
};
exception CreateFailure {};
exception RemoveFailure {};
interface Assembly {
void build () raises (CreateFailure);
void tear_down () raises (RemoveFailure);
AssemblyState get_state ();
};
};
Component
Deployment Tool Assembly
Descriptor
Component
Assembly
Deployer Descriptor +
Deployment Tool
ComponentInstallation ComponentInstallation
Component
Code for Assembly Code for
Component A Descriptor + Component B
Deployment Tool
AssemblyFactory
ComponentServer ComponentServer
ComponentServer ComponentServer
Assembly
A instance B instance
Assembly
A instance B instance
K2 from ICMP
C++ on various ORBs
http://www.icmgworld.com