aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs169/pr295491/SpringConfigurableMixin.java
blob: bfcda0f8103d641135422c3d4cf78e416831f0b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
    }    
}