Let’s Implement J2EE Application Controller Design pattern today

I was reading Santosh Sir’s article on application controller pattern last night. Those who have some understanding on J2EE design pattern know the different between Front Controller and Application controller pattern. Struts 1.x is a best example of both.

You can read the Santosh Sir’s article on Front Controller and Application controller pattern.

So Today I have decided to implement application controller design pattern which can use java’s properties file to read and configure controllers.

Start with Controller interface.

View.java is a wrapper view resolver return from Controller’s execute method.

ControllerConfig is used to hold controller’s action with it’s class name.

WebConfig is used to manage all controller configured in properties file. This class will read, and make available all controller Object to Main Servlet.

And Last is our Front Controller servlet (AqsaServlet). Aqsa Servlet is a Centralized control in application, a sigle entry point which manage Protocol Handling, Request Navigation and View Dispatching.

web.xml and controller config properties file will Look similar below…

and ….

#Mapping file contain key value pair
login=com.xpert.controller.LoginController
register=com.xpert.controller.RegistrationController

Now it’s time to create a simple controller, and view to test…

Download Code

About the Author

has written 68 posts.

I Love Coding, Analyzing, Designing and doing it the right way. I am obsessed about learn anything new daily and sharing what I have learn each Day. This Blog is journey of my Zeal, going through step by step to the mountain of desire to become prefect. Google Wanna Hire me ?

Copyright © 2017 http://www.techzoo.org. All rights reserved.
Proudly powered by WordPress. Developed by 7Tech Solutions