Presentation of Ada Web Application made during the AdaCore Tech days 2019. The presentation describes the important components that AWA is made of and explain how they help in building a web application.
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
Ada for Web Development
1. Ada for Web Development
Stéphane Carrez AdaCore Tech Days
2. https://github.com/stcarrez/ada-awa 2
Web Application Architectures
● Legacy HTML web app
● Single page web app
Client Browser
API REST
Server
Back
End
DatabaseGET
HTML+JS
GET
JSON
Static
HTML
React JS
Vue.js
Client Browser Server
Front
End
Server
Back
End
Database
GET
HTML
4. https://github.com/stcarrez/ada-awa 4
AWA Architecture
Ada Web Application
Ada Database
Objects
OpenAPI Ada
Ada
Server Faces
Ada Servlet
Ada WikiAda EL
Ada Security
Ada UtilAda Web Server XML/Ada
MySQL PostgreSQL SQLite
GNU/Linux WindowsFreeBSDNetBSD
Your Web Application
Dynamo
5. https://github.com/stcarrez/ada-awa 5
AWA Features
Comments Counters Votes Tags Changelogs
Users Jobs EventsMails
Wikis Storages ImagesBlogs Questions
General purpose components
System components
Functional components
Permissions
Settings Flotcharts Trumbowyg
SetupWorkspaces
7. https://github.com/stcarrez/ada-awa 7
Challenge: Database Access
Servlet
Filter
Client
Server Faces
Servlet
AWS Module Database
Ada Bean
GET
Do_Filter
Do_Get
Set_Value
Get_Value
Load
Access database content while
using Ada strong typing
8. https://github.com/stcarrez/ada-ado 8
Database Modeling
XML Model
Dynamo
Generator
Model
Doc
(HTML)
SQL
Tables
Ada
Model
Packages
UML Model
Ada Database
Objects Library
Generated Application Model Packages
Your Application Code
Ada Utility Library
Postgresql, MySQL or SQLite
Generate Develop
YAML Model
Design
9. https://github.com/stcarrez/ada-ado 9
Generated Ada Model
● Public object reference type with accessors
● Private implementation type holds the values
● Load, Save, Delete, Find operations
package AWA.Users.Model is
type Status_Type is (INACTIVE, REGISTERING, ACTIVE);
type Email_Ref is new ADO.Objects.Object_Ref with null record;
type User_Ref is new ADO.Objects.Object_Ref with null record;
procedure Set_Name (Object : in out User_Ref; Value : in String);
function Get_Name (Object : in User_Ref) return String;
overriding procedure Save (Object : in out User_Ref; ...);
...
private
type Email_Impl is new ADO.Objects.Object_Record ...;
type User_Impl is new ADO.Objects.Object_Record ...;
end AWA.Users.Model;
10. https://github.com/stcarrez/ada-ado 10
Using the Ada Model
● Declare T_Ref instances
● Use Get_X and Set_X to access attributes
● Use Load, Find to retrieve and Save, Delete to modify
User : User_Ref;
Email : Email_Ref;
User.Set_Name (“Ada Lovelace”);
User.Set_Status (REGISTERING);
User.Save (Session);
...
Email.Set_Emailaddress (“ada@protonmail.com”);
Email.Set_User (User);
Email.Save (Session);
User.Set_Email (Email);
User.Set_Status (ACTIVE);
User.Save (Session);
INSERT INTO user (id,object_version,name,
email,date,status) VALUES(?, ?, ?, ?, ?, ?)
INSERT INTO email (id,version,name,
emailAddress, user) VALUES(?, ?, ?, ?)
UPDATE user SET status = ?, email = ?
WHERE id = ? AND object_version = ?
11. https://github.com/stcarrez/ada-awa 11
Challenge: Access Control
Servlet
Filter
Client
Server Faces
Servlet
AWS Module Database
Ada Bean
GET
Do_Filter
Do_Get
Set_Value
Get_Value
Load
Authorize access
Data access permission checkPermission check in views:
Hide forbidden operations
12. https://github.com/stcarrez/ada-security 12
Ada Security:
Authenticate & Authorize
Security
Context
OpenID
Connect
Authenticate
Postgresql, MySQL or SQLite
[2.3] Check permission
[1.1] Authenticate
OAuth 2
[2.2] Ask authorization
Security Policy Manager
Postgresql, MySQL or SQLite
Users
ACL, Permissions
[2.4] Access granted
[2.4] Access denied
[1.2] create security context
Policy 1 Policy N
13. https://github.com/stcarrez/ada-awa 13
Challenge: Web Presentation
Servlet
Filter
Client
Server Faces
Servlet
AWS Module Database
Ada Bean
GET
Do_Filter
Do_Get
Set_Value
Get_Value
Load
Format user’s data in HTML page
Validate request parameters
15. https://github.com/stcarrez/ada-asf 15
Ada Server Faces
● Facelets: XHTML files with templating
● Component based interface
<f:metadata>
<f:viewParam id=’page’ value=’#{wikiView.name}’/>
<f:viewAction action='#{wikiView.load}'/>
</f:metadata>
<div>
<awa:wiki value=”#{wikiView.content}”/>
</div>
<div class="wikipagefooter">
<h:outputFormat styleClass="wikipagedate"
value="#{wikiMsg.wiki_page_info_date}">
<f:param value="#{wikiView.date}"/>
<f:converter converterId="smartDateConverter"/>
</h:outputFormat>
</div>
Custom UI
component:
render wiki text
Operation called
before rendering
Standard UI
component with
custom format
16. https://github.com/stcarrez/ada-el 16
Ada EL (Java JSR 245)
● The presentation layer need values from Ada
objects
● EL is a simple but powerful expression language
● Java implements EL using introspection
● Implemented in Ada using limited interface
#{wikiView.title} type Wiki_View_Bean is ...
Title : Unbounded_String;
...
end record;
EL expression Ada
17. https://github.com/stcarrez/ada-awa 17
Challenge: REST API
● Single page web app
Client Browser
API REST
Server
Back
End
DatabaseGET
HTML+JS
GET
JSON
Static
HTML
React JS
Vue.js
Expose well defined REST API
for Javascript frameworks
18. https://github.com/stcarrez/swagger-ada 18
OpenAPI Specification
● Started in 2010 to describe REST APIs
● OpenAPI Initiative created in Nov 5, 2015
(Google, Microsoft, IBM, Paypal, ...)
● OpenAPI 3.0 released July 26, 2017
● https://github.com/OAI/OpenAPI-Specification
20. https://github.com/stcarrez/swagger-ada 20
Ada REST Server
Generated code
Your server code and application
Swagger runtime
Brings REST server support with
security and OAuth2 support on
server side
Ada Security
Swagger Ada
Ada Utility Library
Server Skeleton & Model
Server Application
Ada Servlet
XML/Ada AWS
21. https://github.com/stcarrez/ada-awa 21
Conclusion
● Ada for Web Development
– Use UML for database modeling
– Use a security framework to authenticate&authorize
– Use ASF to benefit from Java server technologies
– Use OpenAPI to leverage REST API support
● AWA Programmer’s Guide
– https://ada-awa.readthedocs.io/en/latest/