一个injectee可以知道自己的InjectionPoint吗?

Can an injectee know its own InjectionPoint?

被注入者(比如 EJB)有没有办法知道自己的注入点?

@Stateless
public class SomeService {

    @PostConstruct
    private void constructed() {
        // do post construction job
        // according to the injectionPoint
    }

    @Context
    private InjectionPoint injectionPoint; // is this possible?
}

如果您使用 CDI 注入 EJB(使用 @Inject)并且它具有默认作用域(没有显式作用域或 @Dependent)。

你可以注入它的注入点:

@Stateless
public class SomeService {

    @PostConstruct
    private void constructed() {
        // do post construction job
        // according to the injectionPoint
    }

    @Inject
    private InjectionPoint injectionPoint; // this is possible
}