diff --git a/rate-limiting/etc/rate-limiting.urm.puml b/rate-limiting/etc/rate-limiting.urm.puml
new file mode 100644
index 000000000000..19b2265837de
--- /dev/null
+++ b/rate-limiting/etc/rate-limiting.urm.puml
@@ -0,0 +1,49 @@
+@startuml
+package com.iluwatar.controller {
+ class RateLimitedController {
+ + RateLimitedController()
+ + getRequest() : DtoClass
+ }
+}
+package com.iluwatar.aspect {
+ interface RateLimited {
+ + count() : int {abstract}
+ + timeUnit() : TimeUnit {abstract}
+ }
+ class RateLimiterAspect {
+ - LOGGER : Logger {static}
+ + RateLimiterAspect()
+ + callMethodWithAnnotation()
+ + endpointAfterReturning(jp : JoinPoint, returningValue : Object) : Object
+ + endpointAfterThrowing(jp : JoinPoint, e : Exception)
+ + endpointBeforeInvoke(jp : JoinPoint)
+ }
+}
+package com.iluwatar.pattern {
+ class RateLimiter {
+ + RateLimiter()
+ }
+}
+package com.iluwatar.model {
+ class DtoClass {
+ - id : Long
+ - name : String
+ + DtoClass()
+ # canEqual(other : Object) : boolean
+ + equals(o : Object) : boolean
+ + getId() : Long
+ + getName() : String
+ + hashCode() : int
+ + setId(id : Long)
+ + setName(name : String)
+ + toString() : String
+ }
+}
+package com.iluwatar {
+ class App {
+ - LOGGER : Logger {static}
+ + App()
+ + main(args : String[]) {static}
+ }
+}
+@enduml
\ No newline at end of file
diff --git a/rate-limiting/pom.xml b/rate-limiting/pom.xml
index 4584cf49704b..eac389868bc8 100644
--- a/rate-limiting/pom.xml
+++ b/rate-limiting/pom.xml
@@ -37,10 +37,7 @@
org.springframework
spring-webmvc
-
-
- org.springframework.boot
- spring-boot-starter-web
+ 5.3.34
org.springframework
@@ -49,6 +46,7 @@
org.springframework.boot
spring-boot-starter-thymeleaf
+ 2.7.5
org.junit.jupiter
@@ -64,6 +62,7 @@
org.springframework.boot
spring-boot-starter-test
test
+ 2.7.5
org.springframework
diff --git a/rate-limiting/src/main/java/com/iluwatar/App.java b/rate-limiting/src/main/java/com/iluwatar/App.java
index c443be2baa6d..f83de4341191 100644
--- a/rate-limiting/src/main/java/com/iluwatar/App.java
+++ b/rate-limiting/src/main/java/com/iluwatar/App.java
@@ -38,6 +38,6 @@ public class App {
*/
public static void main(String[] args) {
SpringApplication app = new SpringApplication(App.class);
- System.out.println("Hello world!");
+ app.run(args);
}
}
\ No newline at end of file
diff --git a/rate-limiting/src/main/java/com/iluwatar/aspect/RateLimited.java b/rate-limiting/src/main/java/com/iluwatar/aspect/RateLimited.java
index 69fb8e1c24bc..cee749c2db1e 100644
--- a/rate-limiting/src/main/java/com/iluwatar/aspect/RateLimited.java
+++ b/rate-limiting/src/main/java/com/iluwatar/aspect/RateLimited.java
@@ -1,17 +1,45 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
package com.iluwatar.aspect;
import java.util.concurrent.TimeUnit;
/**
- * AOP annotation.
+ * Annotation for rate limiting method invocations.
*/
public @interface RateLimited {
+
/**
- * invoke method vialotation for one ip address.
+ * Specifies the maximum allowed invocations within the rate limiting window.
+ * Default value is 10.
*/
int count() default 10;
+
/**
- * time unit for reset vialotation.
+ * Specifies the unit of time for the rate limiting window.
+ * Default time unit is seconds.
*/
TimeUnit timeUnit() default TimeUnit.SECONDS;
}
diff --git a/rate-limiting/src/main/java/com/iluwatar/aspect/RateLimiterAspect.java b/rate-limiting/src/main/java/com/iluwatar/aspect/RateLimiterAspect.java
index 6ca7d8ff4d8d..b66e85736087 100644
--- a/rate-limiting/src/main/java/com/iluwatar/aspect/RateLimiterAspect.java
+++ b/rate-limiting/src/main/java/com/iluwatar/aspect/RateLimiterAspect.java
@@ -1,3 +1,27 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
package com.iluwatar.aspect;
import lombok.extern.slf4j.Slf4j;
diff --git a/rate-limiting/src/main/java/com/iluwatar/controller/RateLimitedController.java b/rate-limiting/src/main/java/com/iluwatar/controller/RateLimitedController.java
index 5cb57ac78200..c3ce15ff990d 100644
--- a/rate-limiting/src/main/java/com/iluwatar/controller/RateLimitedController.java
+++ b/rate-limiting/src/main/java/com/iluwatar/controller/RateLimitedController.java
@@ -1,3 +1,27 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
package com.iluwatar.controller;
import com.iluwatar.aspect.RateLimited;
diff --git a/rate-limiting/src/main/java/com/iluwatar/model/DtoClass.java b/rate-limiting/src/main/java/com/iluwatar/model/DtoClass.java
index 2ca4f7dc582e..c35ed371cd90 100644
--- a/rate-limiting/src/main/java/com/iluwatar/model/DtoClass.java
+++ b/rate-limiting/src/main/java/com/iluwatar/model/DtoClass.java
@@ -1,3 +1,27 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
package com.iluwatar.model;
import lombok.Data;
diff --git a/rate-limiting/src/main/java/com/iluwatar/pattern/RateLimiter.java b/rate-limiting/src/main/java/com/iluwatar/pattern/RateLimiter.java
index b25b0ba64b7b..ad3b6a42c5c3 100644
--- a/rate-limiting/src/main/java/com/iluwatar/pattern/RateLimiter.java
+++ b/rate-limiting/src/main/java/com/iluwatar/pattern/RateLimiter.java
@@ -1,3 +1,27 @@
+/*
+ * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+ *
+ * The MIT License
+ * Copyright © 2014-2022 Ilkka Seppälä
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
package com.iluwatar.pattern;
import org.springframework.stereotype.Component;
diff --git a/rate-limiting/src/main/resources/application.properties b/rate-limiting/src/main/resources/application.properties
new file mode 100644
index 000000000000..bafddced850a
--- /dev/null
+++ b/rate-limiting/src/main/resources/application.properties
@@ -0,0 +1 @@
+server.port=8081
\ No newline at end of file
diff --git a/update-header.sh b/update-header.sh
index 48da4dcd6125..568d00d52a03 100755
--- a/update-header.sh
+++ b/update-header.sh
@@ -1,4 +1,29 @@
#!/bin/bash
+#
+# This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
+#
+# The MIT License
+# Copyright © 2014-2022 Ilkka Seppälä
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
# Find all README.md files in subdirectories one level deep
# and replace "### " with "## " at the beginning of lines