| RE: [aspectj-users] How to access "withincode" type |
|
Thanks Ramnivas. It
works now. I can see my advice being called. However, I seems like it introduced
a new problem. In my around advice,
"thisJointPoint" gives me an instance of my aspect which doesn @Pointcut("call(*
java.sql.Statement+.execute* (..)) && @withincode(profiling)") void
profilingSQLExecute(com.xyz.Profiling profiling) {} @Around("profilingSQLExecute(profiling)") public Object
profilingSQLExecute(final ProceedingJoinPoint thisJoinPoint, final
com.xyz.Profiling profiling) throws Throwable Sorry if I DP From:
aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Ramnivas Laddad Dipak, On Jan 24, 2008 4:02 PM, Parmar, Dipak (IS Consultant) <DParmar@xxxxxxxxxxxxxxxxxxx>
wrote: Thanks Dean. With your suggested pointcut definition, I get
a compilation error -- name pattern expected. I don @Pointcut("call(*
java.sql.Statement+.execute*(..)) && withincode(@com.xyz.Profiling *
*(..)) && @annotation(profiling)")void
profilingSQLExecute(com.xyz.Profiling profiling) {} Dipak From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx]
On Behalf Of Dean Wampler I presume
you want the object of the class that implements
"makeProfileDataBaseCall". I @Pointcut("call(*
java.sql.Statement+.execute*(..)) && withincode(@com.xyz.Profiling *
..ProfileMaker+.*(..)) && target(profileMaker) &&
@annotation(profiling)") void
profilingSQLExecute(ProfileMaker profileMaker, com.xyz.Profiling profiling) {} (I forgot
what you called the pointcut method before, so I just made up a name). Note
that you use "target()" and "@annotation" to bind the
object and annotation, respectively, to variables declared in the method. These
variables will then be available in the advice, so you can get the value of the
annotation, etc. The advice method would require the same argument
signature. Notice
also that I used "..ProfileMaker+" to refer to any subclass (i.e.,
implementer) of the interface and I used ".." before the name, which
is the package wildcard with arbitrarily-deep nesting. HTH, dean On Jan
24, 2008, at 12:48 PM, Parmar, Dipak (IS Consultant) wrote: Here
is my pointcut definition @Pointcut("call(*
java.sql.Statement+.execute*(..)) && withincode(@com.xyz.Profiling *
*(..)) ") Here
is my sample mathod
@Profiling(type=ProfilingType.JDBC)
public void makeProfileDataBaseCall() {
.............
CallableStatement statement = connection.prepareCall("{
call PACKAGE.PROCEDURE(?) }");
statement.execute();
........................
} How
I can
get an instance of
"makeProfileDataBaseCall"
method and its annotation? "joinPoint.getSignature()"
gives the "execute" method but
not "makeProfileDataBaseCall"
method. If
this can Thanks, DP _______________________________________________ Dean Wampler, Ph.D. dean at objectmentor.com See also: http://www.aspectprogramming.com AOP advocacy site http://aquarium.rubyforge.org AOP for
Ruby http://www.contract4j.org Design
by Contract for Java5
|