42
ArchStudio

Software Modelling in Arch Studio

Embed Size (px)

Citation preview

Page 1: Software Modelling in Arch Studio

ArchStudio

Page 2: Software Modelling in Arch Studio

Demo using ArchStudio 4 and Myx.fw

• Hello World with 2 components and 1 connector

Page 3: Software Modelling in Arch Studio

Hello World Demo• 1. Create Architecture

• 1.1 Create Structure• 1.2 Create Types Set

• 2. Add Types and Signatures• 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

Page 4: Software Modelling in Arch Studio

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

• 6.4 For Interface• 7. Write Java classes and interfaces

• 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.

Page 5: Software Modelling in Arch Studio

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.

Page 6: Software Modelling in Arch Studio

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.

Page 7: Software Modelling in Arch Studio

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

Page 8: Software Modelling in Arch Studio

1.2 Create Type Set

• On the Outline View, select the root element. Right click on it. Select Create Type Set.

Page 9: Software Modelling in Arch Studio

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

Page 10: Software Modelling in Arch Studio

2. Add Types and Signatures

2.1 For ComponentsCreate 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

Page 11: Software Modelling in Arch Studio

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

Page 12: Software Modelling in Arch Studio

2. Add Types and Signatures

2.2 For ConnectorCreate Signature• Double click on “Proxy Type.”• Right click on the connector and select New

Signature. Repeat this step to create another Signature.

Page 13: Software Modelling in Arch Studio

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

Page 14: Software Modelling in Arch Studio

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

Page 15: Software Modelling in Arch Studio

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

Page 16: Software Modelling in Arch Studio

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

Page 17: Software Modelling in Arch Studio

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.

Page 18: Software Modelling in Arch Studio

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”

Page 19: Software Modelling in Arch Studio

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

Page 20: Software Modelling in Arch Studio

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

Page 21: Software Modelling in Arch Studio

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

Page 22: Software Modelling in Arch Studio

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

Page 23: Software Modelling in Arch Studio

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

Page 24: Software Modelling in Arch Studio

6. Map Architecture to Impl6.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

Page 25: Software Modelling in Arch Studio

6. Map Architecture to Impl6.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

Page 26: Software Modelling in Arch Studio

6. Map Architecture to Impl6.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”

Page 27: Software Modelling in Arch Studio

6. Map Architecture to Impl6.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

Page 28: Software Modelling in Arch Studio

6. Map Architecture to Impl6.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

Page 29: Software Modelling in Arch Studio

6. Map Architecture to Impl6.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”

Page 30: Software Modelling in Arch Studio

6. Map Architecture to Impl6.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

Page 31: Software Modelling in Arch Studio

6. Map Architecture to Impl6.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

Page 32: Software Modelling in Arch Studio

6. Map Architecture to Impl6.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

Page 33: Software Modelling in Arch Studio

6. Map Architecture to Impl6.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]”

Page 34: Software Modelling in Arch Studio

6. Map Architecture to Impl6.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

Page 35: Software Modelling in Arch Studio

6. Map Architecture to Impl6.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

Page 36: Software Modelling in Arch Studio

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

Page 37: Software Modelling in Arch Studio

7. Write Java classes and interfaces

• Right click on helloworld2 package and select New-> Interface

• Interface Name: MessageIntf. Finish.

Page 38: Software Modelling in Arch Studio

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);}

Page 39: Software Modelling in Arch Studio

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");@Overridepublic void begin() {super.begin();// get the service objectMessageIntf messages = (MessageIntf)MyxUtils.getFirstRequiredServiceObject(this, MESSAGES_NAME);// do something with itmessages.processMessage("Hello World!");}public Object getServiceObject(IMyxName interfaceName) {// TODO Auto-generated method stubreturn null;} }

Page 40: Software Modelling in Arch Studio

7. Write Java classes and interfaces

• Copy the following content in MessageReceiver.java and Save the filepackage 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 stubif(interfaceName.equals(MESSAGES_NAME)){return this;}return null;}}

Page 41: Software Modelling in Arch Studio

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

Page 42: Software Modelling in Arch Studio

8. Run Hello World

• You should see the following output in the Console