Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Java: 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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions

Question

=+(17.24) ['If(x) dx Answered: 1 week ago

Answered: 1 week ago

Question

what Computer bus interface connects to mass storage devices

Answered: 1 week ago

Question

Is it clear what happens if an employee violates the policy?

Answered: 1 week ago