-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Tomcat server: Add basic embedded tomcat server * Added ServletInitializer which scan all Controllers and register them in DispatcherServlet, added corresponding annotations * add logs and javaDocs to all required files --------- Co-authored-by: mykola.filimonov <[email protected]>
- Loading branch information
1 parent
e1b67a6
commit 958a31a
Showing
11 changed files
with
477 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.github.bobocodebreskul; | ||
|
||
import io.github.bobocodebreskul.context.annotations.BringComponent; | ||
import io.github.bobocodebreskul.context.annotations.RestController; | ||
import io.github.bobocodebreskul.context.annotations.Get; | ||
|
||
@RestController("/hello") | ||
@BringComponent | ||
public class MyController { | ||
|
||
@Get | ||
public String getHello() { | ||
return "Hello, world!"; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/io/github/bobocodebreskul/context/annotations/Get.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.github.bobocodebreskul.context.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Indicates that the annotated method serves as a GET request handler within a corresponding Controller. | ||
* This annotation is intended for use in combination with the {@link RestController @RestController} annotation. | ||
* | ||
* <p>Usage:</p> | ||
* <pre> | ||
* {@code | ||
* @RestController("/sample") | ||
* public class SampleController { | ||
* | ||
* @Get | ||
* public YourClass doGet() { | ||
* return new YourClass(); | ||
* } | ||
* }} | ||
* </pre> | ||
* | ||
* @see RestController | ||
*/ | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Get { | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/io/github/bobocodebreskul/context/annotations/Post.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.github.bobocodebreskul.context.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Indicates that the annotated method serves as a POST request handler within a corresponding Controller. | ||
* This annotation is designed for use in conjunction with the {@link RestController @RestController} annotation. | ||
* | ||
* <p>Usage:</p> | ||
* <pre> | ||
* {@code | ||
* @RestController("/sample") | ||
* public class SampleController { | ||
* | ||
* @Post | ||
* public YourClass doPost() { | ||
* return new YourClass(); | ||
* } | ||
* }} | ||
* </pre> | ||
* | ||
* @see RestController | ||
*/ | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Post { | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/io/github/bobocodebreskul/context/annotations/RestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.github.bobocodebreskul.context.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Indicates that the annotated class is a RestController, allowing it to be scanned by the ApplicationContext. | ||
* A required request mapping value must be specified. Additionally, HTTP Request Method annotations such as | ||
* {@link Get} or {@link Post} should be added to the methods within the controller. The response from these | ||
* methods will be automatically converted to JSON and sent as the client's response. | ||
* | ||
* <p>Usage:</p> | ||
* <pre> | ||
* {@code | ||
* @RestController("/sample") | ||
* public class SampleController { | ||
* | ||
* @Get | ||
* public YourClass doGet() { | ||
* return new YourClass(); | ||
* } | ||
* }} | ||
* </pre> | ||
*/ | ||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface RestController { | ||
|
||
/** | ||
* Represents path to the resource. | ||
* | ||
* @return the filled controller path | ||
*/ | ||
String value(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.