DeployDirectory details during war package deployment in Liferay

Source: Internet
Author: User
Tags tld

Introduction:

In the previous article, we explained from a macro perspective how Liferay deploys war packages to trigger listeners and complete the deployment process. However, we did not talk about the core deployDirectory, it is used to parse the contents of a temporary directory after the war package has been expanded to this directory, after re-processing and finally copying to the final deployment directory deployDir, we will study this content here:


Debugging analysis:

First, let's look at the input parameters of this complex method:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1545321F6-0.png "title =" 41.png"/>


The srcFile parameter is our temporary directory, that is, the directory corresponding to the expanded war file.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1545322c5-1.png "title =" 42.png"/>

MergeDir is a directory for merge. We set it to create a merge directory in the LIFERAY deployment directory $ LIFERAY_HOME/deploy. Then, we name our war package as a subdirectory, as shown below:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/154532K94-2.png "title =" 43.png"/>

DeployDir Needless to say, that is, the directory in which our applications will be placed under the tomcat webapps directory:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/15453231O-3.png "title =" 44.png"/>

The following three parameters are not required.


Let's start the analysis:

First, call rewriteFiles in row 514th to override several files in the srcDir directory:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/154532E10-4.png "title =" 45.png"/>

I don't need to post the code, so I can understand it at a Glance. Its purpose is for the web. xml, liferay-plugin-package.xml, liferay-display.xml, liferay-portlet.xml, portlet. the five xml files indent sub-elements, and the indentation volume is the distance of a tab. So the final file will become:

<Parent-ele>

<Child-ele>

This indent format


Next, call the mergeDirectory (mergeDir, srcFile) method in row 516th. Because our mergeDir is empty, skip this Code directly.


Then call processPluginPackageProperties (srcFile, displayName, pluginPackage) In line 518th to process the properties file of the plugin package, because we don't have a liferay-plugin-package.properties, instead we use xml files, so this code is skipped.


Next, the copyJars (srcDir, pluginPackage) method will be called in Row 3,

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1545322a6-5.png "title =" 46.png"/>

They will. Multiple jar files under the $ CATALINA_HOME/liferay/com/liferay/portal/deploy/dependencies directory

Copy them to the WEB-INF/lib directory under the portlet temporary directory specified by srcFile.

If you are careful, you will surely ask why the $ CATALINA_HOME/liferay/com/liefray/portal/deploy/dependencies directory is suddenly added. Why are there so many jar files? In fact, I don't know. We will analyze it in the final "answers to the best questions". Let's assume that this directory already exists and these jar files are used.


Then, call the copyProperties (srcFile, pluginPackage) method in Row 3.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1545325B6-6.png "title =" 47.png"/>

The details are saved. It will go to the logging. properties, log4j. properties, service. properties and other files from the $ CATALINA_HOME/temp/liferay/com/liferay/portal/deploy/dependencies directory.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1545325V1-7.png "title =" 48.png"/>

Copy to the WEB-INF/class directory under the portlet temporary directory we specified with the srcFile variable.


Next, it will call the copyTlds (srcFile, pluginPackage) method in line 522nd:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1545322534-8.png "title =" 49.png"/>

They will. aui. tld, liferay-portlet.tld, liferay-portlet-ext.tld, liferay-security.tld, liferay-theme.tld, liferay-ui.tld, liferay-util.tld these Taglib definition files are all copied to the WEB-INF/tld directory under the temporary directory of the portlet we specified with the srcFile variable, where are these original files? Maybe you guessed it. They are still in the $ CATALINA_HOME/temp/liferay/com/liferay/portal/deploy/dependencies directory:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/154532FV-9.png "title =" 50.png"/>


Next, it will call the copyXmls (srcFile, displayName, pluginPackage) method.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/154532C57-10.png "title =" 51.png"/>

First, it will call super. copyXmls is used to determine the server type to determine how to copy the server-specific xml file and web. xml file to the WEB-INF directory under the temporary portlet directory we specified with the srcFile variable:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1545322D6-11.png "title =" 52.png"/>

Because our appServerType is "tomcat", it does not copy the server-specific xml file, but only copies one web. xml file.

Then because our appServerType is 'tomcat ", it will copy the context. xml file to the/META-INF directory under the temporary portlet directory we specified with the srcFile variable.

Finally, copy the _ servlet_context_include.jsp file to the/WEB-INF/jsp directory under the temporary portlet directory specified by srcFile.

Are these xml files still in the $ CATALINA_HOME/temp/liferay/com/liferay/portal/deploy/dependencies directory? Correct answers ~

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/154532Jc-12.png "title =" 53.png"/>


Next, it calls copyPortalDependencies (srcFile) in row 524th, because we didn't define the properties file of the plugin package, so this line was not executed.


Next, it calls updateWebXml (webXml, srcFile, displayName, pluginPackage) in Row 3) the method updates the original xml directly copied from the $ CATALINA_HOME/temp/liferay/com/liferay/portal/deploy/dependencies directory, and adds and deletes the content,This section is also very complicated. I will introduce it in another article)


Next for the jar package processing in/WEB-INF/ext-lib/global and/WEB-INF/ext-lib/portal, copy them to the corresponding directory on the liferay server because we don't have, so skip.


Next, call updateDeployDirectory (srcFile) to update the deployment directory in row 558th.


Then, exclude the jar package:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1545325127-13.png "title =" 55.png"/>

First, it first determines the server type, because we are tomcat, so it will go to all the jar packages in tomcatLibDir in the exclusion list, this tomcatLibDir is

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/154532F10-14.png "title =" 56.png"/>

Then it will read conext. xml. If com. liferay. support. tomcat. loader. PortalClassLoader is specified, Three jar packages will be removed.


Then put the **/WEB-INF/web. xml is also added to the exclude list, because this web. xml is always changed, so our file will not be copied to deployDir of our application under webapps under tomcat. Finally, our exclude list is as follows:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1545322C6-15.png "title =" 58.png"/>


Then, execute the copy operation on Row 3. It will remove the web in the exclude list from our temporary application information of $ CATALINA_HOME/temp/<timestamp>. copy xml and some jar files to the $ CATALINA_HOME/webapps/<Project Name> deployment directory:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/154532EP-16.png "title =" 57.png"/>


Copy the web. xml file separately in the last 678th rows, and set overrite to true to overwrite the original one. We can see this from the timestamp of all files on the server, as shown below:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/15453223D-17.png "title =" 60.png"/>

From the above we can see that under the WEB-INF directory, only the web of the last line. the xml timestamp is changed from the previous one, which indicates that the web. xml is copied separately, and the practice is consistent with the code execution.


In the last 690th rows, the lastModified of the newly generated web. xml is set to the current time + 6 seconds.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1545323395-18.png "title =" 61.png"/>


Finally, let's delete tempDir (that is, in the directory $ CATALINA_HOME/temp/<timestamp>,

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1545322608-19.png "title =" 62.png"/>

It's all done. It's returned from the deployDirectory () method.



Q:

Before summing up, I still have some questions, that is, we can see that many of the deployment actions should first go through the various files in the $ CATALINA_HOME/liferay/com/liefray/portal/deploy/dependencies directory.,Including the properties file, tld file, xml file, and so on) to tempDir. Why is this file generated when it contains so much content? We are now dedicated to this issue.

Soon I found the answer, which was copied from classpath to the $ CATALINA_HOME/temp/liferay directory..

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1545324928-20.png "title =" 64.png"/>

And classpath,After careful search, found from $ CATALINA_HOME/webapps/ROOT/WEB-INF/lib/portal-impl.jar, for example, all the tld files used:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/1545321T8-21.png "title =" 65.png"/>



Summary:

(1) the overall function of deployDirectory is to have a directory structure expanded from the war package in the temp directory of tomcat and then be configured and reorganized, finally, copy the process to the deployment directory of the Response Application under webapps.

(2) First, it will call rewriteFiles to rewrite several xml files in the directory, in order to make the files more standardized and indented.

(3) then it reads the property settings in the plugin-package.properties into Properties.

(4) Call the copyJars () method.The multiple jar files under the CATALINA_HOME/liferay/com/liferay/portal/deploy/dependencies directory are copied to the WEB-INF/lib directory under the temporary portlet directory specified by srcFile.

(5) Call copyProperties.CATALINA_HOME/liferay/com/liferay/portal/deploy/dependencies

Multiple properties files under the directory are copied to the WEB-INF/classes directory under the temporary portlet directory specified by srcFile.

(6) then callCopyTldsCATALINA_HOME/liferay/com/liferay/portal/deploy/dependencies

Multiple tld files under the directory are copied to the WEB-INF/tld directory under the temporary portlet directory specified by srcFile.

(7) then callThe copyXmls method determines the server-specific xml file and web. xml file replication based on the server type.To the WEB-INF directory under the temporary portlet directory specified by srcFile,If the tomcat server also copies the context. xml file to the META-INF directory under the temporary directory of the portlet, and then copies _ servlet_context_include.jsp to the WEB-INF/jsp directory under the temporary directory of the portlet. The above files are obtained from the CATALINA_HOME/liferay/com/liferay/portal/deploy/dependencies directory.

(8) then call updateWebXml (webXml, srcFile, displayName, pluginPackage) the method updates the original xml copied directly from the $ CATALINA_HOME/temp/liferay/com/liferay/portal/deploy/dependencies directory, added and deleted the content, which will be discussed separately in later articles)

(9) Next for jar packages in/WEB-INF/ext-lib/global and/WEB-INF/ext-lib/portal, copy them to the corresponding directory on the liferay Server

(10) copy from every step in step (4)-(8). All these resource files come fromCATALINA_HOME/liferay/com/liferay/portal/deploy/dependencies directory, and these resource files are initially from $ CATALINA_HOME/webapps/ROOT/WEB-INF/lib/portal-impl.jar, these resources will be loaded to classpathResource after Liferay runs.

(11) before finally copying to the deployment directory under webapps, it must first form an exclusion list, indicating that the resources to be copied must be excluded first, web. xml is always excluded. In addition, some jar files depend on our configuration.

(12) Copying to the deploy directory under webapps is always divided into two parts: one is to copy all the file directories in the exclusion list, and the other is to copy the web separately. xml file, so you can see the web. the timestamp of xml is always later than that of other files.

(13) after the last copy, the lastModified attribute of the latest web. xml file will be transferred to the deployment directory of our application under webapps for 6 seconds.






This article from "parallel line cohesion" blog, please be sure to keep this source http://supercharles888.blog.51cto.com/609344/1286631

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.