views:

45

answers:

2

I have been handed a large Spring-Hibernate project and have been told to go through the code and figure out how it works. I have been able to run the project in JBoss and access pages locally, but I have no idea how to figure out how the program is layed out, as I have no web programming experience. I have been told that it is "pretty simple" and is a "normal Spring-Hibernate project."

Any idea where to begin? Thanks

+1  A: 

Well, for starters, you'll really need to learn at least the basics of how these frameworks operate. Here's a tutorial on Spring MVC, and here's a Hibernate tutorial.

You'll need to identify the classes that create the various layers; there are certainly going to be Controller classes (which take a web request and figure out how to construct the response) and DAO classes (Data Access Objects, which manage saving and retrieving data).

There will probably be JSP files which describe the views; that is, what the user sees. The HTML code that builds the actual web pages should be here.

My suggestion: pick one simple page and follow it through. Where's the JSP that sets up the HTML for that page? Where's the controller it gets POSTed to? Does that controller call a service class or a DAO? A validator? Etc. -- type in one bit of data and follow it all the way through. It will help to have an IDE that shows you the structure of the application, and allows you to go into debug mode and step through the code.

Good luck!

JacobM
A: 

First get acquainted with where things are in the web app directory structure. You should be able to find, under WEB-INF, a file called web.xml. That should contain an entry that tells where the Spring application context xml is. If the application was built using annotations this may not help much, otherwise it will show you how the application is put together, what is plugged in where, and how database transactions work. If the application uses annotations for wiring then you're stuck with rooting through the code to find that kind of information.

Spring encourages a layered approach to web applications where you have a controller that receives a web request and calls a service that is transactional, contains business logic, and calls data access objects that talk to a database. But people like to take shortcuts and create unnecessary layers, it's hard telling what you'll find. People have wildly divergent ideas of "normal" and "pretty simple", so good luck.

Nathan Hughes