views:

463

answers:

1

I want to define injection so that only if the injected interface has EJB it will be injected. This is used as a plug-in to the main EJB. How to do this? Is there some annotation for this?

I can use @PostConstruct to manually "inject" the variable. But then I have to handle the dependencies by myself. How can I handle dependencies knowing that one of them is optional? How do I handle the order of deployment of different dependent modules.

Update: I see that google has an inject annotation with optional parameter:

import com.google.inject.Inject;
@Inject(optional = true)

Update 2: JBoss has something that may be what I'm looking for:

import org.jboss.annotation.IgnoreDependency;
@IgnoreDependency @EJB OtherBean otherBean;
A: 

The solution would be to use JNDI and not injection in this particular case. That way I have full control over the dependencies.

Vitaly Polonetsky