Home

 

Defining the business interface

In EJB 3.0, a session bean implements a business interface, which is the interface clients use to access the session bean. The session bean can implement multiple interfaces, for example a local interface and a remote interface. We keep it simple with one local interface, EJBBankService.

The session bean wizard has created the EJBBankService interface. To complete the code:

Open the EJBBankService interface. Notice the @Local annotation.

In the Java editor, add the methods to the interface (Example | 4-5). The code is available in c:\7672code\ejb\source\EJBBankService.txt.

Example 14-5 Business interface of the session bean

@Local
public interface EJBBankService {
	public Customer getCustomer(String ssn) throws ITSOBankException;
	public Customer[] getCustomersAll();
	public Customer[] getCustomers(String partialName) 
														throws ITSOBankException;
	public void updateCustomer(String ssn, String title, String firstName,
									String lastName) throws ITSOBankException;
	public Account[] getAccounts(String ssn) throws ITSOBankException;
	public Account getAccount(String id) throws ITSOBankException;
	public Transaction[] getTransactions(String accountID) 
													throws ITSOBankException;
	public void deposit(String id, BigDecimal amount) 
														throws ITSOBankException; 
	public void withdraw(String id, BigDecimal amount) 
														throws ITSOBankException; 
	public void transfer(String idDebit, String idCredit, BigDecimal amount)
														throws ITSOBankException;
	public void closeAccount(String ssn, String id) 
														throws ITSOBankException; 
	public String openAccount(String ssn) throws ITSOBankException; 
	public void addCustomer(Customer customer) throws ITSOBankException;
	public void deleteCustomer(String ssn) throws ITSOBankException;
}

Organize the imports (press Ctrl+Shift+O). Select java.math.BigDecimal and itso.bank.entities.Transaction when prompted. Save and close the interface.
ibm.com/redbooks