• Post Reply Bookmark Topic Watch Topic
  • New Topic

Concurrency and AspectJ

 
Emil Jennings
Ranch Hand
Posts: 75
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope this is the right place for this question...I have a main class



It is advised by the following aspect:


ProcessOne and ProcessTwo are classes that have methods to display the lists. The problem is with line 46 in the aspect, I don't know what this should return. The idea is that if the list is not empty the code should proceed with the call to ProcessOne or ProcessTwo, and if the list is empty then do not execute the call. This works with lists that have data, but as you can see by line 38 in StartPoint, the list is empty. The return null causes the newP1List = p1Service.take().get(); at line 41 to sit and wait. Any thoughts?

TIA.
 
Emil Jennings
Ranch Hand
Posts: 75
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After some more thought, I had to change the aspect up a bit to:



Instead of checking for an empty list at the call, it is checked at execution. Also the aspect is used on a percflow basis so a separate instance of the aspect is created by each submit statement in StartPoint. I separated the two interfaces in case I want to implement of methods that may use this aspect but may only need one of the interfaces. StartPoint was also slightly changed to:



So this is one way lists can be checked to see if they are empty in a program that uses concurrency. I know that the .isEmpty() could've been used, but when you're working with a bunch of lists in a single method .isEmpty() gets redundant and since one of the purposes of AspectJ is to remove this sort of redundant code, I thought this was a good idea.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!