
EJB
™
Development Using Borland
®
JBuilder
®
8 and BEA WebLogic Server
™
7.0
27
Figure 16: Visual EJBs in JBuilder displaying the fields and methods of entity and session
beans
Open EmployeeSesBean.java in the editor pane ( right-click EmployeeSes and click View
bean source) and change the getEmpName(Short empNo) method as follows”
public String getEmpName(Short empNo) {
String empName = "name not found";
try {
javax.naming.Context context = new
javax.naming.InitialContext();
Object object = context.lookup("java:comp/env/ejb/Employee");
EmployeeHome empHome = (EmployeeHome)
javax.rmi.PortableRemoteObject.narrow(object, EmployeeHome.class);
Employee emp = empHome.findByPrimaryKey(empNo);
empName = emp.getFirstName() + " " + emp.getLastName();
}catch (NamingException ex) {
ex.printStackTrace();
}catch (ClassCastException ex) {
Comentários a estes Manuais