vendredi 26 juin 2015

I am already stuck solving injection of bean implementations into javax.enterprise.inject.Instance<SomeIFace>. I have couple of beans (EJB Singletons) which extend an abstract class which implements the SomeIFace - see the scenario below.

public interface SomeIFace {

    void doStuff();
}

Then there is an abstract class adopting the SomeIFace as follows:

public abstract class SomeAClass implements SomeIFace {

    @Resource
    private TimerService ts;

    public TimerService getTimerService() {
        return ts;
    }

    @Timeout
    public void timeout() {
        doStuff();
    }
}

Actual implementation of a managed bean extends the abstract class SomeAClass as follows:

@Singleton
@Startup
@TransactionManagement(TransactionManagementType.BEAN)
public class SomeClass extends SomeAClass {

    /**
     * {@inheritDoc}
     */
    @Override
    public void doStuff() {
        ...
    }
}

Then in another class I want to get references to all managed beans implementing the SomeIFace, i.e.:

@Inject
@Any
private Instance<SomeIFace> beans;

The problem is that the beans is empty!

When I add the SomeIFace to the implementing bean class explicitly again (i.e. public class SomeClass extends SomeAClass implements SomeIFace), the beans is not empty and a reference appears.

Is anyone able to explain, why I need to repeat the SomeIFace interface directly on bean implementations again to get CDI 1.2 working? In previous version of CDI it was working fine.

Thank you in advance!

Jiri

Aucun commentaire:

Enregistrer un commentaire