This document provides a comprehensive introduction to the Solon Framework, a Java enterprise application development framework designed for full-scenario deployment. This page covers:
For detailed information on specific subsystems:
Solon is built on three core principles, as stated in README.md9:
| Principle | Description |
|---|---|
| Restrained | Minimalist approach to framework design, avoiding unnecessary complexity |
| Efficient | Optimized for performance with lower resource consumption |
| Open | Pluggable architecture with flexible interface specifications |
Unlike traditional Java enterprise frameworks, Solon is built from scratch without dependency on Java EE specifications. This architectural decision enables:
Sources: README.md1-120 README_EN.md1-120
Solon demonstrates exceptional performance metrics compared to traditional frameworks:
| Metric | Improvement | Details |
|---|---|---|
| Concurrency | 700% higher | Based on TechEmpower benchmarks |
| Memory Usage | 50% savings | Optimized bean management and request processing |
| Startup Time | 10x faster | Minimal initialization overhead, efficient classpath scanning |
| Artifact Size | 90% smaller | Modular design allows including only required components |
These characteristics are achieved through:
Sources: README.md55-70 solon-parent/pom.xml1-753
The following diagram illustrates the main architectural layers and their relationships:
Key Classes and Their Roles:
Solon: Static entry point providing global access to the application instance (solon/Solon.java48-404)SolonApp: Main application instance managing lifecycle, configuration, and request routing (solon/SolonApp.java58-780)SolonProps: Configuration loader supporting multiple sources with precedence rules (solon/SolonProps.java47-751)AppContext: IoC container for bean registration and dependency injection (solon/core/AppContext.java)Context: HTTP request/response abstraction for web applications (solon/core/handle/Context.java42-1247)Sources: solon/Solon.java1-404 solon/SolonApp.java1-780 solon/SolonProps.java1-751 solon/core/handle/Context.java1-100
Lifecycle Phases:
app.properties/app.yml and environment-specific files (solon/SolonProps.java100-125)META-INF/services (solon/SolonProps.java376-387)Sources: solon/Solon.java163-271 solon/SolonApp.java244-268 solon/SolonApp.java355-418 solon/SolonProps.java72-220
Solon uses a tiered bundle system to organize over 100 modules:
| Bundle | Purpose | Key Modules |
|---|---|---|
| Bundle 1 | Core functionality, configuration, security | solon-aot, solon-handle, solon-proxy, solon-i18n, solon-mvc, solon-security-* |
| Bundle 2 | Data access and caching | solon-data, solon-cache, solon-data-dynamicds, cache adapters (Caffeine, Jedis, Redisson) |
| Bundle 3 | Web utilities and protocols | solon-web-cors, solon-web-staticfiles, solon-web-sse, solon-server-websocket |
| Bundle 4 | View engines, logging, scheduling | solon-view (FreeMarker, Thymeleaf), solon-logging-*, solon-scheduling-*, solon-faas-luffy |
| Bundle 5 | Serialization and testing | JSON (Snack4, FastJson, Jackson), binary formats, solon-test |
| Bundle 6 | HTTP server implementations | solon-server-jdkhttp, solon-server-jetty, solon-server-tomcat, solon-server-undertow, etc. |
solon-lib: General-purpose applications
solon-web: Web applications
Sources: __release/solon-base-bundle1/pom.xml1-49 __release/solon-base-bundle2/pom.xml1-35 __release/solon-base-bundle3/pom.xml1-31 __release/solon-base-bundle4/pom.xml1-38 __release/solon-base-bundle5/pom.xml1-33 __release/solon-base-bundle6/pom.xml1-35 __release/solon-shortcuts-bundle/pom.xml1-30
Create a minimal Solon application in three steps:
Step 1: Add dependency (pom.xml):
Step 2: Create main class:
Step 3: Create controller:
The application will:
server.port)HelloApp package for @Controller and @Component classes@Mapping annotationshttp://localhost:8080/hello?name=WorldCreate app.yml in src/main/resources:
Access configuration in code:
Sources: solon/SolonApp.java46-53 solon/Solon.java36-47 solon/SolonProps.java100-125 README.md1-120
Solon's configuration system supports hierarchical property sources with clear precedence:
app.properties and app.yml (solon/SolonProps.java103-104)app-{env}.properties and app-{env}.yml based on env parameter (solon/SolonProps.java110-119)solon.config.load (solon/SolonProps.java134-161)solon.config.add parameter (solon/SolonProps.java164)Configuration values support expression resolution with default values:
| Syntax | Description | Example |
|---|---|---|
${key} | Property reference | ${database.url} |
${key:default} | With default value | ${server.port:8080} |
${.key} | Relative reference | ${.username} (within same section) |
Sources: solon/SolonProps.java72-220 solon/core/Props.java40-900 solon/core/util/PropUtil.java1-300
The following diagram shows how HTTP requests flow through Solon's processing pipeline:
Key Components:
Sources: solon/SolonApp.java617-664 solon/core/handle/Context.java42-100
Solon's SPI-based plugin architecture enables modular extensibility:
Plugins are discovered via Java's ServiceLoader mechanism:
META-INF/services/org.noear.solon.core.PluginLifecycle Methods:
init(AppContext ctx): Called during plugin discovery phasestart(AppContext ctx): Called after configuration loading, before bean scanningpreStop(): Called when shutdown signal received, before stoppingstop(): Called during application shutdownExclude plugins without removing dependencies:
Or programmatically:
Sources: solon/SolonProps.java376-396 solon/SolonApp.java355-418 solon/SolonApp.java592-603
| Abstraction | Purpose | Key Interface/Class |
|---|---|---|
| SolonApp | Application instance and lifecycle manager | org.noear.solon.SolonApp |
| AppContext | IoC container for dependency injection | org.noear.solon.core.AppContext |
| Context | HTTP request/response abstraction | org.noear.solon.core.handle.Context |
| Plugin | Extension point for modular features | org.noear.solon.core.Plugin |
| BeanWrap | Bean metadata wrapper | org.noear.solon.core.BeanWrap |
| Router | Request routing and matching | org.noear.solon.core.route.Router |
| Action | Controller method handler | org.noear.solon.core.handle.Action |
solon-lib or solon-web shortcut, or specific bundles@SolonMain, call Solon.start()@Controller, @Component, @Configuration annotationsapp.yml with environment-specific profilesCurrent version: 3.9.3 (solon-parent/pom.xml10)
Supported Java versions:
solon-java25 adapter)For detailed information on specific subsystems:
Sources: solon/Solon.java48-404 solon/SolonApp.java58-780 solon-parent/pom.xml1-30 README.md1-120 UPDATE_LOG.md1-100
Refresh this wiki