DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How does AI transform chaos engineering from an experiment into a critical capability? Learn how to effectively operationalize the chaos.

Data quality isn't just a technical issue: It impacts an organization's compliance, operational efficiency, and customer satisfaction.

Are you a front-end or full-stack developer frustrated by front-end distractions? Learn to move forward with tooling and clear boundaries.

Developer Experience: Demand to support engineering teams has risen, and there is a shift from traditional DevOps to workflow improvements.

Related

  • How Does Video Annotation Augment Computer Vision?
  • Role of Data Annotation Services in AI-Powered Manufacturing
  • Annotating Data at Scale in Real Time
  • Filtering Java Collections via Annotation-Driven Introspection

Trending

  • Preventing Downtime in Public Safety Systems: DevOps Lessons from Production
  • A Complete Guide to Modern AI Developer Tools
  • How to Install and Set Up Jenkins With Docker Compose
  • How to Use Testcontainers With ScyllaDB
  1. DZone
  2. Coding
  3. Languages
  4. New in JAX-RS 2.0 – @BeanParam Annotation

New in JAX-RS 2.0 – @BeanParam Annotation

JAX-RS 2.0 is the latest version of the JSR 311 specification and it was released along with Java EE 7.

By 
Abhishek Gupta user avatar
Abhishek Gupta
DZone Core CORE ·
Jul. 22, 14 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
23.1K Views

Join the DZone community and get the full member experience.

Join For Free

jax-rs is awesome to say the least and one of my favorites! why?

  • feature rich
  • intuitive (hence the learning curve is not as steep)
  • easy-to-use and develop with
  • has great ris – jersey , resteasy etc

there are enough jax-rs fans out there who can add to this! ;-)

jax-rs 2.0 is the latest version of the jsr 311 specification and it was released along with java ee 7.

life without @beanparam

before jax-rs 2.0, in order to pass/inject information from an http request into jax-rs resource implementation methods, one could

1. include multiple method arguments annotated with @formparam , @pathparam , @queryparam etc

1

1_1

2. or, have a model class backed by jaxb/json or a custom messagebodyreader implementation for jax-rs provider to be able to unmarshall the http message body to a java object – read more about this in one of my previous posts

2

3

this means that something like a html5 based client would need to extract the form input, convert it into json or xml payload and then post it over the wire.

simplification in jax-rs 2.0

this process has been simplified by introduction of the @beanparam annotation. it helps inject custom value/domain/model objects into fields or method parameters of jax-rs resource classes.

in case you want to refer to the code (pretty simple) or download the example/run it yourself, here is the github link

all we need to do is, annotate the fields of the model (pojo) class with the injection annotations that already exist i.e. @pathparam, @queryparam, @headerparam, @matrixparam etc – basically any of the @xxxparam metadata types and

4

make sure that we include the @beanparam annotation while injecting a reference variable of this pojo (only on method, parameter or field ).

5

jax-rs provider automatically constructs and injects an instance of your domain object which you can now use within your methods.

just fill in the form information and post it !

6

7

that’s it. . . short and sweet :-)

Annotation

Published at DZone with permission of Abhishek Gupta, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How Does Video Annotation Augment Computer Vision?
  • Role of Data Annotation Services in AI-Powered Manufacturing
  • Annotating Data at Scale in Real Time
  • Filtering Java Collections via Annotation-Driven Introspection

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: