The Windows → Open Perspective → Other → Java EE perspective is opened.
You develop the EJB 3.0 classes in an EJB 3.0 project in the Java EE perspective.
...
1. Choose File → New → Project… from the main menu.
2. Choosing EJB → EJB Project on the New Project screen. Choose Next.
3. Enter ConverterEJB in the Project Name field.
4. Leave the Default Configuration for SAP Libraries in the Configurations field. The default configurations include EJB 3.0 and Java 5.0 project facets.
5. To assign the EJB project to an Enterprise Application project, choose Add project to an EAR and enter ConverterEAR in EAR Project Name field.
The ConverterEAR project is created automatically when you complete the wizard.
6. Choose Finish to create your EJB 3.0 project.
...
1. From the context menu of the ejbModule node of the ConverterEJB project choose New → Other.
2. Choose EJB → EJB 3.0 → EJB Session Bean 3.0 on the New screen. Choose Next.
3. Enter ConverterBean in the EJB Class Name field and com.sap.tutorial.javaee in the Default EJBPackage field.
4. Select Stateless in the Session Type field.
5. Select Container in the Transaction Type field.
6. Deselect the Remote checkbox for Create Business Interface.
7. Choose Finish.
8. Implement the business logic of ConverterBean by entering the following code in its body:
private BigDecimal dollarRate = new BigDecimal("1.2"); private BigDecimal euroRate = new BigDecimal("0.83");
public BigDecimal dollarToEuro(BigDecimal dollars) { BigDecimal result = dollars.multiply(euroRate); return result.setScale(2, BigDecimal.ROUND_UP); }
public BigDecimal euroToDollar(BigDecimal euros) { BigDecimal result = euros.multiply(dollarRate); return result.setScale(2, BigDecimal.ROUND_UP); } |
9. To import the additional classes that you refer in your code, choose Source → Organize Imports from the main menu.
10. To add the dollarToEuro business method to the bean’s local interface, locate the Outline view and from the context menu of the method choose EJB Methods → Add to Local Interfaces.
Repeat the same step to add the euroToDollar method to the local interface as well.
11. Choose File → Save from the main menu to save the bean.