Speaking of the Haojie in the EJB development tool, it is estimated that everyone will consistently think that Non-jbuilder is not, in fact I think so. But recently IECLIPSE is also good. Although there is no strong "EJB Desiner View" support as JB, it is not inferior to XDoclet's versatile and flexible, which makes MyEClipse in front of JB.
If you want to read this article, you have a rich development experience. I have my own ability to do, find, solve the problem, so I will not mention the details of Eclipse and MyEclipse installation configuration, let us start from the WebLogic configuration under MyEclipse. . Look at the graphic:
(Figure 1: WebLogic configuration)
According to your own actual situation, configure many parameters of the above picture, don't forget to click on "Apply" and "OK" buttons, don't forget the similar operations later.
(Figure 2: New an EJB project)
Select a "J2EE - EJB Project" and then NEXT.
(Figure 3: New an EJB Procedure)
Note: Because the current XDoclet version only supports J2EE 1.3, in order to use the xdoclet from the code and configuration description files of the EJB interface, you should choose the J2EE 1.3 specification level.
(Figure 4: New an EJB project is completed)
The project is created, you can see the initial directory structure.
(Figure 5: New a sessionbean module)
Started to create our first sessionBean. "J2EE - EJB - Session Bean" is so simple.
(Figure 6: Create period parameter)
The red frame is represented by the red frame, which is required to pay special attention, explain the following: 1. In order to adapt to the usual method of XDoclet, the package name of the Bean class of the EJB component should be ".ejb", the bean class name should be "" Bean "or" EJB "ends, here I use" bean ". 2. If this bean class is directly used without expansion, a "ejbcreate" method should be implemented. If you use it after the expansion, then you can put it in the subclass and implement it.
(Figure 7: SessionBean is created)
The initial sessionBean code is created. You can see the current directory structure in the left "package explorer". You can see the XDoclet automatically generated code in the right code window. There are some of the various interface code and deployment description documents. The xdoclet tag used, the mark here is very light, and everyone understands that, if you want to change the deployment JNDI name to meet the specific statute requirements of the project, you can modify the red boxes marked in the figure.
(Figure 8: Start xDoclet configuration)
OK, now the most important and most complicated step: XDoclet configuration. In fact, JBuilder's code automatically generated behind the scenes is also XDoclet, but Borland is packaged in a strict, it is transparent to developers. This is a fool, which reduces the difficulty of configuration, and the disadvantages Obviously - loss of flexibility known in xDoclets. MyEclipse provides many standard XDoclet templates, and we can use it directly to customize the number of parameters of the flexible flexible according to the actual situation.
(Figure 9 :)
Add a "Standard EJB" configuration
(Figure 10: Remove unwanted items)
Turn off our current works, such as Dao, DataObject, EntityBMP, EntityCMP, Entitypk, ValueObject, Utilobject. The configuration shown in Fig. 12 is obtained. (Figure 11 :)
(Figure 12 :)
Add a WebLogic deployment description option, then configure it according to actual needs.
(Figure 13 :)
Configure CreateTables and set to AlterorCreate so you can share a deployment description file when you add other EJB components.
(Figure 14 :)
Configuring DESTDIR is the directory where the weblogic-ejb-jar.xml file is located.
(Figure 15 :)
Configure Version, go to two version numbers according to the actual WebLogic version, I use 811, here is set to 8.1.
(Figure 16 :)
Choose Use a dynamic xdoclet configuration file or a static xdoclet configuration file, use the default "dynamic" mode.
(Figure 17 :)
OK, XDoclets can then generate our expectation code and documentation according to its profile.
(Figure 18 :)
XDoclet execution process.
(Figure 19 :)
Finished, look at the file in the red box, how? Sure enough, don't you lose? Here, a remote interface, a local interface, a remote home interface, a local Home interface, an EJB-jar.xml, WebLogic-Ejb-jar.xml, and other files.
(Figure 20 :)
Here is a remote interface. Look at the highlights in the figure, as the name suggestions, replace the sample business method generated by the XDoclet template with your own business method.
(Figure 21 :)
Here is a bean class. It is also an example method to replace the actual business method.
(Figure 22 :)
The code is written, and the file is also finished, um, the deployment.
(Figure 23 :)
The deployment process is simple. Look at the picture, select our "Hello" project in the "Project" option, then click the "Add" button to add a deployment.
(Figure 24 :)
Deploying a WebLogic8 server configured in the article to use JAR packets.
(Figure 25 :)
After the configuration, the startup WebLogic looks. :) BTW, the use of offline deployment (or called "cold deployment"), that is, WebLogic is not started during deployment, this time if the EJB component contains an error that can be discovered in the deployment, then this phase will not Received reports, of course, we can also use online deployment ("hot deployment"?) To instantly deploy possible exception, easy, yourself try it.
(Figure 26 :)
What should I do after deploying? Looking at the screen to stay? Ha ha. . Still writing a client to test your EJB component is not working properly. As shown in the figure, the package and class names have no hard rules other than the basic Java specifications, just habits to set the suffix of the class name to "TestClient".
(Figure 27 :) Because we want to use WEBLOGIC's initial contextFactory, we should import WebLogic's library, which is WL_HOME / Server / lib / weblogic.jar. Of course, this step is not necessarily to do it here, anyway, you can run before the test program is running.
(Figure 28 :)
The actual code of our test client is written, look at the picture, then the two thirty lines of classic code is very simple?
(Figure 29 :)
Calling WebLogic, starting together ~
(Figure 30 :)
WebLogic launched successfully, which will automatically load our EJB components we just reinforced during the startup process. This time no exception is reported, indicating that our EJB component is correct.
(Figure 31 :)
Execute our test client to get the expected output.
(Figure 32 :)
Then observe the WebLogic console, which is also the feedback we expect, Yeah, the homage, and eating.
If you have any questions, please reply to discuss together. I hope I have the opportunity to discuss the development of EntityBean next time, and next is MessageDriveNbean, and integrated examples. :)
Reference: "MyEclipse Application Developer Guide".