The projects in this open source organization are boutiques

preface

In open source China, I wonder if you have noticed a Java open source organization - Dromara?

This organization is a Java open source organization founded by the author of Apache ShenYu (formerly Soul gateway) and participated by many Java open source authors.

In the open source Chinese community, many Java open source authors work independently. The birth of Domara organization is to unite the power of Java open source, build communities, share resources and jointly promote the development of Java open source in China.

At present, Dromara community has 9 GVP projects and some projects with a high number of stars. These open source project communities are very active, and each is a boutique open source work that can improve work efficiency. Let's take stock of four open source projects organized by Dromara. They are very practical tools. Making good use of them will greatly improve your production efficiency!

Sa-Token

First of all, I want to introduce SA token, which is probably the most fully functional lightweight Java permission authentication framework in history.

Simple use, rich features and powerful functions, what is your reason to refuse?

Official website: http://sa-token.dev33.cn/

Gitee managed warehouse: https://gitee.com/dromara/sa-token

Github managed warehouse: https://github.com/dromara/Sa-Token

SA token is a lightweight Java permission authentication framework, which mainly solves the following problems: login authentication, permission authentication, Session session, single sign on, OAuth2.0 and micro service gateway authentication
And a series of permission related problems.

The API design of SA token is very simple. How simple is it? Take login authentication as an example. You only need to:

// Write the account id of the current session when logging in
StpUtil.login(10001);

// Then call the following method at the place where the login needs to be verified:
// If the current session is not logged in, this code will throw an 'NotLoginException' exception
StpUtil.checkLogin();

So far, we have completed login authentication with the help of SA token!

At this time, your little head may be filled with question marks, so simple? What about custom Realm? What about global filters? Don't I have to write various configuration files?

Yes, in SA token, login authentication is so simple that it does not require any complex pre work. Just this line of simple API calls can complete session login authentication!

When you are fed up with the three worships and nine taps of Shiro, spring security and other frameworks, you will understand how simple and elegant the API design of SA token is compared with these traditional and old frameworks!

Example of permission authentication (only sessions with user:add permission can enter the request)

@SaCheckPermission("user:add")
@RequestMapping("/user/insert")
public String insert(SysUser user) {
	// ... 
	return "User increase";
}

Kick an account offline (a NotLoginException exception will be thrown when the other party accesses the system again)

// Force the session with account id 10001 to log off
StpUtil.logoutByLoginId(10001);

In SA token, most functions can be completed in one line of code:

StpUtil.login(10001);                     // Mark the account id of the current session login
StpUtil.getLoginId();                     // Get the login account id of the current session
StpUtil.isLogin();                        // Gets whether the current session has been logged in, and returns true or false
StpUtil.logout();                         // Current session logout login
StpUtil.logoutByLoginId(10001);           // Log off the session with account number 10001 (kick off)
StpUtil.hasRole("super-admin");           // Query whether the current account contains the specified role ID, and return true or false
StpUtil.hasPermission("user:add");        // Query whether the current account contains the specified permission, and return true or false
StpUtil.getSession();                     // Get the Session of the current account id
StpUtil.getSessionByLoginId(10001);       // Get the Session with account id 10001
StpUtil.getTokenValueByLoginId(10001);    // Obtain the token token value with account id 10001
StpUtil.login(10001, "PC");               // Specify the device ID login, which is commonly used for "same end mutually exclusive login"
StpUtil.logoutByLoginId(10001, "PC");     // Specify the device ID for forced logoff (different ends are not affected)
StpUtil.openSafe(120);                    // Enable Level 2 authentication in the current session. The validity period is 120 seconds 
StpUtil.checkSafe();                      // Verify whether the current session is within the validity period of level 2 authentication. If the verification fails, an exception will be thrown 
StpUtil.switchTo(10044);                  // Temporarily switch the current session identity to another account 

Even if you don't run tests, I'm sure you can understand the usage of most API s.

For more information, please refer to: https://gitee.com/dromara/sa-token

Forest

A powerful Http client framework that greatly liberates your Http access work.

Is the Http protocol complex? That's because you haven't used Forest. Although there are many other excellent Http clients in the industry, if you miss Forest, you will miss a large area of elegant and beautiful Forest.

Official website: http://forest.dtflyx.com

Gitee managed warehouse: https://gitee.com/dromara/forest

Github managed warehouse: https://github.com/dromara/forest

Forest is an open source Java HTTP client framework used to access the RESTful interface of third-party services.

It can bind the request parameters of HTTP to the Java interface, and then calling the Java interface is equivalent to sending HTTP requests. Everything is interface oriented.

Many companies need to call many third-party HTTP interfaces in the Java background, such as wechat payment, Youmeng and other third-party platforms.

Many services in the company are written in the world's best language, and the interface can only be called through HTTP interface. Over time, there are many different HTTP call interfaces in Java code, and the call methods are not unified. There are HttpClient, OkHttp and their own packaging. There are two or three HTTP tool classes packaged by different people in the company.

Moreover, the url is basically written in the code, which is difficult to maintain. Different interfaces have different parameter transmission methods, including GET, POST, JSON and XML. When an interface needs to be modified, it takes half a day to find out where the code is.

Forest can help me to decouple HTTP code from business code, and the request caller doesn't have to care about HTTP related details.

Automatically splice various parameters of HTTP

Parameters including URL, Header, Body, etc. can be declared by Java annotations.

Here's a chestnut from Gaode map to see how Forest gracefully declares the HTTP request interface:

/**
 * Gaode map service client interface
 */
@BaseRequest(baseURL = "http://ditu.amap.com")
public interface Amap {

    /**
     * Obtain detailed address according to latitude and longitude
     * @param longitude longitude
     * @param latitude latitude
     * @return Detailed address information
     */
    @Get("/service/regeo")
    Map getLocation(@Query("longitude") String longitude, @Query("latitude") String latitude);

}

... ...

Amap amp = Forest.client(Amap.class);
// Send request to query longitude and latitude
Map locationInfo = amp.getLocation("32.1242832", "56.3290434");

Automatic JSON and XML conversion

In fact, when dealing with HTTP, in addition to wasting time assembling various request parameters, we spend most of our time serializing and deserializing data in various formats, such as JSON and XML.

In the past, with HttpClient, these repetitive mechanical tasks had to be done by ourselves, which was very troublesome.

It's much more convenient to use Forest. For example, if you want to POST a JSON object, just hang @ JSONBody directly. It's so refreshing.

// Convert MyUserInfo directly to JSON
// Convert the JSON data returned by the server response into a result < Boolean > class object
@Post("http://localhost:8080/user")
Result<Booelean> createUser(@JSONBody MyUserInfo user);

Comparison with Retrofit and Feign

I have also used these two open source frameworks before. They are very powerful, but each has its own advantages and disadvantages.

The main problem with Retrofit is that it is too tied to OkHttp. Some functions are limited by OkHttp. For example, I want to process Get requests to transmit Body data, which is a non-standard HTTP request. Forest can switch between OkHttp and HttpClient as the back end at will, and use which one when needed.

The Retrofit annotation is not as rich as Forest. For example, to implement HTTP network proxy, you have to write your own code, and Forest provides @ HTTPProxy annotation, which is set up.

If you want to extend the user-defined annotations, they are all OkHttp based interceptors, which is not particularly convenient. However, the Forest interceptor is much more convenient than OkHttp. Providing oninvoke, beforeexecute, onscience, onError and other callback methods is equivalent to covering the life and death of a request.

Feign's problem is that it is too tightly tied to Spring. Many functions need to be done by Spring. It is too heavy with Spring related packages.

The core package of Forest basically covers all the functions and annotations required by HTTP. It does not rely on Spring and is much lighter without losing convenience.

For more information, please refer to: https://gitee.com/dromara/forest

LiteFlow

An ultra lightweight, fast, stable and choreographable component process engine / rule engine.

Decouple the artifact of complex systems! If you are having a headache designing a complex system, LiteFlow is your best choice. The ultra-low learning cost and powerful editing function make your system more elegant!

Official website: https://yomahub.com/liteflow

Gitee managed warehouse: https://gitee.com/dromara/liteFlow

Github managed warehouse: https://github.com/dromara/liteflow

Liteflow is born to decouple complex logic. If you want to write or reconstruct complex business logic, liteflow is the most appropriate. It is a lightweight and fast component-based process engine framework, which helps decouple business code and make each business segment a component.

Using Liteflow, you need to split the complex business logic into small components according to code fragments, and define a rule process configuration. In this way, all components can be configured according to your rules for complex flow. At the same time, Liteflow supports the hot loading of rule files to complete the modification and take effect immediately. It also provides the extension of a variety of persistence rules.

Using LiteFLow, the three core concepts are components, rules and context.

You need to define your components like this

//Here are common components
@LiteflowComponent(id = "a", name = "assembly A describe")
public class ACmp extends NodeComponent {
    @Override
    public void process() {
        //do your business
    }
}

//This is a conditional component
@LiteflowComponent(id = "b", name = "assembly B describe")
public class BCondCmp extends NodeCondComponent {
    @Override
    public String processCond() {
        //do your business
      	return "e";
    }
}

Then define your rules. LiteFlow supports three formats: xml, yml and json. Here, take xml as an example

<?xml version="1.0" encoding="UTF-8"?>
<flow>
    <chain name="chain1">
        <then value="a,b(c|d|e)"/> <!-- c Is a routing component used to route to c,d,e -->
        <then value="sub_chain"/> <!-- Subprocess -->
    </chain>
  
  	<chain name="sub_chain">
        <when value="f,g,h"/> <!-- when Representative parallelism -->
      	<then value="j,k" /> <!-- then Represents serial -->
    </chain>
</flow>

In this way, your system will execute your business components in the way defined in the rule file. Isn't it simple.

Where is the rule file defined? LiteFlow does not limit the source of your rule file. It can be a local file, a registry, or any database. LiteFlow provides a very free interface for you to expand. You can store it wherever you want. Change the rule file to refresh your rule process in real time! If you want to build a flexible and scalable system, is LiteFlow very suitable.

LiteFlow applies for a slot for each request. You can understand it as a context. All components share this slot. You can access slot in any component to obtain any data, or store any data. You can also extend the slot and customize the properties of the slot.

@LiteflowComponent(id = "a", name = "assembly A describe")
public class ACmp extends NodeComponent {
    @Override
    public void process() {
        Slot slot = this.getSlot();
      	//Through the getData, setData of the slot, or access your own extended slot attribute
    }
}

It is precisely because of the existence of Slot that the differences between components are erased, so that there is no strong dependency between each business component. This design can make your system highly free, component reuse and component exchange order can be easily realized!

LiteFlow also supports access to two scripting languages. At present, it supports Groovy and QLExpress. You can define scripts in xml/yml/json. Take xml as an example:

<?xml version="1.0" encoding="UTF-8"?>
<flow>
    <nodes>
        <node id="s1" name="Normal script" type="script">
            <![CDATA[
                def a=3;
                def b=2;
                slot.setData("s1",a*b);
            ]]>
        </node>

        <node id="s2" name="Conditional script" type="cond_script">
            <![CDATA[
                count = slot.getData("count");
                if(count > 100){
                    return "a";
                }else{
                    return "b";
                }
            ]]>
        </node>
    </nodes>

    <chain name="chain1">
        <then value="a,b,c,s1"/>
    </chain>

    <chain name="chain2">
        <then value="d,s2(a|b)"/>
    </chain>
</flow>

So where to define the script of which language? The script function of LiteFlow is an implementation of SPI mechanism. The script package you rely on is executed in the form of which script.

With the support of scripting language, can even business code be hot deployed? Does it smell good?

LiteFlow has more functions than these. For more information, please go to the official website documentation. I believe LiteFlow will make you feel elegant and amazing.

For more information, please refer to: https://yomahub.com/liteflow

JPom

A simple and light low intrusive online construction, automatic deployment, daily operation and maintenance and project monitoring software

The gospel of DevOps for small and medium-sized companies! Lightweight and powerful, don't you try?

Official website: https://jpom.io/

Gitee managed warehouse: https://gitee.com/dromara/Jpom

Github managed warehouse: https://github.com/dromara/Jpom

Jpom is a simple and light low intrusive online construction, automatic deployment, daily operation and maintenance and project monitoring software

In small and medium-sized companies or teams, the common method of traditional project deployment and operation and maintenance process is to log in to the server, upload new project packages, and execute corresponding command management. If multiple projects are managed, repeat the above steps.

There are many DevOps software on the market, but these software are basically difficult to use and rely on. Jpom is a lightweight DevOps software designed for small and medium-sized companies or teams with low intrusion and light dependence.

Main functions and features of the project

  1. Create, modify, delete project, Jar package management
  2. View console log, backup log, delete log and export log in real time
  3. Online build project release project one click
  4. Multi node management, multi node automatic distribution
  5. Online SSH terminal with terminal log and disable command
  6. Real time monitoring of project status and automatic alarm
  7. cpu, ram monitoring, export stack information, view project process port, server status monitoring
  8. Multi user management, independent user project permissions (upload and delete permissions can be controlled), and perfect operation log
  9. System path white list mode to prevent users from misoperating system files
  10. Manage Nginx configuration files and ssl certificate files online

One click installation (Linux) (recommended)

Plug in end

If the server side also needs to be managed, the plug-in side also needs to be installed on the server side

The installation path is located in the execution command directory (the data and log storage directory is located in the installation path by default. If you need to modify the reference configuration file: extConfig.yml )

yum install -y wget && wget -O install.sh https://dromara.gitee.io/jpom/docs/install.sh && bash install.sh Agent

Alternate address

yum install -y wget && wget -O install.sh https://cdn.jsdelivr.net/gh/dromara/Jpom/docs/install.sh && bash install.sh Agent

Support automatic installation jdk environment

yum install -y wget && wget -O install.sh https://dromara.gitee.io/jpom/docs/install.sh && bash install.sh Agent jdk

After successful startup, the port on the plug-in side is 2123

Server

The installation path is located in the execution command directory (the data and log storage directory is located in the installation path by default. If you need to modify the reference configuration file: extConfig.yml )

If you need to modify the data and log storage path, please refer to jpom.path configuration attribute in extConfig.yml file

yum install -y wget && wget -O install.sh https://dromara.gitee.io/jpom/docs/install.sh && bash install.sh Server

Alternate address

yum install -y wget && wget -O install.sh https://cdn.jsdelivr.net/gh/dromara/Jpom/docs/install.sh && bash install.sh Server


Support automatic installation jdk environment

yum install -y wget && wget -O install.sh https://dromara.gitee.io/jpom/docs/install.sh && bash install.sh Server jdk

Support automatic installation jdk and maven environment

yum install -y wget && wget -O install.sh https://dromara.gitee.io/jpom/docs/install.sh && bash install.sh Server jdk+mvn

After successful startup, the port of the server is 2122 to access the management page, such as http://localhost:2122/

Special reminder: during one click installation, pay attention that the execution commands cannot be in the same directory, that is, the Server side and the Agent side cannot be installed in the same directory

If it cannot be accessed, check whether the firewall systemctl status firewalld is enabled. If the status is green, Active: active (running) can temporarily close the firewall systemctl stop firewalld, and then restart the firewall CMD -- reload (it is recommended to use it only in the test environment and be cautious in the production environment)
If the firewall is still inaccessible after being closed and the ECS is used, you also need to close the firewall in the ECS management background

For more information, please refer to: https://gitee.com/dromara/Jpom

last

The above recommended open source projects are only four of the Dromara Java community. There are many better open source projects in Dromara community. Each project condenses the efforts and efforts of each author day and night. They embrace the world with an open mind and contribute to China's open source cause with the power of technology.

We try to shine, in order to illuminate others and to brighten ourselves.

At the same time, I also hope that more Java open source authors can join the Dromara community, unite our efforts, gather the achievements of all kings, overcome difficulties and overcome difficulties, and help each other in the same boat.

Finally, when I see the children's shoes here, I like them, share them, and watch them!

Tags: Java Open Source

Posted on Thu, 30 Sep 2021 18:41:23 -0400 by ngolehung84