SlideShare a Scribd company logo
JEST: REST on OpenJPA Pinaki Poddar, PhD Java Persistence Evangelist [email_address]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JEST: REST on OpenJPA JEST is RESTful interaction with OpenJPA Runtime http JDBC XML/JSON Java Object Graph
 
JEST: REST on OpenJPA ,[object Object],[object Object],[object Object],[object Object],KISS: Keep It Short and Simple
JEST: Primary Use Cases ,[object Object],[object Object],[object Object]
REST:  RE presentational  S tate  T ransfer C0 C0 C1’ C1’ S1 S2 S1 renders C1 modifies C2 renders Response 1 Request 2 Request 1 Response 2 @  rest State Transition 1 2 3 4 5 6
REST Principles ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Java Persistence API ,[object Object],EntityManagerFactory EntityManager Persistence Unit Persistence Context Second-Tier Caches (optional) Relational Database User Application Data Cache META-INF/persistence.xml Java Object Graph
JPA is Model-View-Controller for Persistence View Control Model /** * A persistent entity **/ @Entity public class   Actor  { @Id private  String  name ; } /** * Find Actor by name **/ public  Actor   findByName( String   name )  { EntityManager em = …; return  em.find( Actor . class , name); } POJO sees uses updates modifies Java Persistence API Relational Database
JPA:  access-detach-merge programming model C0 C0 C1’ C1’ em1 em2 renders C1 modifies C2 renders State Transition SELECT … detach find merge commit UPDATE/INSERT/DELETE … 1 2 3 5 6 4
REST and JPA: brothers separated at birth? Stateless Server Detached Transaction Identifiable Resource Persistent Identity Coherent Representation Persistent Closure Self-descriptive JPA 2.0 Metamodel REST JPA
JEST Resource ,[object Object],[object Object],[object Object]
Customizable, Persistent Closure ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Customization is ability to define what is  reachable  at runtime. x a c1 b c2 d C(x) = {x, a, b, c1, c2, d} C(x) = {x, a, b, d} could be customized to and its complete closure C(x) = {x, b} or An object graph…
Identifiable Resource: URI for persistent object? Actor  p1 = em1.find ( Actor . class , “ John ”); Actor  p2 = em2.find ( Actor . class , “ John ”); name :” John ” hash :  56789 p1 name :” John ” hash :  56789 p2 p1.equals(p2) p1.hashCode()  == p2.hashCode() p1 != p2 public   class   Actor  { @Id String   name ; } Persistent Identity carries the notion that both  p1  and  p2 refer to the same database record. EntityManager EntityManager … Robert … John ACTOR
Customizable, Persistent Closure: State of the art JEST response contains customizable, persistent closure  ,[object Object],[object Object],[object Object],[object Object]
OpenJPA Fetch Plan  @Entity @FetchGroups ({ @FetchGroup ( name =&quot; OnlyName &quot;,  attributes ={ @FetchAttribute ( name =&quot; firstName &quot;), @FetchAttribute ( name =&quot; lastName &quot;) }) }) public   class  Actor { @Id private  String  id ; private  String  firstName ; private  String  lastName ; private  Gender  gender ; private  Date  dob ; @OneToOne private  Actor  partner ; @OneToMany private  Set<Movie>  movies ; // getters and setters }
JEST Representation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JPA Metamodel: Persistent Type System Class Type<X> ManagedType<X> BasicType<X> IdentifiableType<X> EmbeddableType<X> EntityType<X> MappedSuperclassType<X> package javax.persistence.metamodel package java.lang <X>: Type<X> represents Java class X
JPA Metamodel : Persistent Type System Field Attribute<X,Y> SingularAttribute<X,Y> PluralAttribute<X,C,E> ListAttribute<X,E> CollectionAttribute<X,E> SetAttribute<X> MapAttribute<X,K,V> package javax.persistence.metamodel package java.lang.reflect <X>: Attribute<X,Y> declared in Java class X <Y>: Attribute<X,Y> is of type Y  <C>: PluralAttribute<X,C,E> is of Java collection type C <E>: PluralAttribute<X,C,E> contains elements of type E
JPA Metamodel: Persistent Scope java.lang.Class java.lang.reflect.Field Metamodel ManagedType<X> Attribute<X,Y> java.lang.ClassLoader A classloader defines a scope for a set of Java classes A metamodel defines a scope for a set of managed persistent types package javax.persistence.metamodel
Meta-Meta-Data Driven Representation < Actor > < id > 1234 </ id > < firstName > John </ firstName > < lastName > Doe </ lastName > </ Actor > Domain Driven Representation Domain-variant Schema  < instance   id = “Actor-1234”   type =“Actor” > < id   name = “ id ”   type = “long” > 1234 </ id > < basic   name = “firstName”   type = “String” > John </ basic > < basic   name = “lastName”   type = “String” > Doe </ basic > </ instance > Model Driven Representation Domain-invariant Schema  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JSON-based Representation in JEST ,[object Object],[object Object],[ {  &quot;$id&quot; :  Actor-m2 ,  &quot;id&quot;: &quot;m2&quot;,  &quot;dob&quot;: &quot;Tue May 14 1940&quot;,  &quot;firstName&quot;: &quot;Robert&quot;,  &quot;lastName&quot;: &quot;De Niro&quot;,  &quot;gender&quot;: &quot;Male&quot;,  &quot;partner&quot;: {  &quot;$id&quot; :  Actor-f3 ,  &quot;id&quot;: &quot;f3&quot;,  &quot;dob&quot;: “Wed May 15 1960&quot;,  &quot;firstName&quot;: &quot;Jodie&quot;,  &quot;lastName&quot;: &quot;Foster&quot;,  &quot;gender&quot;: &quot;Female“, “ partner”: { “ $ref”  :  Actor-m2 }  }  }  ]  dummy  $id  field dummy  $ref  field resolved circular reference JSON by JEST
JEST URI Syntax identifies JPA  resources. maps to JPA  operation decorates JPA  operation JEST resolves argument strings to strong types, e.g. “ type=Actor ” to  Actor .class . scheme authority path query context action qualifiers arguments OpenJPAEntityManager  em = getPersistenceContext(); em.addFetchPlan(“ basic ”); Actor  a = em.find( Actor . class , “m1”); find plan=basic type=Actor ? jest / / & id=m1 http 8080 openjpa.com / : ://
JEST URI Examples find an Actor with primary key m1 using fetch plan ‘basic’ http :// openjpa.com:8080 / jest / find / plan = basic ? type = Actor & m1 Query for a single Actor by name John http :// openjpa.com:8080 / jest / query / single ? q = select p from Actor   p where   p.name=:n & n = John Get the metamodel http :// openjpa.com:8080 / jest / domain
JEST translates HTTP verbs to JPA operations GET HTTP POST PUT DELETE find() getMetamodel() createQuery().getResultList() getProperties() /find / query / domain / properties merge() persist() remove() JEST Action JPA Operation non-transactional transactional
JEST Deployment < web-app > < servlet > < servlet-name > demo </ servlet-name > < servlet-class > demo.SimpleApp </ servlet-class > </ servlet > < servlet-mapping > < servlet-name > demo </ servlet-name > < url-pattern > /* </ url-pattern > </ servlet-mapping > <!--   Deployment descriptor for JESTServlet.   --> < servlet > < servlet-name > jest </ servlet-name > < servlet-class > org.apache.openjpa.persistence.jest.JESTServlet </ servlet-class > < init-param > < param-name > persistence.unit </ param-name > < param-value > SimplePU </ param-value > </ init-param > </ servlet > < servlet-mapping > < servlet-name > jest </ servlet-name > < url-pattern > /jest/* </ url-pattern > </ servlet-mapping > </ web-app > Deployed as  HTTP Servlet within the  same  module scope Identifies the module by  persistence unit name
Deployment Modes for JEST Servlet JESTServlet emf Module X emf JESTServlet instantiates discovers instantiates or  injected primary mode auxiliary mode default
JEST Client: An afterthought ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
 
 
 
 
 
Why JEST? ,[object Object],[object Object],[object Object],[object Object]
JEST: JPA Detached Transaction C1 C1 C1’ C1’ S1 S2 S1 renders C1 modifies C2 renders A1 A1’ R1 Response 2 @  rest State Transition find() detach() represent() parse() merge() commit()
REST is successful in real world  Success has many friends… “ Amazon has both  SOAP  and  REST  interfaces to their web services, and  85%  of their usage is of the REST interface. ”   Jeff Barr, Web Services Evangelist @ Amazon Reference:  REST vs SOAP at Amazon
Does JEST pass the RESTness est? YES  Q5 . Can server transfer logic to clients? NO  Q4 . Can client determine the exact server endpoint? YES  Q3 . Does response describe their cacheability for the client? NO Q2 . Does server store client context between requests? YES Q1 . Are clients separated from servers by a uniform interface?
Does JEST pass Uniform Interface Test? YES Q9 . Are related resources accessible via received representation? YES Q8 . Does representation carry enough information to be processed by the client? YES Q7 . Can client manipulate received resource representation? YES Q6 . Does request identify a resource?
Why JEST? ,[object Object],[object Object],[object Object],[object Object],[object Object]
How JEST can help your effort? ,[object Object],[object Object],[object Object]
Q&A ,[object Object],[object Object],[object Object],https://cwiki.apache.org/openjpa/jest.html

More Related Content

What's hot

Django - 次の一歩 gumiStudy#3
Django - 次の一歩 gumiStudy#3Django - 次の一歩 gumiStudy#3
Django - 次の一歩 gumiStudy#3
makoto tsuyuki
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScript
T11 Sessions
 
Java Programming Guide Quick Reference
Java Programming Guide Quick ReferenceJava Programming Guide Quick Reference
Java Programming Guide Quick Reference
FrescatiStory
 
Testing untestable code - IPC12
Testing untestable code - IPC12Testing untestable code - IPC12
Testing untestable code - IPC12
Stephan Hochdörfer
 
AMIS definer invoker rights
AMIS definer invoker rightsAMIS definer invoker rights
Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5
Jason Austin
 

What's hot (6)

Django - 次の一歩 gumiStudy#3
Django - 次の一歩 gumiStudy#3Django - 次の一歩 gumiStudy#3
Django - 次の一歩 gumiStudy#3
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScript
 
Java Programming Guide Quick Reference
Java Programming Guide Quick ReferenceJava Programming Guide Quick Reference
Java Programming Guide Quick Reference
 
Testing untestable code - IPC12
Testing untestable code - IPC12Testing untestable code - IPC12
Testing untestable code - IPC12
 
AMIS definer invoker rights
AMIS definer invoker rightsAMIS definer invoker rights
AMIS definer invoker rights
 
Object Oriented PHP5
Object Oriented PHP5Object Oriented PHP5
Object Oriented PHP5
 

Viewers also liked

Dropwizard at Yammer
Dropwizard at YammerDropwizard at Yammer
Dropwizard at Yammer
Jamie Furness
 
Dropwizard
DropwizardDropwizard
Dropwizard Spring - the perfect Java REST server stack
Dropwizard Spring - the perfect Java REST server stackDropwizard Spring - the perfect Java REST server stack
Dropwizard Spring - the perfect Java REST server stack
Jacek Furmankiewicz
 
Use of computer software in airline
Use of computer software in airlineUse of computer software in airline
Use of computer software in airline
saurav rawat
 
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Matt Raible
 
Microservice Architecture JavaCro 2015
Microservice Architecture JavaCro 2015Microservice Architecture JavaCro 2015
Microservice Architecture JavaCro 2015
Nenad Pecanac
 
Java application monitoring with Dropwizard Metrics and graphite
Java application monitoring with Dropwizard Metrics and graphite Java application monitoring with Dropwizard Metrics and graphite
Java application monitoring with Dropwizard Metrics and graphite
Roberto Franchini
 

Viewers also liked (7)

Dropwizard at Yammer
Dropwizard at YammerDropwizard at Yammer
Dropwizard at Yammer
 
Dropwizard
DropwizardDropwizard
Dropwizard
 
Dropwizard Spring - the perfect Java REST server stack
Dropwizard Spring - the perfect Java REST server stackDropwizard Spring - the perfect Java REST server stack
Dropwizard Spring - the perfect Java REST server stack
 
Use of computer software in airline
Use of computer software in airlineUse of computer software in airline
Use of computer software in airline
 
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
Get Hip with JHipster: Spring Boot + AngularJS + Bootstrap - DOSUG February 2016
 
Microservice Architecture JavaCro 2015
Microservice Architecture JavaCro 2015Microservice Architecture JavaCro 2015
Microservice Architecture JavaCro 2015
 
Java application monitoring with Dropwizard Metrics and graphite
Java application monitoring with Dropwizard Metrics and graphite Java application monitoring with Dropwizard Metrics and graphite
Java application monitoring with Dropwizard Metrics and graphite
 

Similar to JEST: REST on OpenJPA

Slice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed PersistenceSlice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed Persistence
Pinaki Poddar
 
Using DAOs without implementing them
Using DAOs without implementing themUsing DAOs without implementing them
Using DAOs without implementing them
benfante
 
Jsp
JspJsp
Os Leonard
Os LeonardOs Leonard
Os Leonard
oscon2007
 
Entity Persistence with JPA
Entity Persistence with JPAEntity Persistence with JPA
Entity Persistence with JPA
Subin Sugunan
 
2008.07.17 발표
2008.07.17 발표2008.07.17 발표
2008.07.17 발표
Sunjoo Park
 
Intro To Hibernate
Intro To HibernateIntro To Hibernate
Intro To Hibernate
Amit Himani
 
REST dojo Comet
REST dojo CometREST dojo Comet
REST dojo Comet
Carol McDonald
 
JSUG - TU Wien Castor Project by Lukas Lang
JSUG - TU Wien Castor Project by Lukas LangJSUG - TU Wien Castor Project by Lukas Lang
JSUG - TU Wien Castor Project by Lukas Lang
Christoph Pickl
 
Architecting Web Services
Architecting Web ServicesArchitecting Web Services
Architecting Web Services
Lorna Mitchell
 
Apache Persistence Layers
Apache Persistence LayersApache Persistence Layers
Apache Persistence Layers
Henning Schmiedehausen
 
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Baruch Sadogursky
 
JavaEE Spring Seam
JavaEE Spring SeamJavaEE Spring Seam
JavaEE Spring Seam
Carol McDonald
 
I Feel Pretty
I Feel PrettyI Feel Pretty
I Feel Pretty
John Quaglia
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server Pages
John Brunswick
 
Struts2
Struts2Struts2
Developing web apps using Java and the Play framework
Developing web apps using Java and the Play frameworkDeveloping web apps using Java and the Play framework
Developing web apps using Java and the Play framework
Victor Porof
 
The java server pages
The java server pagesThe java server pages
The java server pages
Atul Saurabh
 
Json
JsonJson
Javascript2839
Javascript2839Javascript2839
Javascript2839
Ramamohan Chokkam
 

Similar to JEST: REST on OpenJPA (20)

Slice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed PersistenceSlice: OpenJPA for Distributed Persistence
Slice: OpenJPA for Distributed Persistence
 
Using DAOs without implementing them
Using DAOs without implementing themUsing DAOs without implementing them
Using DAOs without implementing them
 
Jsp
JspJsp
Jsp
 
Os Leonard
Os LeonardOs Leonard
Os Leonard
 
Entity Persistence with JPA
Entity Persistence with JPAEntity Persistence with JPA
Entity Persistence with JPA
 
2008.07.17 발표
2008.07.17 발표2008.07.17 발표
2008.07.17 발표
 
Intro To Hibernate
Intro To HibernateIntro To Hibernate
Intro To Hibernate
 
REST dojo Comet
REST dojo CometREST dojo Comet
REST dojo Comet
 
JSUG - TU Wien Castor Project by Lukas Lang
JSUG - TU Wien Castor Project by Lukas LangJSUG - TU Wien Castor Project by Lukas Lang
JSUG - TU Wien Castor Project by Lukas Lang
 
Architecting Web Services
Architecting Web ServicesArchitecting Web Services
Architecting Web Services
 
Apache Persistence Layers
Apache Persistence LayersApache Persistence Layers
Apache Persistence Layers
 
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
 
JavaEE Spring Seam
JavaEE Spring SeamJavaEE Spring Seam
JavaEE Spring Seam
 
I Feel Pretty
I Feel PrettyI Feel Pretty
I Feel Pretty
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server Pages
 
Struts2
Struts2Struts2
Struts2
 
Developing web apps using Java and the Play framework
Developing web apps using Java and the Play frameworkDeveloping web apps using Java and the Play framework
Developing web apps using Java and the Play framework
 
The java server pages
The java server pagesThe java server pages
The java server pages
 
Json
JsonJson
Json
 
Javascript2839
Javascript2839Javascript2839
Javascript2839
 

Recently uploaded

WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
flufftailshop
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
Shinana2
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Tatiana Kojar
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 

Recently uploaded (20)

WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
dbms calicut university B. sc Cs 4th sem.pdf
dbms  calicut university B. sc Cs 4th sem.pdfdbms  calicut university B. sc Cs 4th sem.pdf
dbms calicut university B. sc Cs 4th sem.pdf
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
Skybuffer AI: Advanced Conversational and Generative AI Solution on SAP Busin...
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 

JEST: REST on OpenJPA

  • 1. JEST: REST on OpenJPA Pinaki Poddar, PhD Java Persistence Evangelist [email_address]
  • 2.
  • 3. JEST: REST on OpenJPA JEST is RESTful interaction with OpenJPA Runtime http JDBC XML/JSON Java Object Graph
  • 4.  
  • 5.
  • 6.
  • 7. REST: RE presentational S tate T ransfer C0 C0 C1’ C1’ S1 S2 S1 renders C1 modifies C2 renders Response 1 Request 2 Request 1 Response 2 @ rest State Transition 1 2 3 4 5 6
  • 8.
  • 9.
  • 10. JPA is Model-View-Controller for Persistence View Control Model /** * A persistent entity **/ @Entity public class Actor { @Id private String name ; } /** * Find Actor by name **/ public Actor findByName( String name ) { EntityManager em = …; return em.find( Actor . class , name); } POJO sees uses updates modifies Java Persistence API Relational Database
  • 11. JPA: access-detach-merge programming model C0 C0 C1’ C1’ em1 em2 renders C1 modifies C2 renders State Transition SELECT … detach find merge commit UPDATE/INSERT/DELETE … 1 2 3 5 6 4
  • 12. REST and JPA: brothers separated at birth? Stateless Server Detached Transaction Identifiable Resource Persistent Identity Coherent Representation Persistent Closure Self-descriptive JPA 2.0 Metamodel REST JPA
  • 13.
  • 14.
  • 15. Identifiable Resource: URI for persistent object? Actor p1 = em1.find ( Actor . class , “ John ”); Actor p2 = em2.find ( Actor . class , “ John ”); name :” John ” hash : 56789 p1 name :” John ” hash : 56789 p2 p1.equals(p2) p1.hashCode() == p2.hashCode() p1 != p2 public class Actor { @Id String name ; } Persistent Identity carries the notion that both p1 and p2 refer to the same database record. EntityManager EntityManager … Robert … John ACTOR
  • 16.
  • 17. OpenJPA Fetch Plan @Entity @FetchGroups ({ @FetchGroup ( name =&quot; OnlyName &quot;, attributes ={ @FetchAttribute ( name =&quot; firstName &quot;), @FetchAttribute ( name =&quot; lastName &quot;) }) }) public class Actor { @Id private String id ; private String firstName ; private String lastName ; private Gender gender ; private Date dob ; @OneToOne private Actor partner ; @OneToMany private Set<Movie> movies ; // getters and setters }
  • 18.
  • 19. JPA Metamodel: Persistent Type System Class Type<X> ManagedType<X> BasicType<X> IdentifiableType<X> EmbeddableType<X> EntityType<X> MappedSuperclassType<X> package javax.persistence.metamodel package java.lang <X>: Type<X> represents Java class X
  • 20. JPA Metamodel : Persistent Type System Field Attribute<X,Y> SingularAttribute<X,Y> PluralAttribute<X,C,E> ListAttribute<X,E> CollectionAttribute<X,E> SetAttribute<X> MapAttribute<X,K,V> package javax.persistence.metamodel package java.lang.reflect <X>: Attribute<X,Y> declared in Java class X <Y>: Attribute<X,Y> is of type Y <C>: PluralAttribute<X,C,E> is of Java collection type C <E>: PluralAttribute<X,C,E> contains elements of type E
  • 21. JPA Metamodel: Persistent Scope java.lang.Class java.lang.reflect.Field Metamodel ManagedType<X> Attribute<X,Y> java.lang.ClassLoader A classloader defines a scope for a set of Java classes A metamodel defines a scope for a set of managed persistent types package javax.persistence.metamodel
  • 22.
  • 23.
  • 24. JEST URI Syntax identifies JPA resources. maps to JPA operation decorates JPA operation JEST resolves argument strings to strong types, e.g. “ type=Actor ” to Actor .class . scheme authority path query context action qualifiers arguments OpenJPAEntityManager em = getPersistenceContext(); em.addFetchPlan(“ basic ”); Actor a = em.find( Actor . class , “m1”); find plan=basic type=Actor ? jest / / & id=m1 http 8080 openjpa.com / : ://
  • 25. JEST URI Examples find an Actor with primary key m1 using fetch plan ‘basic’ http :// openjpa.com:8080 / jest / find / plan = basic ? type = Actor & m1 Query for a single Actor by name John http :// openjpa.com:8080 / jest / query / single ? q = select p from Actor p where p.name=:n & n = John Get the metamodel http :// openjpa.com:8080 / jest / domain
  • 26. JEST translates HTTP verbs to JPA operations GET HTTP POST PUT DELETE find() getMetamodel() createQuery().getResultList() getProperties() /find / query / domain / properties merge() persist() remove() JEST Action JPA Operation non-transactional transactional
  • 27. JEST Deployment < web-app > < servlet > < servlet-name > demo </ servlet-name > < servlet-class > demo.SimpleApp </ servlet-class > </ servlet > < servlet-mapping > < servlet-name > demo </ servlet-name > < url-pattern > /* </ url-pattern > </ servlet-mapping > <!-- Deployment descriptor for JESTServlet. --> < servlet > < servlet-name > jest </ servlet-name > < servlet-class > org.apache.openjpa.persistence.jest.JESTServlet </ servlet-class > < init-param > < param-name > persistence.unit </ param-name > < param-value > SimplePU </ param-value > </ init-param > </ servlet > < servlet-mapping > < servlet-name > jest </ servlet-name > < url-pattern > /jest/* </ url-pattern > </ servlet-mapping > </ web-app > Deployed as HTTP Servlet within the same module scope Identifies the module by persistence unit name
  • 28. Deployment Modes for JEST Servlet JESTServlet emf Module X emf JESTServlet instantiates discovers instantiates or injected primary mode auxiliary mode default
  • 29.
  • 30.  
  • 31.  
  • 32.  
  • 33.  
  • 34.  
  • 35.
  • 36. JEST: JPA Detached Transaction C1 C1 C1’ C1’ S1 S2 S1 renders C1 modifies C2 renders A1 A1’ R1 Response 2 @ rest State Transition find() detach() represent() parse() merge() commit()
  • 37. REST is successful in real world Success has many friends… “ Amazon has both SOAP and REST interfaces to their web services, and 85% of their usage is of the REST interface. ” Jeff Barr, Web Services Evangelist @ Amazon Reference: REST vs SOAP at Amazon
  • 38. Does JEST pass the RESTness est? YES Q5 . Can server transfer logic to clients? NO Q4 . Can client determine the exact server endpoint? YES Q3 . Does response describe their cacheability for the client? NO Q2 . Does server store client context between requests? YES Q1 . Are clients separated from servers by a uniform interface?
  • 39. Does JEST pass Uniform Interface Test? YES Q9 . Are related resources accessible via received representation? YES Q8 . Does representation carry enough information to be processed by the client? YES Q7 . Can client manipulate received resource representation? YES Q6 . Does request identify a resource?
  • 40.
  • 41.
  • 42.