The projects in this open source organization are all excellent

foreword

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

This organization was founded by the author of Apache ShenYu (formerly Soul Gateway), a Java open source organization participated by many Java open source authors.

In the open source Chinese community, many Java open source authors work independently and operate projects independently. The Domara organization was born to unite the power of Java open source, build a community, share resources, and jointly promote the development of Java open source in China.

At present, the 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 a look at the four open source projects in the Dromara organization. They are all very practical tools, and using them well will greatly improve your productivity!

Sa-Token

The first thing I want to introduce is Sa-Token, which is probably the most comprehensive lightweight Java authorization authentication framework in history.

Simple usage, rich features, and powerful functions, what reason do you have to refuse?

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

Gitee hosted repository: https://gitee.com/dromara/sa-token

Github hosted repository: https://github.com/dromara/Sa-Token

Sa-Token is a lightweight Java authority authentication framework, which mainly solves a series of authority-related problems such as: 登录认证, 权限认证, Session会话, 单点登录, OAuth2.0, 微服务网关鉴权etc.

The API design of Sa-Token is very simple. How simple is it? Taking login authentication as an example, you only need:

// 在登录时写入当前会话的账号id
StpUtil.login(10001);

// 然后在需要校验登录处调用以下方法:
// 如果当前会话未登录,这句代码会抛出 `NotLoginException` 异常
StpUtil.checkLogin();

So far, we have completed the login authentication with the help of Sa-Token!

At this time, your little head may be full of question marks, is it that simple? What about custom Realm? What about global filters? Don't I have to write various configuration files?

That's right, in Sa-Token, login authentication is so simple, no complex pre-work is required, just this simple API call can complete session login authentication!

When you are fed up with Shiro, SpringSecurity and other frameworks, you will understand how simple and elegant the API design of Sa-Token is compared to these traditional old frameworks!

Permission authentication example (only sessions with user:addpermissions can enter the request)

@SaCheckPermission("user:add")
@RequestMapping("/user/insert")
public String insert(SysUser user) {
	// ... 
	return "用户增加";
}

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

// 使账号id为 10001 的会话强制注销登录
StpUtil.logoutByLoginId(10001);

In Sa-Token, most functions can be completed with one line of code:

StpUtil.login(10001);                     // 标记当前会话登录的账号id
StpUtil.getLoginId();                     // 获取当前会话登录的账号id
StpUtil.isLogin();                        // 获取当前会话是否已经登录, 返回true或false
StpUtil.logout();                         // 当前会话注销登录
StpUtil.logoutByLoginId(10001);           // 让账号为10001的会话注销登录(踢人下线)
StpUtil.hasRole("super-admin");           // 查询当前账号是否含有指定角色标识, 返回true或false
StpUtil.hasPermission("user:add");        // 查询当前账号是否含有指定权限, 返回true或false
StpUtil.getSession();                     // 获取当前账号id的Session
StpUtil.getSessionByLoginId(10001);       // 获取账号id为10001的Session
StpUtil.getTokenValueByLoginId(10001);    // 获取账号id为10001的token令牌值
StpUtil.login(10001, "PC");               // 指定设备标识登录,常用于“同端互斥登录”
StpUtil.logoutByLoginId(10001, "PC");     // 指定设备标识进行强制注销 (不同端不受影响)
StpUtil.openSafe(120);                    // 在当前会话开启二级认证,有效期为120秒 
StpUtil.checkSafe();                      // 校验当前会话是否处于二级认证有效期内,校验失败会抛出异常 
StpUtil.switchTo(10044);                  // 将当前会话身份临时切换为其它账号 

Even if you don't run the tests, you can expect to get a sense of the vast majority of API usage.

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 complicated? That's because you haven't used Forest, although there are many other excellent Http clients in the industry, but if you miss Forest, you will miss a large elegant and beautiful forest.

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

Gitee hosted repository: https://gitee.com/dromara/forest

Github hosted repository: https://github.com/dromara/forest

Forest is an open source Java HTTP client framework for accessing third-party service RESTful interfaces.

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

Many companies need to call many third-party HTTP interfaces in the Java background, such as WeChat Pay, Umeng and other third-party platforms.

There are still many services in the company written in the world's best language, and the interface can only be called through the HTTP interface. So over time, there are many various HTTP calling interfaces in the Java code, and the calling methods are not uniform. Some are written by HttpClient, some are written by OkHttp, and some are packaged by themselves. It is only packaged by different people within the company. There are two or three types of HTTP tools.

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 transmission, and XML transmission. When there is an interface that needs to be modified, it will take half a day to find where the code is.

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

Automatically splicing various parameters of HTTP

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

Here is a chestnut of a high moral map to see how Forest elegantly declares the HTTP request interface:

/**
 * 高德地图服务客户端接口
 */
@BaseRequest(baseURL = "http://ditu.amap.com")
public interface Amap {

    /**
     * 根据经纬度获取详细地址
     * @param longitude 经度
     * @param latitude 纬度
     * @return 详细地址信息
     */
    @Get("/service/regeo")
    Map getLocation(@Query("longitude") String longitude, @Query("latitude") String latitude);

}

... ...

Amap amp = Forest.client(Amap.class);
// 发送请求查询经纬度
Map locationInfo = amp.getLocation("32.1242832", "56.3290434");

Automatic JSON and XML conversion

In fact, when we work with HTTP, in addition to wasting various request parameters, most of the time is spent serializing and deserializing data in various formats, such as JSON and XML.

Before using HttpClient, these repetitive mechanical tasks had to be done by myself, which was very troublesome.

It is much more convenient to use Forest. For example, to POST a JSON object, just hang @JSONBody directly, it is so refreshing.

// 直接将 MyUserInfo 转换成 JSON
// 将服务端响应返回的 JSON 数据转换成 Result<Boolean> 类对象
@Post("http://localhost:8080/user")
Result<Booelean> createUser(@JSONBody MyUserInfo user);

Comparison with Retrofit and Feign

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

The main problem of Retrofit is that it is too tied to OkHttp, and some functions are restricted by OkHttp. For example, it is difficult for me to process non-standard HTTP requests such as Get requests to transmit Body data, while Forest can switch between OkHttp and OkHttp at will. HttpClient is used as the backend, which one should be used when needed.

The richness of Retrofit annotations is not as good as that of Forest. For example, to implement HTTP network proxy, you need to write code yourself, while Forest provides @HTTPProxy annotation, and you are done after setting it up.

If you want to extend custom annotations, they are all based on OkHttp interceptors, which is not particularly convenient, while Forest interceptors are much more convenient than OkHttp, providing callback methods such as onInvoke, beforeExecute, onSccuess, onError, etc., which is equivalent to covering the life and death of a request. .

The problem with Feign is that it is too tightly tied to Spring, many functions need to be done by Spring, and too many Spring related packages are too heavy.

The core package of Forest basically covers all the functions and annotations required by HTTP. It does not depend on Spring. It is much lighter and more convenient.

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

LiteFlow

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

The artifact of decoupling complex systems! If you are having a headache designing a complex system, then LiteFlow is the best choice for you, with ultra-low learning costs and powerful orchestration functions, making your system more elegant!

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

Gitee hosted repository: https://gitee.com/dromara/liteFlow

Github hosted repository: https://github.com/dromara/liteflow

Liteflow was born to decouple complex logic. If you want to rewrite or refactor complex business logic, liteflow is the most suitable. It is a lightweight and fast component-based process engine framework, which orchestrates components to help decouple business code and make each business segment a component.

With Liteflow, you need to split complex business logic into small components by 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 hot loading of rule files, and the modification takes effect immediately. And provide a variety of ways to persist rules extensions.

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

You need to define your component like this

//这里普通组件
@LiteflowComponent(id = "a", name = "组件A描述")
public class ACmp extends NodeComponent {
    @Override
    public void process() {
        //do your business
    }
}

//这是条件组件
@LiteflowComponent(id = "b", name = "组件B描述")
public class BCondCmp extends NodeCondComponent {
    @Override
    public String processCond() {
        //do your business
      	return "e";
    }
}

Then go to define your rules, LiteFlow supports xml, yml, json three formats, here is an example of xml format

<?xml version="1.0" encoding="UTF-8"?>
<flow>
    <chain name="chain1">
        <then value="a,b(c|d|e)"/> <!-- c为路由组件,用来路由到c,d,e -->
        <then value="sub_chain"/> <!-- 子流程 -->
    </chain>
  
  	<chain name="sub_chain">
        <when value="f,g,h"/> <!-- when代表并行 -->
      	<then value="j,k" /> <!-- then代表串行 -->
    </chain>
</flow>

In this way, your system will execute your business components in the way defined by the rule file. Is not 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 extend, you can store it wherever you want. Change the rule file to refresh your rule flow in real time! If you want to make a highly flexible and scalable system, is LiteFlow very suitable?

LiteFlow develops and applies for a Slot for each request. You can understand it as a context, and all components share this Slot. You can obtain arbitrary data by accessing Slot in any component, and you can also store arbitrary data. You can also extend Slot to customize the properties of this slot.

@LiteflowComponent(id = "a", name = "组件A描述")
public class ACmp extends NodeComponent {
    @Override
    public void process() {
        Slot slot = this.getSlot();
      	//通过对slot的getData,setData,或者存取你自己扩展的slot属性
    }
}

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

LiteFlow also supports access to two scripting languages, currently Groovy and QLExpress are supported. You can define scripts in xml/yml/json, the following takes xml as an example:

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

        <node id="s2" name="条件脚本" 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 do you define which language script is used? The script function of LiteFlow is the implementation of an SPI mechanism. Which script package you rely on is executed in which script mode.

With the support of scripting languages, can even business code be hot-deployed? Is it fragrant?

The functions of LiteFlow are far more than these. If you want to know more, please go to the official website documentation to check and understand. Believe that LiteFlow will make you feel elegant and stunning.

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

JPom

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

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

Official website: https://jpom.io/

Gitee hosted repository: https://gitee.com/dromara/Jpom

Github hosted repository: https://github.com/dromara/Jpom

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

The 中小公司或者团队common method for traditional project deployment and operation and maintenance processes in China is to log in to the server to upload a new project package, execute corresponding command management, and repeat the above steps if managing multiple projects.

There are many DevOps software on the market, but these software are basically difficult to use and rely heavily on. Jpom is a DevOps software for 中小公司或者团队design .低侵入轻依赖轻量级

Main functions and features of the project

  1. Create, modify, delete projects, Jar package management
  2. View console logs, backup logs, delete logs, and export logs in real time
  3. Build a project online and publish a project with one click
  4. Multi-node management, multi-node automatic distribution
  5. Online SSH terminal with terminal logs and disable commands
  6. Real-time monitoring project status abnormal 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, delete permissions can be controlled), perfect operation log
  9. System path whitelist mode, to prevent users from mistakenly operating system files
  10. Online management of Nginx configuration files, ssl certificate files

One-click installation (Linux) (recommended)

Plug-in side

If the server also needs to be managed, the plugin also needs to be installed on the server

The installation path is located in the execution command directory (the data and log storage directories are 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

备用地址

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

支持自动安装jdk环境

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

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

Server

The installation path is located in the execution command directory (the data and log storage directories are 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 paths, please extConfig.ymlrefer to the jpom.pathconfiguration properties in the file

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

备用地址

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


支持自动安装jdk环境

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

支持自动安装jdk和maven环境

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

After the startup is successful, the port of the server is 2122Access management page such ashttp://localhost:2122/

Special reminder: When one-click installation, pay attention that the execution command cannot be in the same directory, that is, the server side and the agent side cannot be installed in the same directory

If you cannot access, check whether the firewall is turned on systemctl status firewalld. If the status is green, you Active: active (running)can temporarily turn off the firewall systemctl stop firewalld, and then restart the firewall firewall-cmd --reload(recommended to use only in the test environment, and use it with caution in the production environment). If you still cannot access after turning off the firewall, and use the Cloud server, you also need to turn off the firewall in the cloud server management background

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

finally

The open source projects recommended above are just 4 of them in the Dromara Java community, and there are many more excellent open source projects in the Dromara community. Every project embodies the hard work and dedication of every author day and night. They embrace the world with an open mind and use the power of technology to contribute to China's open source cause.

We strive to shine, in order to illuminate others, but also to brighten ourselves.

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

Finally, when you see this children's shoes, like it, share it, and watch it!

{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324146012&siteId=291194637