We will create a session bean that wraps access to the company behind a session bean interface. This is another example of the Data Access Object (dao) pattern. This is one of the typical ways we use a session bean.
This dao looks pretty much the same as the session bean from our first EJB example. As with the first example, we’ve placed the interface in one package and the implementation (the session bean) in a second interface.
CompanyDao.java
To create this interface:
Expand Ejb3Tutorial2 and select the src directory
Right-click, select New::Interface
Enter dao for the package and CompanyDao for the name
Click Finish
Type the code into the file and save it
CompanyDaoImpl.java
To create this class:
Expand Ejb3Tutorial2 and select the src directory
Right-click, select New::Class
Enter dao.impl for the package and CompanyDaoImpl for the name
Comments