EJB Learning (i)--EJB and web packaging

Source: Internet
Author: User
Tags jboss server

In the Java version of the University cloud Platform, each module built at the bottom of the time to build three projects, namely the JAR project (object core layer), war project (corresponding to the web layer) and Ear project (corresponding to the ear layer), just started to contact these several projects, some have been blindfolded. Recently in summing up the knowledge of EJB, these projects have some basic understanding, the following will be a summary of how each project is packaged.


Before we get to know EJB,EJB is Sun's Java EE server-side component Model , and the design goal and core application is to deploy distributed applications. in simple terms, a program that has already been written (that is, a class) is packaged and placed on the server for execution. So what's the matter of packing? That is the question we are going to discuss today.


1.EJB Packaging


To publish an EJB, you must call her a *.jar file, and an EJB-packaged directory structure is as follows:


    
For example, we teacher the overall core layer of the module in a university project:        
2.WEB Application Packaging
a WEB application needs to be made into a war package when it is published to the Jboss server. The directory structure after the Web app is packaged is as follows:
    
For example, we teacher the module's total Web layer in a university project:
    
3. Enterprise Application Packaging
A complete enterprise application consists of an EJB module and a WEB module, which we need to make into a *.ear file when releasing the enterprise application, and we must configure the Application.xml file before packaging, which is stored in the packaged Meta-inf directory. We need to specify the EJB module and Web module information in the Application.xml file, such as the Application.xml configuration in our university, we can see all the EJB modules and the Web modules under the Teacher module from this XML file. Where tool, base, API, Core is the EJB module, and the Web is the Web module.     
<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE application Public "-//sun Microsystems, inc.//dtd EE application 1.3//en" "http://java.sun.com/dtd/ Application_1_3.dtd "><application> <display-name>itoo-basic-teacher-ear</display-name> < module> <ejb>itoo-tool-0.0.1-20150511.192711-61.jar</ejb> </module> <module> <ejb&gt ;itoo-base-0.0.1-snapshot.jar</ejb> </module> <module> <ejb> itoo-basic-api-0.0.1-snapshot.jar</ejb> </module> <module> <ejb> itoo-basic-teacher-core-0.0.1-snapshot.jar</ejb> </module> <module> <web> <web-uri&gt ;itoo-basic-teacher-web-0.0.1-snapshot.war</web-uri> <context-root>/itoo-basic-teacher-web</ context-root> </web> </module> <module> <ejb>itoo-excelv2.0-api-0.0.1-20150716.044824-2 9.jar</ejb> </module> <module> <ejb>itoo-cloud-api-0.0.1-20150716.233937-30.jar</ejb> </module> <module> <ejb> Itoo-authority-api-0.0.1-20150717.015628-31.jar</ejb> </module></application>

4. EJB Packaging using a third-party class library
     for third-party class libraries for specific applications, the best option is to put them in an EJB Jar file. Each jar file has a
manifest file, which is created automatically by the Jar tool and the default name is manifest. Mf. We can add a Class-path property to the manifest file, referencing the JAR file it depends on. We can manually edit the MANIFEST.MF file and add the Class-path attribute based on the original content. The value of the Class-path property is the relative URL used to search for third-party class libraries. This URL is always relative to the component that contains the Class-path property. Multiple URLs can be specified within a single Class-path attribute, and a manifest file can contain multiple Class-path properties.

    Join me in the teacher module above refers to the third-party class library, named Upload.jar, Socket.jar, We just need to be in the manifest. MF file manually add class-path:upload.jar Socket.jar to complete the following directory structure:
    

4. Java EE application package with a third-party class library shared


A Java EE project typically consists of multiple EJB and Web applications, and if multiple EJBS and Web applications share a third-party class library, suppose a Java EE project contains two ejbs and a Web application whose filenames are: HelloWorld . jar, Hellochina.jar,myejbtest.war. Each of the three modules uses a third-party class library, named: Tools.jar now we're going to edit the MANIFEST.MF file for these three modules, and add the Class-path attribute based on the original content.
The following directory is packaged:                                                                                                                      the file suffix of the Java EE application is the ear, and the modules used by the application are defined in the Application.xml file, and the application.xml contents of this example are as follows:     
<?xml version= "1.0" encoding= "UTF-8"? ><application xmlns= "Http://java.sun.com/xml/ns/j2ee" version= "1.4" Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= "http://java.sun.com/xml/ns/j2eehttp:/ /java.sun.com/xml/ns/j2ee/application_1_4.xsd "><display-name>EJB3Trail</display-name>< Description>j2ee Made Easy Trail map</description><module><ejb>helloworld.jar</ejb>< /module><module><ejb> hellochina.jar</ejb></module><module><web>< web-uri>myejbtest.war</web-uri><context-root>myejbtest</context-root></web></ Module></application>

The above is a brief introduction to the EJB and Web project packaging, most of which refer to the "EJB 3.0 Getting Started Tutorial" This book, feel inside said very good, here also recommend to everybody.



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

EJB Learning (i)--EJB and web packaging

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.