Using AOP for non services

https://github.com/jembi/openmrs-module-msfcore/blob/MOO-14-registration-fix/api/src/main/java/org/openmrs/module/msfcore/MSFCoreActivator.java

use the MOO-14-registration-fix branch

Sorry, I didn’t realize you were working on a different branch, now I see the activator and dependency in the branch. Then you need to fix the dependency issues first to resolve the class loading issue, your aspectj config looks correct to me even though I doubt if the point cut expression will work.

am not sure which dependencies or class loading are a problem, all works well without aspectj which makes me doubt if its not it causing issues even when logs are not straight

I think the issue has to do with the way proxies are handled in spring i.e cglib vs jdk proxies, those offending classes from the app framework module in the logs don’t implement any interface so they are autowired by the target class.

1 Like

now u are getting to my problem, any recommendations on how to resolve this proxy conflict

how is this in your evaluation of this blocker then?

CC: @dkayiwa, @wyclif, did u guys see my above response?

I thought you were doing a throw away module to reproduce the problem.

sorry just found some time to do that, here is the throw away module it actually looks like its now a classloading issue that i can’t figure out why it happens with aspectj on my classpath in the shortest time i had to check it out again

Looks like you’re missing the apsectjrt library that contains that class.

that happens even with apsectjrt, i also tried various libraries that provide aspectj

Sometimes saying it doesn’t work even when I add it isn’t enough, because we don’t know exactly what you are doing or what mistake you could be making.

FYI, I don’t seem to see it in the pom file of the project you shared anyways, sometimes if you have duplicate libraries you end up with class loading issues too, you might want to use maven dependency tree plugin to first confirm that it’s not included, before you add it.

Sorry for the typos! I’ve edited the post

i hope u are not saying i sound junior man, i wrote that sample module for any to take a look and spent some minutes following out the dependency issues, that’s how i found aspectj in spring etc. any ways, i plan to spend on time on this in the future if none has taken a look then

Was just saying sometimes it’s nice to give more details on the actual changes you tried to make and the error message for those other changes.

Are you sure only including spring aspects automatically includes the aspectrj dependency?

You need to clean up the OpenMRS dependencies because they are missing in the api sub project which leads to compilation issues and the pointcut expression also needs to be fixed.

@k.joseph sorry that I haven’t been following this thread at all, but assuming your use case is to track login/logout events, you could consider contributing this as an openmrs-core feature, rather than trying to catch it via AOP.

For example in core we have PrivilegeListener and in fact this is used within UserContext (see here). It seems appropriate to add an analogous listener for login/logout events.

1 Like

sure thanks @darius for the suggestion, i completely agree, actually looking through that pivilegeLister made me figure out some previous hasPrivilege issue.

I have this morning had some minutes on this and wired a pull request through https://issues.openmrs.org/browse/TRUNK-5416

Sounds good to add it as a core feature but I was guessing he was looking for a short term solution before a new version with the feature is released.

am actually happy building off the latest core since i suspect more feature contributions our current project may get into core