WAS v8.5 > End-to-end paths > Web services - RESTful services > Use Java contexts and dependency injection with JAX-RSDefine the resources in JAX-RS web applications.
Configure the development environment.
Step 2 towards the goal: Use Java contexts and dependency injection with JAX-RS
Resources are the basic building block of a RESTful service. Resources can contain static or dynamically updated data. Examples of resources from an online book store application include a book, an order from a store, and a collection of users. By identifying the resources in the application, we can make the service more useful and easier to develop.
Subtopics
- Define the resources in RESTful applications
You can use Java API for RESTful Web Services (JAX-RS) to develop services that follow REST principles. RESTful services are based on manipulating resources. Resources can contain static or dynamically updated data. By identifying the resources in the application, we can make the service more useful and easier to develop.- Define the URI patterns for resources in RESTful applications
REST services are based on manipulating resources. Resources for RESTful services are addressable, and URLs are the primary way of achieving addressability in REST.- Define resource methods for RESTful applications
Individual resources can define their capabilities using supported HTTP methods. In REST services, the supported methods are GET, PUT, DELETE, and POST. All operations are typically conducted using one of the predefined HTTP methods with a resource.- Define the HTTP headers and response codes for RESTful applications
HTTP headers and status codes are useful to help intermediary and client programs understand information about requests and responses for applications. HTTP headers contain metadata information. HTTP status codes provide status information about the response.- Define media types for resources in RESTful applications
Resources are represented by multiple formats. XML, JSON, Atom, binary formats such as PNG, JPEG, GIF, plain text, and proprietary formats are used to represent resources. Representational State Transfer (REST) provides the flexibility to represent a single resource in multiple formats.- Define parameters for request representations to resources in RESTful applications
Parameters are used to pass and add additional information to a request. We can use parameters as part of the URL or in the headers. Path parameters, matrix parameters, query parameters, header parameters, and cookie parameters are useful for passing in additional information to a request.- Define exception mappers for resource exceptions and errors
Java API for RESTful Web Services (JAX-RS) applications can produce exceptions and errors. The default behavior is to use the exception handling functionality of application container such as JSP error pages. However, we can customize the error handling and send specific responses back when an exception or error occurs.
Configure the JAX-RS application.
Subtopics
- Define the resources in RESTful applications
You can use Java API for RESTful Web Services (JAX-RS) to develop services that follow REST principles. RESTful services are based on manipulating resources. Resources can contain static or dynamically updated data. By identifying the resources in the application, we can make the service more useful and easier to develop.- Define the URI patterns for resources in RESTful applications
REST services are based on manipulating resources. Resources for RESTful services are addressable, and URLs are the primary way of achieving addressability in REST.- Define resource methods for RESTful applications
Individual resources can define their capabilities using supported HTTP methods. In REST services, the supported methods are GET, PUT, DELETE, and POST. All operations are typically conducted using one of the predefined HTTP methods with a resource.- Define the HTTP headers and response codes for RESTful applications
HTTP headers and status codes are useful to help intermediary and client programs understand information about requests and responses for applications. HTTP headers contain metadata information. HTTP status codes provide status information about the response.- Define media types for resources in RESTful applications
Resources are represented by multiple formats. XML, JSON, Atom, binary formats such as PNG, JPEG, GIF, plain text, and proprietary formats are used to represent resources. Representational State Transfer (REST) provides the flexibility to represent a single resource in multiple formats.- Define parameters for request representations to resources in RESTful applications
Parameters are used to pass and add additional information to a request. We can use parameters as part of the URL or in the headers. Path parameters, matrix parameters, query parameters, header parameters, and cookie parameters are useful for passing in additional information to a request.- Define exception mappers for resource exceptions and errors
Java API for RESTful Web Services (JAX-RS) applications can produce exceptions and errors. The default behavior is to use the exception handling functionality of application container such as JSP error pages. However, we can customize the error handling and send specific responses back when an exception or error occurs.
Related
Define the resources in RESTful applications
Define the URI patterns for resources in RESTful applications
Define resource methods for RESTful applications
Define the HTTP headers and response codes for RESTful applications
Define media types for resources in RESTful applications
Define parameters for request representations to resources in RESTful applications
Define exception mappers for resource exceptions and errors