Liferay uses Servicebuilder class to parse Service.xml

Source: Internet
Author: User

Liferay has a service builder mechanism that generates a set of interfaces and classes and configuration files for the persistence Layer and service layer, and when we write a service.xml and invoke ant target as Build-service, The framework uses the Servicebuilder class to parse the Service.xml file:

For example, the service.xml we create is:

<?xml version= "1.0" encoding= "UTF-8"?> <! DOCTYPE service-builder Public "-//LIFERAY//DTD Service builder 6.0.0//en" "http://www.liferay.com/dtd/ Liferay-service-builder_6_0_0.dtd "> <service-builder package-path=" com.sample.productregistration "> <  Author>charles wang</author> <namespace>walmart</namespace> <entity name= "Product" Local-service= "true" Remote-service= "false" > <!--PK fields--> <column name= "PR Oductid "type=" Long "primary=" true "/> <!--Audit fields--> <column name=" Produc Tname "type=" string "/> <column name=" serialnumber "type=" String "/>" <column name= "CompanyID" 
     
        "Type=" Long "/> <column name=" groupId "type=" Long "/> <!--order--> <order by= "ASC" > <order-column name= "productName"/> </order> 
     
        <!--Finder methods--> <finder name= "G_PN" return-type= "Collection" > 
             
        <finder-column name= "GroupId"/> <finder-column name= "ProductName"/> </finder> <finder return-type= "Collection" name= "CompanyID" > <finder-column name= "Compa" 
            Nyid "/> </finder> <finder return-type=" Collection "name=" GroupId "> <finder-column name= "GroupId"/> </finder> </entity> </service-builder>

When we run Build-service Target, the location of this service.xml file is used with the first parameter servicebuilder: (see Ant script fragment)

<if> <not> <isset Proper 
                                             ty= "Service.input.file"/> </not> <then> <property name= "Service.input.file" value= "${basedir}/docroot/web-inf/ser Vice.xml "/> </then> </if> <jav
                                A classname= "Com.liferay.portal.tools.servicebuilder.ServiceBuilder"
                classpathref= "Service.classpath" outputproperty= "Service.test.output" > <arg value= "-dexternal-properties=com/liferay/portal/tools/dependencies/p Ortal-tools.properties "/> <arg value="-dorg.apache.commons.logging.log=org.apache. Commons.logging.impl.Log4JLogger "/> <arg value=" Service.input.file=${service.input.file} "/> 
                                <arg value= "Service.hbm.file=${basedir}/docroot/web-inf/src/meta-inf/portlet-hbm.xml"/> <arg value= "Service.orm.file=${basedir}/docroot/web-inf/src/meta-inf/portlet-orm.xml"/&gt 
                                ; <arg value= "service.model.hints.file=${basedir}/docroot/

So, it will call Servicebuilder's main function, and we'll switch to here:

public static void Main (string[] args) 
  { 
    Map arguments = argumentsutil.parsearguments (args); 
     
    Initutil.initwithspring (true); 
     
    String fileName = (string) arguments.get ("Service.input.file"); 
    String hbmfilename = (string) arguments.get ("Service.hbm.file"); 
    String ormfilename = (string) arguments.get ("Service.orm.file"); 
String modelhintsfilename = (string) arguments.get ("Service.model

Therefore, the Service.xml file path is eventually passed to the constructor of the Servicebuilder class, and the path parameter is ultimately resolved by the private method _getcontent () method:

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.