This was both easier and harder than I thought it would be. First all you need to do to get the target is call thisJoinPoint.getTarget() and cast it to whatever it is.
Now the harder part was adding an interface and class variable to multiple classes that match a
pattern. This was the only way I could guarantee each class that matches the pattern could be acessed with genetic code.
In order to add methods and variables to a class you need to have a marker interface. In the following code snippet I have two interfaces that are real that require methods. I define the other method within the aspect.
Declare the required methods of the real interfaces (ApplicationContextAware, ApplicationContextRetrievable) using the local marker interface (Auditable). The context setter method is required for ApplicationContextAware. I needed a getter method too. So I created the ApplicationContextRetriever interface for that.
You have to do it this way bacause AspectJ does not allow you to add a single method or variable to a class pattern with wild characters. You have to use the interface. And you cannot use external interfaces to add. So use an internal marker interface to add actual methods for real interfaces. Seems odd. But that is how it is.
What this code does is, to all the methods that match the pattern com.mycomp.*.*(..), adds the ApplicationContextAware interface , a class variable context, and setter/getter methods for the context variable.
Here comes the magic. Now that the classes are ApplicationContextAware, Spring will automatically call the setter when it loads the bean and then the before() advise will be able to call the getter. Now you have access to each bean's ApplicationContext without having to tie each bean to Spring in its code.