Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions api-boot-project/api-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,6 @@
<optional>true</optional>
</dependency>

<!--ApiBoot RateLimiter-->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>api-boot-plugin-rate-limiter</artifactId>
<optional>true</optional>
</dependency>

<!--Nacos Config-->
<dependency>
<groupId>com.alibaba.boot</groupId>
Expand Down Expand Up @@ -256,6 +249,11 @@
<artifactId>quartz</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<optional>true</optional>
</dependency>
<!--apiboot tools-->
<dependency>
<groupId>org.minbox.framework</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

package org.minbox.framework.api.boot.autoconfigure.ratelimiter;

import org.minbox.framework.api.boot.plugin.rate.limiter.ApiBootRateLimiter;
import org.minbox.framework.api.boot.plugin.rate.limiter.aop.advisor.ApiBootRateLimiterAdvisor;
import org.minbox.framework.api.boot.plugin.rate.limiter.aop.interceptor.ApiBootRateLimiterMethodInterceptor;
import org.minbox.framework.api.boot.plugin.rate.limiter.centre.RateLimiterConfigCentre;
import org.minbox.framework.api.boot.plugin.rate.limiter.centre.support.DefaultRateLimiterConfigCentre;
import org.minbox.framework.api.boot.plugin.rate.limiter.result.RateLimiterOverFlowResponse;
import org.minbox.framework.api.boot.plugin.rate.limiter.support.GoogleGuavaRateLimiter;
import org.minbox.framework.api.boot.limiter.ApiBootRateLimiter;
import org.minbox.framework.api.boot.limiter.aop.advisor.ApiBootRateLimiterAdvisor;
import org.minbox.framework.api.boot.limiter.aop.interceptor.ApiBootRateLimiterMethodInterceptor;
import org.minbox.framework.api.boot.limiter.centre.RateLimiterConfigCentre;
import org.minbox.framework.api.boot.limiter.centre.support.DefaultRateLimiterConfigCentre;
import org.minbox.framework.api.boot.limiter.result.RateLimiterOverFlowResponse;
import org.minbox.framework.api.boot.limiter.support.GoogleGuavaRateLimiter;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;
import org.minbox.framework.api.boot.plugin.rate.limiter.centre.RateLimiterConfigCentre;
import org.minbox.framework.api.boot.plugin.rate.limiter.centre.support.NacosRateLimiterConfigCentre;
import org.minbox.framework.api.boot.limiter.centre.RateLimiterConfigCentre;
import org.minbox.framework.api.boot.limiter.centre.support.NacosRateLimiterConfigCentre;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
*/

package org.minbox.framework.api.boot.autoconfigure.ratelimiter;

import org.minbox.framework.api.boot.plugin.rate.limiter.ApiBootRateLimiter;
import org.minbox.framework.api.boot.plugin.rate.limiter.centre.RateLimiterConfigCentre;
import org.minbox.framework.api.boot.plugin.rate.limiter.support.RedisLuaRateLimiter;
import org.minbox.framework.api.boot.limiter.ApiBootRateLimiter;
import org.minbox.framework.api.boot.limiter.centre.RateLimiterConfigCentre;
import org.minbox.framework.api.boot.limiter.support.RedisLuaRateLimiter;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand Down
5 changes: 0 additions & 5 deletions api-boot-project/api-boot-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,6 @@
</dependency>

<!--ApiBoot RateLimiter-->
<dependency>
<groupId>org.minbox.framework</groupId>
<artifactId>api-boot-plugin-rate-limiter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.minbox.framework</groupId>
<artifactId>api-boot-starter-rate-limiter</artifactId>
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion api-boot-project/api-boot-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<module>api-boot-plugin-security</module>
<module>api-boot-plugin-oauth</module>
<module>api-boot-plugin-resource-load</module>
<module>api-boot-plugin-rate-limiter</module>
<module>api-boot-plugin-sequence</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,17 @@
<groupId>org.minbox.framework</groupId>
<artifactId>api-boot-starter</artifactId>
</dependency>
<!--ApiBoot RateLimiter Plugin-->
<dependency>
<groupId>org.minbox.framework</groupId>
<artifactId>api-boot-plugin-rate-limiter</artifactId>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright [2019] [恒宇少年 - 于起宇]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.minbox.framework.api.boot.tools;

import org.springframework.core.BridgeMethodResolver;
import org.springframework.util.ClassUtils;

import java.lang.reflect.Method;

/**
* Aop Tools
*
* @author 恒宇少年
*/
public class AopTools {
/**
* get method declared annotation
*
* @param targetClass class instance
* @param method method instance
* @param annotationClass annotation class
* @param <T> annotation type
* @return annotation instance
*/
public static <T> T getMethodAnnotation(Class targetClass, Method method, Class annotationClass) {
Method specificMethod = ClassUtils.getMostSpecificMethod(method, targetClass);
// declared method object instance
Method declaredMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
return (T) declaredMethod.getDeclaredAnnotation(annotationClass);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright [2019] [恒宇少年 - 于起宇]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.minbox.framework.api.boot.tools;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.springframework.util.ObjectUtils;

/**
* json tools
*
* @author 恒宇少年
*/
public class JsonTools {
/**
* beautify object to json
*
* @param object object
* @return object json string
*/
public static String beautifyJson(Object object) {
if (ObjectUtils.isEmpty(object)) {
return null;
}
return JSON.toJSONString(object,
SerializerFeature.PrettyFormat,
SerializerFeature.SortField,
SerializerFeature.MapSortField
);
}

/**
* beautify string to json
*
* @param json json string
* @return after beautify json
*/
public static String beautifyJson(String json) {
if (ObjectUtils.isEmpty(json)) {
return json;
}
return JSON.toJSONString(
JSONObject.parse(json),
SerializerFeature.PrettyFormat
);
}
}
25 changes: 25 additions & 0 deletions api-boot-project/api-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<artifactId>api-boot-common</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.minbox.framework</groupId>
<artifactId>api-boot-tools</artifactId>
<optional>true</optional>
</dependency>

<!--Spring-->
<dependency>
Expand Down Expand Up @@ -50,6 +55,17 @@
<artifactId>spring-boot-starter-aop</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<optional>true</optional>
</dependency>


<!--Others-->
<dependency>
Expand Down Expand Up @@ -108,6 +124,15 @@
<artifactId>quartz</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>nacos-config-spring-boot-starter</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
*
*/

package org.minbox.framework.api.boot.plugin.rate.limiter;
package org.minbox.framework.api.boot.limiter;

/**
* Definition of current limiting interface
* <p>
* a unified method for defining current limiting needs
* <p>
* Basic Abstract implementation class
* {@link org.minbox.framework.api.boot.plugin.rate.limiter.support.AbstractRateLimiter}
* {@link org.minbox.framework.api.boot.limiter.support.AbstractRateLimiter}
* <p>
* Current restriction of token bucket mode of single application provided by Google
* {@link org.minbox.framework.api.boot.plugin.rate.limiter.support.GoogleGuavaRateLimiter}
* {@link org.minbox.framework.api.boot.limiter.support.GoogleGuavaRateLimiter}
* <p>
* Implementation of redis Lua script for microservices and distributed applications
* {@link org.minbox.framework.api.boot.plugin.rate.limiter.support.RedisLuaRateLimiter}
* {@link org.minbox.framework.api.boot.limiter.support.RedisLuaRateLimiter}
*
* @author 恒宇少年
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

package org.minbox.framework.api.boot.plugin.rate.limiter.annotation;
package org.minbox.framework.api.boot.limiter.annotation;

import java.lang.annotation.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
*
*/

package org.minbox.framework.api.boot.plugin.rate.limiter.aop.advisor;
package org.minbox.framework.api.boot.limiter.aop.advisor;

import org.aopalliance.aop.Advice;
import org.minbox.framework.api.boot.plugin.rate.limiter.annotation.RateLimiter;
import org.minbox.framework.api.boot.plugin.rate.limiter.aop.interceptor.ApiBootRateLimiterMethodInterceptor;
import org.minbox.framework.api.boot.limiter.annotation.RateLimiter;
import org.minbox.framework.api.boot.limiter.aop.interceptor.ApiBootRateLimiterMethodInterceptor;
import org.springframework.aop.Pointcut;
import org.springframework.aop.support.AbstractPointcutAdvisor;
import org.springframework.aop.support.ComposablePointcut;
Expand Down
Loading