Hi, Im having trouble with my code after migrating to this version of play.
Im using hibernate envers library to generate audit trails.
I have extendend the envers library to add the username to the revision info table. This is done with the followign class.
public class ExtendAuditEntityListener implements EntityTrackingRevisionListener {
/**
* Completa la data de la entidad con información auditable.
*
* @param entityClass
* @param entityName
* @param entityId
* @param auditType
* @param auditEntity
*/
@Override
@Transactional
public void entityChanged(
@SuppressWarnings("rawtypes")
Class entityClass, String entityName, Serializable entityId, RevisionType auditType, Object auditEntity) {
IITSecurity.IITAuthenticator actionAuthenticator = new IITSecurity.IITAuthenticator();
Optional<String> login = actionAuthenticator.getUsername(play.mvc.Controller.ctx().request());
String loginStr = "";
if (login != null)
loginStr = login.get();
ExtendAuditEntity audit = (ExtendAuditEntity) auditEntity;
audit.setLogin(loginStr);
audit.addModifiedEntityName(entityClass.getName());
}
}
my issue is that play.mvc.Controller.ctx().request() is deprecated, and dont know how to replace it. I have try to inject the httpcontext in this class but im getting this error during runtime.
Error injecting constructor, org.hibernate.InstantiationException: Could not instantiate managed bean directly : model.entities.generic.ExtendAuditEntityListener
Please any advise is welcome!
Thanks, Sergio