You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SpringConfigurableMixin.java 882B

123456789101112131415161718192021222324252627282930
  1. package com.j4fe.aspects;
  2. import javax.persistence.EntityManager;
  3. import javax.persistence.PersistenceContext;
  4. import javax.persistence.Entity;
  5. import org.springframework.beans.factory.annotation.Configurable;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. public aspect SpringConfigurableMixin {
  8. public static interface EntityManagerAware {
  9. EntityManager getEntityManager();
  10. }
  11. // not working
  12. // declare @type : (@Entity *) : @Configurable(autowire = Autowire.BY_TYPE, preConstruction = true);
  13. // also not working
  14. // declare @type : (@Entity *) : @Configurable
  15. declare parents : (@Entity *) implements EntityManagerAware;
  16. @PersistenceContext
  17. transient private EntityManager EntityManagerAware.entityManager;
  18. public EntityManager EntityManagerAware.getEntityManager() {
  19. return entityManager;
  20. }
  21. }