SlideShare a Scribd company logo
Lecture 19 
Application Architecture
Agenda 
 Layering 
 Application Architecture 
 Play! implementation 
 Introduction to REST
Architecture Considerations
Three Layers 
 Presentation Layer for the User Interface 
 Domain Layer for the domain logic 
 Data Source Layer for the data access 
Client 
Client 
Domain Data Source 
– Separation of concern
Presentation Layer 
 Consideration 
– Separating the Presentation Logic from the Domain 
Logic 
– Simple vs. Rich user interface 
– Should content be editable frequently
User Interfaces 
 Clear separation of concerns is important 
– Define the Presentation Logic 
– Design the domain layer so the presentation can get 
the information needed 
– Semantics – or the meaning of things is important 
– Presentation logic must avoid making assumptions on 
the domain – the semantics should be a part of the 
domain 
• Use Data Transfer Objects to store semantics
Client Types 
 Native OS Applications 
– Windows, iOS, Android, Linux 
 Embedded 
– Run inside Web Browsers 
– Flash, Java Applets 
 Interactive Web Applications 
– HTML with JavaScript 
 HTML Presentation in Browsers 
– Simple HTML
Client Types 
 Mobile is not a client type 
– It’s just smaller screen 
– Which 60% people hold vertically 
 People have their phones with them all the time 
 Check their phone about110 times per day
L19 Application Architecture
Different user motivations
Responsive Web Design 
 Web pages that automatically adjust to the 
screen size 
– Should be the default design 
 Problems with RWD 
– Does not deal with context 
– What would a persons be 
looking for when using 
a mobile phone? 
– Excuse to avoid apps, when app might be a better 
choice
Native vs. Web 
 Debate
MOBILE WEB MOBILE APP 
Downloaded, runs 
Using a mobile 
on native hardware 
web browser 
PROS 
Content is indexable 
Device independent (almost) 
Easier/Faster development & update 
Easier to measure 
CONS 
Connection Dependence 
Limited hardware integration 
Bandwidth & browser limited UX 
PROS 
Connection independence 
Better hardware integration 
Better graphic performance & UX 
CONS 
Content is not web indexable 
Device dependence 
More expensive development & update 
More complex to measue 
Source: moz.com/blog/
Content Delivery 
 Native, Embedded and Interactive Web Apps 
– Require HTTP API call for dynamic content 
– For example SOAP, REST with Json or XML 
 HTML Presentation in Browsers 
– Server side generated
Content Type 
 Static Content such as graphic assets, doesn’t 
change frequently 
 Editable Content such as text, layout, mashed-up 
content, editable by content owners, 
frequently 
 Dynamic Content stored in database and 
manipulated by the domain logic
Content Management Systems 
 Content is separated form the Enterprise system 
– Managed by CMS software with its own database 
– HTTP API calls for dynamic content from the 
enterprise system 
CLIENT 
Web Browser 
HTML 
JavaScript CMS 
Enterprise 
Application 
HTTP/REST/Json 
OPERATOR 
Editable 
content 
Static 
content 
Dynamic 
content 
Static 
content
Domain Layer 
 Where is the domain logic? 
– Application Servers 
– Lightweight Containers
Application Servers 
 Domain Components are deployed on 
Application Servers 
– Distributed Multi-tiered Applications 
– Example: 
• Web Servers, EJB Servers
Lightweight Containers 
 Assemble components from different projects 
into a cohesive application 
– Wiring is done with “Inversion of Control” - config 
– Provide life-cycle management of objects 
– Provide context 
Web Browser 
(User Interface) 
Web Browser 
(User Interface) 
Web Server 
Web Layer 
Lightweight Container 
Domain 
Layer 
Data 
Source 
Layer 
Database
Data Source Layer 
 How to create the mapping from the domain to 
the Data Source Layer 
– Gateways with no domain logic 
– Records managed with some domain logic 
– Data Mappers
Data Source Layer 
 Domain Model uses gateway 
Domain 
Layer 
Data 
Source 
Layer
Object Relational Mapping (ORM) 
 Use a mapping layer to map between objects 
and tables 
– Mapping a data representation from an object model 
to a relational data model with a SQL-based schema 
 Mapping requires 
metadata 
– XML 
 Authoring and 
maintaining 
metadata is less work than maintaining SQL
The Big Picture 
Client 
Web 
Data 
Domain 
Server Source 
DB 
CMS 
REST
The Big Picture in SOA 
Client 
Web 
SERVICE Data 
Domain 
Server Source 
DB 
CMS 
REST 
Web 
Data 
REST 
SERVICE Domain 
Server Source 
DB 
Frameworks Libraries 
Shared 
Objects
Architecture Decisions
Advice is a dangerous gift 
There are no right answers 
“Use the advice to prod your thinking, but don’t use it as 
a replacement for your thinking”
Three Layers 
 Presentation Layer for the User Interface 
 Domain Layer for the domain logic 
 Data Source Layer for the data access 
Presentation 
Layer 
Domain Data Source 
– What patterns to use?
Domain Layer 
 Transaction Script 
 Domain Model 
 Table Module
Domain Layer 
 Transaction Script 
– Procedural 
– Encapsulates the logic of each transaction 
– Works well for systems that are transactional in 
nature 
 Drawbacks 
– Does not handle complexity of logic 
– Code duplications
Domain Layer 
 Domain Model 
– Works nicely for any type of domain logic 
– Flexibility in creating an object oriented classes that 
use abstractions and polymorphism 
– Beautiful code 
 Drawbacks 
– Learning curve – understanding the model 
– Requires skills 
– Doesn’t map easily to relational database
Domain Layer 
 Table Module 
– Works well for data driven applications 
– Fits well with relational databases 
– Requires Record Set functionality 
 Drawbacks 
– Structured around the database 
– Needs tooling support, for example Record Set 
– Can become dependent on the environment
Data Source Layer 
 Data Source for Transaction Script 
– Fits well to use the Gateway patterns 
– Row Data Gateway or Table Data Gateway 
– Depends on the applications 
– If the transactions are dealing with each row per 
transactions, then Row Data Gateway works 
– If working with tables, Table Data Gateway works
Data Source Layer 
 Data Source for Table Module 
– Table Module requires good support from Record 
Set 
– Table Data Gateway fits this well
Data Source Layer 
 Data Source for Domain Model 
– If the Domain Model is fairly simple, and maps the 
database, Active Record works well 
– If you want to provide abstraction the gateway 
patterns become better choice, Row Data Gateway 
and Table Data Gateway 
– If things get more complication and there is need to 
keep the model independent from the data source, 
Data Mapper should be considered
Model View Controller 
 For all types MVC architectural patterns applies 
 Web Frameworks are usually implemented 
using the Front Controller pattern 
 Each request has an Action or a Controller 
 Views are handle by Template View
The Big Picture 
Domain Layer 
Presentation 
Layer 
Service 
Layer 
Data Source 
Domain 
DB
QUIZ 
We have a relatively simple domain logic that maps nicely to 
the data schema, and we have good tools for Record Set 
handling. What Domain Layer pattern would make sense? 
A) Service Layer 
B) Domain Model 
C) Transaction Script 
D) Table Module 
✔
Play! Framework 
38
Exercise 
 Design Web Application RuNews 
– Front page displays RSS news items 
– Content read with ImportContentProcess 
– User can sign up and login
Overivew 
Controller 
View 
Service Layer 
Domain Model 
Table Data 
Gateway 
routes ApplicationConext.xml 
users
Signup 
 As a user, I want to be able to sign up 
Registration 
Fields: name, username, password, email 
Validtaion: 
all fields are required 
username must be at least 4 characters 
password must be confirmed (typed in twice)
L19 Application Architecture
Play setup 
43 
 Project is created: RuNews 
 Structure 
controllers 
is.ru.honn.news 
views
The Database 
 Table users 
44 
CREATE TABLE users 
( 
id int Identity (1, 1) primary key NOT NULL, 
name varchar(128), 
username varchar(128) unique, 
password varchar(128), 
email varchar(128), 
)
Application.java 
45 
package controllers; 
import play.*; 
import play.mvc.*; 
import views.html.*; 
public class Application extends Controller 
{ 
public static Result index() 
{ 
return ok(index.render()); 
} 
}
index 
 View is views/index.scala.html 
 Compiled: views/html/index 
46 
@main(Html("RuNews")) { 
<h2>Registration</h2> 
<p> 
Here you can sign up: <a class="btn” 
href="@routes.SignUp.blank">Sign up</a> 
</p> 
}
Routing 
 conf/routes contains the routing information 
47 
# Routes 
# This file defines all application routes (Higher priority routes first) 
# ~~~~ 
# Home page 
GET / controllers.Application.index() 
# Sign Up 
GET /signup controllers.SignUp.blank() 
POST /signup controllers.SignUp.submit() 
# Map static resources from the /public folder to the /assets URL path 
GET /assets/*file controllers.Assets.at(path="/public", file)
RuNews Example 
 User 
48 
public class User 
{ 
protected int id; 
protected String name; 
protected String username; 
protected String password; 
protected String email; 
public User() 
{ 
} 
public User(int id, String name, String username, String password, 
String email) 
{ 
this.id = id; 
this.name = name; 
this.username = username;
RuNews Example 
 UserService is a Service Layer interface 
 UserServiceData contains the implementation 
49 
public interface UserService 
{ 
public int signup(User user); 
public User login(String username, String password); 
public void setUserDataGateway(UserDataGateway userDataGateway); 
}
Adding Domain and Data Layers 
 Implementation of Service 
Layer, Domain and Data 
Source Layers added 
– Added as is 
– Should be in model 
50
Adding Domain and Data Layers 
 ApplicationContext.xml added to conf 
– Drop data.xml 
51 
<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd"> 
<bean id="userService" class="is.ru.honn.news.service.UserServiceData"> 
<property name="userDataGateway" ref="userDataGateway"/> 
</bean> 
<bean id="userDataGateway" class="is.ru.honn.news.data.UserData"> 
<property name="dataSource" ref="dataSource"/> 
</bean> 
<bean id="dataSource" 
class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/> 
<property name="url" value="jdbc:jtds:sqlserver://hrnem.ru.is:1433"/>
Adding Domain and Data Layers 
 Table Data Gateway injected into service 
52 
public class UserServiceData implements UserService 
{ 
RuDataAccessFactory factory; 
UserDataGateway userDataGateway; 
public UserServiceData() 
{ 
} 
public void setUserDataGateway(UserDataGateway UserDataGateway) 
{ 
this.userDataGateway = UserDataGateway; 
}
RuNews Example 
 Signup is a Controller 
53 
import views.html.signup.*; 
import is.ru.honn.news.domain.UserRegistration; 
public class SignUp extends Controller 
{ 
final static Form<UserRegistration> signupForm 
= Form.form(UserRegistration.class); 
public static Result blank() 
{ 
return ok(form.render(signupForm)); 
}
RuNews Example 
 Signup is a Controller 
54 
public static Result submit() 
{ 
Form<UserRegistration> filledForm = signupForm.bindFromRequest(); 
... 
if (filledForm.hasErrors()) { 
return badRequest(form.render(filledForm)); 
} 
else { 
User created = filledForm.get(); 
ApplicationContext ctx = new FileSystemXmlApplicationContext 
("/conf/ApplicationContext.xml"); 
UserDataGateway userDataGateway = 
(UserDataGateway)ctx.getBean("userDataGateway"); 
userDataGateway.addUser((User)created); 
return ok(summary.render(created)); 
} 
} 
}
RuNews Example 
 form.scala.html is the view 
55 
@(signupForm: Form[is.ru.honn.news.domain.UserRegistration]) 
@import helper._ 
@import helper.twitterBootstrap._ 
@title = { 
Sign Up 
} 
@main(title, nav = "signup") { 
@helper.form(action = routes.SignUp.submit) { 
<fieldset> 
<legend>Account informations</legend> 
@inputText( 
signupForm("name"), 
'_label -> "Name", 
'_help -> "Please enter your name.", 
'_error -> signupForm.globalError 
)
RuNews Example 
 form.scala.html is the view 
56 
@inputText( 
signupForm("username"), 
'_label -> "Username", 
'_help -> "Please choose a valid username.", 
'_error -> signupForm.globalError 
) 
@inputText( 
signupForm("email"), '_label -> "Email", 
'_help -> "Enter a valid email address." 
) 
@inputPassword( 
signupForm("password"), 
'_label -> "Password", 
'_help -> "A password must be at least 6 characters. " 
)... 
</fieldset>
RuNews Example 
 forms.scala.html is the view 
57 
<fieldset> 
@checkbox( 
signupForm("accept"), 
'_label -> None, '_text -> "You agree the Terms and conditions", 
'_showConstraints -> false 
) 
</fieldset> 
<div class="actions"> 
<input type="submit" class="btn primary" value="Sign Up"> 
<a href="@routes.Application.index" class="btn">Cancel</a> 
</div> 
} 
}
RuNews Example 
 summary.scala.html displayes the user 
58 
@(user: is.ru.honn.news.domain.User) 
@main(Html("Account created!"), nav = "signup") { 
<h2>Your account:</h2> 
<p>Name: @user.getName()</p> 
<p>Username: @user.getUsername()</p> 
<p>Email: @user.getEmail()</p> 
}
59
L19 Application Architecture
L19 Application Architecture
L19 Application Architecture
L19 Application Architecture
L19 Application Architecture
Ad

More Related Content

What's hot (19)

L17 Presentation Layer Design
L17 Presentation Layer DesignL17 Presentation Layer Design
L17 Presentation Layer Design
Ólafur Andri Ragnarsson
 
Software architecture & design patterns for MS CRM Developers
Software architecture & design patterns for MS CRM  Developers Software architecture & design patterns for MS CRM  Developers
Software architecture & design patterns for MS CRM Developers
sebedatalabs
 
Intro to salesforce platform for developers
Intro to salesforce platform for developersIntro to salesforce platform for developers
Intro to salesforce platform for developers
Roy Gilad
 
Ead pertemuan-7
Ead pertemuan-7Ead pertemuan-7
Ead pertemuan-7
Yudha Arif Budiman
 
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
Daniel Cai
 
L01 Enterprise Application Architecture
L01 Enterprise Application ArchitectureL01 Enterprise Application Architecture
L01 Enterprise Application Architecture
Ólafur Andri Ragnarsson
 
Rest introduction
Rest introductionRest introduction
Rest introduction
William Martinez Pomares
 
Enterprise Data Integration for Microsoft Dynamics CRM
Enterprise Data Integration for Microsoft Dynamics CRMEnterprise Data Integration for Microsoft Dynamics CRM
Enterprise Data Integration for Microsoft Dynamics CRM
Daniel Cai
 
Mobile Web Network
Mobile Web NetworkMobile Web Network
Mobile Web Network
chenjennan
 
Introduction to SalesForce
Introduction to SalesForceIntroduction to SalesForce
Introduction to SalesForce
Sujit Kumar
 
Salesforce for marketing
Salesforce for marketingSalesforce for marketing
Salesforce for marketing
Bohdan Dovhań
 
The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...
The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...
The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...
Lucas Jellema
 
Ladies Be Architects - Integration - Multi-Org, Security, JSON, Backup & Restore
Ladies Be Architects - Integration - Multi-Org, Security, JSON, Backup & RestoreLadies Be Architects - Integration - Multi-Org, Security, JSON, Backup & Restore
Ladies Be Architects - Integration - Multi-Org, Security, JSON, Backup & Restore
gemziebeth
 
Ladies Be Architects: Integration Study Group: Security & State Management
Ladies Be Architects: Integration Study Group: Security & State ManagementLadies Be Architects: Integration Study Group: Security & State Management
Ladies Be Architects: Integration Study Group: Security & State Management
gemziebeth
 
Ladies Be Architects - Study Group III: OAuth 2.0 (Ep 1)
Ladies Be Architects - Study Group III: OAuth 2.0 (Ep 1)Ladies Be Architects - Study Group III: OAuth 2.0 (Ep 1)
Ladies Be Architects - Study Group III: OAuth 2.0 (Ep 1)
gemziebeth
 
Getting data into microsoft dynamics crm faster
Getting data into microsoft dynamics crm fasterGetting data into microsoft dynamics crm faster
Getting data into microsoft dynamics crm faster
Daniel Cai
 
Unlock the Power of Streaming Data with Kinetica and Confluent Platform
Unlock the Power of Streaming Data with Kinetica and Confluent PlatformUnlock the Power of Streaming Data with Kinetica and Confluent Platform
Unlock the Power of Streaming Data with Kinetica and Confluent Platform
confluent
 
SHAREPOINT (ROR)
SHAREPOINT (ROR)SHAREPOINT (ROR)
SHAREPOINT (ROR)
Shashank Salwan
 
Improve Internet Efficiency With EPiServer Portal Framework
Improve Internet Efficiency With EPiServer Portal FrameworkImprove Internet Efficiency With EPiServer Portal Framework
Improve Internet Efficiency With EPiServer Portal Framework
Martin Edenström MKSE.com
 
Software architecture & design patterns for MS CRM Developers
Software architecture & design patterns for MS CRM  Developers Software architecture & design patterns for MS CRM  Developers
Software architecture & design patterns for MS CRM Developers
sebedatalabs
 
Intro to salesforce platform for developers
Intro to salesforce platform for developersIntro to salesforce platform for developers
Intro to salesforce platform for developers
Roy Gilad
 
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
CRM magic with data migration & integration (Presentation at CRMUG Summit 2013)
Daniel Cai
 
Enterprise Data Integration for Microsoft Dynamics CRM
Enterprise Data Integration for Microsoft Dynamics CRMEnterprise Data Integration for Microsoft Dynamics CRM
Enterprise Data Integration for Microsoft Dynamics CRM
Daniel Cai
 
Mobile Web Network
Mobile Web NetworkMobile Web Network
Mobile Web Network
chenjennan
 
Introduction to SalesForce
Introduction to SalesForceIntroduction to SalesForce
Introduction to SalesForce
Sujit Kumar
 
Salesforce for marketing
Salesforce for marketingSalesforce for marketing
Salesforce for marketing
Bohdan Dovhań
 
The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...
The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...
The Story of How an Oracle Classic Stronghold successfully embraced SOA (ODTU...
Lucas Jellema
 
Ladies Be Architects - Integration - Multi-Org, Security, JSON, Backup & Restore
Ladies Be Architects - Integration - Multi-Org, Security, JSON, Backup & RestoreLadies Be Architects - Integration - Multi-Org, Security, JSON, Backup & Restore
Ladies Be Architects - Integration - Multi-Org, Security, JSON, Backup & Restore
gemziebeth
 
Ladies Be Architects: Integration Study Group: Security & State Management
Ladies Be Architects: Integration Study Group: Security & State ManagementLadies Be Architects: Integration Study Group: Security & State Management
Ladies Be Architects: Integration Study Group: Security & State Management
gemziebeth
 
Ladies Be Architects - Study Group III: OAuth 2.0 (Ep 1)
Ladies Be Architects - Study Group III: OAuth 2.0 (Ep 1)Ladies Be Architects - Study Group III: OAuth 2.0 (Ep 1)
Ladies Be Architects - Study Group III: OAuth 2.0 (Ep 1)
gemziebeth
 
Getting data into microsoft dynamics crm faster
Getting data into microsoft dynamics crm fasterGetting data into microsoft dynamics crm faster
Getting data into microsoft dynamics crm faster
Daniel Cai
 
Unlock the Power of Streaming Data with Kinetica and Confluent Platform
Unlock the Power of Streaming Data with Kinetica and Confluent PlatformUnlock the Power of Streaming Data with Kinetica and Confluent Platform
Unlock the Power of Streaming Data with Kinetica and Confluent Platform
confluent
 
Improve Internet Efficiency With EPiServer Portal Framework
Improve Internet Efficiency With EPiServer Portal FrameworkImprove Internet Efficiency With EPiServer Portal Framework
Improve Internet Efficiency With EPiServer Portal Framework
Martin Edenström MKSE.com
 

Similar to L19 Application Architecture (20)

L11 Application Architecture
L11 Application ArchitectureL11 Application Architecture
L11 Application Architecture
Ólafur Andri Ragnarsson
 
soa1.ppt
soa1.pptsoa1.ppt
soa1.ppt
ShanmugamS34
 
L21 scalability
L21 scalabilityL21 scalability
L21 scalability
Ólafur Andri Ragnarsson
 
L13 Oranizing Domain Logic
L13 Oranizing Domain LogicL13 Oranizing Domain Logic
L13 Oranizing Domain Logic
Ólafur Andri Ragnarsson
 
RavenDB overview
RavenDB overviewRavenDB overview
RavenDB overview
Igor Moochnick
 
Web Services Foundation Technologies
Web Services Foundation TechnologiesWeb Services Foundation Technologies
Web Services Foundation Technologies
Pankaj Saharan
 
Webinar How to Achieve True Scalability in SaaS Applications
Webinar How to Achieve True Scalability in SaaS ApplicationsWebinar How to Achieve True Scalability in SaaS Applications
Webinar How to Achieve True Scalability in SaaS Applications
Techcello
 
Front Range PHP NoSQL Databases
Front Range PHP NoSQL DatabasesFront Range PHP NoSQL Databases
Front Range PHP NoSQL Databases
Jon Meredith
 
lec-01-WP.pdf
lec-01-WP.pdflec-01-WP.pdf
lec-01-WP.pdf
FumikageTokoyami4
 
Peoplesoft PIA architecture
Peoplesoft PIA architecturePeoplesoft PIA architecture
Peoplesoft PIA architecture
Amit rai Raaz
 
Ikenstudiolive
IkenstudioliveIkenstudiolive
Ikenstudiolive
iken Solutions - Web Space-
 
Transforming a Large Mission-Critical E-Commerce Platform from a Relational A...
Transforming a Large Mission-Critical E-Commerce Platform from a Relational A...Transforming a Large Mission-Critical E-Commerce Platform from a Relational A...
Transforming a Large Mission-Critical E-Commerce Platform from a Relational A...
MongoDB
 
Enterprise Software Architecture
Enterprise Software ArchitectureEnterprise Software Architecture
Enterprise Software Architecture
rahmed_sct
 
SharePoint 2013 - What's New
SharePoint 2013 - What's NewSharePoint 2013 - What's New
SharePoint 2013 - What's New
AdventosConsulting
 
Technology Overview
Technology OverviewTechnology Overview
Technology Overview
Liran Zelkha
 
MOSS 2007 Deployment Fundamentals -Part2
MOSS 2007 Deployment Fundamentals -Part2MOSS 2007 Deployment Fundamentals -Part2
MOSS 2007 Deployment Fundamentals -Part2
Information Technology
 
Introduction and Basics to web technology .pptx
Introduction and Basics to web technology .pptxIntroduction and Basics to web technology .pptx
Introduction and Basics to web technology .pptx
LEENASAHU42
 
ArcReady - Architecting For The Cloud
ArcReady - Architecting For The CloudArcReady - Architecting For The Cloud
ArcReady - Architecting For The Cloud
Microsoft ArcReady
 
Introduction To Cloud Computing
Introduction To Cloud ComputingIntroduction To Cloud Computing
Introduction To Cloud Computing
Rinat Shagisultanov
 
Web engineering
Web engineeringWeb engineering
Web engineering
•sreejith •sree
 
Web Services Foundation Technologies
Web Services Foundation TechnologiesWeb Services Foundation Technologies
Web Services Foundation Technologies
Pankaj Saharan
 
Webinar How to Achieve True Scalability in SaaS Applications
Webinar How to Achieve True Scalability in SaaS ApplicationsWebinar How to Achieve True Scalability in SaaS Applications
Webinar How to Achieve True Scalability in SaaS Applications
Techcello
 
Front Range PHP NoSQL Databases
Front Range PHP NoSQL DatabasesFront Range PHP NoSQL Databases
Front Range PHP NoSQL Databases
Jon Meredith
 
Peoplesoft PIA architecture
Peoplesoft PIA architecturePeoplesoft PIA architecture
Peoplesoft PIA architecture
Amit rai Raaz
 
Transforming a Large Mission-Critical E-Commerce Platform from a Relational A...
Transforming a Large Mission-Critical E-Commerce Platform from a Relational A...Transforming a Large Mission-Critical E-Commerce Platform from a Relational A...
Transforming a Large Mission-Critical E-Commerce Platform from a Relational A...
MongoDB
 
Enterprise Software Architecture
Enterprise Software ArchitectureEnterprise Software Architecture
Enterprise Software Architecture
rahmed_sct
 
Technology Overview
Technology OverviewTechnology Overview
Technology Overview
Liran Zelkha
 
MOSS 2007 Deployment Fundamentals -Part2
MOSS 2007 Deployment Fundamentals -Part2MOSS 2007 Deployment Fundamentals -Part2
MOSS 2007 Deployment Fundamentals -Part2
Information Technology
 
Introduction and Basics to web technology .pptx
Introduction and Basics to web technology .pptxIntroduction and Basics to web technology .pptx
Introduction and Basics to web technology .pptx
LEENASAHU42
 
ArcReady - Architecting For The Cloud
ArcReady - Architecting For The CloudArcReady - Architecting For The Cloud
ArcReady - Architecting For The Cloud
Microsoft ArcReady
 
Ad

More from Ólafur Andri Ragnarsson (20)

Nýsköpun - Leiðin til framfara
Nýsköpun - Leiðin til framfaraNýsköpun - Leiðin til framfara
Nýsköpun - Leiðin til framfara
Ólafur Andri Ragnarsson
 
Nýjast tækni og framtíðin
Nýjast tækni og framtíðinNýjast tækni og framtíðin
Nýjast tækni og framtíðin
Ólafur Andri Ragnarsson
 
New Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course IntroductionNew Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course Introduction
Ólafur Andri Ragnarsson
 
L01 Introduction
L01 IntroductionL01 Introduction
L01 Introduction
Ólafur Andri Ragnarsson
 
L23 Robotics and Drones
L23 Robotics and Drones L23 Robotics and Drones
L23 Robotics and Drones
Ólafur Andri Ragnarsson
 
L22 Augmented and Virtual Reality
L22 Augmented and Virtual RealityL22 Augmented and Virtual Reality
L22 Augmented and Virtual Reality
Ólafur Andri Ragnarsson
 
L20 Personalised World
L20 Personalised WorldL20 Personalised World
L20 Personalised World
Ólafur Andri Ragnarsson
 
L19 Network Platforms
L19 Network PlatformsL19 Network Platforms
L19 Network Platforms
Ólafur Andri Ragnarsson
 
L18 Big Data and Analytics
L18 Big Data and AnalyticsL18 Big Data and Analytics
L18 Big Data and Analytics
Ólafur Andri Ragnarsson
 
L17 Algorithms and AI
L17 Algorithms and AIL17 Algorithms and AI
L17 Algorithms and AI
Ólafur Andri Ragnarsson
 
L16 Internet of Things
L16 Internet of ThingsL16 Internet of Things
L16 Internet of Things
Ólafur Andri Ragnarsson
 
L14 From the Internet to Blockchain
L14 From the Internet to BlockchainL14 From the Internet to Blockchain
L14 From the Internet to Blockchain
Ólafur Andri Ragnarsson
 
L14 The Mobile Revolution
L14 The Mobile RevolutionL14 The Mobile Revolution
L14 The Mobile Revolution
Ólafur Andri Ragnarsson
 
New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine
Ólafur Andri Ragnarsson
 
L12 digital transformation
L12 digital transformationL12 digital transformation
L12 digital transformation
Ólafur Andri Ragnarsson
 
L10 The Innovator's Dilemma
L10 The Innovator's DilemmaL10 The Innovator's Dilemma
L10 The Innovator's Dilemma
Ólafur Andri Ragnarsson
 
L09 Disruptive Technology
L09 Disruptive TechnologyL09 Disruptive Technology
L09 Disruptive Technology
Ólafur Andri Ragnarsson
 
L09 Technological Revolutions
L09 Technological RevolutionsL09 Technological Revolutions
L09 Technological Revolutions
Ólafur Andri Ragnarsson
 
L07 Becoming Invisible
L07 Becoming InvisibleL07 Becoming Invisible
L07 Becoming Invisible
Ólafur Andri Ragnarsson
 
L06 Diffusion of Innovation
L06 Diffusion of InnovationL06 Diffusion of Innovation
L06 Diffusion of Innovation
Ólafur Andri Ragnarsson
 
New Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course IntroductionNew Technology Summer 2020 Course Introduction
New Technology Summer 2020 Course Introduction
Ólafur Andri Ragnarsson
 
New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine New Technology 2019 L13 Rise of the Machine
New Technology 2019 L13 Rise of the Machine
Ólafur Andri Ragnarsson
 
Ad

Recently uploaded (20)

Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 

L19 Application Architecture

  • 1. Lecture 19 Application Architecture
  • 2. Agenda  Layering  Application Architecture  Play! implementation  Introduction to REST
  • 4. Three Layers  Presentation Layer for the User Interface  Domain Layer for the domain logic  Data Source Layer for the data access Client Client Domain Data Source – Separation of concern
  • 5. Presentation Layer  Consideration – Separating the Presentation Logic from the Domain Logic – Simple vs. Rich user interface – Should content be editable frequently
  • 6. User Interfaces  Clear separation of concerns is important – Define the Presentation Logic – Design the domain layer so the presentation can get the information needed – Semantics – or the meaning of things is important – Presentation logic must avoid making assumptions on the domain – the semantics should be a part of the domain • Use Data Transfer Objects to store semantics
  • 7. Client Types  Native OS Applications – Windows, iOS, Android, Linux  Embedded – Run inside Web Browsers – Flash, Java Applets  Interactive Web Applications – HTML with JavaScript  HTML Presentation in Browsers – Simple HTML
  • 8. Client Types  Mobile is not a client type – It’s just smaller screen – Which 60% people hold vertically  People have their phones with them all the time  Check their phone about110 times per day
  • 11. Responsive Web Design  Web pages that automatically adjust to the screen size – Should be the default design  Problems with RWD – Does not deal with context – What would a persons be looking for when using a mobile phone? – Excuse to avoid apps, when app might be a better choice
  • 12. Native vs. Web  Debate
  • 13. MOBILE WEB MOBILE APP Downloaded, runs Using a mobile on native hardware web browser PROS Content is indexable Device independent (almost) Easier/Faster development & update Easier to measure CONS Connection Dependence Limited hardware integration Bandwidth & browser limited UX PROS Connection independence Better hardware integration Better graphic performance & UX CONS Content is not web indexable Device dependence More expensive development & update More complex to measue Source: moz.com/blog/
  • 14. Content Delivery  Native, Embedded and Interactive Web Apps – Require HTTP API call for dynamic content – For example SOAP, REST with Json or XML  HTML Presentation in Browsers – Server side generated
  • 15. Content Type  Static Content such as graphic assets, doesn’t change frequently  Editable Content such as text, layout, mashed-up content, editable by content owners, frequently  Dynamic Content stored in database and manipulated by the domain logic
  • 16. Content Management Systems  Content is separated form the Enterprise system – Managed by CMS software with its own database – HTTP API calls for dynamic content from the enterprise system CLIENT Web Browser HTML JavaScript CMS Enterprise Application HTTP/REST/Json OPERATOR Editable content Static content Dynamic content Static content
  • 17. Domain Layer  Where is the domain logic? – Application Servers – Lightweight Containers
  • 18. Application Servers  Domain Components are deployed on Application Servers – Distributed Multi-tiered Applications – Example: • Web Servers, EJB Servers
  • 19. Lightweight Containers  Assemble components from different projects into a cohesive application – Wiring is done with “Inversion of Control” - config – Provide life-cycle management of objects – Provide context Web Browser (User Interface) Web Browser (User Interface) Web Server Web Layer Lightweight Container Domain Layer Data Source Layer Database
  • 20. Data Source Layer  How to create the mapping from the domain to the Data Source Layer – Gateways with no domain logic – Records managed with some domain logic – Data Mappers
  • 21. Data Source Layer  Domain Model uses gateway Domain Layer Data Source Layer
  • 22. Object Relational Mapping (ORM)  Use a mapping layer to map between objects and tables – Mapping a data representation from an object model to a relational data model with a SQL-based schema  Mapping requires metadata – XML  Authoring and maintaining metadata is less work than maintaining SQL
  • 23. The Big Picture Client Web Data Domain Server Source DB CMS REST
  • 24. The Big Picture in SOA Client Web SERVICE Data Domain Server Source DB CMS REST Web Data REST SERVICE Domain Server Source DB Frameworks Libraries Shared Objects
  • 26. Advice is a dangerous gift There are no right answers “Use the advice to prod your thinking, but don’t use it as a replacement for your thinking”
  • 27. Three Layers  Presentation Layer for the User Interface  Domain Layer for the domain logic  Data Source Layer for the data access Presentation Layer Domain Data Source – What patterns to use?
  • 28. Domain Layer  Transaction Script  Domain Model  Table Module
  • 29. Domain Layer  Transaction Script – Procedural – Encapsulates the logic of each transaction – Works well for systems that are transactional in nature  Drawbacks – Does not handle complexity of logic – Code duplications
  • 30. Domain Layer  Domain Model – Works nicely for any type of domain logic – Flexibility in creating an object oriented classes that use abstractions and polymorphism – Beautiful code  Drawbacks – Learning curve – understanding the model – Requires skills – Doesn’t map easily to relational database
  • 31. Domain Layer  Table Module – Works well for data driven applications – Fits well with relational databases – Requires Record Set functionality  Drawbacks – Structured around the database – Needs tooling support, for example Record Set – Can become dependent on the environment
  • 32. Data Source Layer  Data Source for Transaction Script – Fits well to use the Gateway patterns – Row Data Gateway or Table Data Gateway – Depends on the applications – If the transactions are dealing with each row per transactions, then Row Data Gateway works – If working with tables, Table Data Gateway works
  • 33. Data Source Layer  Data Source for Table Module – Table Module requires good support from Record Set – Table Data Gateway fits this well
  • 34. Data Source Layer  Data Source for Domain Model – If the Domain Model is fairly simple, and maps the database, Active Record works well – If you want to provide abstraction the gateway patterns become better choice, Row Data Gateway and Table Data Gateway – If things get more complication and there is need to keep the model independent from the data source, Data Mapper should be considered
  • 35. Model View Controller  For all types MVC architectural patterns applies  Web Frameworks are usually implemented using the Front Controller pattern  Each request has an Action or a Controller  Views are handle by Template View
  • 36. The Big Picture Domain Layer Presentation Layer Service Layer Data Source Domain DB
  • 37. QUIZ We have a relatively simple domain logic that maps nicely to the data schema, and we have good tools for Record Set handling. What Domain Layer pattern would make sense? A) Service Layer B) Domain Model C) Transaction Script D) Table Module ✔
  • 39. Exercise  Design Web Application RuNews – Front page displays RSS news items – Content read with ImportContentProcess – User can sign up and login
  • 40. Overivew Controller View Service Layer Domain Model Table Data Gateway routes ApplicationConext.xml users
  • 41. Signup  As a user, I want to be able to sign up Registration Fields: name, username, password, email Validtaion: all fields are required username must be at least 4 characters password must be confirmed (typed in twice)
  • 43. Play setup 43  Project is created: RuNews  Structure controllers is.ru.honn.news views
  • 44. The Database  Table users 44 CREATE TABLE users ( id int Identity (1, 1) primary key NOT NULL, name varchar(128), username varchar(128) unique, password varchar(128), email varchar(128), )
  • 45. Application.java 45 package controllers; import play.*; import play.mvc.*; import views.html.*; public class Application extends Controller { public static Result index() { return ok(index.render()); } }
  • 46. index  View is views/index.scala.html  Compiled: views/html/index 46 @main(Html("RuNews")) { <h2>Registration</h2> <p> Here you can sign up: <a class="btn” href="@routes.SignUp.blank">Sign up</a> </p> }
  • 47. Routing  conf/routes contains the routing information 47 # Routes # This file defines all application routes (Higher priority routes first) # ~~~~ # Home page GET / controllers.Application.index() # Sign Up GET /signup controllers.SignUp.blank() POST /signup controllers.SignUp.submit() # Map static resources from the /public folder to the /assets URL path GET /assets/*file controllers.Assets.at(path="/public", file)
  • 48. RuNews Example  User 48 public class User { protected int id; protected String name; protected String username; protected String password; protected String email; public User() { } public User(int id, String name, String username, String password, String email) { this.id = id; this.name = name; this.username = username;
  • 49. RuNews Example  UserService is a Service Layer interface  UserServiceData contains the implementation 49 public interface UserService { public int signup(User user); public User login(String username, String password); public void setUserDataGateway(UserDataGateway userDataGateway); }
  • 50. Adding Domain and Data Layers  Implementation of Service Layer, Domain and Data Source Layers added – Added as is – Should be in model 50
  • 51. Adding Domain and Data Layers  ApplicationContext.xml added to conf – Drop data.xml 51 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="userService" class="is.ru.honn.news.service.UserServiceData"> <property name="userDataGateway" ref="userDataGateway"/> </bean> <bean id="userDataGateway" class="is.ru.honn.news.data.UserData"> <property name="dataSource" ref="dataSource"/> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/> <property name="url" value="jdbc:jtds:sqlserver://hrnem.ru.is:1433"/>
  • 52. Adding Domain and Data Layers  Table Data Gateway injected into service 52 public class UserServiceData implements UserService { RuDataAccessFactory factory; UserDataGateway userDataGateway; public UserServiceData() { } public void setUserDataGateway(UserDataGateway UserDataGateway) { this.userDataGateway = UserDataGateway; }
  • 53. RuNews Example  Signup is a Controller 53 import views.html.signup.*; import is.ru.honn.news.domain.UserRegistration; public class SignUp extends Controller { final static Form<UserRegistration> signupForm = Form.form(UserRegistration.class); public static Result blank() { return ok(form.render(signupForm)); }
  • 54. RuNews Example  Signup is a Controller 54 public static Result submit() { Form<UserRegistration> filledForm = signupForm.bindFromRequest(); ... if (filledForm.hasErrors()) { return badRequest(form.render(filledForm)); } else { User created = filledForm.get(); ApplicationContext ctx = new FileSystemXmlApplicationContext ("/conf/ApplicationContext.xml"); UserDataGateway userDataGateway = (UserDataGateway)ctx.getBean("userDataGateway"); userDataGateway.addUser((User)created); return ok(summary.render(created)); } } }
  • 55. RuNews Example  form.scala.html is the view 55 @(signupForm: Form[is.ru.honn.news.domain.UserRegistration]) @import helper._ @import helper.twitterBootstrap._ @title = { Sign Up } @main(title, nav = "signup") { @helper.form(action = routes.SignUp.submit) { <fieldset> <legend>Account informations</legend> @inputText( signupForm("name"), '_label -> "Name", '_help -> "Please enter your name.", '_error -> signupForm.globalError )
  • 56. RuNews Example  form.scala.html is the view 56 @inputText( signupForm("username"), '_label -> "Username", '_help -> "Please choose a valid username.", '_error -> signupForm.globalError ) @inputText( signupForm("email"), '_label -> "Email", '_help -> "Enter a valid email address." ) @inputPassword( signupForm("password"), '_label -> "Password", '_help -> "A password must be at least 6 characters. " )... </fieldset>
  • 57. RuNews Example  forms.scala.html is the view 57 <fieldset> @checkbox( signupForm("accept"), '_label -> None, '_text -> "You agree the Terms and conditions", '_showConstraints -> false ) </fieldset> <div class="actions"> <input type="submit" class="btn primary" value="Sign Up"> <a href="@routes.Application.index" class="btn">Cancel</a> </div> } }
  • 58. RuNews Example  summary.scala.html displayes the user 58 @(user: is.ru.honn.news.domain.User) @main(Html("Account created!"), nav = "signup") { <h2>Your account:</h2> <p>Name: @user.getName()</p> <p>Username: @user.getUsername()</p> <p>Email: @user.getEmail()</p> }
  • 59. 59