Adding a Simple Business Method


To add a business method:

  1. Choose the Add | Business Method popup menu item from an enterprise bean's node (as shown in Figure 11-7), or choose EJB Methods | Add Business Method by right-clicking in the Source Editor for a bean implementation class (as shown in Figure 11-8).

    Figure 11-7. Projects window and adding a method to an enterprise bean

    Figure 11-8. Source Editor and adding a method to an enterprise bean

  2. In the Add Business Method dialog box (shown in Figure 11-9), enter a method name, a list of parameters and their type, and possible exceptions that will be thrown by this business method.

    Figure 11-9. Add Business Method dialog box

    Notice the change inside the bean implementation Java file (as shown in Figure 11-10). It now contains the new business method body, and now you can use the capabilities of the IDE's Source Editor to finish the implementation of the method.

    Figure 11-10. Source Editor with new business method added

  3. When you are done coding the method, right-click your project's node in the Projects window and choose Build Project to trigger the compilation of the Java files and the creation of the EJB archive (JAR) file in the dist directory.

It is also possible to use the IDE's editor hints mechanism to synchronize business method implementation and definition in the interface. If you type a new business method in the Source Editor, and then select the method name in the Source Editor, the IDE displays hints. One of them is Add to Local Interface, as seen in Figure 11-11.

Figure 11-11. Editor Hints for EJB Business Methods


After selecting this hint, you can verify that the definition was added in the interface and that the EJB has a new Business Method (as shown in Figure 11-12).

Figure 11-12. EJB new Business Methods




NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net