Development in the ext environment

仉明知
2023-12-01

Development in the ext environment

From LiferayPedia

Jump to: navigation, search

This guide explains how to do usual development tasks in the extension environment. It should be considered an extension to the Development in the Extension Environment Guide found in Liferay's Official Documentation] (section on Development). Be sure to check the documents that correspond to your version of Liferay.

Development is done in the /ext directory. When new versions of Liferay come out, the /portal directory can be replaced with the new version, and the /ext directory "updated" by re-running the build-ext target found in /portal/build.xml.

Any new jar files required by your extensions should be placed in /ext/ext-lib

WARNING: This article describes the versions from 4.0 to 4.2 of the extension environment. Version 4.3 has some changes that are documented in the Official Documentation]

Note: The default Language.properties file is located at /portal/portal-impl/classes/content/Language.properties. The Language-ext.properties file referred to in the docs is located at /ext/ext-impl/classes/content/Language-ext.properties


<script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
[ edit]

Normal development process

Typically, customization/development need only occur inside the "extension environment." The normal development cycle from within the extension environment is:

  1. Ensure "extension environment" is set up (see the topic Setting up the Extension Environment)
  2. Customize portal properties by editing file /ext/ext-impl/classes/portal-ext.properties
  3. Customize settings in web.xml by adding entries to /ext/ext-web/docroot/WEB-INF/web.xml. (just put the fragments you want. The changes will be merged in to final web.xml by deployment process.
  4. Turn portlets you want to deploy on/off by editing /ext/ext-web/docroot/WEB-INF/liferay-portlet-ext.xml
  5. Customize language/display information by editing /ext/ext-impl/classes/content/Language-ext.properties or /ext/ext-impl/classes/content/Language-ext_en.properties(see Language/display customization)
  6. New classes to be made part of the core portal system should be created in /ext/ext-impl/src.
  7. To create an entirely new portlet, follow the directions here: http://content.liferay.com/4.0.0/docs/quickstart/ch04s02.html
  8. Run the "deploy" target from /ext/build.xml. This will merge all of the changes from above, build the system, and deploy to the configured application server (configured in /ext/app.server.<developerName>.properties file).

If developing a single portal instance, and customization is desireable, create, update, and/or modify files by placing them in the /ext/ext-web/docroot directory. When ready to deploy, call the "deploy" target in /ext/ext-web/build.xml. This will unjar the "default" web configuration from /ext/ext-ear/modules/portal-war, to a temporary directory, overwrite the temp dir with those file in /ext/ext-web/docroot, then deploy to the app server.

[ edit]

Customizing the Liferay Core

If customizing the core portal system (i.e. modifying the base Liferay source for consumption by the Liferay community), the development cycle is the following:

  1. Make your changes in the appropriate /portal/ source file (most interesting core stuff is in /portal/portal-impl/src)
    1. If adding a column to an entity, do NOT modify the XXXModel.java file, but add it to appropriate service.xml (see Services, entities, and ServiceBuilder)
    2. If adding a new method to one of the services, modify XXXServiceImpl.java or XXXLocalServiceImpl.java. Don't modify any of the other service interfaces (see Services, entities, and ServiceBuilder)
    3. If any mods are made in 1 and/or 2 above, run the "build-service-portal" and/or "build-service-portlets" target in /portal/portal-impl/build.xml to regenerate the code. See the "Services, entities, and ServiceBuilder" section below for details.
  2. Run the "start" target in /portal/build.xml (to rebuild the portal)
  3. Run the "build-ext" target in /portal/build.xml (to rebuild the extension environment, re-deploying the new changes from step 2 above).

This will rebuild the extension environment, but preserve all of your customized "*-ext.*" files. You can then deploy THOSE changes by re-running the "deploy" target in /ext/build.xml

Notes: In theory, multiple web sites can be developed concurrently by creating various site directories in /ext/web-sites/<domainName>-web. The "liferay.com-web" directory. All sites placed in this dir will have the various files from above merged in. liferay.com-web seems to be the target of this process. As of 4.1.x, however, it does not appear that the deployment process (i.e. the "deploy" target) recognizes any directories other than liferay.com-web.

Interesting tidbit: The liferay.com-web directory seems to be created in the /portal/ tree initially by info in the /portal/web-sites/web-sites.xml. web-sites.xml is used by com.liferay.portal.tools.WebSiteBuilder to build various sites under the /ext/web-sites dir.

[ edit]

Overriding JSP's from Liferay Core

JSP's from core can be easily customized/overridden by making a parallel change in the EXT environment. For example, if you want to modify the view.jsp of the login portlet, here are the steps:

  1. Locate the JSP code in the portal core (portal/portal-web/docroot/html/portlet/login/view.jsp)
  2. Copy the file to the corresponding location in the EXT environment (creating folders as necessary)
    1. Create the folder path: ext/ext-web/docroot/html/portlet/login/
    2. Copy the JSP from portal to ext: view.jsp
  3. Make desired changes to JSP in EXT environment
  4. Deploy changes
    1. Since we only made changes to JSP's, we can use the "deploy-fast" ant target in the build script of ext/ext-web/build.xml which will only deploy modified jsp's (very fast!).
[ edit]

Configuring Log4J logging

  1. Copy /portal/portal-impl/classes/META-INF/portal-log4j.xml to /ext/ext-impl/classes/META-INF/portal-log4j-ext.xml (i.e. copy from the /portal/portal-impl dir to the /ext/ext-impl, then rename to portal-log4j-ext.xml)
  2. Copy /portal/portal-impl/classes/META-INF/log4j.dtd to the same /ext/ext-impl/classes/META-INF dir as above
  3. Modify your new portal-log4j-ext.xml with whatever log4j parameters you want
  4. Deploy your extension environment
  5. Note that if you are deploying the portal under the Apache Geronimo application server, and you want to output DEBUG and TRACE messages, then may need to adjust the log4j Threshold default from INFO to DEBUG or TRACE. The Geronimo Console interface provides a feature whereby you can set the logging threshold at runtime via the browser. This is achieved by the following line in the var/log/server-log4j.properties file: log4j.appender.CONSOLE.Threshold=${org.apache.geronimo.log.ConsoleLogLevel}
[ edit]

Development shortcuts

Since development frequently involves frequent interations over the code/deploy/test/debug cycle, rebuilding the entire system, rolling it up to the extension environment, and re-deploying can quickly slow down productivity. Here are some development shortcuts you can use if your changes are isolated to a particular area of the code:

To modify anything located in /portal/portal-impl/

  1. Insure there is a customized /portal/app.server.<developerName>.properties file (may have to copy from the /ext/ directory
  2. modify the source code
  3. Execute the "deploy" target in /portal/portal-impl/build.xml
  4. repeat from step #2

To modify anything located in /portal/portal-web/

  1. Insure there is a customized /portal/app.server.<developerName>.properties file (may have to copy from the /ext/ directory
  2. modify the source code
  3. Execute the "war" target in /portal/portal-web/build.xml
  4. Execute the "build-ext" target in /portal/build.xml
  5. repeat from step #2

To modify any jsp's

  1. modify source code in {$App Server}/webapps/ROOT/html/
  2. refresh page
  3. repeat from step #1
  4. save code in ext-web/docroot/html before deploying from /ext/ext-web

another alternative is to use the 'deploy-fast' ant task in /portal/portal-web/build.xml. This will deploy any modified jsps only to your app server.  

原出处:http://wiki.liferay.com/index.php/Development_in_the_ext_environment

 类似资料:

相关阅读

相关文章

相关问答