当前位置:网站首页>The projects in this open source organization are boutiques

The projects in this open source organization are boutiques

2021-10-14 06:28:03 Platinum saidong

Preface

In open source China , I wonder if you have noticed one Java Open source organization ——Dromara?

This organization is made up of Apache ShenYu( Formerly known as Soul gateway ) The author of , Many bits Java Open source authors participate in a Java Open source organization .

In the open source Chinese community , quite a lot Java Open source authors are fighting their own battles , Independently operated projects .Domara Organizations were born to unite Java The power of open source , Build communities together , Resource sharing , Jointly promote China Java The development of open source .

at present Dromara The community has 9 individual GVP project , And some of the Star A high number of projects . These open source project communities are very active , Each is a high-quality open source work that can improve work efficiency . Let's take stock of Dromara Organize the 4 Open source projects . Are very practical tools , Making good use of these will greatly improve your productivity !

Sa-Token

The first thing I want to introduce is Sa-Token, Probably the most versatile lightweight in history Java Authorization framework .

Easy to use , Rich features , Powerful features , What reason do you have to refuse ?

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

Gitee Hosting warehouses :https://gitee.com/dromara/sa-token

Github Hosting warehouses :https://github.com/dromara/Sa-Token

Sa-Token It's a lightweight Java Authorization framework , Main solution : Login authentication Permission authentication Session conversation Single sign on OAuth2.0 Micro service gateway Authentication And so on .

Sa-Token Of API The design is very simple , How simple is it ? Take login authentication as an example , You only need to :

//  Write the account of the current session at login id
StpUtil.login(10001);

//  Then call the following method where the login needs to be verified :
//  If the current session is not logged in , This code will throw  `NotLoginException`  abnormal 
StpUtil.checkLogin();

thus , We have used Sa-Token Complete login authentication !

At this time, your little head may be full of question marks , It's that simple ? Customize Realm Well ? The global filter ? Don't I have to write all kinds of configuration files ?

you 're right , stay Sa-Token in , Login authentication is so simple , No complex front work is required , Just this line of simple API call , You can complete session login authentication !

When you're fed up with Shiro、SpringSecurity After the three bows and nine knocks of the frame , You will understand , Compared with these traditional frameworks ,Sa-Token Of API How simple the design is 、 grace !

Permission authentication example ( Only with user:add Only the session with permission can enter the request )

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

Kick an account offline ( When the other party visits the system again, it will throw NotLoginException abnormal )

//  Make account number id by  10001  Forced logoff login for session 
StpUtil.logoutByLoginId(10001);

stay Sa-Token in , Most functions are OK One line of code complete :

StpUtil.login(10001);                     //  Mark the current session login account id
StpUtil.getLoginId();                     //  Get the login account of the current session id
StpUtil.isLogin();                        //  Gets whether the current session is logged in ,  return true or false
StpUtil.logout();                         //  Log out of current session 
StpUtil.logoutByLoginId(10001);           //  Let the account number be 10001 Session log off ( Kick people off the line )
StpUtil.hasRole("super-admin");           //  Query whether the current account contains the specified role ID ,  return true or false
StpUtil.hasPermission("user:add");        //  Query whether the current account contains specified permissions ,  return true or false
StpUtil.getSession();                     //  Get the current account number id Of Session
StpUtil.getSessionByLoginId(10001);       //  Get account number id by 10001 Of Session
StpUtil.getTokenValueByLoginId(10001);    //  Get account number id by 10001 Of token Token value 
StpUtil.login(10001, "PC");               //  Specify device ID login , Commonly used in “ Peer exclusive login ”
StpUtil.logoutByLoginId(10001, "PC");     //  Specify the device ID to force logoff  ( Different ends are not affected )
StpUtil.openSafe(120);                    //  Enable Level 2 authentication in the current session , Valid for 120 second  
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 believe you can also realize the vast majority of API Usage of .

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

Forest

A great liberation of your Http The power of access work Http Client Framework .

Http Is the agreement complicated ? That's because you haven't used Forest, Although there are many other excellent in the industry Http client , But you missed Forest, Will miss a large area of elegant and beautiful forest .

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

Gitee Hosting warehouses :https://gitee.com/dromara/forest

Github Hosting warehouses :https://github.com/dromara/forest

Forest It's an open source Java HTTP Client Framework , Used to access third-party services RESTful Interface .

It will be able to HTTP The request parameters of are bound to Java On the interface , Then call Java The interface is sending HTTP request . Everything is interface oriented .

Many companies need to be in Java The background calls many third parties HTTP Interface , For example, wechat payment 、 Youmeng and other third-party platforms .

There are also many services within the company that are written in the best language in the world , Naturally, the interface can only pass through HTTP Interface to call . So over time , stay Java There are so many different kinds of HTTP Call interface , And the way of calling is not uniform , Yes HttpClient Written 、 Yes OkHttp Written 、 It has its own packaging , It's packed by different people in the company HTTP There are two or three kinds of tools .

and url Basically written in code , It's hard to maintain , Different interfaces have different transmission modes of parameters , Yes GET 、 Yes POST, Yes JSON Transmission of 、 Yes XML Transmission of . When an interface needs to be modified , Finished , It takes half a day to find out where the code is .

and Forest Can help me put HTTP Code and business code are decoupled , The request caller doesn't have to care HTTP Relevant details .

Automatic splicing HTTP All kinds of parameters

Include URL、Header、Body And so on Java Comment to declare .

Here's a chestnut of gaude map , Let's see Forest How elegant a statement HTTP Request interface's :

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

    /** *  Get the detailed address according to longitude and latitude  * @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 a request to query longitude and latitude 
Map locationInfo = amp.getLocation("32.1242832", "56.3290434");

Automatically JSON and XML transformation

Actually , We deal with HTTP At work , In addition to wasting time assembling various request parameters , Most of the time is spent serializing and deserializing data in various formats , Such as JSON and XML.

Previously used HttpClient, These repetitive mechanical tasks should be done by ourselves , It is trouble .

use Forest It's much more convenient , For example POST One JSON object , Just hang up @JSONBody Just fine , It's so refreshing .

//  Direct will  MyUserInfo  convert to  JSON
//  Return the response from the server  JSON  Data to  Result<Boolean>  Class object 
@Post("http://localhost:8080/user")
Result<Booelean> createUser(@JSONBody MyUserInfo user);

and Retrofit as well as Feign Comparison

I've used these two open source frameworks before , They're powerful , But each has its own advantages and disadvantages .

Retrofit The main problems are OkHttp Tied too dead , Some functions are OkHttp It's limited , For example, I want to deal with Get Request transmission Body The data is non-standard HTTP It's hard to ask , and Forest You can switch freely OkHttp and HttpClient As the back-end , Use what you need when you need it .

Retrofit Annotations are not as rich as Forest, For example, to achieve HTTP Network agents have to write their own code , and Forest Provides @HTTPProxy annotation , Set it up and it's done .

If you want to extend custom annotations, they are based on OkHttp Interceptor , It's not particularly convenient , and Forest Interceptors are better than OkHttp It's a lot more convenient , Provide onInvoke, beforeExecute, onSccuess, onError And so on , It is equivalent to covering the birth, age, illness and death of a request .

and Feign The problem is with Spring Tied too tight , Many functions need to depend on Spring To do , Too much Spring The package is too heavy .

Forest The core package basically covers all HTTP Required functions and annotations , Do not rely on Spring, It's much lighter , But without losing convenience .

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

LiteFlow

An ultra lightweight , Fast , Stable , Choreographable component-based process engine / Rules engine .

The artifact of decoupling complex systems ! If you're having a headache designing a complex system , that LiteFlow It's your only choice , Ultra low learning cost , Powerful layout function , Make your system more elegant !

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

Gitee Hosting warehouses :https://gitee.com/dromara/liteFlow

Github Hosting warehouses :https://github.com/dromara/liteflow

Liteflow Born to decouple complex logic , If you're going to rewrite or refactor complex business logic , use liteflow The best fit is . It's a light weight , Fast component process engine framework , Component choreography , Help decouple business code , Let every business segment be a component .

Use Liteflow, You need to break complex business logic into small components according to code fragments , And define a rule flow configuration . such , All the components , Can be configured according to your rules to carry out complex flow . meanwhile Liteflow Supports hot loading of rule files , Immediately complete the modification and take effect . And provide a variety of ways to extend persistence rules .

Use LiteFLow, The three core concepts are components , Rules and context .

You need to define your components like this

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

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

Then define your rules ,LiteFlow Support xml,yml,json Three formats , Here we use xml Form as an example

<?xml version="1.0" encoding="UTF-8"?>
<flow>
    <chain name="chain1">
        <then value="a,b(c|d|e)"/> <!-- c For routing components , Used to route to c,d,e -->
        <then value="sub_chain"/> <!--  Sub process  -->
    </chain>
  
  	<chain name="sub_chain">
        <when value="f,g,h"/> <!-- when On behalf of parallel  -->
      	<then value="j,k" /> <!-- then Represents serial  -->
    </chain>
</flow>

So your system will follow the way defined in the rule file , To execute your business components . Is it simple .

Where is the rule file defined ,LiteFlow It doesn't limit the source of your rule file , It can be a local file , It can be a registry , Can be any database .LiteFlow Provides a very free interface for you to expand , You can store it anywhere you want . Change rule file , You can refresh your rules and processes in real time ! If you want to be flexible , Scalable system ,LiteFlow Is it very suitable .

LiteFlow For every request to open up an application Slot, You can understand it as context , All components share this Slot. You can do this in any component Slot Access to arbitrary data , You can also store any data . You can also expand Slot, Customize this slot Properties of .

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

Because of it Slot The existence of , To smooth out the differences between components , So that there is no strong dependency between each business component . This design , You can make your system highly liberalized , Component reuse , The component exchange sequence can be easily realized !

LiteFlow And support 2 Access to a scripting language , At present, we support Groovy and QLExpress Two script languages . You can xml/yml/json Define scripts , The following xml For 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=" Condition 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 which language the script is ,LiteFlow The script function of is a SPI Implementation of mechanism , Which script package do you rely on , Just what kind of script to execute .

With the support of scripting language , Even business code can be hot deployed ? Fragrant but not fragrant ?

LiteFlow It does much more than that , Want to know more , Please check the documents on the official website . Believe in LiteFlow Will make you feel elegant and amazing .

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

JPom

A simple, lightweight, low intrusive online build 、 Automatic deployment 、 Daily Operation 、 Project monitoring software

SME team DevOps The Gospel of ! Lightweight and powerful , You don't try ?

Official website :https://jpom.io/

Gitee Hosting warehouses :https://gitee.com/dromara/Jpom

Github Hosting warehouses :https://github.com/dromara/Jpom

Jpom It's a simple, light, low intrusive online build 、 Automatic deployment 、 Daily Operation 、 Project monitoring software

stay Small and medium-sized companies or teams Traditional project deployment in 、 The general method of operation and maintenance process is to log in to the server and upload a new project package , Execute the corresponding command management , If you are managing multiple projects, repeat the above steps .

There are many on the market DevOps Software, but these software will be difficult to use , Heavy dependence .Jpom It's for Small and medium-sized companies or teams A design Low invasion , Light dependence A paragraph Lightweight Of DevOps Software .

Main functions and features of the project

  1. establish 、 modify 、 Delete the project 、Jar Package management
  2. View console logs in real time 、 Backup log 、 Delete log 、 Export log
  3. Online build project release project one click
  4. Multi node management 、 Multi node automatic distribution
  5. On-line SSH terminal , And there are terminal logs and disable commands
  6. Real time monitoring project status abnormal automatic alarm
  7. cpu、ram monitor 、 Export stack information 、 View project process port 、 Server status monitoring
  8. Multi user management , User project permissions are independent ( Upload 、 Delete permission can control ), Perfect operation log
  9. System path whitelist mode , Prevent users from operating system files by mistake
  10. Online management Nginx The configuration file 、ssl Certificate file

A key to install (Linux)( recommend )

Plug in side

If the server also needs to be managed , You also need to install plug-ins on the server

The installation path is located in the execute command directory ( data 、 The log storage directory is located in the installation path by default , If necessary, 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 Environmental Science 

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 side

The installation path is located in the execute command directory ( data 、 The log storage directory is located in the installation path by default , If necessary, modify the reference configuration file :extConfig.yml

If you need to modify the data 、 Please refer to... For log storage path extConfig.yml In file jpom.path Configuration properties

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 Environmental Science 

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 Environmental Science 

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 server port is 2122 Access management page for example http://localhost:2122/

Special reminder : When installing with one click, please note that the command cannot be executed in the same directory , namely Server End sum Agent The client cannot be installed in the same directory

If not accessible , Check whether the firewall is turned on systemctl status firewalld, If the status is displayed in green Active: active (running) The firewall can be temporarily closed systemctl stop firewalld, Then restart the firewall firewall-cmd --reload( It is recommended to use only in a test environment , Use with caution in the production environment ) If you still can't access after closing the firewall , And the cloud server is used , You also need to turn off 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 , just Dromara Java One of them in the community 4 individual ,Dromara There are many better open source projects in the community . Every project condenses the painstaking efforts and efforts of each author day and night , They embrace the world with an open mind , Use the power of technology to contribute to China's open source cause .

We try to shine , To illuminate others , Also for the sake of bright self .

At the same time, I also hope to have more Java Open source authors can join Dromara Community , Gather our strength , Gather your achievements , Break open a way through bramble and Thistle , In the same boat .

Last , See these children's shoes , give the thumbs-up , Share , It's interesting to see !

版权声明
本文为[Platinum saidong]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/10/20211002145418004a.html

随机推荐