[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-dev] A little help with perthis/pertarget ...
|
Can anyone help me refactor this aspect so that it's not a singleton? I
have attempted to use both perthis and pertarget but when I do, the
advice no longer kicks in. The aspect is actually picking out all the
methods on my EJB tier so there are multiple threads in flight here. I
want an instance of the aspect per each thread. I was and want to
simply have a "private long start;" instead of a "private Hashtable ht
= new Hashtable();" but, I had to introduce the Hashtable so my
singleton aspect would work properly. Here is my aspect as it currently
exists. Again it works as expected but, I want to utilize perthis or
pertarget as opposed to incurring the overhead with the Hashmap
approach.
package com.xxx.aspect;
import org.slf4j.*;
import javax.ejb.*;
import com.xxx.ejb.stateless.*;
import java.util.*;
/**
* Profiles
*/
aspect ProfileAspect {
private Hashtable ht = new Hashtable();
private static final Logger LOG = LoggerFactory
.getLogger("com.ing.uds.
aspect.ProfileAspect");
pointcut services(): (execution(* *Service.* (..)));
before(): services() {
ht.put(thisJoinPoint.getThis(), new Long(System.currentTimeMillis()));
}
after(): services() {
LOG.debug("{}|{}", thisJoinPoint, Long.toString(System.currentTimeMillis()-((Long)ht.get(thisJoinPoint.getThis())).longValue()));
}
}