66import java .util .logging .Logger ;
77
88import jazzyframework .controllers .MetricsController ;
9+ import jazzyframework .data .CrudProcessor ;
910import jazzyframework .di .DIContainer ;
1011import jazzyframework .routing .Router ;
1112
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