Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] what pointcut to use ?

Respected all,

i am a newbie to aspect programming,
my problem is this,i have the servlet,

import java.io.*;
import java.net.*;

import javax.servlet.*;
import javax.servlet.http.*;

public class newlayer extends HttpServlet {

public void init(ServletConfig config) throws ServletException {
        super.init(config);

    }

    public void destroy() {

    }

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();

        //output your page here



        String projid=request.getParameter("proj");
        String lyrnm=request.getParameter("lyrtxt");
        String lyrdesc=request.getParameter("lyrdesc");

***********************************************************************
        if(!(lyrnm.equalsIgnoreCase(""))){
DAOFactory mysqlFactory =DAOFactory.getDAOFactory(DAOFactory.MYSQL);
            userDAO usrDAO =mysqlFactory.getUserDAO();

            /*calling update new layer*/
            String stat=usrDAO.newlayer(projid,lyrnm,lyrdesc);
            out.println("<html>");
            out.println("<head>");

            if(stat.equalsIgnoreCase("exists")){
                out.println("layer "+lyrnm+" "+stat);
            }
            else{
                out.println("<script language='javascript'>");
out.println("window.parent.location='http://172.16.35.5:8080/entry.jsp?projid="+projid+"&lyrnm="+lyrnm+"&prcsnm='");
                out.println("</script>");
            }
            out.println("<title>Servlet</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("layer "+lyrnm+" "+stat);
            out.println("</body>");
            out.println("</html>");

            mysqlFactory.closeDAOFactory();
        }
        else{
            out.println("Invalid layer name");

        }

************************************************************************
        out.close();
    }

protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /** Returns a short description of the servlet.
     */
    public String getServletInfo() {
        return "Short description";
    }

}

the code between the asterik lines create a new instace of DAOfactory class and based on the resturn value(i.e variable stat) i am ouputting a page.

i want this to be made an aspect bcoz this code occurs in many other classes ...

Please help me out ....and show me how to do that......this is very urgent.....

muthu.





___________________________________________________
Click below to experience Sooraj R Barjatya's latest offering
'Main Prem Ki Diwani Hoon' starring Hrithik, Abhishek
 & Kareena http://www.mpkdh.com



Back to the top