100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Samenvatting Frameworks Voor Serverapplicaties (E761038) $0.00

Summary

Samenvatting Frameworks Voor Serverapplicaties (E761038)

 169 views  44 purchases
  • Course
  • Institution

Samenvatting Frameworks Voor Serverapplicaties (E), niet mijn beste samenvatting maar wel handig

Last document update: 3 year ago

Preview 6 out of 58  pages

  • January 3, 2021
  • April 13, 2021
  • 58
  • 2020/2021
  • Summary
avatar-seller
Samenvatting Frameworks voor serverapps 3de bach 2020-2021



Frameworks voor serverapplicaties
Spring/REST + ORM bij java (JPA):

Annotatie Context Uitleg Ver-
plicht
@RestController REST - De methodes van deze klasse ja
basics worden gebruik om REST-
aanvragen af te handelen
@RequestMapping(“pad/{id}”) REST Duidt het pad aan. Met ja
@PathVariable(“id”) als je {…} in
pad hebt
@GetMapping REST Methode handelt GET af ja
@PostMapping met @RequestBody REST @RequestBody duidt aan wat in ja
body POST zit
@PutMapping REST zowel @PathVariabele(“…”) en ja
@RequestBody
@DeleteMapping(“/{id}”) REST Verwijder bij @PathVariabele ja
@Component Voor constructor injection, object
uit logicalaag. @Service en
@Repository leiden hiervan af
REST + Junit5+Spring, willekeurige poort,
unit test injecteren WebTestClient
@Autowired REST + injecteren van bv. postDAO
unit test
@Service Spring maakt bean die gebruikt
kan worden voor dependency
injection (zie ook @component)

@Entity JPA staat vaak samen met @Table
@Embeddable valueobj hfst3: klasse van value-obj, in ja
plaats van @Entity
@Embedded valueobj eigenschap van embeddable nee
zelf klasse, bv. Adres (=valueobj)
@Table(name=”…”) JPA staat vaak bij @Entity, bepaalt nee
welke tabel in DB. Niet
hoofdlettergevoelig
@Id() JPA hfst 3. Automatisch ID genereren

bv. in klasse:
Hoeft niet boven ‘id’ te staan.
@GeneratedValue(strategy= JPA Alternatief IDENTITY: AUTO, ~
GenerationType.IDENTITY) SEQUENCE en TABLE.
@Basic JPA geeft eenvoudige eigenschap aan Nee
@Column(name=”NAAM”) JPA koppel eigenschap aan kolom Nee
@Transient JPA eigenschap niet bewaren in DB
@Inheritance(strategy = JPA, erf JOINED / SINGLE_TABLE Nee
InheritanceType.SINGLE_TABLE) (standaard) / TABLE_PER_CLASS.
@DiscriminatorColumn(name=”PERSOON_TYPE”, JPA, erf .INTEGER / .STRING (standaard) Nee
discriminatortype = DiscriminatorType.STRING) /.CHAR
1

,Samenvatting Frameworks voor serverapps 3de bach 2020-2021


@DiscriminatorValue(“K”) JPA, erf waarde ~ objecttype. Nee
In afgeleide klassen
@GenericGenerator(name=”generator”, JPA Primaire sleutel delen over
strategy=”increment”) verschillende tabellen
@GeneratedValue(generator=”generator”)
@ElementCollection valueobj Collectie van niet-primitieve Ja
types. S15 van 3.4
@CollectionTable(name=”…” joinColumns=”…”) valueobj Soms
bv. @CollectionTable(name = "subsidies",
joinColumns = @JoinColumn(name =
"sportclub"))
@PrimaryKeyJoinColumn(name=”ID”) JPA erf Kolom FK ~ PK
@JoinColumn(name = “…”) valueobj
/relaties
@AttributesOverrides({ valueobj Als je de kolom wilt hernoemen Niet
@AttributeOverride(name=”jaar”, altijd
column = @Column(name=”sub_jaar”)), …
})

@ManyToOne(mappedBy=”andereklasse”) relaties 1-op-veel. mappedBy moet enkel Ja
@OneToMany(cascade=CascadeType.REMOVE, bij bidirectioneel .
mappedBy=”…”) Alternatief remove: ALL,
DETATCH, MERGE, PERSIST,
REFRESH, REMOVE.
@ManyToOne(fetch = FetchType.LAZY) EntityM Standaard meestal lazy, eager: bij
@ManyToOne(fetch = FetchType.EAGER), opvragen ook andere halen
@ManyToMany(mappedBy=”andereklasse”) relaties veel-op-veel; idem mappedBy Ja
relaties Bij veel-op-veel relaties, de
mapping, annotatie boven
hashset.
@OneToOne() relaties 1-op-1 relatie. Zie slides Ja
@OneToOne(optional=false)
@MapsId relaties De ID van x moet je gebruiken als
mijn ID. Bij 1-op-1
@JoinColumn(name=”…”, unique=true, relaties Voor een unieke FK (gebruikt bij
nullable=false, updatable=false) 1-op-1)

@PersistenceContext EntityM EntityManager bij container
@PersistenceUnit EntityM EntityManager bij applicatie




@SpringBootTest testing Boven testklasse -> volledige Ja
context ter beschikking
@Test testing boven methode met testcode Ja




2

,Samenvatting Frameworks voor serverapps 3de bach 2020-2021


Bij C# (geen annotatie maar met [ ] )




Attributen met [ ] Context Uitleg
[Route(“api/[naamController]”)] controller pad REST-service
[ApiController] controller controller voor REST API
[Produces("application/json")] controller staat boven controller


[required] data-annotatie mag niet null zijn
[DefaultValue(…)] data-annotatie standaardwaarde instellen
[HttpGet], [HttpPost], [HttpPut(“{id}”)], controller Welke HTTP-methode
[HttpGet(“{id}”)], [HttpDelete(“{id}”)]


[Display(Name = “White Player”)] validatie Inhoud van label in form
[Required(ErrorMessage = “….”] validatie error bij veld leeggelaten
[EnumDataType(typeof(…), validatie kijken of het van een
ErrorMessage=”…”)] bepaald EnumDataType is




3

,Samenvatting Frameworks voor serverapps 3de bach 2020-2021


Inhoud
1. Intro REST .....................................................................................................................................................6
In Java...........................................................................................................................................................7
2. Unit testing in Java – Junit ...........................................................................................................................9
Test schrijven ...............................................................................................................................................9
3. ORM: object relational mapping ............................................................................................................... 10
3.1 ORM .................................................................................................................................................... 10
3.2 JPA in Spring ........................................................................................................................................ 10
3.3 ORM – overerving ............................................................................................................................... 11
3.4 ORM – associaties – value-objecten ................................................................................................... 11
3.5 ORM – associaties – relaties ............................................................................................................... 12
3.6 ORM - werking .................................................................................................................................... 12
3.7 Objecten opvragen zonder identifier: JPQL / SQL .............................................................................. 13
4. JDBC .......................................................................................................................................................... 15
4.1 inleiding............................................................................................................................................... 15
4.2 Basiswerking ....................................................................................................................................... 15
4.3 PreparedStatement............................................................................................................................. 16
4.4 CallableStatement ............................................................................................................................... 17
4.5 Transacties .......................................................................................................................................... 17
4.6 DataSource .......................................................................................................................................... 18
4.7 Scrollable & aanpasbare ResultSet ..................................................................................................... 18
4.8 RowSet ................................................................................................................................................ 19
4.9 SQL3 – gegevenstypes......................................................................................................................... 19
ORM vs. JDBC ............................................................................................................................................ 19
5. ADO.NET.................................................................................................................................................... 20
5.1 Inleiding............................................................................................................................................... 20
5.2 DataSet ................................................................................................................................................ 20
5.3 DataProvider ....................................................................................................................................... 21
5.4 ADO.NET basiswerking ........................................................................................................................ 21
JDBC vs ADO.NET ...................................................................................................................................... 23
5.5 ADO.NET – DataAdapter ..................................................................................................................... 23
5.6 ADO.NET – Opdrachten met parameters ........................................................................................... 24
5.7 ADO.NET – DataAdapter aanpassingen doorvoeren .......................................................................... 24
5.8 ADO.NET – Transacties........................................................................................................................ 25
6. REST-services in .NET (deel 2) ................................................................................................................... 26
6.1 Inleiding............................................................................................................................................... 26
6.2 basiswerking ....................................................................................................................................... 27
7. OpenAPIspecificatie .................................................................................................................................. 29
7.1 Wat is OpenAPI-specificatie ................................................................................................................ 29
7.2 OpenAPI-specificatie: structuur .......................................................................................................... 29
7.3 OpenAPI-specificatie in .NET............................................................................................................... 30
8. ASPNET Core MVC..................................................................................................................................... 31
8.1 ASPNET Core MVC - MVC in webapplicaties ....................................................................................... 31

4

,Samenvatting Frameworks voor serverapps 3de bach 2020-2021


8.2 ASPNET Core MVC – voorbeeld .......................................................................................................... 31
8.3 ASPNET Core MVC – routing ............................................................................................................... 32
8.4 ASPNET Core MVC – model en controller ........................................................................................... 33
8.5 ASPNET Core MVC – view ................................................................................................................... 33
8.6 ASPNET Core MVC - data van controller naar view ............................................................................ 34
Via ViewData ......................................................................................................................................... 34
Via parameter van Methode View ........................................................................................................ 34
8.7 ASPNET Core MVC - data van de client naar de server....................................................................... 34
8.8 ASPNET Core MVC - dependency injection ......................................................................................... 35
8.9 ASPNET Core MVC – validatie ............................................................................................................. 35
8.10 ASPNET Core MVC - overposting en XSRF......................................................................................... 36
Voorkomen van overposting................................................................................................................. 36
Cross-site request forgery; XSRF, CSRF ................................................................................................. 36
8.11 ASPNET Core MVC – localization ...................................................................................................... 36
8.12 ASPNET Core MVC - authenticatie en autorisatie ............................................................................. 38
9. Node.js ...................................................................................................................................................... 39
9.1 NPM: node package manager ............................................................................................................. 39
9.2 eenvoudige HTTP-server ..................................................................................................................... 39
9.3 routing................................................................................................................................................. 40
9.4 Architectuur van node.js ..................................................................................................................... 42
9.5 inleiding express ................................................................................................................................. 42
9.6 Middleware (bespreking app.js) ...................................................................................................... 44
9.7 routing in Express................................................................................................................................ 45
9.8 View in Express ................................................................................................................................... 46
10 Websockets .............................................................................................................................................. 47
Architectuur .............................................................................................................................................. 47
Protocol ..................................................................................................................................................... 47
Voordelen websockets.............................................................................................................................. 49
11. webapplicaties ........................................................................................................................................ 50
11.1 Authenticatie: cookies en tokens...................................................................................................... 50
11.1 Authenticatie: OAuth2 ...................................................................................................................... 50
11.1 Authenticatie: SSO en 2FA ................................................................................................................ 52
11.2 Meestvoorkomende beveiligingsproblemen .................................................................................... 52
11.3 Verschillende types webapps ........................................................................................................... 53
Statische website .................................................................................................................................. 53
Dynamische website ............................................................................................................................. 53
Single Page Applications (SPA) .............................................................................................................. 53
Progressive web apps (PWA) ................................................................................................................ 54
12. XML ......................................................................................................................................................... 55
12.1 XML - introductie .............................................................................................................................. 55
12.2 structuur XML-document.................................................................................................................. 55
12.3 namenruimtes ................................................................................................................................... 57




5

, Samenvatting Frameworks voor serverapps 3de bach 2020-2021


1. Intro REST
Webservice = een dienst die aangeboden wordt via het web (HTTP-berichten, HTTP : client-server-,
transport-, en aanvraag-antwoord protocol. Hypertext Transfer Protocol).
REST is een architecturale stijl (abstractie). = Representational State Transfer. Architectuur van “the web.”
Conventie voor HTTP-services (request van client geeft response van web server).
CRUD-operaties: create, read, update & delete.
Herhaling HTTP-methodes: (Alles behalve post is idempotent.)
 GET Safe, idempotent, cacheable Statuscodes
 PUT idempotent
 DELETE idempotent
 HEAD safe, idempotent
 POST



Intermediaries = proxies & gateways. Ze kunnen
allemaal aan caching doen.

Voordelen: efficiëntie, schaalbaarheid en user perceived performance.  Network performance
(+ simplicity, evolvability, extensibility, reusability, visibility, portability, reliability, configuration)

Bij REST: resources worden geïdentificeerd door URI’s en hebben uniforme
interface. Protocol is client-server, statusloos, cacheable & gelaagd. Code on
demand (optioneel).



Client-server
Client en server zijn onafhankelijk (API tussen beiden), kunnen evolueren. Client kent enkel URI. Uniforme
interface onafhankelijk van type client.



Uniforme interface
De Interface is onafhankelijk van type client, bron-georiënteerd (= elke webservice/URI stelt een bron
voor), gebruikt HTTP-methodes expliciet. Gebruikers kunnen via links zelf makkelijk bronnen ontdekken.

Examen: bv. ze geeft Javacode (bv. @PostMapping(“…”)) en vraagt de HTTP-vraag en HTTP-antwoord. Zie
slides “info examen”.

GET




POST






6

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller indinginf. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $0.00. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

75632 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
Free  44x  sold
  • (0)