[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Basic understanding question
|
Hi,
I want to use AOP for some time measurement in my EJB application.
I have implemented the code in one bean the way I wanted it and than
tryied to
created an aspect with before and after which should do the same as before.
---- bean without AOP ---
public void ejbCreate() throws CreateException {
try {
Context naming = new InitialContext();
fHome = (MeasureCollectorLocalHome)
naming.lookup("java:comp/env/ejb/de.mgmedv.perfload.collector.ejb.collector");
fBean = fHome.create();
} catch (Exception ex) {
throw new EJBException("Couldn't get URL: ", ex);
}
}
public String sayHello() {
TimeInterval ti = new TimeInterval();
ti.start();
String str = "Hello World"; // this should be left in the
actual bean
ti.stop();
fBean.collectMeasuring(ti);
return str;
}
---- end of code ----
I have to extend the ejbCreate and the actual method where I want to
measure.
In a first step I only replaced the measure part and created an aspect
for that.
But the problem is that the fBean null in my measure aspect.
when I decompile the bean I get the method like this:
public String sayHello() {
String str;
BasicTimeAspect.aspectOf().ajc$before$de_mgmedv_perfload_collector_aspects_AbstractTimeAspect$513(ajc$tjp_0);
str = "Hello World";
goto _L1
throwable;
BasicTimeAspect.aspectOf().ajc$after$de_mgmedv_perfload_collector_aspects_AbstractTimeAspect$5a3(ajc$tjp_0);
throw throwable;
_L1:
BasicTimeAspect.aspectOf().ajc$after$de_mgmedv_perfload_collector_aspects_AbstractTimeAspect$5a3(ajc$tjp_0);
return str;
}
For me it looks like that I don't have access to the variable I defined
in the ejbCreate. Later, the part of the ejbCreate method has to be an
aspect as well.
How can I solve this problem?
The best solution for me would be If I specifiy in which functions I
want to measure and the ejbCreate of this Bean is changed automatially
as well.
Is this possilbe somehow? - When I have both modifications in One aspect
I sould have access to the variables as well - Am I right?
Thanks,
Michael Dempfle