CMI 1'0 tutorial in Eclipse - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

CMI 1'0 tutorial in Eclipse

Description:

Deactivate. What happens when application is done. Instantiate. Calc. Input. Foundation ... deactivate() What to do when application is done? Often empty. ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 28
Provided by: defau635
Category:

less

Transcript and Presenter's Notes

Title: CMI 1'0 tutorial in Eclipse


1
CMI 1.0 tutorial in Eclipse
  • March 7 2006
  • CS509

2
Preliminaries
  • Moving away from strict Object-Oriented solutions
  • Goal is to have full Component-Based Software
    Engineering
  • Many assumptions are going to change
  • Need new development processes

3
Sample OO example
  • Problem Read two numbers from user and compute
    their product
  • Divide into (a) user interface (b) processing
  • Grab code from Examples_2007/modular
  • ComputeController
  • GUIBased (Execute this class)
  • Processor
  • TextBased (Execute this class)

4
UML highlights
5
CBSE Industries
  • Third party development
  • GUIBased and TextBased
  • Processor
  • Neither should know of the other
  • Not possible for GUIBased to instantiate
    Processor
  • Need standard solution
  • Deployment becomes an issue
  • In the same way that JDK 1.5 is deployed

6
Select File ? New Project
Then select Java Project
7
Enter Project Name
Enter oldCMI and press Finish
Will appear under your package explorer in Eclipse
8
File ? Import
First Select project oldCMI Then from File
menu select Import
Select Archive file (or Zip file if that is
presented to you)
9
Browse to ZIP location
Click on Browse to locate the file
oldCMITutorial.zip Click Finish
10
Run the Demonstration
Browse to the File oldCMIoldcmiFoundation.java
Right Click the mouse on the file Foundation.java
and select menu item Debug As?Java Application
11
You will see usage information
Usage java oldcmi.Foundation ltscriptsDirgt
ltstorageDirgt ltblocksDirgt ltscriptsDirgt is
directory where scripts are located.
ltstorageDirgt is directory for persistentStorage.
ltblocksDirgt is directory where block .jar
files exist.
Select menu Run ? Debug and you will see
something like the following
Foundation will be selected. Click on the
arguments tab.
12
Enter arguments to application
Enter scripts storage blocks exactly in the
Program Arguments window. Then click on the
Debug button at the bottom.
13
Proper Execution should occur
Enter in 2 numbers separated by a space and the
program will multiply them together. Enter -1
1 to exit.
14
CMI 1.0 in a nutshell
  • A technology that enables independently-developed
    components to communicate with each other
  • Relies on Foundation container that manages the
    lifecycle of the components

15
CMI 1.0 Component Life Cycle
  • Instantiate
  • More comprehensive and powerful than new
  • Connect
  • Enable components to communicate with each other
    via standardized (and versioned!) interfaces
  • Activate
  • Rudimentary control flow
  • Deactivate
  • What happens when application is done

16
Instantiate
ICalc
ICalc
Load class from tutorial.jar Create new instance
Load class from calc.jar Create new instance
Foundation
17
Connect
ICalc
ICalc
connect (IBlock b, String iname)
Have Input connect to Calc on ICalc interface.
Why?Because Input Requires some component
through the ICalc interface.
Foundation
18
Activate
ICalc
ICalc
activate
activate
Foundation
19
Deactivate
ICalc
ICalc
deactivate
deactivate
Foundation
20
Tutorial Phase Two
  • Develop a second Calculator component that adds
    the numbers instead
  • Develop Block Template
  • Fill in add computation
  • Package Deploy
  • Modify Instantiation Scripts
  • Execute

21
1. Develop Block Template
  • In the Eclipse project for the CMI 1.0 tutorial
  • Create new package (I call it two)
  • Within this package create a new class that
    implements IBlock
  • Click on Add to locate IBlock interface
  • Once done, click Finish

22
Methods for IBlock component
  • activate()
  • Initiate the execution of component at run-time
    note that this must return true, otherwise
    Foundation will assume failure
  • connect (IBlock, String)
  • If component has external dependency, it can only
    be fulfilled by having an external component
    satisfy it. The component is responsible for
    storing this reference for later use see
    FirstTry in tutorial for example
  • deactivate()
  • What to do when application is done? Often empty.

23
Methods for IBlock component (cont)
  • getProvided()
  • Return those interfaces provided by this
    component. Never return null but rather an empty
    Enumeration
  • getRequired()
  • Return required interfaces. Never return null but
    rather an empty Enumeration
  • Default Constructor()
  • Each Block component must have a default
    no-argument constructor for Foundation to
    instantiate it.

24
Full Implementation for Adder
  • package two
  • import ifaces.ICalc
  • import java.util.Enumeration
  • import java.util.Vector
  • import oldcmi.interfaces.IBlock
  • public class Adder implements IBlock, ICalc
  • public boolean activate() return true
  • public boolean connect(IBlock obj, String
    interfaceName) return false
  • public void deactivate()
  • public Enumeration getProvided()

25
Deploy Adder Component
  • Create JAR file within blocks/ directory
  • Right-click two package and select Export

Make sure that you select the ifaces package as
well as the two package. Make sure that JAR
file is located within the blocks/
directory. Then click Next
26
Deploy Adder Component (cont)
  • Create the JarDesc file within two package.
  • Then click Finish.

Note how adder.jar file appears in blocks/
directory
27
Rewrite Application scripts
  • Modify instantiate.scr in scripts/ directory
  • Now re-launch Foundation

here we put a list of commands to instantiate
components we are going to use instantiate
two.Adder from adder.jar as Calc instantiate
tutorial.FirstTry from tutorial.jar as Input
Reading Scripts from scripts Connect
Successful Storage Directory C\Documents and
Settings\George\workspace\S07\storage Trying to
load two.Adder Trying to load
tutorial.FirstTry FirstTry Enter two numbers,
separated by a space and press return. I will
perform a computation on them. enter "-1 -1" to
stop. 6 7 compute(6,7) 13 -1 -1 Program stopped.
Write a Comment
User Comments (0)
About PowerShow.com