INF 123 Software Architectures Distributed Systems and Interoperability
INF 123: Software Architectures, Distributed Systems, and Interoperability Discussion Session Week 4 - Spring 2008 Instructor: Prof. Richard N. Taylor TA: Rosalva Gallardo
Overview n n n Questions about Assignment 1 Arch. Studio 4 Hello World Demo using Arch. Studio 4 and Myx. fw
Questions about Assignment 1 How our answer for 2. 2 should look like? Should I include code details? n How many types of connector do we have for 2. 3? n Any other questions? ==> Post your questions in the Noteboard and check it often n
Arch. Studio 4 An Introductory Tutorial Slides adapted from Hazel Asuncion
Roadmap n n What is Arch. Studio 4 Concepts n n Toolset integrated with Eclipse n n n n x. ADL 2. 0 Data Bindings Myx Architectural Style Eclipse plug-in AIM Launcher Arch. Edit Archipelago Arch. Light Selector Type Wrangler Using Arch. Studio n Hello World Demo
What is Arch. Studio 4? n n Architecture-centric IDE Open-source Eclipse plug-in Integrated tools for software architecture n n Modeling Visualization Analysis Implementation Ref: http: //www. isr. uci. edu/projects/archstudio/
Just Another IDE? n n No, it complements existing IDEs like Eclipse Minimize architectural drift “Architectural drift: is the introduction of principal design decisions into a system’s descriptive architecture that are not included in, encompassed by, or implied by the prescriptive architecture, but which do not violate any of the prescriptive architecture’s design decisions… If not properly addressed, architectural drift will eventually result in architectural erosion. ” [Taylor et al, 2009] n Built on its own architecture style
Concepts x. ADL 2. 0 n Data Bindings n Myx Architectural Style n
x. ADL 2. 0 n n n Architectural Description Language in XML developed by ISR at UCI This ADL is defined in a set of XML Schemas Modeling language behind Arch. Studio Modular and highly extensible Core models n n Ref: Components (computation) Connectors (communication) Interfaces (the exposed entry and exit points for components and connectors) Configurations (topology) http: //www. isr. uci. edu/projects/archstudio/xadl 2. html http: //www. ics. uci. edu/~edashofy/papers/icse 2002 -presentation. ppt http: //www. isr. uci. edu/projects/xarchuci/
x. ADL 2. 0 n n n Tools can access the architecture description in x. ADL 2. 0 via a common interface, the component x. Arch. ADT. Base: x. Arch Instances Core Extensions n n n Architecture structures and types Product Families – versions, options, variants Implementation mappings – architecture types to implementations Ref: http: //www. ics. uci. edu/~edashofy/papers/icse 2002 -presentation. ppt
x. ADL 2. 0: CM/Product Family Arch Ref: http: //www. ics. uci. edu/~edashofy/papers/icse 2002 -presentation. ppt
x. ADL 2. 0: Implementation Mapping Arch. Studio 4 currently supports mapping to Java files Ref: http: //www. ics. uci. edu/~edashofy/papers/icse 2002 -presentation. ppt
XML e. Xtensible Markup Language n Means of representing structured data n Looks like HTML but the tags are userdefined n Schema n Describe data in the XML doc n The “rules” for the XML doc n Ref: http: //www. w 3 schools. com/xml/default. asp
x. ADL 2. 0 Core Model <arch. Structure id="arch. Structure 90164" type="types: Arch. Structure"> <description>main</description> <component id="componentffa 805157" type="types: Component"> <description>Server</description> <interface id="interfaceffa 80123" type="types: Interface"> <description>get. Resource</description> <direction>in</direction> </interface> </component> <component id="componentffa 12852" type="types: Component"> <description>Client</description> <interface id="interfaceffa 57518" type="types: Interface"> <description>get. Resource</description> <direction>out</direction> </interface> </component> <connector id="connectorffa 12435" type="types: Connector"> <description>HTTP</description> <interface id="interfaceffa 54685" type="types: Interface"> <description>get. Resource</description> <direction>in</direction> </interface> <interface id="interfaceffa 54686" type="types: Interface"> <description>get. Resource</description> <direction>out</direction> </interface> </connector> </arch. Structure> Server HTTP Client
x. ADL 2. 0 Components <component id="componentffa 805157" type="types: Component"> <description>Server</description> <interface id="interfaceffa 80123" type="types: Interface"> <description>get. Resource</description> <direction>in</direction> </interface> </component> <component id="componentffa 12852" type="types: Component"> <description>Client</description> <interface id="interfaceffa 57518" type="types: Interface"> <description>get. Resource</description> <direction>out</direction> </interface> </component> Server HTTP Client
x. ADL 2. 0 Connector Server <connector id="connectorffa 12435" type="types: Connector"> <description>HTTP</description> <interface id="interfaceffa 54685" type="types: Interface"> <description>get. Resource</description> <direction>in</direction> </interface> <interface id="interfaceffa 54686" type="types: Interface"> <description>get. Resource</description> <direction>out</direction> </interface> </connector> HTTP Client
x. ADL 2. 0 Interfaces <component id="componentffa 805157" type="types: Component"> <description>Server</description> <interface id="interfaceffa 80123" type="types: Interface"> <description>get. Resource</description> <direction>in</direction> </interface> </component> <component id="componentffa 12852" type="types: Component"> <description>Client</description> <interface id="interfaceffa 57518" type="types: Interface"> <description>get. Resource</description> <direction>out</direction> </interface> </component> <connector id="connectorffa 12435" type="types: Connector"> <description>HTTP</description> <interface id="interfaceffa 54685" type="types: Interface"> <description>get. Resource</description> <direction>in</direction> </interface> <interface id="interfaceffa 54686" type="types: Interface"> <description>get. Resource</description> <direction>out</direction> </interface> </connector> Server HTTP Client
Data Bindings A set of Java classes that can be used to create and manipulate architecture descriptions Generated by “Apigen” tool, based on XML schemas Reduces the complexity of editing architecture descriptions by hiding the XML and providing constructs more familiar to architects Parses from and serializes to XML n n n XML API (DOM, SAX) n n Elements Attributes Documents Namespaces Data Binding API n n vs. Ref: http: //www. ics. uci. edu/~edashofy/papers/icse 2002 -presentation. ppt n n Components Connectors Interfaces Links Configurations etc.
Data Binding Library Ref: Dashofy, E. , Asuncion, H. , et al. Arch. Studio 4: An Architecture-Based Meta-modeling Environment. ICSE 2007 Demo Paper.
Myx Architecture Style n Purpose n n n Heritage n n Support building flexible, high performance toolintegrating environments Serve as a foundation for building environments in Eclipse Borrows most of key properties from C 2 style System implementation currently supported in Arch. Studio 4 Ref: http: //www. isr. uci. edu/projects/archstudio/myx. html
Myx Architectural Style n Rules n n n Components are the loci of computation Connectors are the loci of communication Components communicate only through well-defined provided and required interfaces Components and connectors have two ‘faces’: ‘top’ and ‘bottom’ Components interact through three distinct patterns • Synchronous bottom-to-top procedure call • Asynchronous top-to-bottom (notification) messaging • Asynchronous bottom-to-top (request) messaging n n n Components may only make assumptions about the services provided above them, and may make no assumptions about the services provided below them. Applications have at least one main thread of control. Additional threads may be created by components as necessary. Asynchronous connectors also have their own threads. Shared Memory Ref: http: //www. isr. uci. edu/projects/archstudio/resources/myx-whitepaper. pdf
Myx Architectural Style n Benefits Easy to reuse - components are relatively independent of each other n Easy to reconfigure – communication only via explicit interfaces n Enables runtime modification – through dynamic proxies and event pumps n
Myx. fw Framework n n n Difficult to adhere to the constraints of a style using an existing programming language Bridge the gap between Myx and Java: myx. fw Component and Connectors implement IMyx. Brick interface Ref: http: //www. ics. uci. edu/~edashofy/classes/211/myx-assignment. ppt
Implementing a myx. fw component n Components have main classes that implement IMyx. Brick n n They may have as many auxiliary classes as you want The main class may just be a wrapper for services provided internally Abstract. Myx Simple. Brick implements extends Ref: Lunar. Lander Components http: //www. ics. uci. edu/~edashofy/classes/211/myx-assignment. ppt IMyx. Brick
Implementing a myx. fw component n Components have three main jobs Store data from the framework (IMyx. Brick. Items) n Implement lifecycle methods (init, begin, end, destroy) n Provide true objects for all provided interfaces n Ref: http: //www. ics. uci. edu/~edashofy/classes/211/myx-assignment. ppt
Component Jobs n Store IMyx. Brick. Items from the framework n n n The framework needs to store some data about the component along with the component Abstract base classes take care of this for you Implement lifecycle methods n Called by the framework when the architecture is in particular states • • init(): Brick is created begin(): Brick is wired into the architecture and ready to start end(): Brick is about to be unwired and shut down destroy(): Brick is about to be dismissed Ref: http: //www. ics. uci. edu/~edashofy/classes/211/myx-assignment. ppt
Component Jobs n Provide true objects for each provided interface Each provided/required interface has a name n The framework will occasionally ask a component “give me the object that corresponds to this provided interface” n Likewise, a component may request, from the framework, the true object corresponding to one of its required interfaces n Ref: http: //www. ics. uci. edu/~edashofy/classes/211/myx-assignment. ppt
Toolset Integrated with Eclipse n n Eclipse plug-in Arch. Studio Perspective n n AIM Launcher – launch the system in development within Arch. Studio Arch. Edit • Visualization • Tree-view – schema driven • Indicate implementation mappings n Archipelago • Visualization and modeling • Boxes and arrows n n n Arch. Light - analysis Selector – product Families Type Wrangler – consistency checks between types and instances
Arch. Studio 4. 0 Built on its own tools and technologies n Architecture specified in x. ADL 2. 0 n Upon invocation n Bootstrapper parses the Arch. Studio x. ADL file using the Data Binding Library n Bootstrapper steps through x. ADL file and instantiates the various components n
Arch. Studio Tools n n Ref: x. Arch. ADT – Data Store Live integration between tools
Using Arch. Studio n Hello World Demo
Hello World Demo n 1. Create Architecture n n n 2. Add component n n n 1. 1 Create Structure 1. 2 Create Types Set and Component Type 2. 1 Edit description 2. 2 Assign type to component 3. Map Architecture to Implementation 4. Write Hello. World Java class 5. Move xml file to Java Project 6. Run Hello World
1. Create Architecture n n n In Eclipse, go to Arch. Studio Perspective Create a new project. File->New->Project. General->Project. Next. Project Name: Hello. World. Project. Finish
1. Create Architecture n Right-click on the Project and select New>Other…Arch. Studio 4 -> Arch. Studio architecture Description File Name: Architecture. xml. Finish. n Open the xml file with Archipelago. n
1. 1 Create Structure n On the Outline View, expand the root element. Right click on Structures. Select New Structure. n Expand Structures. Right click on the new Structure and select Edit Description. n New Description: Hello. World
1. 2 Create Type Set and Component Type n On the Outline View, select the root element. Right click on it. Select Create Type Set. n Expand Types. Right click on Component Types and select New Component Type. n Select the new Type. Right click on it and select Edit Description. n New Description: Hello. World. Type
2. Add Component n In the Outline View, double click on the Hello. World structure n Right click on the Archipelago View and Select New Component
2. 1 Edit description n Right click on the new component. Select Edit Description… n New Description: Hello. World
2. 2 Assign type to component n Select Hello. World. Type in the Outline View. Drag it and drop it on the Hello. World component.
3. Map Architecture to Implementation n In the Navigator View, right click on the xml file. Open With->Arch. Edit n In the Outline View, Expand Xarch, Arch Types, Component Type [Hello. World. Type]. Right click on it. Select Promote to Variant. Component. Type. Impl
3. Map Architecture to Implementation n Similarly, right click on Component Type [Hello. World Type]. Select Add Implementation. Right click on Implementation and select Promote to Java. Implementation Right click on Implementation and select Add Main Class
3. Map Architecture to Implementation n Right click on Main Class and select Add Java. Class. Name n Expand Main. Class and double click on Java Class. Name and enter “Hello. World” as a value
4. Write Java Class n n n Create Java Project. File->New->Java Project Name: Hello. World. Next. Click on Projects, Add. . Check edu. uci. isr. myx. fw. OK and Finish.
4. Write Java Class n Right click on Hello. World project and select New-> Class n Class Name: Hello World. Finish.
4. Write Java Class n Copy the following content in Hello. World. java and Save the file import edu. uci. isr. myx. fw. Abstract. Myx. Simple. Brick; import edu. uci. isr. myx. fw. IMyx. Name; import edu. uci. isr. myx. fw. Myx. Utils; public class Hello. World extends Abstract. Myx. Simple. Brick{ // category: constructor public Hello. World( ){} // category: startup and cleanup public void init(){} public void begin() { System. out. println("Hello world!"); } public void end(){} public void destroy(){} // override a required method public Object get. Service. Object(IMyx. Name name){ //Since we are not implementing an interface in this class //we will return null. //if(name. equals(INTERFACE_NAME_IN_NAME)){ // return this; //} return null; } }
5. Move XML file to Java Project n Create “arch” folder in Hello. World/src n Move (drag and drop)Architecture. xml from Hello. World. Project to Hello. World/src/arch
6. Run Hello World In the Navigator View, right click on Architecture. xml, select Open With AIM Launcher n In the Outline View, double click on Hello. World n Click on Instantiate n
6. Run Hello World n You should see the following output in the Console
- Slides: 48