Packaging, deploying and compiling considerations

 

Packaging, deploying and compiling considerations

 

+

Search Tips   |   Advanced Search

 

 

Create the deployment descriptors

A WAR must have a web.xml and a portlet.xml file in order to comply with J2EE specifications. For standard portlets only, web.xml only needs to contain servlet information, not portlet information. If the standard portlet does not contain servlets, web.xml must still be present, though the content of the file will be empty. However, in an IBM portlet web.xml must contain both servlet and portlet information. The web.xml and portlet.xml files must be modified to enable portlet cooperation. You must modify web.xml to refer to the property broker classes. For IBM only, the servlet class entry should specify the com.ibm.wps.pb.wrapper.PortletWrapper class in the property broker.

The portlet.xml file must specify the location of the WSDL file associated with each portlet. To achieve this, modify portlet.xml to add a configuration parameter to each concrete portlet that exposes actions to the property broker through the WSDL file. For the IBM example portlet.xml file below, the configuration parameter, c2a-action-descriptor, must specify a URL that points to the WSDL file that declares actions. The configuration parameter, c2a-nls-file, must specify the base name of an NLS resource file containing the translated text corresponding to the captions and descriptions of actions and properties. This file may be packaged in the same WAR file, so a relative path may be used.

  • Standard portlet examples

    Sample web.xml file for standard portlet with empty content: This sample is from pbjsrsampleshipping.war.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
                             "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
        <display-name>Shipping Portlets - Standard Version</display-name>
    </web-app>
    

    Sample standard portlet.xml file

    <?xml version="1.0"?>
    <portlet-app 
       xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
       version="1.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd                        http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
        <portlet>
            <description xml:lang="en">
               Displays details for a particular order         </description>
            <portlet-name>StandardOrderDetail</portlet-name>
            <display-name xml:lang="en">Standard Order Detail</display-name>
            <portlet-class>
               com.ibm.wps.portlets.shipping.OrderDetailPortlet         </portlet-class>
            <expiration-cache>3600</expiration-cache>
            <supports>
                <mime-type>text.html</mime-type>
            </supports>
            <supported-locale>en</supported-locale>
            <resource-bundle>nls.StandardOrderDetail</resource-bundle>
            <portlet-preferences>
                <preference>
                    <name>
                       com.ibm.portal.propertybroker.wsdllocation                 </name>
                    <value>/wsdl/OrderDetail.wsdl</value>
                </preference>
                <preference>
                    <name>com.ibm.portal.context.enable</name>
                    <value>true</value>
                </preference>
            </portlet-preferences>        
        </portlet>
        
       ...
        
    </portlet-app>
    

    • For standard portlets, a special <preference> entry must be used to specify the application portlet class.

      <portlet-preferences>
         <preference>
            <name>com.ibm.portal.propertybroker.wsdllocation</name>
            <value>/wsdl/OrderDetail.wsdl</value>
         </preference>
      </portlet-preferences>
      

  • IBM portlet examples

    Sample web.xml file for IBM portlet: This sample is from pbshipexample.war.

         
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC 
              "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" 
              "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
       <web-app id="ShippingPortletsC2ANew">
          <display-name>Shipping Portlets</display-name>
          <servlet id="OrderDetailC2A">
             <servlet-name>Order Detail</servlet-name>
             <servlet-class>
                com.ibm.wps.pb.wrapper.PortletWrapper          </servlet-class>
                <init-param>
                <param-name>
                   c2a-application-portlet-class             </param-name>
                <param-value>
                   com.ibm.wps.portlets.shipping.OrderDetailPortlet             </param-value>
                </init-param>
             <load-on-startup>0</load-on-startup>
          </servlet>
          <servlet id="OrderMonthC2A">
             <servlet-name>Orders</servlet-name>
             <servlet-class>
                com.ibm.wps.pb.wrapper.PortletWrapper          </servlet-class>
                <init-param>
                <param-name>c2a-application-portlet-class</param-name>
                <param-value>
                   com.ibm.wps.portlets.shipping.OrderMonthPortlet             </param-value>
                </init-param>
             <load-on-startup>0</load-on-startup>
          </servlet>
    
    ...
    
          <servlet-mapping id="OrderDetailMapping">
           <servlet-name>Order Detail</servlet-name>
           <url-pattern>/OrderDetail/*</url-pattern>
        </servlet-mapping>
        <servlet-mapping id="OrderMonthMapping">
             <servlet-name>Orders</servlet-name>
             <url-pattern>/Orders/*</url-pattern>
          </servlet-mapping>
    
    ...
    
      </web-app>
    

    • The portlet wrapper must be specified. For example, <servlet-class>com.ibm.wps.pb.wrapper.PortletWrapper</servlet-class>.

    • The <init-param> entry must be used to specify the application portlet class.

      <init-param>
         <param-name>c2a-application-portlet-class</param-name>
         <param-value>
            com.ibm.wps.portlets.shipping.OrderDetailPortlet    </param-value>
      </init-param>
      

      Sample IBM portlet.xml file

      <?xml version="1.0"?>
      <!DOCTYPE portlet-app-def PUBLIC 
                "-//IBM //DTD Portlet Application 1.1//EN" "portlet_1.1.dtd">
      <portlet-app-def>
         <portlet-app uid="com.ibm.wps.portlets.shippingc2anew">
            <portlet-app-name>Shipping Application</portlet-app-name>
            <portlet id="OrderDetailC2A" href="WEB-INF/web.xml#OrderDetailC2A">
               <portlet-name>Order Detail</portlet-name>
               <cache>
                    <expires>3600</expires>
                      <shared>YES</shared>
                  </cache>
                  <allows>
                  <maximized/>
                  <minimized/>
               </allows>
               <supports>
                  <markup name="html">
                      <view output="fragment"/>
                  </markup>
               </supports>
            </portlet>
         ...
      
         <concrete-portlet-app 
            uid="concrete.com.ibm.wps.portlets.shippingc2anew">
            <portlet-app-name>Shipping Application</portlet-app-name>
            <concrete-portlet href="#OrderDetailC2A">
               <portlet-name>Order Detail</portlet-name>
               <default-locale>en</default-locale>
               <language locale="en">
              <title>Order Detail</title>
              <title-short>OD</title-short>
              <description>
                 Displays details for a particular order         </description>
              <keywords>
                 Property Broker, Click-to-Action, C2A, Cooperative Portlets         </keywords>
            </language>
      
            <config-param>
               <param-name>c2a-action-descriptor</param-name>
               <param-value>/wsdl/OrderDetail.wsdl</param-value>
            </config-param>
            <config-param>
               <param-name>c2a-nls-file</param-name>
               <param-value>nls.shipping</param-value>
            </config-param>
          </concrete-portlet>
         ...
      
          </concrete-portlet-app>
      </portlet-app-def>
      

      In order to support translation, portlets must provide resource bundles in the appropriate location in the WAR file. For IBM portlets, the resource file name to be used can be specified in the <config-param> parameter. For more information see Internationalization.

     

    WAR file considerations

    Once the code and deployment changes have been made for using the property broker, additional libraries and files must be packaged along with the application. After you package the WAR file, it is ready to be installed. Use the following table to package the files in the correct location.

    Portlet type File name Path Original location
    IBM portlet only pbportlet.jar

    The version of pbportlet.jar must match the version of the product being used.

    /WEB-INF/lib portal_server_root/pb/lib
    Standard and IBM WSDL file relative to the root of the WAR file or an absolute URL  

     

    Additional considerations for compiling

    If you are using your own development environment, make sure to add the wp.propertybroker.standard.api.jar (for standard portlets) or wp.propertybroker.legacy.api.jar (for IBM portlets) file to the class path. This JAR file can be found in the portal_server_root/shared/app directory. For other JAR file requirements, see Creating a simple portlet.

     

    Related information