EJB 3.0: Business Layer

In this phase we will see how JDeveloper solves the business layer. EJB 3.0 is the standard to solve it. This is about to construct the business process, which will be called by the view, web services, …

We will base on a past post, where we  created the persistence layer for our little application.

In the EJB diagram created before, we just drag the Session Bean from the palette, to begin the wizard to create the bean:

Create EJB Session Bean

I create the bean lebrijo.services.DepartmentsServiceBean, we only select the Departments entity methods. It creates the methods: persist, merge, remove and getDepartamentsFindAll(). It creates two interfaces: local and remote, to execute the service at the same or outside the virtual machine.

JDeveloper implements a facade pattern with CRUD actions (Create-Read-Update-Delete) over the entities.

When we create th bean lebrijo.services.EmployeesServiceBean will be created the getEmployeesFindByName method, because we created this query in the past post. If you want to add more EJB-QL methods based, we could do it with contextual menu >Edit Session Facade…

To keep it simple I hold the interfaces in a subpackage called services.interfaces.

We can test the service with right button over EmployeesServiceBean > Create Sample Java Client, with we create lebrijo.test.EmployeesServiceClient:

Create Test client
We will write the parameter “%P” to find the employee whose name starts with P.

            for (Employees employees : (List<iployees>)employeesService.getEmployeesFindByName( "P%" )) {

Making ‘Run’ with contextual menu over EmployeesServiceBean, Weblogic starts deploying the application. An making ‘Run’ over EmployeesServiceClient, it will be executed the test: it shows the log of the server with all employee whose name starts with P:

Testing …

Leave a Reply

Your email address will not be published. Required fields are marked *