Code Monkey home page Code Monkey logo

simpleaffablebean's Introduction

SimpleAffableBean

This project is a rewrite of the Affable Bean EJB web app, moving away from EJB and using a simpler technology stack.

This software is an adaptation from the Affable Bean project.
That project was released under the 2-clause Berkeley licence by Sun and then Oracle. Please see the LICENCE.affablebean.txt file for compliance and licensing concerns for the original project.

This project is being released under the "new" BSD 3-clause license.

The starting point for this project is the complete Affable beans project at: https://netbeans.org/projects/samples/downloads/download/Samples/JavaEE/ecommerce/AffableBean_complete.zip

Problems Being Addressed

Hardly anyone I know uses the EJB stack as it was meant to be used, with session and entity beans, data sources, services and the rest of it.
I've found that some of the best technology stacks avoid too much abstraction, and are straightforward to use, and lead to code that is straightforward to reason about.

I would classify a full-blown EJB container as getting low-marks in those areas.

Solutions Being Proposed

The goal of this rewrite is to enable the use of a pure servlet container (such as Tomcat or Jetty) to run the AffableBean project. To achieve this, we will be writing our own DataSource wrapper, writing a separate business logic layer (services and daos) and using a combination of servlets and JSPs for the front layer (including the ViewModel pattern of modelling the view at the servlet layer with bean classes).

As progress is made, I'll be tweaking the implementation here and perhaps strategies as I learn limitations along the way.

Changes to the Original AffableBean Implementation

  • We forego the use of EJB database patterns for a DAO pattern using JDBC access to MySQL
  • All pages except the Admin pages use the MVVM model for presentation layer simplicity.
  • Servlets have been separated out for ease of readability and maintenance.
  • Fewer URLs are used and correspond to pages
  • Language switching now uses a returnUrl parameter to know what page to return to (allowing removal of the 'view' session parameter mechanism)
  • All POST operations use the POST-redirect-GET pattern to avoid page reloads performing POST actions
  • Checkout no longer invalidates the session but does clear the cart
  • Added a "Continue Shopping" button to the confirmation page that goes to the home page
  • Header information is separated into a collection of @included JSP fragments for clarity.
  • Customer details entered on checkout are remembered in case of error (except for credit card)
  • Validation has been moved into the business layer and uses an exception
  • All model objects are immutable once constructed
  • Cache control headers are page-specific to tell browsers to avoid caching customer-specific pages.
  • A basic local WAR build using gradle
  • A central error servlet handling all error pages
  • Logging for service classes to allow for easier debugging
  • Added a servlet context listener to log servlet context and session context events
  • Use a customer form model object to model the data in the customer form
  • Added second-level caching using Guava for category and product model objects, with ability to periodically refresh the caches
  • Moved folders to be standard for the build system
  • Added acceptance test regime using Selenium-HtmlUnitDriver

simpleaffablebean's People

Contributors

nowucca avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.