Skip to main content

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


>In this class req is the protected member of RequestHandler and is of
>type Request.

Where is type Request? For your pointcut to match it must be a super-type of MyMethodRequestHandler and hence RequestHandler: "pointcut HandlePointcut(Request req): ... && target(req);"

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/



"Kaul, Dimple" <dimple.kaul@xxxxxxxxxxxxxx>
Sent by: ajdt-dev-bounces@xxxxxxxxxxx

14/08/2006 19:10

Please respond to
AspectJ Development Tools developer discussions <ajdt-dev@xxxxxxxxxxx>

To
ajdt-dev@xxxxxxxxxxx
cc
Subject
[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


_______________________________________________
ajdt-dev mailing list
ajdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ajdt-dev


Back to the top