The journey of EJB Technology (III.)

Source: Internet
Author: User

Common development patterns for EJBS

This article's application server takes WebLogic as an example, the other server process is similar.

In the Java-EE platform, the development of EJB is the most important part. This article tries to describe the common development patterns and methods from several aspects. Whether it is for beginners, or experienced friends have a certain reference value.

As you know, EJB is a very headache for beginners, whether it is development or release, testing, especially entity beans more headaches, so this article introduces several methods for design, development, testing, for reference.

WebLogic platform, as the industry's best products, itself provides a lot of excellent tools to develop, publish Java EE applications. Beyond that, and other integrated development environments, such as JBuilder, Visualcafe, and together ControlCenter, which supports the entire process of software development. With the support of the industry in such a way, the application of WebLogic platform is more extensive.

The first way:

Develop EJBS with generic software, such as JCreator, EditPlus, and so on. For beginners, this way is better, the EJB mechanism can have a more in-depth understanding. After writing, place all the EJB source files in a directory of SRC and create a directory deployment in the current directory (parallel to the SRC directory). And the written configuration description file Ejb-jar.xml and weblogic-ejb-jar.xml copy directory deployment. You can then copy the following batch file to the parent directory of the directory SRC, and then run the batch file. (Of course, you need to set CLASSPATH and related variables before this, and you'll know by yourself)

//用于编译打包EJB的批处理文件compilejar.bat:
mkdir classes
mkdir lib
mkdir classes\META-INF
copy deployment\*.xml classes\META-INF
javac -d classes src\*.java
cd classes
jar cf ..\lib\temp.jar *
cd ..
cd lib
java weblogic.ejbc -keepgenerated temp.jar xxxEJB.jar
del temp.jar
cd ..
//最终,我们得到了XXXEJB.jar,也就是可以用来直接在WebLogic中发布的jar文件

We use WEBLOGIC.EJBC to compile EJB, the old version of WebLogic is WEBLOGIC.EJBC20. (Note: The compilation of EJB in WebLogic is precompiled, that is, it generates all the target files required for the EJB, but some application servers are not, for example, JBoss is generated dynamically during runtime with the help of reflection mechanism!) )

So we got Xxxejb.jar and posted it on WebLogic. There are two ways to choose if you don't use other tools to weblogic your own assistive tools. First of all, through the console, this is the easiest way, you should generally know how to get it. Second, through the WebLogic provided by the Startwlbuilder.cmd tool. The first thing to connect to WebLogic is when you start, as shown in Figure 1 (figure). Step is the main menu-〉tools-〉connect to Server.

Then, after connecting to the server, open the EJB to deploy, or the Web application. And then you can publish it. Both of these options are possible. Of course, personally like the second, because it can check your EJB packaging to meet the requirements, and you need to modify the EJB configuration descriptor is very simple, this graphical interface operation is very convenient, thus greatly improve the success rate of deploy.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.