Skip to content

hcoona/enterprise-java-sample

Repository files navigation

Enterprise Java Sample

This is a sample project with best practice for enterprise Java developing. It’s particular because:

  1. It provide both RESTful API & Grpc API

  2. It fits into JavaEE 8 specification without the EJB parts, but not relying on any JavaEE application servers

Main projects

Service-side projects

API

Recommend to follow the Google API Design Guide.

Define wrapper interfaces for services to hide the details about communicating through Grpc or RESTful. Annotate on the interface to identify whether the API is stable, to identify the API is for internal or external.

Grpc Client

RESTful Client

JPA model

The AbstractEntity is to ensure using auto-incremental Id field in database. It would bring better performance.

Create indexes for searchable fields, especially for the "natural id" field.

Assign column length for String type fields.

Assign cascading for One-To-Many relationship.

Use DeltaSpike to simplify the implementation of Repository pattern.

Common

The common project is separate because we want to build several server apps with the same business logics. It’s usually merged into the server app.

Presentation Layer Model

The presentation layer model directly matches the JSON entities accept from or return to user through RESTful API.

ServiceImpl

It implements the API, contains the real business logics.

Grpc-only Server

RESTful-only Server

The restful server follows the standard RESTful design style.

Mixed Server

Client-side projects

Grpc-only Agent

RESTful-only Agent

Mixed Agent

Auxiliary projects

Checkstyle

Dependencies POM

Future

  1. Add static analysis

    1. SonarQube

    2. PMD

    3. FindBugs

  2. Add Liquibase

  3. MicroMeter

Releases

No releases published

Packages

No packages published

Languages