PDA

View Full Version : How to extend the current Infrastructure in Spring?


bosco_v
Jul 27th, 2005, 01:52 PM
My Web application is extending myAbsInfraServlet for authentication,
authorization and other infrastructure related cross-cutting issues.
I could not find the solution to migrate it to Spring (may include hibernate in the near future). I am very new to Spring framework. In the forum I saw some where that we can resolve this kind of issue with WebApplicationContext . Can anyone tell me how? I am using WSAD 5.1.2 (J2EE 1.3, Servlet 2.3, JSP 1.2). Appreciated your help in advance.

public abstract class myAbsInfraServlet
extends HttpServlet implements Constants
{

public void init()throws ServletException {
//loading system related properties, data source etc,.
}

public void doGet(HttpServletRequest req, HttpServletResponse rep)
throws ServletException, IOException
{
//First time entry: display signon page......
//Second time onwards: validate user authentication, autherization
// and the prodcuts he is authorized to and related stuff.....
//if fails, re-display the signon page..

//Session variable: DB Connection String, user name, app name...
myDoGet(userid, req, rep); //this may override by child class...
}
//doPost same as above.........

protected abstract String getApplicationName(HttpServletRequest req)
throws NullAppException;

}//end of myAbsInfraServlet .........

Rod Johnson
Jul 27th, 2005, 01:56 PM
My Web application is extending myAbsInfraServlet for authentication,
authorization and other infrastructure related cross-cutting issues.
Acegi Security provides an excellent security infrastructure built on Spring.

Cross-cutting issues can be addressed using Spring MVC Handler Interceptors (web tier) or Spring AOP (any tier).

Infrastructure: the application context and Dependency Injection provides a consistent framework for avoiding the need for custom lookups.

And Spring DAO provides a powerful, simple approach to data access. Spring also has a transaction management abstraction that works in just about any environment.

Your questions are pretty general, so I've just outlined some of the major capabilities that may meet your requirements. You might do better to ask more focused questions in particular areas.

bosco_v
Jul 27th, 2005, 02:21 PM
Thanks Rod Johnson for your reply.

Here's a sample servlet that extending the existing myAbsInfraServlet:

I want to use my own security, database connection pooling, authorization and authentication because of other non-tech reasons (even though Acegi Security is much better)

public class ManageUsers extends myAbsInfraServlet
{
public void myDoGet(String userid, HttpServletRequest req,
HttpServletResponse resp)
{
//do some business logic
//create users bean...
//forward it to jsp...
}
}

The above code validates the user validity (bec's of myAbsInfraServlet) and allows him/her to see the results if s he is authorized. If not re-paint signon page. As a new learner I tried using DispatcherServlet, but failed.

Could you please tell me how to re-write the above code in Spring.
Must have to use myAbsInfraServlet.