Solon Framework Documentation

repository·main·Indexed 25 days ago

https://github.com/opensolon/solon

A high-performance, lightweight Java enterprise framework designed for high concurrency and low resource consumption. Solon supports JDK 8, 11, 17, 21, and 25, as well as GraalVM native images. The ecosystem includes Nami for HTTP RPC and REST API client support, solon-server-nettyhttp for HTTPS configuration, and a hotplug system for plugin management via PluginManager.

Tokens
44.8K
Snippets
98
Records
274
Agent score
83%

What's inside Solon

  1. Overview of Solon Logging Architecture

    main

    The solon-logging-simple module provides an implementation of the SLF4J interface, serving as an entry point for distributed logging services.

    In the current architecture, solon.cloud no longer depends directly on solon.logging.impl. Instead, logging functionality is delegated to specific plugins depending on your requirements:

    • Local Logging (Log4j2): Use log4j2-solon-plugin.
    • Local Logging (Logback): Use logback-solon-plugin.
    • Distributed Logging: Use water-solon-plugin for distributed logging services.
  2. Overview of Shaded JSON in solon-configuration-processor

    main
    The solon-configuration-processor uses a shaded version of JSON APIs. This implementation is derived from com.vaadin.external.google:android-json, which provides a clean-room re-implementation of the org.json APIs. This is done to avoid the licensing restrictions associated with the original org.json library.
  3. Overview of Solon Framework

    main

    Solon is an enterprise-grade Java application development framework designed for all scenarios. It is built from the ground up to be restrained, efficient, and open. Key performance characteristics include:

    • High Concurrency: Up to 700% higher concurrency (based on TechEmpower benchmarks).
    • Low Memory Footprint: Reduces memory usage by approximately 50%.
    • Fast Startup: 10x faster startup times, which is beneficial for debugging and serverless environments.
    • Small Package Size: Reduces deployment package size by 90%.
    • Broad Compatibility: Non-Java-EE architecture that supports Java 8 through Java 25, and is compatible with GraalVM Native Image runtimes.
  4. Use Nami for HTTP RPC or REST API client support

    main

    Nami is a companion project for Solon that provides client support for HTTP RPC or REST APIs. It is compatible with three communication channels: HTTP, Socket, and WebSocket.

    To use Nami, you can either use dependency injection with the @NamiClient annotation (requires a LoadBalance implementation for service discovery/routing) or use the Nami.builder() fluent API for manual client creation.

    // Example of manual client creation using the builder
    IComplexModelService service = Nami.builder()
                                        .encoder(SnackTypeEncoder.instance)
                                        .url("http://localhost:8080/ComplexModelService/")
                                        .create(IComplexModelService.class);
  5. Use properties format for parameters and rendering output

    main

    The solon-serialization-properties module adds support for handling parameters in properties format and rendering output in the same format.

    Parameter Input Formats

    The module supports both prefixed and non-prefixed property-style query parameters:

    • Prefixed: ?user.id=1&user.name=noear&user.aaa[]=1&user.aaa[]=2
    • Non-prefixed: ?id=1&name=noear&aaa[]=1&aaa[]=2

    Output Format

    When rendering output using this module, data is formatted as standard properties (key-value pairs), including support for array indexing (e.g., aaa[0]=1).

    aaa[0]=1
    aaa[1]=2
    date=Sat Apr 27 08:46:52 CST 2024
    id=1
    name=noear
    sex=0
  6. Use Action filter system instead of Before/After Handlers

    main

    Starting from version 2.9.3, the Before and After Handler system is deprecated. You should migrate to the new Action filter system.

    • Deprecated: Before and After Handlers.
    • Recommended: Action filter system.
    • Deprecated Bean retrieval: Props:getBean and NvMap:getBean should be replaced by Props:toBean.
  7. Configure solon-maven-plugin for packaging

    main

    Use the solon-maven-plugin to handle project packaging. Unlike the traditional maven-assembly-plugin approach which keeps individual JAR files and prevents overwriting of identical files, this plugin provides a streamlined packaging process. It is recommended to perform a clean before packaging.

    <build>
        <plugins>
            <plugin>
                <groupId>org.noear</groupId>
                <artifactId>solon-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
  8. Migrate from solon-boot to solon-server

    main
    In recent versions, the solon-boot-* plugins have been renamed to solon-server-*. Additionally, the solon.boot package has been renamed to solon.server. Related utility classes in the old package are marked as deprecated.