-
1. Re: Tracing/Logging - Actual RMI calls vs calls between EJBs
kabirkhan Nov 23, 2006 5:23 PM (in response to ykrishnaprasad)EJB 2 or 3?
-
2. Re: Tracing/Logging - Actual RMI calls vs calls between EJBs
ykrishnaprasad Nov 24, 2006 11:51 AM (in response to ykrishnaprasad)EJB 3
-
3. Re: Tracing/Logging - Actual RMI calls vs calls between EJBs
kabirkhan Nov 26, 2006 5:10 PM (in response to ykrishnaprasad)There is no easy way to do this at the AOP layer, but it seems that if the call is local the EJBContainerInvocation will contain something under
invocation.getMetaData("IS_LOCAL", "IS_LOCAL");
You could customize the stack of interceptors used for your ejb 3 container(s) in ejb3-interceptors-aop.xml, or create your own domains by deploying your own whatever-aop.xml file and override the domain used in your bean using the @Domain annotation.
I am not sure if this is shown in the ejb3 documentation, but there is a test in the ejb3 testsuite under org.jboss.ejb3.test.aspectdomain that you could look at. -
4. Re: Tracing/Logging - Actual RMI calls vs calls between EJBs
ykrishnaprasad Nov 28, 2006 7:46 PM (in response to ykrishnaprasad)Kabir,
In my interceptor class i can get a reference to the target object.
How can i get a reference to the caller object in the interceptor class?
Thanks -
5. Re: Tracing/Logging - Actual RMI calls vs calls between EJBs
kabirkhan Nov 28, 2006 7:56 PM (in response to ykrishnaprasad)You can't if you use "execution" or "field" pointcuts, if you want access to the caller you need a "call" pointcut, but those have certain limitations.
-
6. Re: Tracing/Logging - Actual RMI calls vs calls between EJBs
nacho26 Dec 8, 2006 7:00 PM (in response to ykrishnaprasad)Hello Krishna,
I am trying to get something similar working as you had put in your question on the message forums. I am trying to get the "caller" and "callee" of a call between two EJBs. Do you have suggestions ?
Thanks for your time !
Gunjan"ykrishnaprasad" wrote:
Kabir,
In my interceptor class i can get a reference to the target object.
How can i get a reference to the caller object in the interceptor class?
Thanks -
7. Re: Tracing/Logging - Actual RMI calls vs calls between EJBs
ykrishnaprasad Dec 11, 2006 12:05 PM (in response to ykrishnaprasad)I haven't yet exactly figured out the solution to my specific problem.But here is somthing that might be of help - caller pointcuts(http://wiki.jboss.org/wiki/Wiki.jsp?page=CallerPointcuts) and MethodCalledByMethod class in org.jboss.aop.joinpoint package.
If i am successful i will post a reply.
I am open to any ideas you might be able to throw in. -
8. Re: Tracing/Logging - Actual RMI calls vs calls between EJBs
ykrishnaprasad Dec 11, 2006 2:34 PM (in response to ykrishnaprasad)Kabir,
a) Can get the type of an invocation(whether its a METHOD)?
To be specific i was looking at -http://www.onjava.com/pub/a/onjava/2003/05/28/aop_jboss.html?page=1
Things might have changed since the article was written.Wondering how to do the same with the new APIs.
b) Can i use org.jboss.aop.joinpoint.MethodCalledByMethodInvocation to see if a method is invoked by another method?
Appreciate if you could point me to any examples.
Thanks. -
9. Re: Tracing/Logging - Actual RMI calls vs calls between EJBs
stalep Dec 12, 2006 3:03 AM (in response to ykrishnaprasad)"ykrishnaprasad" wrote:
a) Can get the type of an invocation(whether its a METHOD)?
i guess you mean in the interceptor, so yes. just either try to cast it to a MethodInvocation or check if its an instanceof MethodInvocation."ykrishnaprasad" wrote:
b) Can i use org.jboss.aop.joinpoint.MethodCalledByMethodInvocation to see if a method is invoked by another method?
i believe you are thinking of cflow here. with cflow you can define a stack of eg. method calls that has to occur before a pointcut matches.
take a look at the cflow examples in the dist and let me know if it solves your problem. -
10. Re: Tracing/Logging - Actual RMI calls vs calls between EJBs
flavia.rainone.old Dec 12, 2006 6:56 AM (in response to ykrishnaprasad)You can write an advice that receives a MethodCalledByMethodInvocation. This way, you can access the caller.
However, this invocation must be used only on advices bound to "call" pointcut expressions.
If you use an "execution" pointcut, what you get is MethodInvocation, and you will only have access to the called method.
If you use call + withincode on your pointcut expression, you can specify the method called (inside of call), and the caller method (inside of withincode).
Look at this example:call(int java.util.ArrayList->size()) AND withincode(void Driver->caller())
This pointcut expression matches all calls to ArrayList.size() made by the method Driver.caller(). Look at the complete example here:
http://labs.jboss.com/portal/jbossaop/docs/1.5.0.GA/docs/aspect-framework/examples/caller/caller.html
We will allow more flexibility in this area on JBoss AOP 2.0. You will be able to receive the caller and the target of the call as arguments to your advice. -
11. Re: Tracing/Logging - Actual RMI calls vs calls between EJBs
ykrishnaprasad Dec 12, 2006 5:20 PM (in response to ykrishnaprasad)Thanks a bunch guys!
I think i got the basic caller pointcut working for MethodCalledByMethodInvocation.
Here is a simple set of classes that i used for this purpose:package DCR2; public class HelloAOP { public static void main(String args[]){ new callTest().printText(); } public void callMe(){ System.out.println("AOP!"); } } package DCR2; public class callTest { public void printText(){ callMe(); } public void callMe(){ System.out.println("AOP!"); } } package DCR2; import org.jboss.aop.advice.Interceptor; import org.jboss.aop.joinpoint.Invocation; import org.jboss.aop.joinpoint.MethodCalledByMethodInvocation; public class HelloAOPInterceptor implements Interceptor{ public String getName(){ return "HelloAOPInterceptor"; } public Object invoke(Invocation invocation) throws Throwable{ if (invocation instanceof MethodCalledByMethodInvocation){ System.out.print("MethodCalledByMethodInvocation, "); } else System.out.print("Hello, "); return invocation.invokeNext(); } }
And my jboss-aop.xml looks like:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <aop> <bind pointcut="call(public void DCR2.callTest->callMe()) and withincode(public void DCR2.callTest->printText())"> <interceptor class="DCR2.HelloAOPInterceptor"/> </bind> </aop>
The output after running the project should be:
MethodCalledByMethodInvocation, AOP!
The reason i used the callTest class in between is that i could not get the interceptor to work if i had a statementnew HelloAOP().callMe(); (a method call in the constructor) instead of: new callTest().printText();
What i could do on the whole is to see if a call for a method is coming from another method or not. My next step is to see if i can differentiate between a method call coming from a JSP page(JSP->EJB) and the method calling method(EJB->EJB).
I may have to comeback for your help again.