Date post: | 04-Jun-2018 |
Category: |
Documents |
Upload: | jayavardhankoti |
View: | 221 times |
Download: | 0 times |
of 20
8/13/2019 EclipseLink HTML5
1/20
1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Building HTML5 Applications with EclipseLink:
JSON, JAX-RS, JPA & JavaScript
Shaun Smith
@shaunMsmith
Doug Clarke
@doug_clarke
8/13/2019 EclipseLink HTML5
2/20
2 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
JAXB: Java Architecture
Java Persistence: The Problem Space
CUST
ID NAME C_RATING
Relational
Customerid: int
name: StringcreditRating: int
Java
8/13/2019 EclipseLink HTML5
3/20
3 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Software Evolution
Computing architecture is constantly evolving:
Mainframe, client/server, web/thin client, mobile
Current technologies with increasing adoption
Cloud computing
HTML 5
NoSQL databases
Java EE 7 is evolving to address many of theserequirements
EclipseLink JPA and JAXB are also evolving!
8/13/2019 EclipseLink HTML5
4/20
4 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
New Features
JSON Binding
RESTful JPAJPA RS
Dynamic
Configuration
Provisioning
NoSQL Database Support
Tenant Isolation
8/13/2019 EclipseLink HTML5
5/20
5 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
JSON Binding / EclipseLink JSON-B
Provides Java/JSON binding similar to Eclipse
JAXBs Java/XML binding.
Marshall Java domain model to and from JSON
Currently no Java standardEclipseLink interp
JAXB XML bindings for JSON
Content-type selectable by setting property on
Marshaller/Unmarshaller
8/13/2019 EclipseLink HTML5
6/20
6 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
JAXB mapped Java
J
X
XML and JSON from JAXB Mappings
8/13/2019 EclipseLink HTML5
7/20
7 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
RESTful JPA
Provides a service that exposes JPA mapped e
over REST via JAX-RS
HTTP message body either XML or JSON
Client
HTML 5 with JavaScript (primary focus)
JavaFX
8/13/2019 EclipseLink HTML5
8/20
8 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPAHigh Level Architec
Java EE Server
JDBCHTTP/S
Client R
8/13/2019 EclipseLink HTML5
9/20
9 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPA ExampleGET Invoi
public class InvoiceService {...
public Invoice read(int id) {
return null;
}
...
8/13/2019 EclipseLink HTML5
10/20
10 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPA ExampleGET Invoi
@Stateless
public class InvoiceService {...
public Invoice read(int id) {
return entityManager.find(Invoice.cla
}
...
8/13/2019 EclipseLink HTML5
11/20
11 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPA ExampleGET Invoi
@Path("/invoice")
@Stateless
public class InvoiceService {...
public Invoice read(int id) {
return entityManager.find(Invoice.cla
}
...
8/13/2019 EclipseLink HTML5
12/20
12 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPA ExampleGET Invoi
@Path("/invoice")
@Stateless
public class InvoiceService {...
@GET
@Path("{id}")
public Invoice read(@PathParam("id")int i
return entityManager.find(Invoice.cla
}
...
8/13/2019 EclipseLink HTML5
13/20
13 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPA ExampleGET Invoi
@Path("/invoice")
@Stateless
public class InvoiceService {...
@GET
@Path("{id}")
@Produces({"application/xml", "application
public Invoice read(@PathParam("id") int i
return entityManager.find(Invoice.cla
}
...
8/13/2019 EclipseLink HTML5
14/20
14 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPA ExampleGET Invoi
@Path("/invoice")
@Stateless
public class InvoiceService {...
@GET
@Path("{id}")
@Produces({"application/xml", "application
public Invoice read(@PathParam("id") int i
return entityManager.find(Invoice.cla
}
...GET http://[machine]:[port]/[web-context]/inv
8/13/2019 EclipseLink HTML5
15/20
15 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
JAX-RS with JPA
JAX-RS
JPA
Invoice Bean Payment BeanContract Bean
GET http://.../invoice/4
GET http://.../invoice/4
mapped to bean
Accounting PU Human ResourceContracting PU
Bean
uses JPA
8/13/2019 EclipseLink HTML5
16/20
16 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
JPA-RS
JPA-RS
JAX-RS
Accounting PU Human ResourceContracting PU
...
JPA
GET http://.../MyApp/Accounting/Inv
JPA-RS maps URI http://.../MyApp/Accoto AccountingPU and Invoiceentity
JAX-RS http://.../MyApp/Accounting/
mapped to JPA-RSservice
8/13/2019 EclipseLink HTML5
17/20
17 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
REST Resource Mapping
REST requires URIs for identifiable resources
Resources not 1:1 with classes
may be a graph of closely related objects
Resources are connected via links
Need a way to define Resource Model that can
leveraged by JAXB/JSON Binding
8/13/2019 EclipseLink HTML5
18/20
19 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Resource Model
Maps Java Object Model to REST Resources
O
ResourceModel
8/13/2019 EclipseLink HTML5
19/20
20 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
EclipseLink Resource Model
In development
Resources (sub-graphs of domain
graph) can be marshalled andunmarshalled (and reconnected)
Links are being automatically generated
Currently requires use of JAXB annotations
Future: simplify metadata declaration of
resources
8/13/2019 EclipseLink HTML5
20/20
21 Copyright 2011, Oracle and/or its affiliates. All rights reserved.
Summary
Java is evolvingand EclipseLink is evolving too
JSON Binding
JPA-RS
REST Resource Mapping
NoSQL
Tenant Isolation
EclipseLink is thecenter of innovation in Java pe