├── .gitignore
├── LICENSE
├── example
├── feego-common-example-api-starter
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── lvyahui8
│ │ │ └── example
│ │ │ └── .gitignore
│ │ └── test
│ │ └── java
│ │ └── io
│ │ └── github
│ │ └── lvyahui8
│ │ └── example
│ │ └── .gitignore
├── feego-common-example-api
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── lvyahui8
│ │ │ └── example
│ │ │ └── api
│ │ │ ├── .gitignore
│ │ │ ├── dto
│ │ │ └── UserDTO.java
│ │ │ └── facade
│ │ │ └── UserQueryFacade.java
│ │ └── test
│ │ └── java
│ │ └── io
│ │ └── github
│ │ └── lvyahui8
│ │ └── example
│ │ └── .gitignore
├── feego-common-example-client
│ ├── pom.xml
│ ├── signature_test.http
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── lvyahui8
│ │ │ │ └── example
│ │ │ │ └── client
│ │ │ │ ├── ClientApplication.java
│ │ │ │ └── service
│ │ │ │ ├── OrderService.java
│ │ │ │ └── impl
│ │ │ │ └── OrderServiceImpl.java
│ │ └── resources
│ │ │ ├── application.properties
│ │ │ └── dubbo-consumer.properties
│ │ └── test
│ │ └── java
│ │ └── io
│ │ └── github
│ │ └── lvyahui8
│ │ └── example
│ │ └── .gitignore
├── feego-common-example-service
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ └── java
│ │ │ └── io
│ │ │ └── github
│ │ │ └── lvyahui8
│ │ │ └── example
│ │ │ ├── code
│ │ │ └── Code.java
│ │ │ ├── configuration
│ │ │ ├── BeanConfiguration.java
│ │ │ ├── CacheKey.java
│ │ │ ├── CustomLogHandler.java
│ │ │ ├── CustomLogger.java
│ │ │ ├── LoggingConfiguration.java
│ │ │ └── RuntimeSettings.java
│ │ │ ├── facade
│ │ │ └── impl
│ │ │ │ └── UserQueryFacadeImpl.java
│ │ │ ├── package-info.java
│ │ │ ├── reddot
│ │ │ └── AppRedDot.java
│ │ │ ├── service
│ │ │ ├── UserCacheObject.java
│ │ │ ├── UserService.java
│ │ │ └── impl
│ │ │ │ └── UserServiceImpl.java
│ │ │ └── task
│ │ │ └── UserProfileReloadTask.java
│ │ └── test
│ │ └── java
│ │ └── io
│ │ └── github
│ │ └── lvyahui8
│ │ └── AppTest.java
├── feego-common-example-start
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── lvyahui8
│ │ │ │ └── example
│ │ │ │ ├── ServerApplication.java
│ │ │ │ ├── configuration
│ │ │ │ ├── .gitignore
│ │ │ │ ├── CustomWebMvcConfigurer.java
│ │ │ │ └── HttpRequestLogContextFilter.java
│ │ │ │ └── resources
│ │ │ │ └── MainController.java
│ │ └── resources
│ │ │ ├── application.properties
│ │ │ ├── dubbo-provider.properties
│ │ │ └── strings
│ │ │ ├── homepage.json
│ │ │ └── member
│ │ │ └── account.json
│ │ └── test
│ │ ├── java
│ │ └── io
│ │ │ └── github
│ │ │ └── lvyahui8
│ │ │ └── example
│ │ │ ├── BasicTest.java
│ │ │ ├── DistributedLockTest.java
│ │ │ ├── MsgCodeTest.java
│ │ │ ├── NamedLockExecutorTest.java
│ │ │ ├── RedDotTest.java
│ │ │ ├── ResourceStringsTest.java
│ │ │ └── SystemLoggerTest.java
│ │ └── resources
│ │ └── .gitignore
└── keys
│ ├── sign_request_pri.key
│ ├── sign_response_pri.key
│ ├── verify_request_pub.key
│ └── verify_response_pub.key
├── feego-common-configuration-processor
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── io
│ │ │ └── github
│ │ │ └── lvyahui8
│ │ │ └── configuration
│ │ │ ├── annotations
│ │ │ ├── ModuleLoggerAutoGeneration.java
│ │ │ ├── ResourceStrings.java
│ │ │ ├── RuntimeConfiguration.java
│ │ │ └── Singleton.java
│ │ │ ├── processor
│ │ │ ├── ModuleLoggerProcessor.java
│ │ │ ├── ResourceStringsProcessor.java
│ │ │ ├── RuntimeConfigurationProcessor.java
│ │ │ └── SingletonProcessor.java
│ │ │ └── utils
│ │ │ └── BuildUtils.java
│ └── resources
│ │ └── META-INF
│ │ └── services
│ │ └── javax.annotation.processing.Processor
│ └── test
│ └── java
│ └── io
│ └── github
│ └── lvyahui8
│ └── configuration
│ └── .gitignore
├── feego-common-logging
├── feego-common-logging-autoconfigure
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── lvyahui8
│ │ │ │ └── sdk
│ │ │ │ └── logging
│ │ │ │ └── autoconfigure
│ │ │ │ ├── ModuleLoggerAutoConfiguration.java
│ │ │ │ └── ModuleLoggerProperties.java
│ │ └── resources
│ │ │ └── META-INF
│ │ │ └── spring.factories
│ │ └── test
│ │ ├── java
│ │ └── io
│ │ │ └── github
│ │ │ └── lvyahui8
│ │ │ └── sdk
│ │ │ └── logging
│ │ │ ├── .gitignore
│ │ │ ├── BaseTest.java
│ │ │ ├── LoggingTestCase.java
│ │ │ ├── TestApplication.java
│ │ │ └── TestLogger.java
│ │ └── resources
│ │ └── application.properties
├── feego-common-logging-starter
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── lvyahui8
│ │ │ │ └── sdk
│ │ │ │ └── logging
│ │ │ │ └── .gitignore
│ │ └── resources
│ │ │ └── META-INF
│ │ │ └── spring.provides
│ │ └── test
│ │ └── java
│ │ └── io
│ │ └── github
│ │ └── lvyahui8
│ │ └── sdk
│ │ └── logging
│ │ └── .gitignore
└── feego-common-logging
│ ├── pom.xml
│ └── src
│ ├── main
│ └── java
│ │ └── io
│ │ └── github
│ │ └── lvyahui8
│ │ └── sdk
│ │ └── logging
│ │ ├── configuration
│ │ ├── DefaultLogConfiguration.java
│ │ └── LogConstants.java
│ │ ├── context
│ │ ├── LogContext.java
│ │ └── LogContextHolder.java
│ │ ├── event
│ │ └── LogEvent.java
│ │ ├── factory
│ │ ├── AbstractLoggerFactory.java
│ │ ├── Log4j2ModuleLoggerFactory.java
│ │ ├── LogbackModuleLoggerFactory.java
│ │ └── ModuleLoggerFactory.java
│ │ ├── handler
│ │ ├── AbstractLogHandler.java
│ │ ├── DefaultLogHandler.java
│ │ └── LogHandler.java
│ │ └── logger
│ │ ├── DefaultModuleLogger.java
│ │ ├── EnumModuleLogger.java
│ │ ├── LogEventReactor.java
│ │ ├── LogSchema.java
│ │ ├── ModuleLogger.java
│ │ ├── ModuleLoggerRepository.java
│ │ └── RootLogger.java
│ └── test
│ └── java
│ └── io
│ └── github
│ └── lvyahui8
│ └── sdk
│ └── logging
│ ├── .gitignore
│ ├── RepeatModuleTestApplication.java
│ ├── TestApplication.java
│ ├── TestLogger.java
│ └── TestLogger2.java
├── feego-common-service
├── feego-common-service-starter
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── lvyahui8
│ │ │ │ └── sdk
│ │ │ │ ├── .gitignore
│ │ │ │ ├── autoconfigure
│ │ │ │ ├── CoreAutoConfiguration.java
│ │ │ │ ├── DistributeLockAutoConfiguration.java
│ │ │ │ └── GroupServiceAutoConfiguration.java
│ │ │ │ └── properties
│ │ │ │ ├── ExecutorProperties.java
│ │ │ │ └── ServiceProperties.java
│ │ └── resources
│ │ │ ├── META-INF
│ │ │ └── spring.factories
│ │ │ └── logback-spring.xml.backup
│ │ └── test
│ │ └── java
│ │ └── io
│ │ └── github
│ │ └── lvyahui8
│ │ └── sdk
│ │ └── .gitignore
└── feego-common-service
│ ├── pom.xml
│ └── src
│ ├── main
│ ├── java
│ │ └── io
│ │ │ └── github
│ │ │ └── lvyahui8
│ │ │ └── sdk
│ │ │ ├── .gitignore
│ │ │ ├── cache
│ │ │ └── AsyncRefreshableCacheObject.java
│ │ │ ├── constants
│ │ │ └── Constant.java
│ │ │ ├── guid
│ │ │ └── GUIDGenerator.java
│ │ │ ├── lock
│ │ │ ├── DistributedLock.java
│ │ │ ├── LockFactory.java
│ │ │ ├── NamedLockExecutor.java
│ │ │ ├── RedisDistributedLock.java
│ │ │ └── RedisLockFactory.java
│ │ │ ├── proxy
│ │ │ ├── DecisionMaker.java
│ │ │ ├── GroupService.java
│ │ │ └── GroupServiceProxy.java
│ │ │ ├── reddot
│ │ │ ├── DefaultRedDotManager.java
│ │ │ ├── RedDot.java
│ │ │ ├── RedDotInstance.java
│ │ │ └── RedDotManager.java
│ │ │ ├── security
│ │ │ └── CryptologySecurityUtils.java
│ │ │ ├── utils
│ │ │ ├── AsyncTaskExecutor.java
│ │ │ ├── AsyncTaskExecutorInitializer.java
│ │ │ ├── RetryUtils.java
│ │ │ └── SystemUtils.java
│ │ │ └── weak
│ │ │ ├── OnException.java
│ │ │ └── WeakDependencyGroup.java
│ └── resources
│ │ └── .gitignore
│ └── test
│ └── java
│ └── io
│ └── github
│ └── lvyahui8
│ ├── .gitignore
│ ├── sdk
│ └── guid
│ │ └── GUIDGeneratorTest.java
│ └── security
│ └── CryptologySecurityUtilsTest.java
├── feego-common-web
├── feego-common-web-starter
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ └── io
│ │ │ │ └── github
│ │ │ │ └── lvyahui8
│ │ │ │ └── web
│ │ │ │ ├── .gitignore
│ │ │ │ ├── autoconfigure
│ │ │ │ ├── WebAutoConfiguration.java
│ │ │ │ └── WebMvcBeanPostProcessor.java
│ │ │ │ └── properties
│ │ │ │ ├── SecurityProperties.java
│ │ │ │ └── WebProperties.java
│ │ └── resources
│ │ │ └── META-INF
│ │ │ └── spring.factories
│ │ └── test
│ │ └── java
│ │ └── io
│ │ └── github
│ │ └── lvyahui8
│ │ └── web
│ │ └── .gitignore
└── feego-common-web
│ ├── pom.xml
│ └── src
│ ├── main
│ └── java
│ │ └── io
│ │ └── github
│ │ └── lvyahui8
│ │ └── web
│ │ ├── .gitignore
│ │ ├── code
│ │ ├── C.java
│ │ ├── Code.java
│ │ ├── CodePrefix.java
│ │ ├── CodeRepository.java
│ │ └── MsgCode.java
│ │ ├── constant
│ │ └── WebConstant.java
│ │ ├── context
│ │ ├── RequestContext.java
│ │ └── RequestMessage.java
│ │ ├── request
│ │ └── SignedRequest.java
│ │ ├── response
│ │ ├── RestResponseFormatter.java
│ │ └── StandardResponse.java
│ │ ├── signature
│ │ ├── .gitignore
│ │ ├── SignatureService.java
│ │ ├── SignatureSettings.java
│ │ └── impl
│ │ │ └── SignatureServiceImpl.java
│ │ └── wrapper
│ │ ├── .gitignore
│ │ ├── ResettableHttpServletRequest.java
│ │ ├── SignatureFilter.java
│ │ ├── TeeHttpServletResponse.java
│ │ └── TraceFilter.java
│ └── test
│ └── java
│ └── io
│ └── github
│ └── lvyahui8
│ └── .gitignore
├── feego-common.jmx
├── pom.xml
├── readme.assets
├── guid.assets
│ ├── image-20201003000028945.png
│ └── image-20201004223800706.png
├── guid.md
├── image-20201013232937970.png
├── image-20201013233502251.png
├── lock.assets
│ └── image-20200321185855112.png
├── lock.md
├── logging.assets
│ ├── image-20200307233100343.png
│ └── image-20200307233522279.png
├── logging.md
└── signature.md
├── readme.md
├── release.bat
└── release.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | *.iml
3 | *.log
4 | target
5 | *.class
6 | *.zip
7 | *.tar.gz
8 | *.tgz
9 | *.versionsBackup
--------------------------------------------------------------------------------
/example/feego-common-example-api-starter/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | feego-common
7 | io.github.lvyahui8
8 | 1.2.2
9 | ../../pom.xml
10 |
11 | 4.0.0
12 |
13 | feego-common-example-api-starter
14 |
15 | feego-common-example-api-starter
16 |
17 |
18 | true
19 |
20 |
21 |
22 |
23 | junit
24 | junit
25 | test
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/example/feego-common-example-api-starter/src/main/java/io/github/lvyahui8/example/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lvyahui8/feego-common/1c77080c6641c7d49d9dc0aaa3cb2cac053a7fb3/example/feego-common-example-api-starter/src/main/java/io/github/lvyahui8/example/.gitignore
--------------------------------------------------------------------------------
/example/feego-common-example-api-starter/src/test/java/io/github/lvyahui8/example/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lvyahui8/feego-common/1c77080c6641c7d49d9dc0aaa3cb2cac053a7fb3/example/feego-common-example-api-starter/src/test/java/io/github/lvyahui8/example/.gitignore
--------------------------------------------------------------------------------
/example/feego-common-example-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | feego-common
7 | io.github.lvyahui8
8 | 1.2.2
9 | ../../pom.xml
10 |
11 | 4.0.0
12 |
13 | feego-common-example-api
14 |
15 | feego-common-example-api
16 |
17 |
18 | true
19 |
20 |
21 |
22 |
23 | junit
24 | junit
25 | test
26 |
27 |
28 |
29 | org.projectlombok
30 | lombok
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/example/feego-common-example-api/src/main/java/io/github/lvyahui8/example/api/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lvyahui8/feego-common/1c77080c6641c7d49d9dc0aaa3cb2cac053a7fb3/example/feego-common-example-api/src/main/java/io/github/lvyahui8/example/api/.gitignore
--------------------------------------------------------------------------------
/example/feego-common-example-api/src/main/java/io/github/lvyahui8/example/api/dto/UserDTO.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.api.dto;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
9 | * @since 2020/3/21 11:18
10 | */
11 | @Data
12 | public class UserDTO implements Serializable {
13 | private static final long serialVersionUID = 2386235266784577053L;
14 | Long id;
15 | String username;
16 | String email;
17 | }
18 |
--------------------------------------------------------------------------------
/example/feego-common-example-api/src/main/java/io/github/lvyahui8/example/api/facade/UserQueryFacade.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.api.facade;
2 |
3 | import io.github.lvyahui8.example.api.dto.UserDTO;
4 |
5 | /**
6 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
7 | * @since 2020/3/21 11:17
8 | */
9 | public interface UserQueryFacade {
10 | /**
11 | * 根据用户id查询用户信息
12 | * @param userId 用户id
13 | * @return 用户信息
14 | */
15 | UserDTO getUserById(Long userId);
16 | }
17 |
--------------------------------------------------------------------------------
/example/feego-common-example-api/src/test/java/io/github/lvyahui8/example/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lvyahui8/feego-common/1c77080c6641c7d49d9dc0aaa3cb2cac053a7fb3/example/feego-common-example-api/src/test/java/io/github/lvyahui8/example/.gitignore
--------------------------------------------------------------------------------
/example/feego-common-example-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | feego-common
7 | io.github.lvyahui8
8 | 1.2.2
9 | ../../pom.xml
10 |
11 | 4.0.0
12 |
13 | feego-common-example-client
14 |
15 | feego-common-example-client
16 |
17 |
18 | true
19 |
20 |
21 |
22 |
23 | junit
24 | junit
25 | test
26 |
27 |
28 |
29 | io.github.lvyahui8
30 | feego-common-service-starter
31 |
32 |
33 | org.springframework.data
34 | spring-data-redis
35 |
36 |
37 |
38 |
39 |
40 | org.apache.dubbo
41 | dubbo
42 |
43 |
44 |
45 | org.apache.dubbo
46 | dubbo-dependencies-zookeeper
47 | pom
48 |
49 |
50 | org.slf4j
51 | slf4j-log4j12
52 |
53 |
54 |
55 |
56 |
57 | io.github.lvyahui8
58 | feego-common-example-api
59 |
60 |
61 |
62 | org.apache.httpcomponents
63 | httpclient
64 |
65 |
66 |
67 | io.github.lvyahui8
68 | feego-common-configuration-processor
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/example/feego-common-example-client/signature_test.http:
--------------------------------------------------------------------------------
1 | POST /save HTTP/1.1
2 | Host: 127.0.0.1:8080
3 | X-Feego-Signature: signature=
4 | Content-Type: application/json
5 |
6 | {
7 | "username" : "feego"
8 | }
9 |
10 | ###
--------------------------------------------------------------------------------
/example/feego-common-example-client/src/main/java/io/github/lvyahui8/example/client/ClientApplication.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.client;
2 |
3 | import io.github.lvyahui8.configuration.annotations.ModuleLoggerAutoGeneration;
4 | import io.github.lvyahui8.sdk.security.CryptologySecurityUtils;
5 | import io.github.lvyahui8.example.client.service.OrderService;
6 | import io.netty.handler.codec.http.HttpHeaderNames;
7 | import io.netty.handler.codec.http.HttpHeaderValues;
8 | import lombok.extern.slf4j.Slf4j;
9 | import org.apache.commons.codec.binary.Base64;
10 | import org.apache.commons.io.IOUtils;
11 | import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
12 | import org.apache.http.HttpResponse;
13 | import org.apache.http.client.HttpClient;
14 | import org.apache.http.client.methods.HttpPost;
15 | import org.apache.http.entity.StringEntity;
16 | import org.apache.http.impl.client.HttpClientBuilder;
17 | import org.springframework.boot.SpringApplication;
18 | import org.springframework.boot.autoconfigure.SpringBootApplication;
19 | import org.springframework.context.ConfigurableApplicationContext;
20 | import org.springframework.context.annotation.PropertySource;
21 |
22 | import java.nio.charset.StandardCharsets;
23 |
24 | /**
25 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
26 | * @since 2020/3/21 11:15
27 | */
28 | @SpringBootApplication
29 | @EnableDubbo(scanBasePackages = "io.github.lvyahui8.example.client")
30 | @PropertySource("classpath:dubbo-consumer.properties")
31 | @ModuleLoggerAutoGeneration({"order"})
32 | @Slf4j
33 | public class ClientApplication {
34 | public static void main(String[] args) throws Exception {
35 | ConfigurableApplicationContext context = SpringApplication.run(ClientApplication.class, args);
36 | OrderService orderService = context.getBean(OrderService.class);
37 | orderService.createOrder(1L);
38 |
39 | String httpBody = "{\n" +
40 | " \"username\" : \"feego\"\n" +
41 | "}";
42 | String key = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBANMQDJAjncKfZ+Hw\nlNB2sW01AiSzuD77bnf3YF3Iy/J3+8a5mmm1u4fEDwlc9Vkm6doY1ExWoVt8e/eG\nxH7UgViGm2MC0RVcmwSQEf/YGl2iv+YXFgWhN/4LLrSbekFV2m9zPUAdifRMMo0v\nffDlG4xtdTngVhliA4i4zs/+I2ZBAgMBAAECgYEAuR5FdpLWhuIbUi8ZxvGj0t4A\nYEKFIjCTBoOhMQCx6JvV58nYpkjwDzcl3Rd8VdJsn47RfZcp9Tzs2gCJDZjDTFJj\nwWsIWIRE77YX1K3TezBDdFh1rc2zUIy0u3jvbkPJguZeKFYtff2ACrVTnGybfpbS\ns04e4WnjPJmgivmnazECQQD2moEgZjlaILQuURE59baY5TYqltZRRFvt+PrerJ5H\nzWUNbD//bcsTSbDEw1+s7g654InPZvvjkbHL3AWBsj79AkEA2xrcgDzkEWrxzdmg\n6qEeU3l/PcxKI66S7DEY74fdf8V1ZIQEHG1iyAAqfyADdXyofHqhABE4Bnub0mUn\nSAjBlQJAbnMrDIDchSKKsQf8KDKGUxquVQrz+LgeWIqgiiVUSyKSdR2b2GKrhvsF\nYkuDSafiDpyj/LHKddWmhYEJMlrMXQJBAMJ+1b4AT3Qmuv9AcNfWrlTrRUhWUHnc\nPg/shXYb5UPGxK61gfC6KTXg79hpUqi4P9hAAytMHa+jim753CTVoQECQQDD3myY\nEOdz7JGlfcXaavtPRQlfo5FRQI8iR82rpUZ6H0ZoXpw+n1F+4X720g2ah76eMB7B\nJbeETpR4PBckfjo1";
43 | Base64 base64 = new Base64();
44 | byte[] decodeKey = base64.decode(key);
45 | HttpClient httpClient = HttpClientBuilder.create().build();
46 | HttpPost httpPost = new HttpPost("http://127.0.0.1:8080/save");
47 | String headerKey = "X-Feego-Signature";
48 | httpPost.setHeader(HttpHeaderNames.CONTENT_TYPE.toString(), HttpHeaderValues.APPLICATION_JSON.toString());
49 | httpPost.setHeader(headerKey, "signature=" + base64.encodeAsString(CryptologySecurityUtils.sign(('.' + httpBody).getBytes(),decodeKey,"SHA1withRSA")));
50 | httpPost.setEntity(new StringEntity(httpBody));
51 | for (int i = 0; i < 100; i++) {
52 | HttpResponse response = httpClient.execute(httpPost);
53 | log.info("status:{}",response.getStatusLine());
54 | log.info("sign header:{}",response.getFirstHeader(headerKey).getValue());
55 | log.info(IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8));
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/example/feego-common-example-client/src/main/java/io/github/lvyahui8/example/client/service/OrderService.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.client.service;
2 |
3 | /**
4 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
5 | * @since 2020/3/21 12:31
6 | */
7 | public interface OrderService {
8 | /**
9 | * 创建订单
10 | * @param buyerId 买家id
11 | */
12 | void createOrder(Long buyerId);
13 | }
14 |
--------------------------------------------------------------------------------
/example/feego-common-example-client/src/main/java/io/github/lvyahui8/example/client/service/impl/OrderServiceImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.client.service.impl;
2 |
3 | import feego.common.io.github.lvyahui8.example.client.SystemLogger;
4 | import io.github.lvyahui8.example.api.dto.UserDTO;
5 | import io.github.lvyahui8.example.api.facade.UserQueryFacade;
6 | import io.github.lvyahui8.example.client.service.OrderService;
7 | import org.apache.dubbo.config.annotation.Reference;
8 | import org.springframework.stereotype.Service;
9 |
10 | /**
11 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
12 | * @since 2020/3/21 12:32
13 | */
14 | @Service
15 | public class OrderServiceImpl implements OrderService {
16 |
17 | @Reference
18 | private UserQueryFacade userQueryFacade;
19 |
20 | @Override
21 | public void createOrder(Long buyerId) {
22 | UserDTO user = userQueryFacade.getUserById(buyerId);
23 | SystemLogger.order.info("create order for user: {}",user);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/example/feego-common-example-client/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.main.allow-bean-definition-overriding=true
--------------------------------------------------------------------------------
/example/feego-common-example-client/src/main/resources/dubbo-consumer.properties:
--------------------------------------------------------------------------------
1 | dubbo.application.name=annotation-consumer
2 | dubbo.registry.address=zookeeper://127.0.0.1:2181?timeout=60000
3 | dubbo.consumer.timeout=3000
--------------------------------------------------------------------------------
/example/feego-common-example-client/src/test/java/io/github/lvyahui8/example/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lvyahui8/feego-common/1c77080c6641c7d49d9dc0aaa3cb2cac053a7fb3/example/feego-common-example-client/src/test/java/io/github/lvyahui8/example/.gitignore
--------------------------------------------------------------------------------
/example/feego-common-example-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | feego-common
7 | io.github.lvyahui8
8 | 1.2.2
9 | ../../pom.xml
10 |
11 | 4.0.0
12 |
13 | feego-common-example-service
14 |
15 | feego-common-example-service
16 |
17 |
18 | true
19 |
20 |
21 |
22 |
23 | junit
24 | junit
25 | test
26 |
27 |
28 |
29 | io.github.lvyahui8
30 | feego-common-web-starter
31 |
32 |
33 |
34 | org.springframework.boot
35 | spring-boot-starter
36 |
37 |
38 |
39 | org.springframework.boot
40 | spring-boot-starter-data-redis
41 |
42 |
43 |
44 | io.github.lvyahui8
45 | feego-common-example-api
46 |
47 |
48 |
49 | org.apache.dubbo
50 | dubbo
51 |
52 |
53 |
54 | org.apache.dubbo
55 | dubbo-dependencies-zookeeper
56 | pom
57 |
58 |
59 | org.slf4j
60 | slf4j-log4j12
61 |
62 |
63 |
64 |
65 |
66 | io.github.lvyahui8
67 | feego-common-configuration-processor
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/code/Code.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.code;
2 |
3 | import io.github.lvyahui8.web.code.C;
4 | import io.github.lvyahui8.web.code.CodePrefix;
5 | import io.github.lvyahui8.web.code.MsgCode;
6 |
7 | /**
8 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
9 | * @since 2020/3/18 21:42
10 | */
11 | public interface Code {
12 | enum General implements MsgCode {
13 | /**
14 | * 成功
15 | */
16 | @C(0) success,
17 | @C(value = -1,msg = "unknown exception") unknown,
18 | ;
19 | }
20 |
21 | @CodePrefix("4")
22 | enum Client implements MsgCode {
23 | /**
24 | * 客户端相关错误
25 | */
26 | no_permit,
27 | @C(301) no_login_session,
28 | ;
29 | }
30 |
31 | @CodePrefix("5")
32 | enum Component implements MsgCode {
33 |
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/configuration/BeanConfiguration.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.configuration;
2 |
3 | import io.github.lvyahui8.configuration.annotations.ModuleLoggerAutoGeneration;
4 | import io.github.lvyahui8.example.service.UserService;
5 | import io.github.lvyahui8.example.service.impl.UserServiceImpl;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 |
9 | /**
10 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
11 | * @since 2020/2/22 10:44
12 | */
13 | @Configuration
14 | @ModuleLoggerAutoGeneration({"member","rebate","item"})
15 | public class BeanConfiguration {
16 | @Bean
17 | public UserService userService() {
18 | return new UserServiceImpl();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/configuration/CacheKey.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.configuration;
2 |
3 | /**
4 | * @author feego lvyahui8@gmail.com
5 | * @date 2021/1/20
6 | */
7 | public enum CacheKey {
8 | user_profile("up"),
9 | ;
10 |
11 | String key;
12 |
13 | CacheKey(String key) {
14 | this.key = key;
15 | }
16 |
17 | public String getKey() {
18 | return key;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/configuration/CustomLogHandler.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.configuration;
2 |
3 | import io.github.lvyahui8.sdk.logging.handler.AbstractLogHandler;
4 | import io.github.lvyahui8.sdk.logging.handler.DefaultLogHandler;
5 | import io.github.lvyahui8.sdk.logging.logger.LogSchema;
6 | import io.github.lvyahui8.web.context.RequestContext;
7 | import org.slf4j.event.Level;
8 |
9 | import java.util.HashMap;
10 | import java.util.Map;
11 |
12 | /**
13 | * @author feego lvyahui8@gmail.com
14 | * @date 2020/10/10
15 | */
16 | public class CustomLogHandler extends DefaultLogHandler {
17 |
18 | /**
19 | * 可以结合一些运行时配置系统,使得level运行时可以动态调整
20 | */
21 | public static final Map levelMap = new HashMap<>();
22 | static {
23 | levelMap.put(CustomLogger.uc,Level.ERROR);
24 | }
25 |
26 | @Override
27 | public Level innerRuntimeLevel(String enumLoggerName) {
28 | CustomLogger customLogger = null;
29 | try {
30 | customLogger = CustomLogger.valueOf(enumLoggerName);
31 | } catch (Exception ignored) {}
32 | if (customLogger != null) {
33 | return levelMap.containsKey(customLogger) ?
34 | levelMap.get(customLogger) : super.runtimeLevel(enumLoggerName);
35 | }
36 | return super.innerRuntimeLevel(enumLoggerName);
37 | }
38 |
39 | @Override
40 | public LogSchema innerBeforeOutput(LogSchema logSchema) {
41 | logSchema.prepend("tid",Thread.currentThread().getId())
42 | .prepend("rid", RequestContext.getTraceId());
43 | return super.innerBeforeOutput(logSchema);
44 | }
45 |
46 | @Override
47 | public LogSchema monitor(LogSchema logSchema) {
48 | logSchema.of("user_id","lyh");
49 | return super.monitor(logSchema);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/configuration/CustomLogger.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.configuration;
2 |
3 | import io.github.lvyahui8.sdk.logging.logger.EnumModuleLogger;
4 | import io.github.lvyahui8.sdk.logging.logger.ModuleLogger;
5 |
6 | /**
7 | * @author feego lvyahui8@gmail.com
8 | * @date 2020/9/23
9 | */
10 | public enum CustomLogger implements EnumModuleLogger {
11 | uc,
12 | ;
13 | }
14 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/configuration/LoggingConfiguration.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.configuration;
2 |
3 | import io.github.lvyahui8.configuration.annotations.ModuleLoggerAutoGeneration;
4 | import org.springframework.context.annotation.Configuration;
5 |
6 | /**
7 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
8 | * @since 2020/2/22 10:58
9 | */
10 | @Configuration
11 | @ModuleLoggerAutoGeneration({"promotion"})
12 | public class LoggingConfiguration {
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/configuration/RuntimeSettings.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.configuration;
2 |
3 | import io.github.lvyahui8.configuration.annotations.RuntimeConfiguration;
4 | import io.github.lvyahui8.example.api.dto.UserDTO;
5 | import lombok.Data;
6 |
7 | /**
8 | * @author yahui.lv lvyahui8@gmail.com
9 | * @date 2020/4/8 21:05
10 | */
11 | @RuntimeConfiguration
12 | @Data
13 | public class RuntimeSettings {
14 | String homepageUrl = "https://www.cnblogs.com/lvyahui";
15 | Boolean entrySwitch = false;
16 | boolean open;
17 | UserDTO commonUserDTO = new UserDTO();
18 | }
19 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/facade/impl/UserQueryFacadeImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.facade.impl;
2 |
3 | import io.github.lvyahui8.example.api.dto.UserDTO;
4 | import io.github.lvyahui8.example.api.facade.UserQueryFacade;
5 | import io.github.lvyahui8.example.service.UserCacheObject;
6 | import org.apache.dubbo.config.annotation.Service;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 |
9 | /**
10 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
11 | * @since 2020/3/21 11:21
12 | */
13 | @Service
14 | public class UserQueryFacadeImpl implements UserQueryFacade {
15 |
16 | UserCacheObject userCacheObject;
17 |
18 | public void setUserCacheObject(UserCacheObject userCacheObject) {
19 | this.userCacheObject = userCacheObject;
20 | }
21 |
22 | @Override
23 | public UserDTO getUserById(Long userId) {
24 | return userCacheObject.get(userId);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/package-info.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lvyahui8/feego-common/1c77080c6641c7d49d9dc0aaa3cb2cac053a7fb3/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/package-info.java
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/reddot/AppRedDot.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.reddot;
2 |
3 | import io.github.lvyahui8.sdk.reddot.RedDot;
4 |
5 | import java.util.LinkedList;
6 | import java.util.List;
7 |
8 | /**
9 | * @author feego lvyahui8@gmail.com
10 | * @date 2021/1/22
11 | */
12 | @SuppressWarnings({"unused"})
13 | public enum AppRedDot implements RedDot {
14 | root(null),
15 | hp(root),
16 | channels(hp),
17 | my_account(root),
18 | profile(my_account),
19 | asset(profile),
20 | ;
21 |
22 | AppRedDot parent;
23 |
24 | List children = new LinkedList<>();
25 |
26 | AppRedDot(AppRedDot parent) {
27 | this.parent = parent;
28 | if (parent != null) {
29 | parent.children.add(this);
30 | }
31 | }
32 |
33 | @Override
34 | public String id() {
35 | return name();
36 | }
37 |
38 | @Override
39 | public RedDot parent() {
40 | return parent;
41 | }
42 |
43 | @Override
44 | public boolean isLeaf() {
45 | return children.isEmpty();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/service/UserCacheObject.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.service;
2 |
3 | import io.github.lvyahui8.example.api.dto.UserDTO;
4 | import io.github.lvyahui8.example.configuration.CacheKey;
5 | import io.github.lvyahui8.sdk.cache.AsyncRefreshableCacheObject;
6 | import org.springframework.data.redis.core.StringRedisTemplate;
7 | import org.springframework.stereotype.Component;
8 |
9 | /**
10 | * @author feego lvyahui8@gmail.com
11 | * @date 2021/1/20
12 | */
13 | @Component
14 | public class UserCacheObject extends AsyncRefreshableCacheObject {
15 |
16 | final UserService userService;
17 |
18 | public UserCacheObject(StringRedisTemplate redisTemplate, UserService userService) {
19 | super(redisTemplate);
20 | this.userService = userService;
21 | }
22 |
23 | @Override
24 | protected UserDTO syncLoad(Long userId) {
25 | return userService.getUser(userId);
26 | }
27 |
28 | @Override
29 | protected boolean preventBreakdown() {
30 | return true;
31 | }
32 |
33 | @Override
34 | protected String getRedisKey(Long userId) {
35 | return CacheKey.user_profile.getKey() + userId;
36 | }
37 |
38 | @Override
39 | protected int getLogicTimeoutSecond() {
40 | return 1;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/service/UserService.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.service;
2 |
3 |
4 | import io.github.lvyahui8.example.api.dto.UserDTO;
5 |
6 | /**
7 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
8 | * @since 2020/2/22 10:43
9 | */
10 | public interface UserService {
11 | UserDTO getUser(Long id) ;
12 | }
13 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/service/impl/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.service.impl;
2 |
3 | import io.github.lvyahui8.example.api.dto.UserDTO;
4 | import io.github.lvyahui8.example.service.UserService;
5 |
6 | /**
7 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
8 | * @since 2020/2/22 10:43
9 | */
10 | public class UserServiceImpl implements UserService {
11 | @Override
12 | public UserDTO getUser(Long id) {
13 | UserDTO userDTO = new UserDTO();
14 | userDTO.setEmail("lvyahui8@gmai.com");
15 | userDTO.setUsername("feego" + System.currentTimeMillis());
16 | userDTO.setId(id);
17 | try {
18 | Thread.sleep(1000L);
19 | } catch (InterruptedException ignored) { }
20 | return userDTO;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/main/java/io/github/lvyahui8/example/task/UserProfileReloadTask.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.task;
2 |
3 | import io.github.lvyahui8.example.api.dto.UserDTO;
4 | import io.github.lvyahui8.example.service.UserCacheObject;
5 | import lombok.RequiredArgsConstructor;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.scheduling.annotation.Scheduled;
8 | import org.springframework.stereotype.Component;
9 |
10 | /**
11 | * @author feego lvyahui8@gmail.com
12 | * @date 2021/1/21
13 | */
14 | @Component
15 | @RequiredArgsConstructor(onConstructor = @__({@Autowired}))
16 | public class UserProfileReloadTask {
17 |
18 | final UserCacheObject userCacheObject;
19 |
20 | boolean loaded = false;
21 |
22 | @Scheduled(cron = "*/5 * * * * ?")
23 | public void reload() {
24 | if (! loaded) {
25 | for (long i = 0; i < 10; i++) {
26 | userCacheObject.load(i);
27 | }
28 | loaded = true;
29 | }
30 |
31 | for (long i = 0; i < 10; i++) {
32 | long begin = System.currentTimeMillis();
33 | UserDTO userDTO = userCacheObject.get(i);
34 | System.out.println(userDTO + ". cost:" + (System.currentTimeMillis() - begin) );
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/example/feego-common-example-service/src/test/java/io/github/lvyahui8/AppTest.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8;
2 |
3 | import static org.junit.Assert.assertTrue;
4 |
5 | import org.junit.Test;
6 |
7 | /**
8 | * Unit test for simple App.
9 | */
10 | public class AppTest
11 | {
12 | /**
13 | * Rigorous Test :-)
14 | */
15 | @Test
16 | public void shouldAnswerWithTrue()
17 | {
18 | assertTrue( true );
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/example/feego-common-example-start/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | feego-common
7 | io.github.lvyahui8
8 | 1.2.2
9 | ../../pom.xml
10 |
11 | 4.0.0
12 |
13 | feego-common-example-start
14 |
15 | feego-common-example-start
16 |
17 |
18 | true
19 | true
20 |
21 |
22 |
23 |
24 | junit
25 | junit
26 | test
27 |
28 |
29 | io.github.lvyahui8
30 | feego-common-example-service
31 |
32 |
33 | org.springframework.boot
34 | spring-boot-starter-test
35 | test
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/example/feego-common-example-start/src/main/java/io/github/lvyahui8/example/ServerApplication.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example;
2 |
3 | import io.github.lvyahui8.configuration.annotations.ModuleLoggerAutoGeneration;
4 | import io.github.lvyahui8.configuration.annotations.ResourceStrings;
5 | import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
6 | import org.springframework.boot.SpringApplication;
7 | import org.springframework.boot.autoconfigure.SpringBootApplication;
8 | import org.springframework.context.annotation.PropertySource;
9 | import org.springframework.scheduling.annotation.EnableScheduling;
10 |
11 | /**
12 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
13 | * @since 2020/2/16 22:08
14 | */
15 | @SpringBootApplication
16 | @ModuleLoggerAutoGeneration({"campaign","status"})
17 | @EnableScheduling
18 | @EnableDubbo(scanBasePackages = "io.github.lvyahui8.example")
19 | @PropertySource("classpath:dubbo-provider.properties")
20 | @ResourceStrings("strings/")
21 | public class ServerApplication {
22 | public static void main(String[] args) throws Exception {
23 | SpringApplication.run(ServerApplication.class,args);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/example/feego-common-example-start/src/main/java/io/github/lvyahui8/example/configuration/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lvyahui8/feego-common/1c77080c6641c7d49d9dc0aaa3cb2cac053a7fb3/example/feego-common-example-start/src/main/java/io/github/lvyahui8/example/configuration/.gitignore
--------------------------------------------------------------------------------
/example/feego-common-example-start/src/main/java/io/github/lvyahui8/example/configuration/CustomWebMvcConfigurer.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.configuration;
2 |
3 |
4 | import org.springframework.boot.web.servlet.FilterRegistrationBean;
5 | import org.springframework.context.annotation.Bean;
6 | import org.springframework.context.annotation.Configuration;
7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
8 |
9 | /**
10 | * @author feego lvyahui8@gmail.com
11 | * @date 2021/5/15
12 | */
13 | @Configuration
14 | public class CustomWebMvcConfigurer implements WebMvcConfigurer {
15 | @Bean
16 | public FilterRegistrationBean httpRequestLogContextFilter() {
17 | FilterRegistrationBean registrationBean = new FilterRegistrationBean<>();
18 | registrationBean.setFilter(new HttpRequestLogContextFilter());
19 | registrationBean.setName("httpRequestLogContextFilter");
20 | registrationBean.addUrlPatterns("/*");
21 | return registrationBean;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/feego-common-example-start/src/main/java/io/github/lvyahui8/example/configuration/HttpRequestLogContextFilter.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.configuration;
2 |
3 |
4 | import io.github.lvyahui8.sdk.logging.context.LogContextHolder;
5 | import io.github.lvyahui8.sdk.logging.logger.LogEventReactor;
6 |
7 | import javax.servlet.*;
8 | import java.io.IOException;
9 |
10 | /**
11 | * @author feego lvyahui8@gmail.com
12 | * @date 2021/5/15
13 | */
14 | public class HttpRequestLogContextFilter implements Filter {
15 |
16 | @Override
17 | public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
18 | try {
19 | LogContextHolder.initDiscardedEventQueue(null);
20 | chain.doFilter(request,response);
21 | } finally {
22 | LogEventReactor.replayDiscardedEventsIfHasError();
23 | LogContextHolder.resetLogContext();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/example/feego-common-example-start/src/main/java/io/github/lvyahui8/example/resources/MainController.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example.resources;
2 |
3 | import feego.common.io.github.lvyahui8.example.SystemLogger;
4 | import io.github.lvyahui8.example.api.dto.UserDTO;
5 | import io.github.lvyahui8.sdk.lock.DistributedLock;
6 | import io.github.lvyahui8.sdk.lock.LockFactory;
7 | import io.github.lvyahui8.sdk.logging.logger.LogSchema;
8 | import lombok.extern.slf4j.Slf4j;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.data.redis.core.StringRedisTemplate;
11 | import org.springframework.web.bind.annotation.*;
12 |
13 | import java.util.UUID;
14 |
15 | /**
16 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
17 | * @since 2020/2/16 22:04
18 | */
19 | @RequestMapping("/")
20 | @RestController
21 | @Slf4j
22 | public class MainController {
23 | private static int n = 0 ;
24 |
25 | @Autowired
26 | LockFactory lockFactory;
27 |
28 | @Autowired
29 | StringRedisTemplate redisTemplate;
30 |
31 |
32 | @RequestMapping("/update")
33 | public Object update() {
34 | DistributedLock lock = lockFactory.newDistributeLock("feego:common:update.key", UUID.randomUUID().toString());
35 | boolean locked = false;
36 | try {
37 | if (locked = lock.tryLock()) {
38 | SystemLogger.campaign.info("Got the lock");
39 | return n++;
40 | } else {
41 | SystemLogger.campaign.warn("Didn't get the lock");
42 | return 0;
43 | }
44 | } finally {
45 | if (locked) {
46 | lock.unlock();
47 | }
48 | }
49 | }
50 |
51 | @RequestMapping("/status")
52 | public Object status() {
53 | SystemLogger.status.info(LogSchema.empty().of("status","ok"));
54 | SystemLogger.status.trace("trace log example");
55 | SystemLogger.status.debug("debug log example");
56 | SystemLogger.status.warn("warn log example");
57 | SystemLogger.status.error("error log example");
58 | // 出现error级别的日志, 之前的内容会被回朔
59 | for (int i = 0; i < 20; i++) {
60 | SystemLogger.status.trace("trace after error");
61 | }
62 | return "ok";
63 | }
64 |
65 | @PostMapping("/save")
66 | public Object save(@RequestBody UserDTO userDTO) {
67 | log.info(userDTO.toString());
68 | return "success";
69 | }
70 |
71 | @GetMapping("/query")
72 | public Object query() {
73 | /// log.info("query");
74 | return redisTemplate.opsForValue().get("main");
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/example/feego-common-example-start/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=80
2 | spring.mvc.favicon.enabled=true
3 |
4 | feego.common.logging.module-logger-enums=io.github.lvyahui8.example.configuration.CustomLogger
5 | feego.common.logging.log-handler=io.github.lvyahui8.example.configuration.CustomLogHandler
6 | feego.common.logging.storage-path=logs/
7 |
8 | feego.common.web.format-response=false
9 | feego.common.web.security.signature.default-verify-request-public-key=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDTEAyQI53Cn2fh8JTQdrFtNQIk\ns7g++25392BdyMvyd/vGuZpptbuHxA8JXPVZJunaGNRMVqFbfHv3hsR+1IFYhptj\nAtEVXJsEkBH/2Bpdor/mFxYFoTf+Cy60m3pBVdpvcz1AHYn0TDKNL33w5RuMbXU5\n4FYZYgOIuM7P/iNmQQIDAQAB\n
10 | feego.common.web.security.signature.default-sign-response-private-key=MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAKTz6YhUNP7kGNAa\nFEJ1fymu/J6ddwVU6D8IkWvJq78DHemh3Pg4SvDdxGUSunV1m3CMnoJKU2QoqOcO\njnlQa4CYIL5/f3a8LFBaytcmPTJ+4YPug1Aki6xxd0O5pPtcZDTvz8FJIwdpFEz1\ng9LTSEHOSaruSYWpKs5mMzXXKDrfAgMBAAECgYEAmlitHWaFzDeMzDSK3oDpAwz8\nzkJTW0bOpiSTRgOH1AzLkZBmnlC2Ntmb6mNy23O3hcHek9WOYDr3iHSDdhp8629B\nv2H/KlpZKBFLwOdakwrD5vNPoBZEg17vmrNAzETPtuiz0/l20bi6f3JvRJqwLJ+e\ni7MlYHxdU10fYEgncSkCQQDSUqHGuXEuqU8Gb4Nuh+EUiUFFc4Qu/pMi3161KtqP\n/HHZv3HfL5tIr2Wc4l65jlfsaTJ3ubOGdrj3FI5Tyb97AkEAyMbVSn2KYOqWlSsd\nETfpMMXahhFSrb23y2B8hwYJyABMrgd5UURovikMHMJv3y2bjPoZ83uSQbR2+e1E\nVrkC7QJAMvMZhY5+wJL7Nc/lwuzftZ3aVfy51LiO5C/APZr3/1FkMx+RckOSFnWG\n5A5ibAjze62wMBioSLaR8CjmoZ2J6QJAHvwgeoh5TI+ngYnPyJJ6WF6QZNRTkCCR\nNr/DOAtEgysYqlrY7CPEjmRDTETtguHE+bK3Qo41ehJhshxdyYxv2QI/elo5+Gz1\nVNkdHze9oyL5zzePagAM5nb3SyLtnmCiGgN8Nf0T3jdLQMta4E9vpQaZbyC54JAw\nq6jcjhQxj1hW\n
11 | feego.common.web.security.signature.open=true
12 | feego.common.web.security.signature.clients[0].app-id=default
13 | feego.common.web.security.signature.clients[0].verify-request-public-key=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDTEAyQI53Cn2fh8JTQdrFtNQIk\ns7g++25392BdyMvyd/vGuZpptbuHxA8JXPVZJunaGNRMVqFbfHv3hsR+1IFYhptj\nAtEVXJsEkBH/2Bpdor/mFxYFoTf+Cy60m3pBVdpvcz1AHYn0TDKNL33w5RuMbXU5\n4FYZYgOIuM7P/iNmQQIDAQAB\n
14 |
15 | spring.main.allow-bean-definition-overriding=true
16 |
17 | spring.redis.database=0
18 | spring.redis.host=127.0.0.1
19 | spring.redis.port=6379
20 | spring.redis.password=admin888
--------------------------------------------------------------------------------
/example/feego-common-example-start/src/main/resources/dubbo-provider.properties:
--------------------------------------------------------------------------------
1 | dubbo.application.name=annotation-provider
2 | dubbo.registry.address=zookeeper://127.0.0.1:2181?timeout=60000
3 | dubbo.protocol.name=dubbo
4 | dubbo.protocol.port=20880
--------------------------------------------------------------------------------
/example/feego-common-example-start/src/main/resources/strings/homepage.json:
--------------------------------------------------------------------------------
1 | {
2 | "success" : true,
3 | "code" : 0,
4 | "data" : {
5 | "domain" : "www.google.com"
6 | }
7 | }
--------------------------------------------------------------------------------
/example/feego-common-example-start/src/main/resources/strings/member/account.json:
--------------------------------------------------------------------------------
1 | {
2 | "success" : true,
3 | "code" : 0,
4 | "data" : {
5 | "uid" : 123434,
6 | "username" : "feego"
7 | }
8 | }
--------------------------------------------------------------------------------
/example/feego-common-example-start/src/test/java/io/github/lvyahui8/example/BasicTest.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example;
2 |
3 | import lombok.extern.slf4j.Slf4j;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.context.SpringBootTest;
6 | import org.springframework.test.context.junit4.SpringRunner;
7 |
8 | import java.util.UUID;
9 |
10 | /**
11 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
12 | * @since 2020/2/28 23:06
13 | */
14 | @RunWith(SpringRunner.class)
15 | @SpringBootTest
16 | @Slf4j
17 | public class BasicTest {
18 | public static void main(String[] args) {
19 | System.out.println(UUID.randomUUID().toString());
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/example/feego-common-example-start/src/test/java/io/github/lvyahui8/example/MsgCodeTest.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example;
2 |
3 | import io.github.lvyahui8.example.code.Code;
4 | import org.junit.Test;
5 |
6 | import java.text.DecimalFormat;
7 |
8 | /**
9 | * @author lvyahui (lvyahui8@gmail.com,lvyahui8@126.com)
10 | * @since 2020/3/18 21:56
11 | */
12 | public class MsgCodeTest {
13 |
14 | enum SimpleMsgCode {
15 | success(0,"success"),
16 | unknown(-1 , "unknown exception"),
17 | ;
18 | String msg;
19 | Integer code;
20 |
21 | SimpleMsgCode(Integer code,String msg) {
22 | this.msg = msg;
23 | this.code = code;
24 | }
25 |
26 | public Integer getCode() {
27 | return code;
28 | }
29 |
30 | public String getMsg() {
31 | return msg;
32 | }
33 | }
34 |
35 | enum Client {
36 | reqest_illegal,
37 | traffic_limmit,
38 | }
39 |
40 | enum TPB {
41 | member_system_err,
42 |
43 | }
44 |
45 | @Test
46 | public void testBasic() throws Exception {
47 | System.out.println(Code.General.success.getCode());
48 | System.out.println(Code.General.success.getMsg());
49 | System.out.println(Code.General.unknown.getCode());
50 | System.out.println(Code.General.unknown.getMsg());
51 | System.out.println(Code.Client.no_permit.getCode());
52 | System.out.println(Code.Client.no_permit.getMsg());
53 | System.out.println(Code.Client.no_login_session.getCode());
54 | System.out.println(Code.Client.no_login_session.getMsg());
55 | }
56 |
57 | @Test
58 | public void testPerformance() throws Exception {
59 | /// final int n = new DecimalFormat(",####").parse("1,0000,0000").intValue();
60 | final int n = new DecimalFormat(",####").parse("100,0000").intValue();
61 | System.out.println("loop times:" + n);
62 | long begin = System.currentTimeMillis();
63 | /// // 预先加载到缓存, 实际测试并没有太大区别
64 | /// Code.General.success.getCode();
65 | for (int i = 0 ;i < n ; i ++) {
66 | SimpleMsgCode.success.getCode();
67 | }
68 | System.out.println("simpleMsgCode.getCode cost time:" + (System.currentTimeMillis() - begin) + " ms");
69 | begin = System.currentTimeMillis();
70 | for (int i = 0 ; i < n ; i ++) {
71 | Code.General.success.getCode();
72 | }
73 | System.out.println("MsgCode.getCode cost time:" + (System.currentTimeMillis() - begin) + " ms");
74 | begin = System.currentTimeMillis();
75 | for (int i = 0 ;i < n ; i ++) {
76 | SimpleMsgCode.success.getMsg();
77 | }
78 | System.out.println("simpleMsgCode.getMsg cost time:" + (System.currentTimeMillis() - begin) + " ms");
79 | begin = System.currentTimeMillis();
80 | for (int i = 0 ; i < n ; i ++) {
81 | Code.General.success.getMsg();
82 | }
83 | System.out.println("MsgCode.getMsg cost time:" + (System.currentTimeMillis() - begin) + " ms");
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/example/feego-common-example-start/src/test/java/io/github/lvyahui8/example/NamedLockExecutorTest.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example;
2 |
3 | import io.github.lvyahui8.sdk.lock.NamedLockExecutor;
4 | import lombok.Data;
5 | import org.junit.Assert;
6 | import org.junit.Test;
7 |
8 | import java.util.concurrent.ExecutorService;
9 | import java.util.concurrent.Executors;
10 | import java.util.concurrent.atomic.AtomicBoolean;
11 | import java.util.concurrent.atomic.AtomicInteger;
12 | import java.util.concurrent.atomic.AtomicLong;
13 |
14 | /**
15 | * @author feego lvyahui8@gmail.com
16 | * @date 2021/2/3
17 | */
18 | public class NamedLockExecutorTest {
19 | @Data
20 | class Resource {
21 | int state = 0;
22 | }
23 | @Test
24 | public void testExec() throws Exception {
25 | ExecutorService service = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
26 |
27 | final Resource resource = new Resource();
28 | final AtomicBoolean flag = new AtomicBoolean(true);
29 | final AtomicInteger reloadCount = new AtomicInteger(0);
30 | final AtomicLong accessCount = new AtomicLong(0);
31 | long begin = System.currentTimeMillis();
32 | for (int i = 0; i < 10; i++) {
33 | service.submit(() -> {
34 | while(flag.get()) {
35 | try {
36 | Resource k = NamedLockExecutor.exec("" + (101 % 100),() -> {
37 | // 访问资源
38 | // System.out.println("state=" + resource.state);
39 | accessCount.incrementAndGet();
40 | return resource.state <= 0 ? null : resource;
41 | } ,() -> {
42 | // 加载资源
43 | resource.state += 1;
44 |
45 | System.out.println("reloaded:" + reloadCount.incrementAndGet());
46 | return resource;
47 | });
48 | Assert.assertEquals(k.state,1);
49 | } catch (Exception e) {
50 | e.printStackTrace();
51 | }
52 | }
53 | });
54 | }
55 | for (int i = 0; i < 1000; i++) {
56 | Thread.sleep(1000);
57 | // 将资源失效掉 (过期)
58 | resource.state = 0;
59 | }
60 | System.out.printf("refresh done, cost:%dms\n",System.currentTimeMillis() - begin);
61 |
62 |
63 |
64 | flag.set(false);
65 | service.shutdownNow();
66 | System.out.printf("access cnt:%d,reload cnt:%d, cost:%dms%n",
67 | accessCount.get(),
68 | reloadCount.get(),
69 | System.currentTimeMillis() - begin);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/example/feego-common-example-start/src/test/java/io/github/lvyahui8/example/RedDotTest.java:
--------------------------------------------------------------------------------
1 | package io.github.lvyahui8.example;
2 |
3 | import io.github.lvyahui8.example.reddot.AppRedDot;
4 | import io.github.lvyahui8.sdk.reddot.RedDotManager;
5 | import lombok.extern.slf4j.Slf4j;
6 | import org.apache.dubbo.rpc.cluster.router.condition.config.AppRouter;
7 | import org.junit.Assert;
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.boot.test.context.SpringBootTest;
12 | import org.springframework.data.redis.core.RedisTemplate;
13 | import org.springframework.test.context.junit4.SpringRunner;
14 |
15 | import java.util.Map;
16 |
17 | /**
18 | * @author feego lvyahui8@gmail.com
19 | * @date 2021/1/23
20 | */
21 | @RunWith(SpringRunner.class)
22 | @SpringBootTest
23 | @Slf4j
24 | public class RedDotTest {
25 |
26 | @Autowired
27 | RedDotManager redDotManager;
28 |
29 | @Autowired
30 | public RedisTemplate