2.1.2. Creating a portal extension

Here you create a portal extension webapp and a jar to register it to portal container.

An example of the poorest portal extension - like the one in this tutorial - contains only configuration xml file. You can use Maven or Aunt to build it, or simply create a directory then archive it with jar or zip command or any archiver you have.

In case you need one, this is the instruction to use jar command (that is available once you installed JDK).

Note

Take care that WEB-INF/ must be the top folder inside the .war, and conf/ must be the top folder inside the .jar.

  1. Create a portal extension. For example, it is named custom-extension.war.

    • WEB-INF/web.xml:

      
      <web-app>
          <display-name>custom-extension</display-name>
          <listener>
              <listener-class>org.exoplatform.container.web.PortalContainerConfigOwner</listener-class>
          </listener>
      </web-app>
    • WEB-INF/conf/configuration.xml: this file is supposed to be service configuration; however, in the poorest portal extension you just write the root element configuration. You will be told to fill more configuration in later tutorials.

      
      <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd http://www.exoplatform.org/xml/ns/kernel_1_2.xsd"
         xmlns="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd">
      </configuration>
  2. Create a jar that declares custom-extension.war as a portal dependency.

    This jar contains only conf/configuration.xml file and can be named, for example custom-extension-config.jar.

    
    <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd http://www.exoplatform.org/xml/ns/kernel_1_2.xsd"
       xmlns="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd">
        <external-component-plugins>
            <!-- The full qualified name of the PortalContainerConfig -->
            <target-component>org.exoplatform.container.definition.PortalContainerConfig</target-component>
            <component-plugin>
                <!-- The name of the plugin -->
                <name>Add PortalContainer Definitions</name>
                <!-- The name of the method to call on the PortalContainerConfig in order to register the PortalContainerDefinitions -->
                <set-method>registerChangePlugin</set-method>
                <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
                <type>org.exoplatform.container.definition.PortalContainerDefinitionChangePlugin</type>
                <priority>101</priority>
                <init-params>
                    <values-param>
                        <name>apply.specific</name>
                        <value>portal</value>
                    </values-param>
                    <object-param>
                        <name>addDependencies</name>
                        <object type="org.exoplatform.container.definition.PortalContainerDefinitionChange$AddDependencies">
                            <!-- The name of the portal container -->
                            <field name="dependencies">
                                <collection type="java.util.ArrayList">
                                    <value>
                                        <string>custom-extension</string>
                                    </value>
                                </collection>
                            </field>
                        </object>
                    </object-param>
                </init-params>
            </component-plugin>
        </external-component-plugins>
    </configuration>
    • priority: set to "101" that is higher than platform-extension.war if you want your custom-extension to override configuration in that one.

    • dependencies: a collection of portal extensions. Here it is only custom-extension.

Deployment

To deploy this poorest portal extension in case you do not use Add-ons Manager:

For Tomcat:

  1. Add custom-extension.war to the $PLATFORM_TOMCAT_HOME/webapps/ directory.

  2. Add custom-extension-config.jar to the $PLATFORM_TOMCAT_HOME/lib directory.

  3. Restart the server.

For JBoss:

  1. Add new WEB-INF/jboss-deployment-structure.xml file to custom-extension.war with the following content:

    
    <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
        <!-- This is the top level ear module, which contains all the classes in the EAR's lib folder     -->
        <deployment>
        <!-- This allows you to define additional dependencies, it is the same as using the Dependencies: manifest attribute -->
            <dependencies>
                <module name="deployment.platform.ear" export="true"/>
            </dependencies>
        </deployment>
    </jboss-deployment-structure>
  2. Add custom-extension.war to $PLATFORM_JBOSS_HOME/standalone/deployments/ directory.

  3. Add custom-extension-config.jar to $PLATFORM_JBOSS_HOME/standalone/deployments/platform.ear!/lib directory.

  4. Restart the server.

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus