I have been going through some Spring / AOP tutorials and have somewhat familiarized myself with the related concepts.
Now coming to my requirements, I need to create an Activities Log implementation which will save the activities of a logged-in user in the DB which can range from applying for a service or creating new users in case of Admin
users, etc. On invocation of any method having an annotation (say @ActivityLog
), this information is to be persisted in the form of actorId
, actionComment
, actionTime
, actedUponId
, ... etc.
Now, if I create a POJO class (that maps to a ActivityLog
table in the DB) and want to save this data from inside the Advice
(preferably using the same transaction as the method, method uses @Transactional
annotation), how do I actually populate the variables in this POJO?? I can probably get the actorId
from the session object & actionTime
can simply be new Date()
but how about the dynamic values for actionComment
/ actedUponId
?
Any help will be brilliant! (BTW, I have a requirement to not use Hibernate Interceptors.)