Skip to content

Commit 0414ba1

Browse files
committed
✨ feat: Add core CRUD annotation system - @crud annotation for auto-generating REST endpoints - @CrudOverride for method customization - CrudProcessor for processing CRUD controllers - ApiResponse for standardized responses - Zero-boilerplate CRUD operations generation
1 parent a171cf3 commit 0414ba1

File tree

5 files changed

+1777
-1
lines changed

5 files changed

+1777
-1
lines changed

src/main/java/jazzyframework/core/Server.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.logging.Logger;
77

88
import jazzyframework.controllers.MetricsController;
9+
import jazzyframework.data.CrudProcessor;
910
import jazzyframework.di.DIContainer;
1011
import jazzyframework.routing.Router;
1112

@@ -18,6 +19,7 @@
1819
* <li>Accepting client connections and delegating requests to appropriate handlers</li>
1920
* <li>Automatically initializing dependency injection with component discovery</li>
2021
* <li>Registering the metrics endpoint if enabled</li>
22+
* <li>Processing @Crud annotations and auto-generating CRUD endpoints</li>
2123
* <li>Managing server lifecycle and cleanup</li>
2224
* </ul>
2325
*
@@ -45,6 +47,9 @@ public Server(Router router, Config config) {
4547
this.config = config;
4648

4749
initializeDependencyInjection();
50+
51+
// Process @Crud annotations after DI initialization
52+
processCrudAnnotations();
4853

4954
if (config.isEnableMetrics()) {
5055
router.addRoute("GET", "/metrics", "getMetrics", MetricsController.class);
@@ -63,6 +68,21 @@ private void initializeDependencyInjection() {
6368
diContainer.initialize();
6469
logger.info("Dependency injection enabled with automatic component discovery");
6570
}
71+
72+
/**
73+
* Processes @Crud annotations and automatically generates CRUD endpoints.
74+
*/
75+
private void processCrudAnnotations() {
76+
try {
77+
CrudProcessor crudProcessor = new CrudProcessor(router, diContainer);
78+
crudProcessor.processAllCrudControllers();
79+
logger.info("@Crud annotations processed and CRUD endpoints generated");
80+
} catch (Exception e) {
81+
logger.warning("Failed to process @Crud annotations: " + e.getMessage());
82+
e.printStackTrace();
83+
// Don't fail startup if CRUD processing fails
84+
}
85+
}
6686

6787
/**
6888
* Gets the DI container used by this server.
@@ -81,7 +101,7 @@ public DIContainer getDIContainer() {
81101
*/
82102
public void start(int port) {
83103
try (ServerSocket serverSocket = new ServerSocket(port)) {
84-
logger.info("Server started on port " + port + " with dependency injection");
104+
logger.info("Server started on port " + port + " with dependency injection and auto-CRUD");
85105

86106
while (true) {
87107
Socket clientSocket = serverSocket.accept();

0 commit comments

Comments
 (0)