You are on page 1of 20

Software Architecture Lab Manual (CSE701)

Sr.no EXPERIMENT Pg no Date Signature

1 Understanding the fundamentals of Software architecture,


qualities & its terminologies.

2
Steps to draw the Use-Case Diagram using Rational Rose.

3 Demonstrate a struts application which accepts user inputs


and show input values.

4 Demonstrate Hibernate application to store employee object to


the database.

5 Demonstrate stateless session bean in EJB

6 Demonstrate Angular JS directives

7 Architectural Study of Java Message Service (JMS) will be submitted by


students which comprised of:
1. JMS introduction 2. Block Diagram 3. Setup Configurations 4. Advantages

8 Architectural Study of Remote Method Invocation (RMI) will be submitted by


students which comprised of:
1. RMI introduction 2. Block Diagram 3. Setup Configurations 4. Advantages
EXPERIMENT NO. 1

AIM: Understanding the fundamentals of Software architecture, qualities & its terminologies.
The architecture of a system describes its major components, their relationships (structures), and how they
interact with each other. Software architecture and design includes several contributory factors such as Business
strategy, quality attributes, human dynamics, design, and IT environment.

We can segregate Software Architecture and Design into two distinct phases: Software Architecture and
Software Design. In Architecture, nonfunctional decisions are cast and separated by the functional
requirements. In Design, functional requirements are accomplished.
Software Architecture
Architecture serves as a blueprint for a system. It provides an abstraction to manage the system complexity
and establish a communication and coordination mechanism among components.
• It defines a structured solution to meet all the technical and operational requirements, while optimizing the
common quality attributes like performance and security.
• Further, it involves a set of significant decisions about the organization related to software development and
each of these decisions can have a considerable impact on quality, maintainability, performance, and the overall
success of the final product. These decisions comprise of –
o Selection of structural elements and their interfaces by which the system is composed.
o Behavior as specified in collaborations among those elements.
o Composition of these structural and behavioral elements into large subsystem.
o Architectural decisions align with business objectives.
o Architectural styles guide the organization.

Software Design
Software design provides a design plan that describes the elements of a system, how they fit, and work together
to fulfill the requirement of the system. The objectives of having a design plan are as follows –
• To negotiate system requirements, and to set expectations with customers, marketing, and management
personnel.
• Act as a blueprint during the development process.
• Guide the implementation tasks, including detailed design, coding, integration, and testing.
It comes before the detailed design, coding, integration, and testing and after the domain analysis, requirements
analysis, and risk analysis.

Goals of Architecture
The primary goal of the architecture is to identify requirements that affect the structure of the application. A
well-laid architecture reduces the business risks associated with building a technical solution and builds a bridge
between business and technical requirements.
Some of the other goals are as follows –
• Expose the structure of the system, but hide its implementation details.
• Realize all the use-cases and scenarios.
• Try to address the requirements of various stakeholders.
• Handle both functional and quality requirements.
• Reduce the goal of ownership and improve the organization’s market position.
• Improve quality and functionality offered by the system.
• Improve external confidence in either the organization or system.

Limitations
Software architecture is still an emerging discipline within software engineering. It has the following limitations

• Lack of tools and standardized ways to represent architecture.
• Lack of analysis methods to predict whether architecture will result in an implementation that meets the
requirements.
• Lack of awareness of the importance of architectural design to software development.
• Lack of understanding of the role of software architect and poor communication among stakeholders.
• Lack of understanding of the design process, design experience and evaluation of design.
EXPERIMENT NO. 2

Aim: Steps to draw the Use-Case Diagram using Rational Rose.

Hardware Requirements:

Pentium 4 processor (2.4 GHz), 128 Mb RAM, Standard keyboard n mouse, colored monitor.

Software Requirements:

Rational Rose, Windows XP,

Theory:

According to the UML specification a use case diagram is ―a diagram that shows the relationships among
actors and use cases within a system.‖ Use case diagrams are often used to:

• Provide an overview of all or part of the usage requirements for a system or organization in the form
of an essential model or a business model
• Communicate the scope of a development project
• Model your analysis of your usage requirements in the form of a system use case model

Use case models should be developed from the point of view of your project stakeholders and not from the
(often technical) point of view of developers. There are guidelines for:

1.UseCases

A use case describes a sequence of actions that provide a measurable value to an actor. A use case is drawn as
a horizontal ellipse on a UML use case diagram.

1. Use Case Names Begin with a Strong Verb


2. Name Use Cases Using Domain Terminology
3. Place Your Primary Use Cases in The Top-Left Corner of The Diagram
4. Imply Timing Considerations by Stacking Use Cases.

2. Actors

An actor is a person, organization, or external system that plays a role in one or more interactions with your
system (actors are typically drawn as stick figures on UML Use Case diagrams).

1. Place Your Primary Actor(S) In the Top-Left Corner of the Diagram


2. Draw Actors to The Outside of a Use Case Diagram
3. Name Actors with Singular, Business-Relevant Nouns
4. Associate Each Actor with One Or More Use Cases
5. Actors Model Roles, Not Positions
6. Use <<system>> to Indicate System Actors
7. Actors Don ‘t Interact with One Another
8. Introducing Actor Called ―Time‖toInitiateScheduled Events

3. Relationships
There are several types of relationships that may appear on a use case diagram:

• An association between an actor and a use case


• An association between two use cases
• A generalization between two actors
• A generalization between two use cases

Associations are depicted as lines connecting two modeling elements with an optional open- headed
arrowhead on one end of the line indicating the direction of the initial invocation of the relationship.
Generalizations are depicted as a close-headed arrow with the arrow pointing towards the more general
modeling element.

1. Indicate An Association Between an Actor and A Use Case If the Actor Appears Within the Use
Case Logic
2. Avoid Arrowheads on Actor-Use Case Relationships
3. Apply <<include>> When You Know Exactly When to Invoke the Use Case
4. Apply <<extend>> When A Use Case May Be Invoked Across Several Use Case Steps
5. Introduce <<extend>> associations sparingly
6. Generalize Use Cases When a Single Condition Results in Significantly New Business Logic
7. Do Not Apply <<uses>>, <<includes>>, or<<extends>>
8. Avoid More Than Two Levels of Use Case Associations
9. Place An Included Use Case to The Right of The Invoking Use Case
10. Place An Extending Use Case Below the Parent Use Case
11. Apply the ― IsLike‖ Rule to Use Case Generalization
12. Place an Inheriting Use Case Below The Base UseCase
13. Apply the ―IsLike‖ Rule to Actor Inheritance
14. Place an Inheriting Actor Below the Parent Actor

4. System Boundary Boxes

The rectangle around the use cases is called the system boundary box and as the name suggests it indicates the
scope of your system – the use cases inside the rectangle represent the functionality that you intend to
implement.

1. Indicate Release Scope with a System Boundary Box.


2. Avoid Meaningless System Boundary Boxes.

Creating Use Case Diagrams

We start by identifying as many actors as possible. You should ask how the actors interact with the system to
identify an initial set of use cases. Then, on the diagram, you connect the actors with the use cases with which
they are involved. If actor supplies information, initiates the use case, or receives any information as a result
of the use case, then there should be an association between them.
Procedure (for rational rose):

Click on the File menu and selectNew.


Now from the Dialogue Box that appears ,select the language which you want to use for creating
yourmodel.
In the left hand side window ofRational Rose right click on ―UseCaseview‖and select New>Use
CaseDiagram.

Enter the name of new Use Case file in the space provided and then click on thatfile name.
You can now use the window that appears on right hand side to draw your UseCase diagram
using the buttons provided on the verticaltoolbar.
Conclusion: The use case diagram was made successfully by following the steps described above.
Some Sample Use Case Diagrams are given below for illustration purpose:

Authenticat
ion

User/B Searchi
T ng

Data
Transfer
Administra
tor

MobilityManage
ment

Signalling
Management

Software Updation

Fig.1 – Use Case Diagram for Bluetooth Software

Experiment 3

Aim: Demonstrate a struts application which accepts user inputs and show input values.

We are going to create a registration form using struts UI tags and store these
information into the oracle database.

Create table in the oracle database.


1. CREATE TABLE “STRUTSUSER”
2. ( “NAME” VARCHAR2(4000),
3. “PASSWORD” VARCHAR2(4000),
4. “EMAIL” VARCHAR2(4000),
5. “GENDER” VARCHAR2(4000),
6. “COUNTRY” VARCHAR2(4000)
7. )
8. /

The steps to create the registration application in struts2 are as follows:

1. Create input page (index.jsp)


2. Create the action class (RegisterAction.java)
3. Create the class to store data (RegisterDao.java)
4. Map the request in (struts.xml) file and define the view components
5. Create view components

2) Create input page (index.jsp)

1. <%@ taglib uri=”/struts-tags” prefix=”s” %>


2.
3. <s:form action=”register”>
4. <s:textfield name=”name” label=”UserName”></s:textfield>
5. <s:password name=”password” label=”Password”></s:password>
6. <s:textfield name=”email” label=”Email”></s:textfield>
7. <s:radio list=”{‘male’,’female’}” name=”gender”></s:radio>
8. <s:select cssStyle=”width:155px;”list=”{‘india’,’pakistan’,’other’,}”
9. name=”country” label=”Country”></s:select>
10.
11. <s:submit value=”register”></s:submit>
12.
13. </s:form>

3) Create the action class (RegisterAction.java)


1. package com.javatpoint;
2.
3. public class RegisterAction {
4. private String name,password,email,gender,country;
5.
6. //setters and getters
7. public String execute(){
8. int i=RegisterDao.save(this);
9. if(i>0){
10. return “success”;
11. }
12. return “error”;
13. }
14. }

4) Create the class to store data (RegisterDao.java)


1. package com.javatpoint;
2. import java.sql.*;
3. public class RegisterDao {
4.
5. public static int save(RegisterAction r){
6. int status=0;
7. try{
8. Class.forName(“oracle.jdbc.driver.OracleDriver”);
9. Connection con=DriverManager.getConnection(
10. “jdbc:oracle:thin:@localhost:1521:xe”,”system”,”oracle”);
11.
12. PreparedStatement ps=con.prepareStatement(“insert into strutsuser values(?,?,?,?,?)”);
13. ps.setString(1,r.getName());
14. ps.setString(2,r.getPassword());
15. ps.setString(3,r.getEmail());
16. ps.setString(4,r.getGender());
17. ps.setString(5,r.getCountry());
18.
19. status=ps.executeUpdate();
20.
21. }catch(Exception e){e.printStackTrace();}
22. return status;
23. }
24. }

5) Map the request in (struts.xml) file and define the view


components(struts.xml)

1. <?xml version=”1.0” encoding=”UTF-8” ?>


2. <!DOCTYPE struts PUBLIC “-//Apache Software Foundation//DTD
3. Struts Configuration 2.1//EN” “http://struts.apache.org/dtds/struts-2.1.dtd”>
4. <struts>
5.
6. <package name=”default” extends=”struts-default”>
7.
8. <action name=”register” class=”com.javatpoint.RegisterAction”>
9. <result name=”success”>register-success.jsp</result>
10. <result name=”error”>register-error.jsp</result>
11. </action>
12.
13. </package>
14. </struts>

6) Create view components

register-success.jsp
1. <%@ taglib uri=”/struts-tags” prefix=”s” %>
2. Welcome, <s:property value=”name”></s:property>
register-error.jsp
1. <%@ taglib uri=”/struts-tags” prefix=”s” %>
2. Sorry, some error 11ccurred!
3. <s:include value=”index.jsp”></s:include>

Experiment 4

Aim: Demonstrate Hibernate application to store employee object to the database.

For creating the hibernate application in Eclipse IDE, we need to follow the following
steps:

1. Create the java project


2. Add jar files for hibernate
3. Create the Persistent class
4. Create the mapping file for Persistent class
5. Create the Configuration file
6. Create the class that retrieves or stores the persistent object
7. Run the application

7) Create the java project

Create the java project by File Menu – New – project – java project . Now specify
the project name e.g. firsthb then next – finish .

8) Add jar files for hibernate

To add the jar files Right click on your project – Build path – Add external
archives. Now select all the jar files as shown in the image given below then click
open.

9) Create the Persistent class

To create the persistent class, Right click on src – New – Class – specify the class
with package name

1. package com.javatpoint.mypackage;
2.
3. public class Employee {
4. private int id;
5. private String firstName,lastName;
6.
7. public int getId() {
8. return id;
9. }
10. public void setId(int id) {
11. this.id = id;
12. }
13. public String getFirstName() {
14. return firstName;
15. }
16. public void setFirstName(String firstName) {
17. this.firstName = firstName;
18. }
19. public String getLastName() {
20. return lastName;
21. }
22. public void setLastName(String lastName) {
23. this.lastName = lastName;
24. }
25. }

10) Create the mapping file for Persistent class

To create the mapping file, Right click on src – new – file – specify the file name
(e.g. employee.hbm.xml) – ok.

1. <?xml version=’1.0’ encoding=’UTF-8’?>


2. <!DOCTYPE hibernate-mapping PUBLIC
3. “-//Hibernate/Hibernate Mapping DTD 5.3//EN”
4. “http://hibernate.sourceforge.net/hibernate-mapping-5.3.dtd”>
5.
6. <hibernate-mapping>
7. <class name=”com.javatpoint.mypackage.Employee” table=”emp1000”>
8. <id name=”id”>
9. <generator class=”assigned”></generator>
10. </id>
11.
12. <property name=”firstName”></property>
13. <property name=”lastName”></property>
14.
15. </class>
16.
17. </hibernate-mapping>

11) Create the Configuration file

The configuration file contains all the informations for the database such as
connection_url, driver_class, username, password etc. To create the configuration file,
right click on src – new – file. Now specify the configuration file name e.g. hibernate.cfg.xml.

1. <?xml version=’1.0’ encoding=’UTF-8’?>


2. <!DOCTYPE hibernate-configuration PUBLIC
3. “-//Hibernate/Hibernate Configuration DTD 5.3//EN”
4. “http://hibernate.sourceforge.net/hibernate-configuration-5.3.dtd”>
5.
6. <hibernate-configuration>
7.
8. <session-factory>
9. <property name=”hbm2ddl.auto”>update</property>
10. <property name=”dialect”>org.hibernate.dialect.Oracle9Dialect</property>
11. <property name=”connection.url”>jdbc:oracle:thin:@localhost:1521:xe</prope
rty>
12. <property name=”connection.username”>system</property>
13. <property name=”connection.password”>oracle</property>
14. <property name=”connection.driver_class”>oracle.jdbc.driver.OracleDriver</pr
operty>
15. <mapping resource=”employee.hbm.xml”/>
16. </session-factory>
17.
18. </hibernate-configuration>

12) Create the class that retrieves or stores the persistent object

In this class, we are simply storing the employee object to the database.

1. package com.javatpoint.mypackage;
2.
3. import org.hibernate.Session;
4. import org.hibernate.SessionFactory;
5. import org.hibernate.Transaction;
6. import org.hibernate.boot.Metadata;
7. import org.hibernate.boot.MetadataSources;
8. import org.hibernate.boot.registry.StandardServiceRegistry;
9. import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
10.
11. public class StoreData {
12.
13. public static void main( String[] args )
14. {
15. StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().configure
(“hibernate.cfg.xml”).build();
16. Metadata meta = new MetadataSources(ssr).getMetadataBuilder().build();
17.
18. SessionFactory factory = meta.getSessionFactoryBuilder().build();
19. Session session = factory.openSession();
20. Transaction t = session.beginTransaction();
21.
22. Employee e1=new Employee();
23. e1.setId(1);
24. e1.setFirstName(“Gaurav”);
25. e1.setLastName(“Chawla”);
26.
27. session.save(e1);
28. t.commit();
29. System.out.println(“successfully saved”);
30. factory.close();
31. session.close();
32. }
33. }

13) Run the application

Before running the application, determine that directory structure is like this.
To run the hibernate application, right click on the StoreData class – Run As – Java
Application.

Experiment 5

Aim: Demonstrate stateless session bean in EJB.

To develop stateless bean application, we are going to use Eclipse IDE and glassfish
3 server.

To create EJB application, you need to create bean component and bean client.

14) Create stateless bean component

To create the stateless bean component, you need to create a remote interface and a bean class.

File: AdderImplRemote.java

1. package com.javatpoint;
2. import javax.ejb.Remote;
3. @Remote
4. public interface AdderImplRemote {
5. int add(int a,int b);
6. }
File: AdderImpl.java
2. package com.javatpoint;
3. import javax.ejb.Stateless;
4.
5. @Stateless(mappedName=”st1”)
6. public class AdderImpl implements AdderImplRemote {
7. public int add(int a,int b){
8. return a+b;
9. }
10. }
2) Create stateless bean client

The stateless bean client may be local, remote or webservice client. Here, we are
going to create remote client. It is console based application.

File: AdderImpl.java
1. package com.javatpoint;
2. import javax.naming.Context;
3. import javax.naming.InitialContext;
4. public class Test {
5. public static void main(String[] args)throws Exception {
6. Context context=new InitialContext();
7. AdderImplRemote remote=(AdderImplRemote)context.lookup(“st1”);
8. System.out.println(remote.add(32,32));
9. }
10. }

Output

Output: 64

Experiment 6

Aim: Demonstrate Angular JS directives

1. ng-init

The ng-init directive can be used to initialize variables in AngularJS application.

<!DOCTYPE html>
<html >
<head>
<script src="~/Scripts/angular.js"></script>
</head>
<body >
<div ng-app ng-init="greet='Hello World!'; amount= 100; myArr
= [100, 200]; person = { firstName:'Steve', lastName :'Jobs'}">
{{amount}} <br />
{{myArr[1]}} <br />
{{person.firstName}}
</div>
</body>
</html>

2. ng-model

The ng-model directive is used for two-way data binding in AngularJS.


<!DOCTYPE html>
<html >
<head>
<script src="~/Scripts/angular.js"></script>
</head>
<body ng-app>
<input type="text" ng-model="name" />
<div>
Hello {{name}}
</div>
</body>
</html>

3. ng-bind

The ng-bind directive binds the model property declared via $scope or ng-model directive or the
result of an expression to the HTML element.

<!DOCTYPE html>
<html >
<head>
<script src="~/Scripts/angular.js"></script>
</head>
<body ng-app="">
<div>
5 + 5 = <span ng-bind="5 + 5"></span> <br />

Enter your name: <input type="text" ng-model="name" /><br


/>
Hello <span ng-bind="name"></span>
</div>
</body>
</html>

4. ng-repeat

The ng-repeat directive repeats HTML once per each item in the specified array collection

<!DOCTYPE html>
<html>
<head>
<script src="~/Scripts/angular.js"></script>
<style>
div {
border: 1px solid green;
width: 100%;
height: 50px;
display: block;
margin-bottom: 10px;
text-align:center;
background-color:yellow;
}
</style>
</head>
<body ng-app="" ng-init="students=['Bill','Steve','Ram']">
<ol>
<li ng-repeat="name in students">
{{name}}
</li>
</ol>
<div ng-repeat="name in students">
{{name}}
</div>
</body>
</html>

5. ng-disabled

The ng-disabled directive disables an HTML element, based on the Boolean value returned from
the specified expression. If an expression returns true the element will be disabled, otherwise
not.

<!DOCTYPE html>
<html>
<head>
<script src="~/Scripts/angular.js"></script>
<style>
div {
width: 100%;
height: 50px;
display: block;
margin: 15px 0 0 10px;
}
</style>
</head>
<body ng-app ng-init="checked=true" >
Click Me: <input type="checkbox" ng-model="checked" /> <br />
<div>
New: <input ng-if="checked" type="text" />
</div>
<div>
Read-only: <input ng-readonly="checked" type="text"
value="This is read-only." />
</div>
<div>
Disabled: <input ng-disabled="checked" type="text"
value="This is disabled." />
</div>
</body>
</html>
Experiment 7

Architectural Study of Java Message Service (JMS) will be submitted by students which
comprised of:

1. JMS introduction 2. Block Diagram 3. Setup Configurations 4. Advantages

Experiment 8

Architectural Study of Remote Method Invocation (RMI) will be submitted by students which
comprised of:

1. RMI introduction 2. Block Diagram 3. Setup Configurations 4. Advantages

You might also like