Adding Enterprise Beans, Files, and Libraries to Your EJB Module


Once you have created an EJB Module project by using the New Project wizard, you can start populating it with new enterprise beans and helper Java classes. The most straightforward way to create files is to open the Projects window, right-click the node where you want to place the file, and choose New and then select a template from the submenu. A short wizard appears for the template, enabling you to set the name and other characteristics of the file. For example, choose the Session Bean template, as shown in Figure 11-4.

Figure 11-4. Adding a file to an EJB module


The wizard will create a session bean and add it to the EJB module. You can specify the bean name and package (make sure you select or create a Java package). You can specify whether this session bean will have a local and/or a remote interface (local is the default) and whether the bean is stateful or stateless. Accept the default values to create a local stateless session bean, as shown in Figure 11-5.

Figure 11-5. New Session Bean page of the New File wizard


Notice the new logical representation of the enterprise bean in the Projects window under the Enterprise Beans node (shown in Figure 11-6). This enterprise bean is a set of Java files (four for a simple session bean):

  • The local interface (BeanNamelocal.java)

  • The local home interface (BeanNameLocalHome.java)

  • The bean implementation itself (BeanNameBean.java)

  • The business interface (BeanNameLocalBusiness.java)

Figure 11-6. Projects window showing a new enterprise bean


The Projects window's logical view hides the complexity of this enterprise bean by showing only a single node that exposes some important methods for the bean, like the local methods.

"Where are my Java files?" When you work with an enterprise bean's node in the Projects window, you do not see all of the Java files and deployment descriptors that are part of the bean. NetBeans IDE keeps all of these files synchronized automatically when you work with the bean's node. If you want to see the individual Java files, you can browse them within the Source Packages node.




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