Reputation: 743
I had a large conversation with my colleague about approach.
On one part, we create simple framework that generates servlet based on annotation. Let's call it controller. It looks the similar like Spring MVC, but without front-controller approach. Instead, this framework generates a new servlet for every class that marked with @Controller annotation.
On other part, we could use front-controller approach, and forget about source generation and recreating the wheel.
I don't know if question is relevant, but what would be better from performance perspective? Use(generate) new servlet for every controller, or use one servlet to resolve actions?
Upvotes: 0
Views: 1189
Reputation: 821
From the performance point of view I don't see any major differences. You probably won't create a number of differents Servlets Objets to make the heap size relevant. Usually the MVC frameworks use only one Controller so, in my opinion, if you wan't to recreating the wheel its a good a idea make it in a standard way.
Anyway, the Controller must be simple and its only logic should be request actions to business Services. You can extend your question to a more generic use of Facade Pattern, not only for servlet Controller. You should use it when the scalability and modularity requirements of your app require it.
Upvotes: 1