devxlogo

Look Up a Bean Interface in EJB 3.0

Look Up a Bean Interface in EJB 3.0

In principle, in EJB 3.0, you can access a bean from another bean by looking it up in the interface (local or remote). Here are two solutions for doing that:

  1. Through the JNDI, you still have the portability:
    //get the default JNDI initial contextContext ctx=new InitialContext();//get the bussiness interfaceObject obj=ctx.lookup(BusinessInterface.class.getName());//convert objBusinessInterface bi=(BusinessInterface)obj;
  2. Through the @EJB annotiation:
    @EJB BusinessInterface bi;   //cooool !

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist