Transcript Slides

INF 123: Software Architectures,
Distributed Systems, and
Interoperability
Discussion Session
Week 5 - Spring 2008
Instructor: Prof. Richard N. Taylor
TA: Rosalva Gallardo
Overview




Assignment 2
Update ArchStudio 4
Create Branch in SVN
Demo using ArchStudio 4 and Myx.fw

Hello World with 2 components and 1 connector
Assignment 2

It is published in the class website
Update ArchStudio 4



Help -> Software Updates -> Find and Install
Select Search for new features to install. Next
New Remote Site…

Name: ArchStudio 4 (Dev)

URL: http://www.isr.uci.edu/projects/archstudio-
update-dev
 Select to install all the options
=> After you are done with this update, you will not need to
run ArchStudio from the source code. Close the
ArchStudio projects (see next slide) and Instantiate the
LL architecture using the AIM Launcher. You will see
that we do not require a new instance of Eclipse now :)
Close ArchStudio Projects
Source Code


In the Package
Explorer, select all the
projects that start with
edu.uci.*, except for
edu.uci.isr.myx.fw
Go to Project -> Close
Project
Create Branch in SVN
Go to the SVN Repository Exploring
 Select LunarLander in trunk. Right click
and select Branch/Tag

Create Branch in SVN

Modify the To URL. Make sure it refers to
<your_repository>/tags/LunarLanderAssignment1

Refresh your repository to see the new folder in
tags
Demo using ArchStudio 4 and
Myx.fw

Hello World with 2 components and 1
connector
Hello World Demo

1. Create Architecture



2. Add Types and Signatures





1.1 Create Structure
1.2 Create Types Set
2.1 For Components
2.2 For Connector
2.3 For Interface
3. Add Components and Connector
4. Assign Types and Map Signature and Interfaces


4.1 For Components
4.2 For Connector
Hello World Demo


5. Create Links
6. Map Architecture to Implementation

6.1 For Components
• 6.1.1 For Component Signatures

6.2 For Connector
• 6.2.1 For Connector Signatures


7. Write Java classes and interfaces




6.4 For Interface
7.1 For Components
7.2 For Interface
8. Run Hello World
Important considerations:


Each time you add or modify something in the xml file, SAVE IT
When you switch between Archipelago and ArchEdit, or vice versa,
make sure that you close the one you are not using.
1. Create Architecture



Create Java Project. File->New->Java Project.
Project Name: HelloWorld2. Next.
Click on Projects, Add.. Check
edu.uci.isr.myx.fw. OK and Finish.
1. Create Architecture

Right-click on the Project and select New>Other…ArchStudio 4 -> ArchStudio
architecture Description
File Name: Architecture.xml. Finish.
 Open the xml file with Archipelago.

1.1 Create Structure

On the Outline View, expand the root
element. Right click on Structures. Select
New Structure.

Expand Structures. Right click on the new
Structure and select Edit Description.

New Description: HelloWorld2
1.2 Create Type Set

On the Outline View, select the root element.
Right click on it. Select Create Type Set.
2. Add Types and Signatures
2.1 For Components

Expand Types. Right click on Component Types and
select New Component Type.

Select the new Type. Right click on it and select Edit
Description.

New Description: Message Sender Type
2. Add Types and Signatures
2.1 For Components
Create Signature
 Double click on “Message Sender Type.”
 Right click on the component and select New Signature.

Similarly, create the Component Type: Message
Receiver Type and add a signature
2. Add Types and Signatures
2.2 For Connector

Expand Types. Right click on Connector Types and
select New Connector Type.

Select the new Type. Right click on it and select Edit
Description.

New Description: Proxy Type
2. Add Types and Signatures
2.2 For Connector
Create Signature
 Double click on “Proxy Type.”
 Right click on the connector and select New Signature. Repeat this
step to create another Signature.
2. Add Types and Signatures
2.3 For Interface

Expand Types. Right click on Interface Types and select
New Interface Type.

Select the new Type. Right click on it and select Edit
Description.

New Description: Message Type
3. Add Components and
Connector
Add Components

In the Outline View, double click on the
HelloWorld2 structure

Right click on the Archipelago View and Select
New Component
3. Add Components and
Connector

Right click on the new component. Select Edit
Description…

New Description: Message Sender

Similarly, create another Component with the
description: Message Receiver
3. Add Components and
Connector
Add Connector

Right click on the Archipelago View
and Select New Connector

Right click on the new connector.
Select Edit Description…

New Description: Proxy
4. Assign Types and Map Sig
4.1 For Components



Right click on Architecture.xml. Open with…
Type Wrangler
In the Outline, expand HelloWorld2
Double click on Message Sender. Click on
Assign Type button. Select Message Sender
Type. OK.
4. Assign Types and Map Sig
4.1 For Components
 In
the Unmapped Signatures box:
 Rename
the signature [New Signature] to
“messages”
 Set its direction to “out”
 Set its type to “Message Type”
4. Assign Types and Map Sig
4.1 For Components

Select the “messages” signature and create a
corresponding interface for the component by using
the “< Create” button

You will see “messages” in the Mapped Interfaces
and Signatures
4. Assign Types and Map Sig
4.1 For Components

Similarly, assign the Type Message Receiver Type to
Message Receiver, rename the signature to
“messages” with direction “in” and type Message
Type, and create the interface.

You should have the following Mapped Interfaces
and Signatures for Message Receiver
4. Assign Types and Map Sig
4.2 For Connector


Double click on Proxy. Click on Assign Type
button. Select Proxy Type. OK.
Rename the Unmapped Signatures as shown:


Signature: in, Direction: in, Type: Message Type
Signature: out, Direction: out, Type: Message Type
4. Assign Types and Map Sig
4.2 For Connector


Select the “in” signature and create a corresponding
interface for the connector by using the “< Create”
button. Do the same for the “out” signature
You will see “in” and “out” in the Mapped Interfaces
and Signatures
5. Create Links





Open Architecture.xml with
Archipelago
Right click and select New Link.
Move the link to connect Message
Sender to Proxy.
Create another Link to connect
Proxy to Message Receiver
Make sure that the link is green in
the interfaces
6. Map Architecture to Impl
6.1 For Components

In the Package Explorer View, right click on the xml file.
Open With->ArchEdit

In the Outline View, Expand Xarch, Arch Types,
Component Type [Message Sender Type]. Right click
on it. Select Promote to VariantComponentTypeImpl
6. Map Architecture to Impl
6.1 For Components



Similarly, right click on Component Type [Message Sender Type].
Select Add Implementation.
Right click on Implementation and select Promote to
JavaImplementation
Right click on Implementation and select Add Main Class
6. Map Architecture to Impl
6.1 For Components

Right click on Main Class and select Add
JavaClassName

Expand MainClass and double click on Java
ClassName and enter “helloworld2.MessageSender” as
a value
=> Similarly,
map “helloworld2.MessageReceiver” to the
“Message Receiver Type”
6. Map Architecture to Impl
6.1.1 For Component Signature

In the Outline View, Expand Xarch, Arch Types,
Component Type [Message Sender Type], Signature
[messages]. Right click on it. Select Promote to
SignatureImpl
6. Map Architecture to Impl
6.1.1 For Component Signature



Similarly, right click on Signature [messages]. Select Add
Implementation.
Right click on Implementation and select Promote to
LookupImplementation
Right click on Implementation and select Add Name
6. Map Architecture to Impl
6.1.1 For Component Signature

Expand Implementation and double click on Name and
enter “messages” as a value
=> Similarly,
map “messages” to the Signature in
“Message Receiver Type”
6. Map Architecture to Impl
6.2 For Connector

In the Outline View, Expand Xarch, Arch Types,
Connector Type [Proxy Type]. Right click on it. Select
Promote to VariantConnectorTypeImpl

Similarly, right click on Connector Type [Proxy Type].
Select Add Implementation.
Right click on Implementation and select Promote to
JavaImplementation

6. Map Architecture to Impl
6.2 For Connector



Right click on Implementation and select Add Main
Class
Right click on Main Class and select Add
JavaClassName
Expand MainClass and double click on Java
ClassName and enter
“edu.uci.isr.myx.conn.SynchronousProxyConnector” as
a value
6. Map Architecture to Impl
6.2.1 For Connector Signature

In the Outline View, Expand Xarch, Arch Types,
Component Type [Proxy Type], Signature [in]. Right
click on it. Select Promote to SignatureImpl
6. Map Architecture to Impl
6.2.1 For Connector Signature




Similarly, right click on Signature [in]. Select Add Implementation.
Right click on Implementation and select Promote to
LookupImplementation
Right click on Implementation and select Add Name
Expand Implementation and double click on Name and enter “in” as
a value
=> Similarly,
map “out” to the Signature [out]I in the Connector Type
[Proxy Type]”
6. Map Architecture to Impl
6.3 For Interface

In the Outline View, Expand Xarch, Arch Types,
Interface Type [Message Type]. Right click on it. Select
Promote to InterfaceTypeImpl

Right click on Interface Type [Message Type]. Select
Add Implementation.
Right click on Implementation and select Promote to
JavaImplementation

6. Map Architecture to Impl
6.3 For Interface



Right click on Implementation and select Add Main
Class
Right click on Main Class and select Add
JavaClassName
Expand MainClass and double click on Java
ClassName and enter “helloworld2.MessageIntf” as a
value
7. Write Java classes and
interfaces



Create the package helloworld2 in the HelloWorld2
project (New -> Package)
Right click on helloworld2 package and select New->
Class
Class Name: MessageSender. Finish.
=> Similarly,
create the class MessageReceiver
7. Write Java classes and
interfaces

Right click on helloworld2 package and select
New-> Interface

Interface Name: MessageIntf. Finish.
7. Write Java classes and
interfaces

Copy the following content in MessageIntf.java and Save the file
package helloworld2;
public interface MessageIntf {
public void processMessage(String message);
}
7. Write Java classes and
interfaces

Copy the following content in MessageSender.java and Save the file
package helloworld2;
import edu.uci.isr.myx.fw.AbstractMyxSimpleBrick;
import edu.uci.isr.myx.fw.IMyxName;
import edu.uci.isr.myx.fw.MyxUtils;
public class MessageSender extends AbstractMyxSimpleBrick {
public static final IMyxName MESSAGES_NAME = MyxUtils.createName("messages");
@Override
public void begin() {
super.begin();
// get the service object
MessageIntf messages = (MessageIntf)MyxUtils.getFirstRequiredServiceObject(this, MESSAGES_NAME);
// do something with it
messages.processMessage("Hello World!");
}
public Object getServiceObject(IMyxName interfaceName) {
// TODO Auto-generated method stub
return null;
}
}
7. Write Java classes and
interfaces

Copy the following content in MessageReceiver.java and Save the file
package helloworld2;
import edu.uci.isr.myx.fw.AbstractMyxSimpleBrick;
import edu.uci.isr.myx.fw.IMyxName;
import edu.uci.isr.myx.fw.MyxUtils;
public class MessageReceiver extends AbstractMyxSimpleBrick implements MessageIntf
{
public static final IMyxName MESSAGES_NAME = MyxUtils.createName("messages");
public void processMessage(String message) {
System.err.println("Received: "+message);
}
public Object getServiceObject(IMyxName interfaceName) {
// TODO Auto-generated method stub
if(interfaceName.equals(MESSAGES_NAME)){
return this;
}
return null;
}
}
8. Run Hello World
In the Package Explorer View, right click
on Architecture.xml, select Open With AIM
Launcher
 In the Outline View, double click on
HelloWorld2
 Click on Instantiate

8. Run Hello World

You should see the following output in the
Console