Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simple Rest Server Instructions Create a simple server that uses simple design patterns Factory : Your server should parse the routes and create a new

Simple Rest Server

Instructions

Create a simple server that uses simple design patterns

  • Factory: Your server should parse the routes and create a new Processor class depending on the route
  • Builder: The process method of your Processor should use the Builder pattern to create a response.
  • DAO: Make a class that abstracts the data interactions away from the rest of the app
  • Singleton: Wrap your daoinstance as a singleton class
  • Lazy Loading: DAOs should only load data when requested
  • DTO: Your JSON parsing, as well as response objects must be DTOs

First parse url, then use factory to instantiate correct Processor class. The factory will internally use the builder pattern to give the processor relevant data. Use builder to set the time, and input parameters.

Processor Class

  • Has a process() method that returns a ResponseDto object
  • Each endpoint is a subclass of Processor
  • Takes a hashmap of key value args
  • User a factory to create these, based on the endpoint
  • Every processor uses a builder and returns the output of builder.build()

Response Class

  • This class gets stringified with GSON
  • Needs a ResponseBuilder helper
  • Needs Params Map (String, String)
  • Needs response dto
  • Needs Response Code (String)

UserDao class

  • Singleton
  • Lazy load data
  • 1 DAO per type of endpoint to hold the data

Endpoints

  • Payment Methods
    • /addPaymentMethod
    • ?method=name
      • creates a new payment method and stores it in the paymentMethod DAO
      • assigns a machine code
      • needs Payment DTO + Payment DAO
    • /getAllPaymentMethods
      • Returns list of all payment methods

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions

Question

9. Mohawk Industries Inc.

Answered: 1 week ago

Question

8. Satyam Computer Services Limited

Answered: 1 week ago

Question

2. Explain how the role of training is changing.

Answered: 1 week ago