Title: Chapter 10 Introduction to Components
1Chapter 10Introduction to Components
2Process Phases Discussed in This Chapter
Requirements Analysis
Design
Architecture
Framework
Detailed Design
Implementation
Key
secondary emphasis
main emphasis
x
x
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
3Learning Goals for This Chapter
Understand
- benefits of components
- what components consist of
- how they are developed
- how they are combined
- with each other
- with applications
- how components can be executed
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
4Design Goal At Work ? Reusability ?
We want to re-use collections of software.
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
5Building With and Without Components
Without components
This affected by window change
With components Parts replaceable without
significant rebuilding
This affected by window change
etc.
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
6Key Concept ? What is a Component? ?
-- a software collection used without alteration.
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
7Components Can Be Made of
- Source code
- Classes -- one or more, possibly related
- Executable code
- Object code
- Virtual object code
- Other files
- Images, text, indices, etc.
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
8The Controlled Juggler Application
9BeanBox Environment
10Selecting Juggler
11Observations on Juggler Source Code 1
- Juggler is a class actually an Applet, so it
implements the Serializable interface - We do not alter (the code for) Juggler
- BeanBox recognizes that Juggler is a Component,
and displays an image of an instance. - Juggler listens for several kinds of events
- BeanBox recognizes that Juggler implements the
Runnable interface, and automatically executes
its run() - Juggler operates by displaying images from the
array images of type Image. The key lines in
run() are - Image img images ( loop 4 ) 1
-
- g.drawImage( img, 0, 0, this )
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
12Observations on Juggler Source Code 2
- rate is a private variable A public method is
available to set it as follows. - public void setAnimationRate( int x )
- rate x
-
- BeanBox recognizes animationRate as an int
property, and allows it to be set. - Juggler code distinguishes the behavior of the
bean between design time, run time etc. For
example - /
- If switching to runtime,
- If switching to design time and debugging is
true, . - /
- public void setDesignTime( boolean dmode ) ..
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
13Design Goal At Work ? Reusability ?
We want to construct and re-use a Juggler
instance connected to Start / Stop buttons.
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
14Causing ExplicitButton Press to
callstopJuggling() on Juggler
15Design Goal At Work ? Reusability ?
We want the functionality and event sensitivity
of a Bean to be available in any context.
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
16What Components Provide The Parts
of a Component
- Set of classes
- providing interfaces
- Manifest
- See below
- Properties
- Methods
- in the form of methods, published in interfaces
- Reactions to Events
- Ability to provide information about themselves
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
17Manifests
- Identification of the component
- Authorship of the component
- List of files or classes making up this component
- Other components on which this one relies Â
- Encryption information
- Means of verifying that all parts of the
component are present - Version number
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
18Introspection Runtime Java Information Includes
Class Name, superclass, super-interfaces, inner classes, fields, constructors, Mmethods
Field Name, type
Constructor Parameters, exceptions
Method Name, parameters, return type, exceptions
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
19Key Concept ? The Aspects of a Component ?
-- properties, functionality, sensitivity to
events, a manifest listing its files, and an
interface providing a self-description.
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
20UML Notation for Components
interfaces supported
components
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
21Phases of a Components Lifetime
Collection of classes manifest
Design / Implementation Time
Instance Creation Time
instance
Assembly Time
application
Deployment Time
x
x
executable
Performed in a development environment e.g.,
BeanBox
Execution Time
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
22Design Phase for Components
- Write source code for classes
- Ensure that the runtime environment contains
library classes required - Conform with required rules, if any (e.g., Java
Beans) - Incorporate required non-library classes
- Create a manifest listing the components parts
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
23Instance Creation Time
Create instance
Store instance
component instance
component
Compiled collection of classes
Component environment
Storage
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
24Assembly Time
Related instances
Instance creation and connection
Components
Storage
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
25Deployment Time
Execution environment
Storage
component
Compiled classes of the application
Complete application
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
26Key Concept ? The Lifecycle of a Component ?
Select, design, code source, instantiate, combine
instances, deploy in applications, execute.
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
27Components in CORBA Have Ports
- Facets (functionality provided for clients)
- Receptacles (functionality it requires)
- Dependence on other components
- Event sources (that its sensitive to)
- Event sinks (that it listens for on other
components) - Attributes (properties)
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
28Ports
receptacles
(Methods)
facets
event sink
attributes
(Properties)
event source
(Events)
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
29Component May Support Interfaces
Interface DepositTransactions . . . Used in
Component Bank supports DepositTransactions
Provide additional parts as desired
Specification of an interface (a list of function
prototypes)
Specification of a component
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
30Finding CORBA Components and Creating Instances
Get reference to component XYBank using the CORBA
naming service. (Not covered here.) Create
instances in two steps. (1) Use create() on
the component Org.omg.Components.ComponentBase
myXYBankInstance XYBank.create() (2) Cast the
instance as XYBank object XYBank bank
(XYBank) myXYBankInstance Now use bank . . .
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.
31Summary Components
- are software elements used without alteration
- allow the re-use of compiled parts
- Interaction via events reduces interdependence
- typically developed in a convenient container
- e.g., for visualizing and interconnecting
- to free the developer from common tasks
- consist of classes, files etc. and a manifest
Adapted from Software Design From Programming to
Architecture by Eric J. Braude (Wiley 2003), with
permission.