2

Is there any way an injectee(EJB, say) know its own injection point?

@Stateless
public class SomeService {

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

    @Context
    private InjectionPoint injectionPoint; // is this possible?
}
Jin Kwon
  • 20,295
  • 14
  • 115
  • 184

1 Answers1

4

If you are injecting your EJB with CDI (using @Inject) and if it has the default scope (no explicit scope or @Dependent).

You can inject its injection point:

@Stateless
public class SomeService {

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

    @Inject
    private InjectionPoint injectionPoint; // this is possible
}
Antoine Sabot-Durand
  • 4,875
  • 17
  • 33