Skip to content

Commit 2bf43db

Browse files
author
Каспшицкий Алексей
committed
feature: Rate Limiting pattern (iluwatar#2973)
java: java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport does not have member field 'com.sun.tools.javac.tree.JCTree qualid'
1 parent 00b4aac commit 2bf43db

File tree

10 files changed

+206
-8
lines changed

10 files changed

+206
-8
lines changed

Diff for: rate-limiting/etc/rate-limiting.urm.puml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@startuml
2+
package com.iluwatar.controller {
3+
class RateLimitedController {
4+
+ RateLimitedController()
5+
+ getRequest() : DtoClass
6+
}
7+
}
8+
package com.iluwatar.aspect {
9+
interface RateLimited {
10+
+ count() : int {abstract}
11+
+ timeUnit() : TimeUnit {abstract}
12+
}
13+
class RateLimiterAspect {
14+
- LOGGER : Logger {static}
15+
+ RateLimiterAspect()
16+
+ callMethodWithAnnotation()
17+
+ endpointAfterReturning(jp : JoinPoint, returningValue : Object) : Object
18+
+ endpointAfterThrowing(jp : JoinPoint, e : Exception)
19+
+ endpointBeforeInvoke(jp : JoinPoint)
20+
}
21+
}
22+
package com.iluwatar.pattern {
23+
class RateLimiter {
24+
+ RateLimiter()
25+
}
26+
}
27+
package com.iluwatar.model {
28+
class DtoClass {
29+
- id : Long
30+
- name : String
31+
+ DtoClass()
32+
# canEqual(other : Object) : boolean
33+
+ equals(o : Object) : boolean
34+
+ getId() : Long
35+
+ getName() : String
36+
+ hashCode() : int
37+
+ setId(id : Long)
38+
+ setName(name : String)
39+
+ toString() : String
40+
}
41+
}
42+
package com.iluwatar {
43+
class App {
44+
- LOGGER : Logger {static}
45+
+ App()
46+
+ main(args : String[]) {static}
47+
}
48+
}
49+
@enduml

Diff for: rate-limiting/pom.xml

+3-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@
3737
<dependency>
3838
<groupId>org.springframework</groupId>
3939
<artifactId>spring-webmvc</artifactId>
40-
</dependency>
41-
<dependency>
42-
<groupId>org.springframework.boot</groupId>
43-
<artifactId>spring-boot-starter-web</artifactId>
40+
<version>5.3.34</version>
4441
</dependency>
4542
<dependency>
4643
<groupId>org.springframework</groupId>
@@ -49,6 +46,7 @@
4946
<dependency>
5047
<groupId>org.springframework.boot</groupId>
5148
<artifactId>spring-boot-starter-thymeleaf</artifactId>
49+
<version>2.7.5</version>
5250
</dependency>
5351
<dependency>
5452
<groupId>org.junit.jupiter</groupId>
@@ -64,6 +62,7 @@
6462
<groupId>org.springframework.boot</groupId>
6563
<artifactId>spring-boot-starter-test</artifactId>
6664
<scope>test</scope>
65+
<version>2.7.5</version>
6766
</dependency>
6867
<dependency>
6968
<groupId>org.springframework</groupId>

Diff for: rate-limiting/src/main/java/com/iluwatar/App.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ public class App {
3838
*/
3939
public static void main(String[] args) {
4040
SpringApplication app = new SpringApplication(App.class);
41-
System.out.println("Hello world!");
41+
app.run(args);
4242
}
4343
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,45 @@
1+
/*
2+
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3+
*
4+
* The MIT License
5+
* Copyright © 2014-2022 Ilkka Seppälä
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
125
package com.iluwatar.aspect;
226

327
import java.util.concurrent.TimeUnit;
428

529
/**
6-
* AOP annotation.
30+
* Annotation for rate limiting method invocations.
731
*/
832
public @interface RateLimited {
33+
934
/**
10-
* invoke method vialotation for one ip address.
35+
* Specifies the maximum allowed invocations within the rate limiting window.
36+
* Default value is 10.
1137
*/
1238
int count() default 10;
39+
1340
/**
14-
* time unit for reset vialotation.
41+
* Specifies the unit of time for the rate limiting window.
42+
* Default time unit is seconds.
1543
*/
1644
TimeUnit timeUnit() default TimeUnit.SECONDS;
1745
}

Diff for: rate-limiting/src/main/java/com/iluwatar/aspect/RateLimiterAspect.java

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
/*
2+
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3+
*
4+
* The MIT License
5+
* Copyright © 2014-2022 Ilkka Seppälä
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
125
package com.iluwatar.aspect;
226

327
import lombok.extern.slf4j.Slf4j;

Diff for: rate-limiting/src/main/java/com/iluwatar/controller/RateLimitedController.java

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
/*
2+
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3+
*
4+
* The MIT License
5+
* Copyright © 2014-2022 Ilkka Seppälä
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
125
package com.iluwatar.controller;
226

327
import com.iluwatar.aspect.RateLimited;

Diff for: rate-limiting/src/main/java/com/iluwatar/model/DtoClass.java

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
/*
2+
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3+
*
4+
* The MIT License
5+
* Copyright © 2014-2022 Ilkka Seppälä
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
125
package com.iluwatar.model;
226

327
import lombok.Data;

Diff for: rate-limiting/src/main/java/com/iluwatar/pattern/RateLimiter.java

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
/*
2+
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3+
*
4+
* The MIT License
5+
* Copyright © 2014-2022 Ilkka Seppälä
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
125
package com.iluwatar.pattern;
226

327
import org.springframework.stereotype.Component;
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
server.port=8081

Diff for: update-header.sh

+25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
11
#!/bin/bash
2+
#
3+
# This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
4+
#
5+
# The MIT License
6+
# Copyright © 2014-2022 Ilkka Seppälä
7+
#
8+
# Permission is hereby granted, free of charge, to any person obtaining a copy
9+
# of this software and associated documentation files (the "Software"), to deal
10+
# in the Software without restriction, including without limitation the rights
11+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
# copies of the Software, and to permit persons to whom the Software is
13+
# furnished to do so, subject to the following conditions:
14+
#
15+
# The above copyright notice and this permission notice shall be included in
16+
# all copies or substantial portions of the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
# THE SOFTWARE.
25+
#
26+
227

328
# Find all README.md files in subdirectories one level deep
429
# and replace "### " with "## " at the beginning of lines

0 commit comments

Comments
 (0)