EJB Interfaces

This page discusses - EJB Interfaces

EJB Interfaces

EJB Interfaces

     

Interface in java means a group of related methods with empty bodies. EJB have generally 4 interfaces. These are as follows

1)Remote interface:- Remote interface are the interface that has the methods that relate to a particular bean instance. In the Remote interface we have all get methods as given below in the program. This is the interface where all of the business method go.javax.ejb.Remote package is used for creating Remote interface.

package ejb;

import javax.ejb.Remote;

@Remote
public interface Bean30Remote {

String getMessage();

String getAddress();

String getCompanyname();
}


2)Local Interface:-Local interface are the type of interface that are used for making local connections to EJB.@Local annotation is used for declaring interface as Local. javax.ejb.Local package is used for creating Local interface.

package ejb;

import javax.ejb.Local;

@Local
public interface NewSessionLocal {

}


3)Home Interface:-
Home interface is the interface that has methods that relate to all EJB of a certain class as a whole. The methods which are defined in this Interface are create() methods and find() methods . The create() method allows us to create beans. find() method is used in Entity beans.

import javax.ejb.EJBHome;
import javax.ejb.CreateException;
import java.rmi.RemoteException;

public interface Bean30RemoteHome extends EJBHome{
public Bean30Remote create() throws CreateException, RemoteException;
}


4)Localhome Interface:-The local interfaces extend the following interfaces. These interfaces are generally for use by clients
 javax.ejb.EJBLocalObject - for the Object interface
 javax.ejb.EJBLocalHome - for the Home interface 

package ejb;

import javax.ejb.EJBLocalHome;
import javax.ejb.CreateException;

public interface NewSessionLocalHome extends EJBLocalHome {
public NewSessionLocal create() throws CreateException;
}