Upload
others
View
8
Download
0
Embed Size (px)
Citation preview
• What’sInJAX-RS2.1?
• ReactiveClient
• ServerSentEvents
• OtherNewAPIs
• BeyondJAX-RS2.1…
• JAX-RSinJavaSE
• Type-safeClientAPIs
• BetterCDIintegration
JAX-RSREFRESHER
• JAX-RSprovidesRESTfulservicesviaResourcesandProviders.
• ResourcesimplementthebusinesslogicofaRESTfulrequest.
• Providershandleinfrastructuretasks,likeconvertingHTTPentitydataintoobjectsandvice-versa(MessageBodyReaders/Writers),convertingexceptionsintoHTTPresponses(ExceptionMappers),filteringrequests/responses(Filters),etc.
JAX-RSREFRESHER
AppendixCfromtheJAX-RS2.1Specification
REACTIVECLIENT
• Introducesreactiveprogrammingmodel.
• BuiltonJava8’sjava.util.concurrent.CompletionStage
• Allowsmultiplestagestobeinvokedinaparticularorder.
• Allowshandlingofexceptionsin-line.
• Async-ready.
• ThespecallowsforoptionalsupportofotherreactiveplatformssuchasRxJava andFlow– notportable…
REACTIVE CLIENTDEMO
• Scenario:Userrunsaconsultantshopandneedstoscheduleconsultantsbasedontheirskilllevelsandavailability.
• Twomicroservices apps:
• Skills– organizesexpertsbytheirskill(rated1=lowestto5=highest).
• Scheduling– organizestheschedulesoftheexperts.
• Requirement:Weneedtoleveragethesetwomicroservices toprovideaschedulingmechanismthatfindsthemostqualifiedconsultantavailable.
SERVERSENTEVENTS
• PartoftheHTML5Spec.
• JAX-RS2.1providesAPIsforSSEserverandclient.
• Canbroadcasteventstoallregisteredclientsorcansendspecificeventstospecificclients.
SSEDEMO
• Chatapplication– UsersregisterwiththechatroomandcanPOSTmessagesthatarethenbroadcasttoallregisteredclientsintheroom.
OTHERNEWAPIS
• NewconnectTimeout(…)andreadTimeout(…)methodsinClientAPIallowsmoreportabletimeoutcode.
• New@PATCHannotation.
• Orderingofprovidersisnowpossibleusing@Priorityannotations– notethatproviderswillbeinvokedinascendingorder(i.e.@Priority(5)willbeinvokedbefore@Priority(10)).
• Sub-resourcelocatorscannowreturnClassobjectsinsteadofonlyinstanceobjects.
• JSON-B1.0Providersoutofthebox*- ifthevendorprovidesJSON-B.
BEYONDJAX-RS2.1…
• Disclaimer:Nopromises!AnythinginthefollowingslidesaresubjecttochangepriortothefinalreleaseofJAX-RSv.Next.
• JavaEE(Oracle)isnowJakartaEE(Eclipse/EE4J)
• ManymembersoftheJAX-RS2.1ExpertGrouparenowcommittersintheJakartaJAX-RSproject.Newmembershavealsojoinedthecommunity.
• Currentreleaseplanning:
• ThefirstreleaseofJakartaEEwillbe100%compatiblewithJavaEE8– thismeansJAX-RS2.1.
• ThenextreleaseofJAX-RSistentativelycalledJAX-RS2.2– somenewfunction,butnobreakingchanges.
• Thenextmajor releaseofJAX-RSistentativelycalled3.0– expectsomebreakingchanges.
JAX-RSINJAVASE
• Thepopularityof“micro”(MicroProfile,SpringBoot,etc.)isnotlostontheJAX-RScommunity.
• Formanyusecases,aJAX-RSenvironmentwithoutallofthe“extras”inafullprofileapplicationservercanhavealotofbenefits.
• ThisproposalintendstoallowdeveloperstostartandstopaJAX-RSapplicationwithafewkeybootstrapAPIs.
• ConsiderMarkusKarg’s minimalexample(https://gist.github.com/mkarg/a38a68f6025f1ef6ddb4916022bd150d):
• https://github.com/eclipse-ee4j/jaxrs-api/issues/509
TYPE-SAFECLIENTAPIS
• CurrentJAX-RSClientAPIsareverysimilartolow-levelframeworks– likeApacheCommonsHTTPClient.
• ManyJAX-RSimplementations(CXF,Jersey,RESTEasy,etc.)haveatype-safe,proxy-basedclientAPIthatallowsdeveloperstocodeclientsthatbetterintegratewiththeirbusinesslogic.
• https://github.com/eclipse-ee4j/jaxrs-api/issues/598
• PossiblymovingEclipseMicroProfile RestClienttoJakartaEE…
TYPE-SAFECLIENTAPIS– THEJAX-RS2.0/2.1WAY
TYPE-SAFECLIENTAPIS– THEMPRESTCLIENTWAY
BETTERCDIINTEGRATION
• CurrentlyCDIintegrationinJAX-RS2.1issomewhatlimited– seesection11.2.3.
• DeveloperscanuseinjectionofotherCDI-managedbeansintoresource,providerandapplicationinstances.
• Mostvendorsprovideintegrationaboveandbeyondthespec– forexample,allowingnon-standardlifecycles(i.e.@ApplicationScoped resourceclasses,orper-requestscopedproviders,etc.),butthisisnotstandardized– andthusnotportable.
• JAX-RSsupportsmultipleinjectionmechanisms- @Contextvs@Inject
• https://github.com/eclipse-ee4j/jaxrs-api/issues/569
BETTERCDIINTEGRATION- PROPOSALS
• InJAX-RS2.2,deprecate@Contextinfavorof@Inject– @Injectdoesnotworkonmethodparameters,sotherecommendationwouldbetoput@Context-basedinjectiontargetsintofields.
•Becomes:
• OtherthingslikeRuntimeDelegate couldalsobecomeCDI-managedbeans.
BETTERCDIINTEGRATION- PROPOSALS
• Theintentistoremove@ContextasaninjectionmechanisminJAX-RS.Ifwedeprecate@ContextinJAX-RS2.2,expectthatitwillberemovedinJAX-RS3.0.
• Otherpossibilitieswouldbetostandardizenon-defaultlifecycles– allowingresourcestobesingletonsandproviderstobeper-request,etc.
SUMMARY
• JAX-RS2.1
• ReactiveClient– usesCompletionStage toenablereactiveprogrammingontheclientside.
• ServerSentEvents– pub/subforRESTfulservices.
• Checkthejavadoc foradditionalchanges:https://jax-rs.github.io/apidocs/2.1/
• JAX-RSFuture
• Morecommunityinvolvement– getinvolvedat:https://projects.eclipse.org/proposals/eclipse-project-jax-rs
• Lotsofnewfeaturescoming– staytuned!
QUESTIONS?
BACKUPSLIDES
RXCLIENT– EXAMPLERESOURCE.JAVA
RXCLIENT – EXAMPLERESOURCE.JAVA (CONTINUED)
SSE CHATRESOURCE.JAVA
SSEINDEX.HTML
SSEINDEX.HTML (CONTINUED)