Professional Documents
Culture Documents
kung-kiu,zw @cs.man.ac.uk
Partially supported by CoLogNet, a European Network of Excellence In this paper we will consider mainly the following software
funded by IST FET. component models: JavaBeans [33], EJB, COM, CCM,
Koala [35], SOFA [29], KobrA [5], ADLs [11], UML2.0 2.3 The Composition of Software Components
[26], PECOS [24], Pin [19] and Fractal [8].
In CBSE, composition is a central issue, since compo-
2.1 The Syntax of Software Components nents are supposed to be used as building blocks from a
The syntax of components defines what they are physi- repository and assembled or plugged together into larger
cally, i.e. the rules for constructing and representing them. blocks or systems. In order to define composition, we need
Ideally the syntax should be embodied in a language that a composition language, e.g. [22]. The composition lan-
can be used for defining and constructing components. guage should have suitable semantics and syntax that are
In current component models, the language for compo- compatible with those of components in the component
nents tends to be a programming language. For example in model. In most of the current component models, e.g. Jav-
both JavaBeans and EJB, components are defined as Java aBeans, EJB, COM and CCM, there is no composition lan-
classes. guage. ADLs of course have composition languages [4].
In order to reason about composition, we need a com-
2.2 The Semantics of Software Components position theory. Such a theory allows us to calculate and
A generally accepted view of a software component is thus predict the result of applying a composition operator to
that it is a software unit consisting of (i) a name; (ii) an in- components (see [13] for a discussion). Current component
terface; and (iii) code (Figure 1 (a)). The code implements models tend not to have composition theories, even those
Name with a composition language.
Interface provided services Composition can take place during different stages of the
Code required services
life cycle of components [10]. We identify two main stages
(a) (b) in this cycle, the design phase and the deployment phase,
Figure 1. A software component. where composition takes place:
the services provided, or operations performed, by the com-
ponent, and is not visible or accessible from outside. The
Design Phase.
interface is the only point of access to the component, so it In this phase, components are designed and con-
should provide all the information that is necessary to use structed, and then may be deposited in a repository
the component. In particular, it should specify the services if there is one. Components constructed in this phase
required by the component in order to produce the services are stateless, since they are just templates (like classes)
it provides (Figure 1 (b)). Required services are typically that cannot execute. The only data that they can con-
input values for parameters of the provides services. The tain at this stage are constants. Nevertheless, (unlike
interface of a component thus specifies the dependencies classes) they can be composed into composite compo-
between its provided and required services. nents. If there is a component repository, then the con-
In current component models, components tend to be structed components, including composite ones, have
objects in the sense of object-oriented programming. The to be catalogued and stored in the repository in such
methods of these objects are their provided services, and a way that they can be retrieved later, as and when
the methods they call in other objects are their required ser- needed.
vices. These objects are usually hosted in an environment,
Deployment Phase.
e.g. a container, which handles access to, and interactions In this stage, component instances are created by in-
between, components. As a result, the semantics of these stantiating (composite) components with initial data,
components is an enhanced version of that of the corre- so that they have states and are ready for execution. If
sponding objects; in particular they can interact with one there is a component repository, then components have
another via mechanisms provided by the environment. to be retrieved from the repository before instantiation.
For example, in JavaBeans and EJB, although syntacti-
cally they are both Java classes, Java beans and enterprise
2.3.1 Composition in the Design Phase
Java beans are different semantically. Semantically a Java
bean is a Java class that is hosted by a container such as In the Design Phase, components can be composed into
BeanBox. Java beans interact with one another via adap- composite components. Composite components are also
tor classes generated by the container. Adaptor classes link stateless. Composite components form sub-parts of a sys-
beans via events. An enterprise Java bean, on the other tem, and as such are useful for designing a system. There-
hand, is a Java class that is hosted and managed by an fore, composition in the design phase is concerned with the
EJB container provided by a J2EE server [31], via two in- design of systems and their sub-parts. If there is a com-
terfaces, the home interface and the remote interface, for ponent repository, then composite components can also be
the enterprise bean. Enterprise beans interact directly via stored in the repository, and retrieved later, like any compo-
method delegation within the EJB container. nents.
For example, in JavaBeans, the container provides a in a language called CoCo (Component Composition Lan-
repository for beans, e.g. ToolBox in the Beans Develop- guage) [17], whilst in Pin, components are defined in a
ment Kit (BDK) [32, 30], which are stored as JAR files. language called CCL (Construction and Composition Lan-
However, no composition is possible in the design phase, guage) [38]. CoCo and CCL are composition languages that
and therefore no composite beans can be formed. are essentially architecture description languages.
The main difference between these categories is that
2.3.2 Composition in the Deployment Phase components in (i) and (ii) are directly executable, in their
In the Deployment Phase, component instances can be com- respective programming languages, whereas components in
posed into a complete system that is executable. The system (iii) are only specifications, which have to be implemented
and its constituent component instances are the end result of somehow using suitable programming languages.
system design (design phase) and implementation (deploy-
ment phase).
3.2 Categories based on Component Semantics
For example, in the deployment phase of JavaBeans, Based on semantics, component models can be grouped
bean instances are created from beans in the repository, and into three categories: (i) component models in which com-
these can be composed (linked) graphically using BeanBox. ponents are classes; (ii) models in which components are
Component Semantics Models
3 Categories of Component Models Classes JavaBeans, EJB
Objects COM, CCM, Fractal
Clearly, we can classify existing software component Architectural Units ADLs, UML2.0, KobrA, Koala, SOFA, PECOS, Pin
models according to component syntax, semantics or com- Figure 3. Categories based on semantics.
position. In this section, we present these three categories. objects; and (iii) those in which components are architec-
tural units (Figure 3).
3.1 Categories based on Component Syntax Component models that belong to (i) are JavaBeans and
Based on component syntax, current models fall into EJB, since semantically components in these models are
three categories: (i) models in which components are de- special Java classes, viz. classes hosted by containers.
fined by object-oriented programming languages, (ii) those Component models that belong to (ii) are COM, CCM
in which an IDL (interface definition language) is used and and Fractal, since semantically components in these models
in which components can be defined in programming lan- are run-time entities that behave like objects. In COM, a
guages with mappings from the IDL; and (iii) those in component is a piece of compiled code that provides some
services, that is hosted by a COM server. In CCM, a com-
Component Syntax Models ponent is a CORBA meta-type that is an extension and spe-
Object−oriented Programming Languages JavaBeans, EJB
Programming Languages with IDL mappings COM, CCM, Fractal
cialisation of a CORBA object, that is hosted by a CCM
Architecture Description Languages ADLs, UML2.0, KobrA, Koala, container on a CCM platform such as OpenCCM [25]. In
SOFA, PECOS, Pin
Fractal, a component is an object-like run-time entity in lan-
Figure 2. Categories based on syntax. guages with mappings from the chosen IDL.
which components are defined by architecture description Component models that belong to (iii) are ADLs,
languages (Figure 2). UML2.0, KobrA, Koala, SOFA, PECOS and Pin. Semanti-
Component models that belong to (i) are JavaBeans and cally, components in these models are units of computation
EJB, where components are implemented in Java. and control (and data) connected together in an architecture.
Component models that belong to (ii) are COM, CCM In ADLs, a component is an architectural unit that repre-
and Fractal. These models use IDLs to define generic in- sents a primary computational element and data store of a
terfaces that can be implemented by components in specific system. In UML2.0, a component is a modular unit of a sys-
programming languages. COM uses the Microsoft IDL [6], tem with well-defined interfaces that is replaceable within
CCM uses the OMG IDL [27], whereas Fractal can use any its environment. In KobrA, components are UML compo-
IDL. nents. In Koala, SOFA and PECOS, a component is a unit
Component models that belong to (iii) are ADLs, of design which has a specification and an implementation.
UML2.0, KobrA, Koala, SOFA, PECOS and Pin. Obvi- In Pin, a component is an architectural unit that specifies a
ously in all ADLs, components are defined in architec- stimulus-response behaviour by a set of ports (pins).
ture description languages. In UML2.0 and KobrA, the 3.3 Categories based on Composition
UML notation is used as a kind of architecture descrip-
tion language, and components are defined by UML dia- To define categories based on composition, we first con-
grams. In Koala and SOFA, components are defined in sider composition in an ideal life cycle. This will provide
ADL-like languages. In PECOS, components are defined a basis for comparing composition in existing component
models. An idealised version of the component life cycle In Category 1, in the design phase, there is a repository
that we described in Section 2 is one where a repository is but there is no composition: components are constructed in-
available in the design phase, and component composition dividually by the builder and stored separately in the repos-
is possible in both the design and the deployment phases. itory. The builder can only construct new components, and
It is depicted in Figure 4. We believe this view of the cannot retrieve components from the repository. In the de-
Design Deployment ployment phase, components are retrieved from the reposi-
Builder Repository Assembler tory, and instantiated, and the assembler can be used to com-
A A pose the instances.
InsA
B
The sole member of this category is JavaBeans (see Fig-
B InsB ure 6). In the design phase, Java beans can be constructed in
C
C InsD a Java programming environment such as Java Development
D
component component instance Kit, and deposited in the ToolBox of the BDK, which is the
InsBC
design phase BC deployment phase repository for Java beans. There is no bean composition in
composition operator composition operator
the design phase. In the deployment phase, the assembler
Figure 4. The idealised component life cycle. is the BeanBox of the BDK, which can be used to compose
ideal component life cycle is the commonly accepted one bean instances by the Java delegation event model.
in CBSE, and not just our own subjective view: all existing Figure 6 shows a simple JavaBeans example. Message-
component models reflect this ideal life cycle to varying de- BeanA and MessageBeanB display the messages “Hello,
grees, as we will show later. I’m Bean A” and “Hello, I’m Bean B” respectively when
In the design phase of the idealised life cycle, a builder notified of the ‘mousePressed’ event by another bean.
tool can be used to (i) construct new components, and then Builder Repository Assembler A = MessageBeanA (JAR file)
deposit them in the repository, e.g. in Figure 4; (ii) re- Bean A
B = MessageBeanB (JAR file)
A A
trieve components from the repository, compose them and C Bean A = MessageBeanA instance
B B
deposit them back in the repository, e.g. in Figure 4, and Bean B
C = Adaptor object
are composed into a composite that is deposited in ToolBox BeanBox
assembler tool can be used to compose them into a com- the bean implementation class, the event state object and
plete system, e.g. in Figure 4, instances of and the event listener interface. These files are deposited into
are created and composed into a system. The system is then the ToolBox of the BDK. No bean composition is possible
executable in the run-time environment of the deployment at this stage.
phase. In the deployment phase, instances Bean A and Bean B
The idealised component life cycle provides a basis for of MessageBeanA and MessageBeanB respectively are cre-
comparing and classifying composition in existing compo- ated by dragging the beans from the ToolBox and dropping
nent models. For instance, some component models do not them into the BeanBox. In the BeanBox, Beans A and B
have composition in the design phase, whilst some mod- can be composed via event handling: a source event in one
els do; some have composition in the deployment, whilst bean can be linked to a target method in the other. For in-
Builder Repository Assembler Builder Repository stance, Beans A and B can be linked in such a way that
A A InsA A A InsA when the mouse is pressed on Bean B, the message “Hello,
B B InsB B B InsB
I’m Bean A” will be displayed by Bean A. The composition
mechanism provided by the BeanBox is an (automatically
Category 1 Category 2
(JavaBeans) (EJB,COM, CCM) generated and compiled) adaptor object that handles events
Builder Repository Builder Repository and passes method calls between the beans.
A A InsA
In Category 2 (Figure 5), in the design phase, there is
A
also a repository, but composition is possible. Like in Cate-
B AB InsAB B InsB
gory 1, the builder can only construct new components, and
Category 3 Category 4
(Koala, SOFA, KobrA) (ADLs, UML2.0, PECOS, Pin, Fractal)
cannot retrieve components from the repository. Moreover,
no composite component can be stored in the repository.
Figure 5. Categories based on composition.
Therefore composition has to be performed by the builder
some do not. Thus many categories are possible. Figure 5 and then has to be stored ‘as is’ in the repository, i.e. as a set
gives four categories that cover all major existing compo- of individual components together with the links between
nent models. them defined by the composition. As a result, this composi-
tion has to be retained even in the deployment phase, since The repository of CORBA components is a CCM container
it is only possible to instantiate the individual components hosted and managed by an application server, and compo-
(and not their composite). Consequently, composition is not sition is also by direct method calls in the design phase. In
possible, and therefore there is no assembler, in the deploy- the deployment phase, the CCM container provides the run-
ment phase. This category includes EJB, COM and CCM. time environment.
For example, in EJB, enterprise beans can be constructed Category 3 (Figure 5) is the same as Category 2 except
in a Java programming environment such as Eclipse [15]. that in Category 3 the builder can retrieve (composite) com-
The repository for enterprise beans is an EJB container ponents from the repository, e.g. in Figure 5, is retrieved
hosted and managed by a J2EE server. In the design phase, from the repository; and the repository can store compos-
enterprise beans are composed by method and event delega- ite components, e.g. in Figure 5, is a composite. No
tion. In the deployment phase, no new composition is pos- new composition is possible in the deployment phase, and
sible (see e.g. [9]), and so there is no assembler. The EJB so there is no assembler. Koala, SOFA and KobrA belong
container provides the run-time environment for the bean to this category.
instances. For example, in Koala, components are definition
Figure 7 shows an EJB example. A book store wishes to files that represent design units in the Koala language.
maintain a database of its book stock. Suppose books can The repository for Koala components is the KoalaModel
be purchased and have their details added to the database Workspace, which is a file system. In the design phase,
by any shop assistant. Then the book store can use a set of Koala components are composed by method calls through
enterprise beans to implement a system that allows multiple connectors. In the deployment phase, Koala components
clients to access and update the database. Suppose this are compiled into a programming language, e.g. C, and ex-
Builder Repository A = BookBean (EJB JAR file) ecuted in the run-time environment of that language.
B = BookStoreBean (EJB JAR file) Figure 8 shows a Koala example of a Stopwatch device
A A InsA
InsA = BookBean instance Builder Repository A = Countdown definition files
C C C
InsB = BookStoreBean instance B = Display definition files
B B InsB A A
C = Method calls AB = Stopwatch definition file
EJB container C
AB InsAB InsAB = Stopwatch binary file
B
Figure 7. Category 2: EJB example. B C = Method calls