COLA Project: A Comprehensive Overview
Introduction to COLA
COLA stands for Clean Object-Oriented and Layered Architecture, which is an architectural approach aimed at organizing application components in a structured and orderly manner. It has reached its fifth major iteration, referred to as COLA v5. The main purpose of COLA is to define a well-structured application framework that effectively manages complexity and maintains order in large software systems.
COLA Architecture
Overview
The architecture of an application is its essential structure, consisting of various components and their interrelationships. The main goal of an application architecture like COLA is to define a good structural framework that helps manage complexity and transition from chaos to order.
COLA was created to fulfill this purpose by providing best practices in application architecture. Its primary focus is on defining a robust application structure and continually exploring ways to manage and organize business applications to reduce entropy and enhance clarity.
COLA Archetypes
COLA encourages applying specific common patterns to application architecture, promoting business-centric designs while decoupling technical complexities. Unlike other architectures like Hexagonal, Onion, and Clean Architecture, COLA offers concrete tools and practical guidance to implement these principles.
To facilitate rapid development, COLA provides two archetypes for different project types, located in the cola-archetypes
directory:
cola-archetype-service
: Used for creating backend services.cola-archetype-web
: Used for creating applications with both adapter and backend service components.
COLA Components
Apart from the architecture, COLA provides several useful components under the cola-components
directory. These components help boost productivity by catering to various functionalities:
Component Name | Function | Dependencies |
---|---|---|
cola-component-dto | Defines DTO format, including paging | None |
cola-component-exception | Defines exception formats, primarily BizException and SysException | None |
cola-component-statemachine | State machine component | None |
cola-component-domain-starter | Spring-managed domain entity component | None |
cola-component-catchlog-starter | Exception handling and logging component | exception , dto components |
cola-component-extension-starter | Extension point component | None |
cola-component-test-container | Test container component | None |
Using COLA
Creating a COLA Application
To create an application using COLA, the following command can be executed:
mvn archetype:generate \
-DgroupId=com.alibaba.cola.demo.web \
-DartifactId=demo-web \
-Dversion=1.0.0-SNAPSHOT \
-Dpackage=com.alibaba.demo \
-DarchetypeArtifactId=cola-framework-archetype-web \
-DarchetypeGroupId=com.alibaba.cola \
-DarchetypeVersion=5.0.0
Upon successful execution, the command generates a structured application codebase, demonstrating the organizational capabilities of COLA.
Running a COLA Application
- Navigate to the project directory and run
mvn install
. To skip tests, add-DskipTests
. - Enter the
start
directory and runmvn spring-boot:run
. Successful execution indicates a running Spring Boot application. - The generated application includes a sample REST request, accessible at
http://localhost:8080/helloworld
.
For a non-web service application, a similar command is used:
mvn archetype:generate \
-DgroupId=com.alibaba.cola.demo.service \
-DartifactId=demo-service \
-Dversion=1.0.0-SNAPSHOT \
-Dpackage=com.alibaba.demo \
-DarchetypeArtifactId=cola-framework-archetype-service \
-DarchetypeGroupId=com.alibaba.cola \
-DarchetypeVersion=5.0.0
Version Evolution
Version 5.0.0
- Support for JDK 17 and SpringBoot 3.x
- Added
cola-archetype-light
for package-based lightweight layer architecture - Introduced
cola-component-unittest
for enhanced unit testing - Enhanced
cola-component-test-container
with Junit5's Extension support
Previous versions have gradually simplified and improved the core components, package logic, and naming conventions to align better with architectural concepts like the hexagonal architecture. Each version iteration aligns with the broader goals of COLA for managing application complexity and improving codebase organization.