123456789101112131415161718192021222324252627282930 |
- package com.j4fe.aspects;
-
- import javax.persistence.EntityManager;
- import javax.persistence.PersistenceContext;
- import javax.persistence.Entity;
- import org.springframework.beans.factory.annotation.Configurable;
- import org.springframework.beans.factory.annotation.Autowired;
-
- public aspect SpringConfigurableMixin {
-
- public static interface EntityManagerAware {
- EntityManager getEntityManager();
- }
-
-
- // not working
- // declare @type : (@Entity *) : @Configurable(autowire = Autowire.BY_TYPE, preConstruction = true);
-
- // also not working
- // declare @type : (@Entity *) : @Configurable
-
- declare parents : (@Entity *) implements EntityManagerAware;
-
- @PersistenceContext
- transient private EntityManager EntityManagerAware.entityManager;
-
- public EntityManager EntityManagerAware.getEntityManager() {
- return entityManager;
- }
- }
|