9. Resources
Every
disAnguishable
enAty
is
a
resource.
A
resource
may
be
a
Web
site,
an
HTML
page,
an
XML
document,
a
Web
service,
a
physical
device,
etc.
URLs
Iden4fy
Resources
Every
resource
is
uniquely
idenAfied
by
a
URL.
9
REST
Fundamentals
12. 12
HTTP Method CRUD Desc.
POST CREATE Create -
GET RETRIEVE Retrieve Safe,Idempotent,Cacheable
PUT UPDATE Update Idempotent
DELETE DELETE Delete Idempotent
REST
HTTP Methods
13. 13
REST
Fundamentals
• Client-Server
• Separation principle
• Components Independent
• Stateless
• Session state on the client
• Visibility, reliability and scalability
• Trade off (network performance, etc.)
• Cacheable
• A response can be cacheable
• Efficiency but reduce reliability
• Layered system
• System scalability
•
14. 14
JAX-‐RS
–
Java
API
for
RESTfull
WebServices
• Annotation driven API
• Expose annotated Java bean as HTTP based services
• Implementation may support WADL
• Define JAVA ó HTTP mapping
• Number of implementations
• Apache CXF
• Apache Wink
• Jersey
15. JAX-‐RS
JAX-RS Annotated Service
@Path("/hello”)
public class HelloWorldService {
@GET
@Path("/{user}")
public String hello(@PathParam("user") String user) {
}
}
20. 20
JavaEE
–
Example
Student REST Service Student DatabaseClients
Let’s take an
example
21. 21
JAX-RS service to
accept HTTP calls
JavaEE
–
Example
@Path("/student”)
public class HelloWorldService {
@GET
@Path(”getall")
@Produces({"application/json”})
public String getAll() {
}
}
22. 22
JavaEE
–
Example
@Stateful
public class StudentManagerImpl implements StudentManager {
@PersistenceContext(unitName = "rest-jpa”)
private EntityManager entityManager;
public Student getStudent(int index) {
Student student = entityManager.find(Student.class, index);
return student;
}
}
JPA based data
access service
23. 23
JavaEE
–
Example
How to integrate
JAX-RS service
with JPA DAO
service ?
JAX-RS service
JPA service
24. 24
JavaEE
–
Example
integra4on
@Path("/student”)
public class HelloWorldService {
StudentManager sm;
public HelloWorldService() {
sm = new StudentManagerImpl();
}
@GET
@Path(”getall")
@Produces({"application/json”})
public String getAll() {
}
}
How to integrate
JAX-RS service
with JPA DAO
service ?
Pure JAVA
25. 25
JavaEE
–
Example
integra4on
@Path("/student”)
public class HelloWorldService {
StudentManager sm;
public void setStudentManager (StudentManager sm) { }
public StudentManager setStudentManager () { }
@GET
@Path(”getall")
@Produces({"application/json”})
public String getAll() {
}
}
How to integrate
JAX-RS service
with JPA DAO
service ?
Spring
Framework
26. 26
JavaEE
–
Example
integra4on
@Path("/student”)
public class HelloWorldService {
@Inject
StudentManager sm;
@GET
@Path(”getall")
@Produces({"application/json”})
public String getAll() {
}
}
How to integrate
JAX-RS service
with JPA DAO
service ?
JavaEE
CDI
27. 27
JavaEE
–
Example
integra4on
How to integrate
JAX-RS service
with JPA DAO
service ?JAX-RS service
JPA service
CDI
29. 29
WSO2
Applica4on
Server
Yet another
app server ?
30. • Tenant-aware data sources
• Tenant-aware JNDI service
• Tenant-aware session persistence
• Tenant-aware user store
• Tenant-aware authentication and
authorization
• Tenant-aware Caching
• Tenant-aware configuration
registry
• Tenant-aware dashboards
• Tenant-aware management
console
JavaEE
–
MulA-‐tenancy
support
31. MulAple
classloading
runAmes
There are four in-built environments
• Tomcat – Only Tomcat libs are visible (Minimal runtime)
• Carbon – Tomcat + Carbon libs are visible
• CXF - Tomcat + CXF + Spring are visible
• Javaee – JavaEE libs are visible
32. MulAple
classloading
runAmes
Ability to create your own custom ‘Classloader Runtime environments’
• Create directory to place your Jar dependencies
• Add an entry to webappclassloading-
environments.xml file
e.g. –You can have number of incompatible versions of
Spring frameworks in server level
33. Server-‐side
JavaScript
• Develop complete server side application using
Jaggery.js and deploy on Application Server
• Web Applications
• RESTfull services
• WebSocket services
36. Web
Service
development
• Supported web service development
models
• JAX –WS ( based on Apache CXF)
• Apache Axis2
• Bring your own WS framework
• Metro, Spring WS
• Rich dashboard and development tools
• Try-It tool support
• Download WS client as maven project
• Basic statistics
• Service publish and discovery support
through WSO2 Governance Registry
• WS – Discovery supported
37. RESTfull
service
development
• Supported RESTfull service
development models.
• JAX –RS ( based on Apache CXF)
• Apache Axis2 REST services
• Jaggery REST services ( Java
Script )
•
• Bring your own WS framework
• Jersey, Rest Easy, Restlet, Spring
• Rich dashboard and development tools
• Swagger support.
• Download REST client as maven
project
• Basic statistics
38. Web
Socket
development
• Supported WebSocket development models
• Java API for WebSocket
• Jaggery Web Sockets ( Java Script )
39. AcAvity
and
server
monitoring
• Embedded Monitoring dashboard
• Request, response, errors, sessions over time
• Geo info , language, referrals
• Alerts on thresholds
• Server and infrastructure health monitoring.