How sxyang-super/exception-unifier works
Project type and purpose
• This is a multi-module, open-source tooling project (not a typical frontend-backend web app). It ships:
• A base Java library (exception-unifier-base) defining your exception pattern and runtime APIs
• A Java annotation processor (exception-unifier-processor) to validate exception usage at compile time
• A Maven plugin (exception-unifier-maven-plugin) with three Mojos (check, sync, push) that:
– Inspects/rewrites exception enums via ASM
– Reads module prefix (BASE or REMOTE)
– Pushes exception metadata to a remote server
• A lightweight Node.js “exms” microservice that acts as the central exception-code management server
File-structure highlights
• Top-level pom.xml aggregates four submodules
• exception-unifier-base (src/main/java/.../base) contains BaseException, assertion interfaces, exception enum patterns
• exception-unifier-processor (src/main/java/.../processor) implements a javax.annotation.processing.Processor
• exception-unifier-maven-plugin (src/main/java/.../mavenplugin) implements three Mojos (CheckMojo, SyncMojo, PushMojo), plus handler and ASM visitor packages
• exms (JavaScript/Node.js) implements an HTTP server with two routes: prefix-route.js and exception-enum.js, backed by a JSON data store
Key README insights
• Pattern: exceptions unified behind BaseException + IExceptionEnum / IExceptionEnumAsserts
• Compile-time: annotation processor enforces enum implementation and generates code
• Build-time: Maven plugin “check” validates no duplicates; “sync” prepends module prefix; “push” POSTs metadata to exms server
• Two source modes: BASE (prefix in POM) vs. REMOTE (prefix fetched from exms via REST)
Components
A. Java Toolchain (left side)
• Developer code: user’s exception classes & enums
• exception-unifier-base: runtime library
• exception-unifier-processor: annotation processor plugged into javac
• exception-unifier-maven-plugin: three Mojos orchestrated by Maven lifecycle
– CheckHandler / SyncHandler / PushHandler
– ASM visitors (ModifyExceptionEnumClassVisitor, ReadExceptionEnumClassVisitor)
B. Build System
• Maven core calls compiler (invokes annotation processor)
• Maven core invokes plugin goals (check, sync bound to compile; push bound to install)
C. Central server (right side)
• exms (Node.js Express service)
• Endpoints:
– GET /prefix/{moduleId} → returns module prefix
– POST /exception-enum/bulk → receives exception metadata JSON
• Data store: source.json (or environment-configured)
Relationships & data flows
1. Developer invokes mvn compile
– Javac + exception-unifier-processor validate enums → error on misuse
– exception-unifier-maven-plugin “check” inspects bytecode with ASM → enforces constraints
– exception-unifier-maven-plugin “sync” either:
• Reads prefix from POM (BASE) or
• Calls exms GET /prefix (REMOTE)
then rewrites enum bytecode to inject full codes (prefix_source_code)
2. Developer invokes mvn install (or package)
– exception-unifier-maven-plugin “push” collects synced metadata and POSTs to exms server
3. exms persists or returns data to clients (remote management UI could be layered on top in future)
Architectural patterns & principles
• Multi-module Maven parent POM pattern
• Annotation-processing plug-in mechanism (javax.annotation.processing)
• Maven Mojo pattern (Command objects per goal)
• Bytecode manipulation with ASM visitors (visitor pattern)
• Microservice (REST API) for central prefix & metadata management
• Clear separation: compile-time validation, build-time code rewriting, runtime base library, external service
Detail checklist
• Component names & versions (2.0.0)
• Module roles (runtime vs. compile vs. build vs. service)
• Package-level interactions (e.g., processor → Base library)
• Source-type branching (BASE vs. REMOTE)