@@ -23,30 +23,31 @@ This README provides quickstart instructions on running [`reactify`]() on bare m
2323[ ![ OpenSSF Best Practices] ( https://www.bestpractices.dev/projects/9383/badge )] ( https://www.bestpractices.dev/projects/9383 )
2424[ ![ Build status] ( https://github.com/ponfee/commons-core/workflows/build-with-maven/badge.svg )] ( https://github.com/hoangtien2k3/reactify/actions )
2525
26- ## Download
26+ ## Getting Started
27+
2728Gradle is the only supported build configuration, so just add the dependency to your project build.gradle file:
2829
2930⬇️ Download Gradle and Maven
3031
3132``` kotlin
3233dependencies {
33- implementation ' io.github.hoangtien2k3:reactify: $latest '
34+ implementation( " io.github.hoangtien2k3:reactify-core:1.1.7 " )
3435}
3536```
3637
3738``` maven
3839<dependency>
3940 <groupId>io.github.hoangtien2k3</groupId>
40- <artifactId>reactify</artifactId>
41- <version>${latest} </version>
41+ <artifactId>reactify-core </artifactId>
42+ <version>1.1.7 </version>
4243</dependency>
4344```
4445
45- The latest ` reactify ` version is: [ ![ GitHub Release] ( https://img.shields.io/github/v/release/hoangtien2k3/reactify?label=latest )] ( https://mvnrepository.com/artifact/io.github.hoangtien2k3/reactify )
46+ The latest ` reactify ` version
47+ is: [ ![ GitHub Release] ( https://img.shields.io/github/v/release/hoangtien2k3/reactify?label=latest )] ( https://mvnrepository.com/artifact/io.github.hoangtien2k3/reactify )
4648
47- The latest stable lib ` reactify ` version is: latestVersion Click [ here] ( https://central.sonatype.com/namespace/io.github.hoangtien2k3 ) for more information on reactify.
48-
49- ## Getting Started
49+ The latest stable lib ` reactify ` version is: latestVersion
50+ Click [ here] ( https://central.sonatype.com/namespace/io.github.hoangtien2k3 ) for more information on reactify.
5051
51521 . Correct and complete setup to start the program ` application.yml ` or ` application.properties `
5253 with [ CONFIG] ( src/main/resources/application.yml )
@@ -56,10 +57,13 @@ The latest stable lib `reactify` version is: latestVersion Click [here](https://
5657
5758Here is a quick teaser of a complete Spring Boot application in Java:
5859
60+ ### Start Using ` reactify-core `
61+
5962``` java
63+
6064@SpringBootApplication
6165@ComponentScan (basePackages = {
62- " io.hoangtien2k3 .reactify.*" ,
66+ " com .reactify.*" ,
6367 " com.example.myproject"
6468})
6569public class Example {
@@ -75,13 +79,94 @@ public class Example {
7579}
7680```
7781
82+ ## Using Lib Reactify-Core Demo:
83+
84+ 1 . ` LocalCache `
85+
86+ ``` java
87+
88+ @LocalCache (durationInMinute = 30 , maxRecord = 10000 , autoCache = true )
89+ public Mono<List<OptionSetValue > > findByOptionSetCode(String optionSetCode) {
90+ return optionSetValueRepository. findByOptionSetCode(optionSetCode). collectList();
91+ }
92+ ```
93+
94+ 2 . ` Keycloak `
95+
96+ application.yml
97+
98+ ``` yml
99+ spring :
100+ security :
101+ oauth2 :
102+ client :
103+ provider :
104+ oidc :
105+ token-uri : ${keycloak.serverUrl}/realms/${keycloak.realm}/protocol/openid-connect/token
106+ registration :
107+ oidc :
108+ client-id : ${keycloak.clientId}
109+ client-secret : ${keycloak.clientSecret}
110+ authorization-grant-type : ${keycloak.grantType} # password || #client_credentials
111+ resourceserver :
112+ jwt :
113+ jwk-set-uri : ${keycloak.serverUrl}/realms/${keycloak.realm}/protocol/openid-connect/certs
114+ keycloak :
115+ client-id : ${keycloak.clientId}
116+
117+ ```
118+
119+ ``` java
120+
121+ @Override
122+ public Mono<Optional<AccessToken > > getToken(LoginRequest loginRequest) {
123+ MultiValueMap<String , String > formParameters = new LinkedMultiValueMap<> ();
124+ formParameters. add(OAuth2ParameterNames . GRANT_TYPE , OAuth2ParameterNames . PASSWORD );
125+ formParameters. add(OAuth2ParameterNames . USERNAME , loginRequest. getUsername());
126+ formParameters. add(OAuth2ParameterNames . PASSWORD , loginRequest. getPassword());
127+ String clientId = loginRequest. getClientId();
128+ if (! DataUtil . isNullOrEmpty(clientId)) {
129+ return keycloakProvider
130+ .getClientWithSecret(clientId)
131+ .flatMap(clientRepresentation - > {
132+ formParameters. add(OAuth2ParameterNames . CLIENT_ID , clientId);
133+ formParameters. add(OAuth2ParameterNames . CLIENT_SECRET , clientRepresentation. getSecret());
134+ return requestToken(formParameters);
135+ })
136+ .switchIfEmpty(Mono . error(new BusinessException (CommonErrorCode . INVALID_PARAMS , " client.id.not.valid" )));
137+ } else {
138+ formParameters. add(OAuth2ParameterNames . CLIENT_ID , keyCloakConfig. getAuth(). clientId());
139+ formParameters. add(OAuth2ParameterNames . CLIENT_SECRET , keyCloakConfig. getAuth(). clientSecret());
140+ }
141+ return requestToken(formParameters);
142+ }
143+ ```
144+
145+ 3 . Call Api Using BaseRest and BaseSoap Client
146+
147+ ``` java
148+ public Mono<String > getEmailsByUsername(String username) {
149+ var payload = new LinkedMultiValueMap<> ();
150+ payload. set(" username" , username);
151+ return SecurityUtils . getTokenUser(). flatMap(token - > {
152+ HttpHeaders headers = new HttpHeaders ();
153+ headers. set(" Authorization" , " Bearer " + token);
154+ return baseRestClient
155+ .get(authClient, " /user/keycloak" , headers, payload, String . class)
156+ .map(response - > {
157+ Optional<?> optionalEmail = (Optional<?> ) response;
158+ return DataUtil . safeToString(optionalEmail. orElse(null ));
159+ });
160+ });
161+ }
162+ ```
163+
78164## Contributing
79165
80166If you would like to contribute to the development of this project, please follow our contribution guidelines.
81167
82168![ Alt] ( https://repobeats.axiom.co/api/embed/31a861bf21d352264c5c122808407abafb97b0ef.svg " Repobeats analytics image ")
83169
84-
85170## Star History
86171
87172<a href =" https://star-history.com/#hoangtien2k3/fw-commons&Timeline " >
0 commit comments