good time of day tell me where I was wrong. It is impossible to implement the method-producer for injection. when trying to get an iterator from Instace, a new instance of the class is invoked with the method-producer, which leads to the recursive call to the method-produсer, but here https://stackoverflow.com/questions/18992641/java-cdi-dynamically-selecting-an -implementation-based-on-qualifier has a similar problem, but it seems I can't make it so that the instance-producer would fall into an instance, and the invocation of the new instance is performed at the iterator iterator call stage it = instance.iterator (); and not at the stage of iteration, the target class HttpAmClientTransportBean.class, in turn, is the successor of the abstract Generic `and BaseAmClientTransport

Class where injection occurs

public class RESTfulAmClientBean extends BaseAmClient<RESTfulAmClientBean> implements RESTfulAmClient , Serializable{ @Inject private Logger logger; @Inject @AmClientTransportProducer private AmClientTransport restfulAmClientTransport; 

Class with method-producer

 public class AmClientTransportProducerBean implements AmClientTransportProducer { @Inject Logger logger; @Inject private AmObjectApiSettingsManager settMgr; public AmClientTransportProducerBean() {} @Override @ru.iteco.amobjectapi.amclients.transports.annotations.AmClientTransportProducer @Produces public AmClientTransport getAmClientTransport(@Any Instance<AmClientTransport> instance ,InjectionPoint ip){ logger.debug("транспорт producer isAmbig:" + instance.isAmbiguous() + " isUnsatt:" + instance.isUnsatisfied()); instance.select(HttpAmClientTransportBean.class); logger.debug("транспорт producer isAmbig:" + instance.isAmbiguous() + " isUnsatt:" + instance.isUnsatisfied()); Iterator<AmClientTransport> it = instance.iterator(); logger.debug("hasNext:" + it.hasNext()); if(!instance.isUnsatisfied()){ for (AmClientTransport transport : instance){ logger.debug("transport class name is : " + transport.getClass().getName()); } }else{ logger.error("no AmClientTransport Implementations"); } return null; } 

HttpAmClientTransportBean class

 @Stateless(mappedName = "HttpAmClientTransport") @Local(HttpAmClientTransport.class) @RestfulAmClientTransport @UnSecure public class HttpAmClientTransportBean extends BaseHttpAmClientTransport<HttpAmClientTransportBean> implements HttpAmClientTransport { /** * Default constructor. */ public HttpAmClientTransportBean() { super(); } /* (non-Javadoc) * @see ru.iteco.amobjectapi.amclients.transports.http.HttpAmClientTransport#getAmClientType() */ @Override public Class<HttpAmClientTransportBean> getAmClientType() { return HttpAmClientTransportBean.class; } @Override public void execute(){ } 

}

    0