[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] ConcurrentModificationException
|
Ciao Luca,
Luca Ferrari wrote:
> I thought it was only thrown by different threads. Now I solved the
> problem.
>
Great! :)
> The fact is that I've got a WorkerThread that, thru reflection, invokes the
> loadAll method on a few classes. So I've got two entry points for the load all
> method call and execution: a direct call and an invocation thru reflection in
> the worker thread. That's why I'm catching both situations.
>
Makes sense ...
> Since we are talking about that....I've got to extract the target class (i.e.,
> the class on which the static method is invoked) in the following way:
>
> before() : emptyLazyLoadingCache(){
>
> // from where I'm calling loadALl?
> Class declaringClass =
> thisJoinPointStaticPart.getSignature().getDeclaringType();
> Class ownerClass = null;
> if( declaringClass.getName().equals("g2.gui.workers.TableSwingWorker") ){
> // obtain the loading class
> TableSwingWorker worker = (TableSwingWorker) thisJoinPoint.getThis();
> ownerClass = worker.getLoadingClass();
> }
> else{
> ownerClass = thisJoinPointStaticPart.getSignature().getDeclaringType();
> }
>
>
> }
>
>
> that is not very elegant, is there another smarter way to pass the class
> context to the advice in both cases?
>
from an AspectJ POV there are no two cases, in both cases by using
thisJoinPointStaticPart.getSignature().getDeclaringType();
you are getting it. You could rewrite it to make it simpler :
Class declaringClass =
thisJoinPointStaticPart.getSignature().getDeclaringType();
if (declaringClass instanceof TableSwingWorker) declaringClass =
((TableSwingWorker)thisJoinPoint.getThis()).getLoadingClass();
But no other standard way arise to my mind.
Ciao,
Simone
--
Simone Gianni CEO Semeru s.r.l. Apache Committer
http://www.simonegianni.it/