Creating a Jax-Rs Application with ADF Model using Jdeveloper

While working on Oracle PaaS it is a common requirement to build REST services and our first choice is usually ADF.

 ADF is good for handling simple Requests and Response pattern and uses ADF model and transaction management to handle and fulfill requests. But there are times when we need to have a complex structure and a framework which can provide a stable and secure Model and also handle complex Request and Response structure.

This is where we can use combination of Jax-Rs with ADF Model approach, Jax-Rs can handle any type of complex Request and Response type and ADF Model can handle DB transactions and security.

Below are the steps for creating the same:

  • Create ADF Rest Web Application
    • Name : XxcomSampleJaxRsRestServiceApp
    • Pkg : xxcom.test.jaxrs
    • Model: XxcomSampleJaxRsRestServiceModel





  • Assign Database to Model project so DB components can be created
  • Create AM
    • Name : XxcomSampleJaxRsRestServiceAM
    • Pkg: xxcom.test.jaxrs.model.am

    • Keep Default settings and Finish
  • Set Connection pooling to true in AM
    • Modify Data Source
    • Add <AM-Pooling jbo.doconnectionpooling="true"/>

  • Delete the Auto generated RestProject
  • Add New Custom REST Web Service Project
    • New Project > Rest WebService Project
    • Name : XxcomSampleJaxRsWebService
    • Pkg : xxcom.test.jaxrs.rest
  • Create New Rest Service
    • Create New > Restful Service in WebService Project


    • Application Class : xxcom.test.jaxrs.rest.RestApplication
    • Appliction Path : api
    • Resource: SampleRestService
    • Service class is created which can then be modified to meet business needs

  • Add New Custom Java Project for storing custom types and their corresponding pojo’s
    • Name : XxcomSampleJaxRsService
    • Pkg : xxcom.test.jaxrs.service
  • Create a Request and Response structure class
    • Create Request Class
      • Name : SampleRestServiceRequest
      • Pkg : xxcom.test.api.model

    • Define Request Parameters inside Request Class
      • Below image shows the structure created using pojo class
    • Create Response Class
      • Name : SampleRestServiceResponse
      • Pkg : xxcom.test.api.model
    • Define response parameters inside Response class

  • Add Dependency XxcomSampleJaxRsService to XxcomSampleJaxRsWebService
  • Edit SampleRestService to include custom Request and Response structure
Currently the response is sum of 2 input params
  • Uncheck AutoGenerate and Sync Weblogic JDBC Descriptors
    • Navigate to Application Properties > Deployment > Weblogic > Uncheck Auto Generate and Sync Weblogic JDBCDescriptors During Deployment
  • Modify WebAppName and Context Root
    • Navigate to XxcomSampleJaxRsWebService> Properties > Java EE Application
  • Compile and run the service, you can test the same using Postman





This is a basic application used to understand the components needed for developing Jax-Rs Application, in future blogs we will be doing a more practical example using ADF Model, modifying Custom Url, removing null properties from Response.

Comments

Popular posts from this blog

Mavenize an Oracle ADF Application

Creating Column Filter on a VBCS Table using ListDataProvider(LDP)

Using Custom Colors in Sunburst Chart