Choose EJB to be injected without recompiling

后端 未结 3 832
离开以前
离开以前 2020-12-21 01:11

Imagine you have two implementations of a @Local interface

@Local
public interface LocalInterface {
}

@Stateless
public class MyFirstImplementa         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-21 01:50

    You can achieve it using the deployment descriptor - ejb-jar.xml. Something like this (might not be 100% accurate, but I think you've got the point):

     
       
          
             MyClass
             
                ejb/myLocalReferencedBean
                Session
                com.yourpackage.LocalInterface
                MyFirstImplementation
                local
             
          
    
          
             MyFirstImplementation
             
          
          
             MySecondImplementation
             
          
       
    
    

    Another way is to use the CDI as described here: Inject @EJB bean based on conditions

提交回复
热议问题