Creating session beans using local business interface

Business interface for the EJB is a simple Java interface annotated either with @Remote or @Local. Therefore, we can create a local interface for a student bean as follows:

import java.util.List; 
import javax.ejb.Local; 
 
@Local 
public interface StudentLocal { 
  public List<Course> getCourses(); 
} 

Furthermore, we can implement a session bean as follows:

import java.util.List; 
import javax.ejb.Local; 
import javax.ejb.Stateful; 
 
@Stateful 
@Local 
public class Student implements StudentLocal { 
  @Override 
  public List<CourseDTO> getCourses() { 
    //get courses are return 
... 
  } 
} 

The client can access the Student EJB only through the local interface:

import javax.ejb.EJB; 
import javax.faces.bean.ManagedBean; 
 
@ManagedBean 
public class StudentJSFBean { 
  @EJB 
  private StudentLocal student; 
} 

A session bean can implement multiple business interfaces.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.41.205