Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ajdt-dev] Query related to aspectJ

Hi all,
   I have this problem in my code. I am doing some stuff with AspectJ.

Following is the class for which i am implementing aspectj.

-----------------------------------------------------------------
import java.sql.Connection;
import java.util.Vector;
import org.myproj.net.Request;
import org.myproj.net.RequestHandler;

public class MyMethodRequestHandler extends RequestHandler {

     public void HandleRequest() throws Exception {
        Vector<String> results;
        try {
    		String dirToList = req.getAttribute("directory");
    		//
		//
		//
		//
        }
        finally {
        }
		Request res = getBaseResponse();
		if (results != null)
			res.setData(new Value(results).toBytes());

		res.write(this.getOutputStream());

	}
}

-----------------------------------------------------------------

In this class req is the protected memember of RequestHandler and is of
type Request.
Now i want to access req in my aspect so that i can access different
values in my aspect

-----------------------------------------------------------------
pointcut HandlePointcut(Request req): execution(public *
org.lstore.lserver.MyMethodRequestHandler.HandleRequest(..)) &&
target(req);
// I tried this(req) also here but that too is not working
Object around(Request req):lsHandle(req){
	Object res = null;
	System.out.printlne("Before   "+thisJoinPoint.getSignature()  ");
	String user_id = req.getAttribute("username");
	return proceed(req);
}

-----------------------------------------------------------------
In this advice it is not able to resolve Requesthandler. Also it never
goes into this pointcut
then for seeing if my pointcut is good or not i tried something like this

-----------------------------------------------------------------
pointcut lsHandle1(): execution(public *
org.lstore.lserver.MyMethodRequestHandler.HandleRequest(..));

before():lsHandle1(){

	System.out.printlne("Before   "+thisJoinPoint.getSignature()  ");
}

-----------------------------------------------------------------
This is working fine.

Can you please help me how i can have advice with request handler. do you
think i am missing something?


Thanks in advance,
Dimple




Back to the top