Wrapping it all up in a separate EAR

We will now look at how to create a separated portal application basing the entire configuration on the extension mechanism described in the previous recipes.

First, we will take a look at the example portal project provided in the GateIn source code, and we will start copying this example project to customize it for our needs.

Getting ready

  • Download the source code of GateIn following the instructions described in the recipe Building and installing GateIn from the source code from Chapter 1, Getting Started
  • Configure your developing environment following the recipe Setting up the development environment from Chapter 1, Getting Started
  • Locate the Maven project dedicated to the portal example at the following path: <GATEIN_SOURCE_ROOT>/examples/portal

How to do it...

Carry out the following steps in order to include all your components in a separate EAR:

  1. We are going to copy the portal folder and use that copy to create the new Maven module project that we want to customize. Supposing that we are using Eclipse IDE, select the portal folder:
    How to do it...
  2. Right-click and select Copy.
  3. Select the examples folder.
  4. Right-click and click on Paste.
  5. Type financials-portal for the new folder and click on the OK button.
    How to do it...
  6. Locate the configuration file for the portal container: /financials-portal/config/src/main/java/conf/configuration.xml
  7. Change the configuration for the portal plugins in the following way:
    <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd http://www.exoplaform.org/xml/ns/kernel_1_2.xsd"
       xmlns="http://www.exoplaform.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>registerPlugin</set-method>
             <!-- The full qualified name of the PortalContainerDefinitionPlugin -->
             <type>org.exoplatform.container.definition.PortalContainerDefinitionPlugin</type>
             <init-params>
                <object-param>
                   <name>financials-portal</name>
                   <object type="org.exoplatform.container.definition.PortalContainerDefinition">
                      <!-- The name of the portal container -->
                      <field name="name"><string>financials-portal</string></field>
                      <!-- The name of the context name of the rest web application -->
                      <field name="restContextName"><string>rest-financials-portal</string></field>
                      <!-- The name of the realm -->
                      <field name="realmName"><string>gatein-domain-financials-portal</string></field>                  
                      <field name="externalSettingsPath">
                         <string>configuration.properties</string>
                      </field>
                      <!-- All the dependencies of the portal container ordered by loading priority -->
                      <field name="dependencies">
                         <collection type="java.util.ArrayList">
                            <value>
                               <string>eXoResources</string>
                            </value>
                            <value>
                               <string>portal</string>
                            </value>
                            <value>
                               <string>dashboard</string>
                            </value>
                            <value>
                               <string>exoadmin</string>
                            </value>
                            <value>
                               <string>eXoGadgets</string>
                            </value>
                            <value>
                               <string>gwtGadgets</string>
                            </value>
                            <value>
                               <string>eXoGadgetServer</string>
                            </value>
                            <value>
                               <string>rest-financials-portal</string>
                            </value>
                            <value>
                               <string>web</string>
                            </value>
                            <!--<value profiles="jboss">
                               <string>gatein-wsrp-integration</string>
                            </value>-->
                            <value>
                               <string>financials-portal</string>
                            </value>
                         </collection>
                      </field>
                   </object>
                </object-param>
             </init-params>
          </component-plugin>
       </external-component-plugins>
    </configuration>
  8. Update pom.xml in the config module with the following snippet:
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <parent>
        <groupId>org.exoplatform.portal</groupId>
        <artifactId>exo.portal.parent</artifactId>
        <version>3.2.0-GA</version>
        <relativePath>../../../pom.xml</relativePath>
      </parent> 
    
      <modelVersion>4.0.0</modelVersion>
      <artifactId>exo.portal.financials.portal.config</artifactId>
      <name>Financials Portal Configuration</name>
      <packaging>jar</packaging>
      <description>Financials Portal Configuration</description>
    </project>
  9. Locate the EAR configuration file: /financials-portal/ear/src/main/application/META-INF/application.xml
  10. Change the enterprise application configuration in the following way:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application PUBLIC
       "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
       "http://java.sun.com/dtd/application_1_3.dtd">
    <application>
      <display-name>financials-portal</display-name>
      <description>Financials Portal Ear</description>
      <module>
        <java>exo.portal.financials.portal.config-3.2.0-GA.jar</java>
      </module>
      <module>
        <web>
          <web-uri>financials-portal.war</web-uri>
          <context-root>financials-portal</context-root>
        </web>
      </module>
      <module>
        <web>
          <web-uri>rest-financials-portal.war</web-uri>
          <context-root>rest-financials-portal</context-root>
        </web>
      </module>
      <module>
        <java>exo.portal.financials.portal.jar-3.2.0-GA.jar</java>
      </module>
    </application>
  11. Update the pom.xml for the EAR module to conform to the new setting:
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <parent>
        <groupId>org.exoplatform.portal</groupId>
        <artifactId>exo.portal.parent</artifactId>
        <version>3.2.0-GA</version>
        <relativePath>../../../pom.xml</relativePath>
      </parent>
    
      <modelVersion>4.0.0</modelVersion>
      <artifactId>gatein-financials-portal</artifactId>
      <packaging>ear</packaging>
      <name>Financials Portal Ear</name>
      <description>Financials Portal Ear</description>
    
      <dependencies>
        <dependency>
          <groupId>org.exoplatform.portal</groupId>
          <artifactId>exo.portal.financials.portal.config</artifactId>
          <version>3.2.0-GA</version><version>3.2.0-GA</version>
        </dependency>
        <dependency>
          <groupId>org.exoplatform.portal</groupId>
          <artifactId>exo.portal.financials.portal.jar</artifactId>
          <version>3.2.0-GA</version>
        </dependency>
        <dependency>
          <groupId>org.exoplatform.portal</groupId>
          <artifactId>exo.portal.component.web.api</artifactId>
          <version>3.2.0-GA</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.exoplatform.portal</groupId>
          <artifactId>exo.portal.financials.portal.war</artifactId>
          <version>3.2.0-GA</version>
          <type>war</type>
        </dependency>
        <dependency>
          <groupId>org.exoplatform.portal</groupId>
          <artifactId>exo.portal.financials.portal.rest-war</artifactId>
          <version>3.2.0-GA</version>
          <type>war</type>
        </dependency>
      </dependencies>
      <build>
        <finalName>${project.artifactId}</finalName>  
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <configuration>
               <displayName>financials-portal</displayName>
               <modules>
                 <jarModule>
                   <groupId>org.exoplatform.portal</groupId>
                   <artifactId>exo.portal.financials.portal.config</artifactId>
                   <includeInApplicationXml>true</includeInApplicationXml>
                 </jarModule>
                 <webModule>
                   <groupId>org.exoplatform.portal</groupId>
                   <artifactId>exo.portal.financials.portal.war</artifactId>
                   <bundleFileName>financials-portal.war</bundleFileName>
                   <contextRoot>financials-portal</contextRoot>
                 </webModule>
                 <webModule>
                   <groupId>org.exoplatform.portal</groupId>
                   <artifactId>exo.portal.financials.portal.rest-war</artifactId>
                   <bundleFileName>rest-financials-portal.war</bundleFileName>
                   <contextRoot>rest-financials-portal</contextRoot>
                 </webModule>
                 <jarModule>
                   <groupId>org.exoplatform.portal</groupId>
                   <artifactId>exo.portal.financials.portal.jar</artifactId>
                   <includeInApplicationXml>true</includeInApplicationXml>
                 </jarModule>
              </modules>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </project>
  12. Update the realm configuration for the Financials portal in the file financials-portal/ear/src/main/application/META-INF/gatein-jboss-beans.xml as follows:
    <deployment xmlns="urn:jboss:bean-deployer:2.0">
    
      <application-policy xmlns="urn:jboss:security-beans:1.0" name="gatein-domain-financials-portal">
        <authentication>
          <login-module code="org.gatein.wci.security.WCILoginModule" flag="optional">
             <module-option name="portalContainerName">financials-portal</module-option>
             <module-option name="realmName">gatein-domain-financials-portal</module-option>
          </login-module>
          <login-module code="org.exoplatform.web.security.PortalLoginModule" flag="required">
             <module-option name="portalContainerName">financials-portal</module-option>
             <module-option name="realmName">gatein-domain-financials-portal</module-option>
          </login-module>
          <login-module code="org.exoplatform.services.security.jaas.SharedStateLoginModule" flag="required">
             <module-option name="portalContainerName">financials-portal</module-option>
             <module-option name="realmName">gatein-domain-financials-portal</module-option>
          </login-module>
          <login-module code="org.exoplatform.services.security.j2ee.JbossLoginModule" flag="required">
             <module-option name="portalContainerName">financials-portal</module-option>
             <module-option name="realmName">gatein-domain-financials-portal</module-option>
          </login-module>
        </authentication>
      </application-policy>
      
    </deployment>
  13. Override the default portal configuration in the file financials-portal/war/src/main/webapp/WEB-INF/conf/configuration.xml:
    <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd http://www.exoplaform.org/xml/ns/kernel_1_2.xsd"
       xmlns="http://www.exoplaform.org/xml/ns/kernel_1_2.xsd">
       <import>war:/conf/financials-portal/common/common-configuration.xml</import>
       <import>war:/conf/financials-portal/jcr/jcr-configuration.xml</import>
       <import>war:/conf/financials-portal/portal/portal-configuration.xml</import>
       <import>war:/conf/financials-portal/web/web-inf-extension-configuration.xml</import>
    </configuration>
  14. Set the specific realm in the JBoss configuration file financials-portal/rest-war/src/main/webapp/WEB-INF/jboss-web.xml:
    <jboss-web>
      <security-domain>java:/jaas/gatein-domain-financials-portal</security-domain>
    </jboss-web>
  15. Change the JCR configuration file for the new portal instance in the file financials-portal/war/src/main/webapp/WEB-INF/conf/financials-portal/jcr/jcr-configuration.xml in the following way:
    <external-component-plugins>
          <!-- The full qualified name of the RepositoryServiceConfiguration -->
          <target-component>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</target-component>
          <component-plugin>
             <!-- The name of the plugin -->
             <name>Sample RepositoryServiceConfiguration Plugin</name>
             <!-- The name of the method to call on the RepositoryServiceConfiguration in order to add the RepositoryServiceConfigurations -->
             <set-method>addConfig</set-method>
             <!-- The full qualified name of the RepositoryServiceConfigurationPlugin -->
             <type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationPlugin</type>
             <init-params>
                <value-param>
                   <name>conf-path</name>
                   <description>JCR configuration file</description>
                   <value>war:/conf/financials-portal/jcr/repository-configuration.xml</value>
                </value-param>
             </init-params>
          </component-plugin>
       </external-component-plugins>
  16. Change the workspace JCR configuration (content store and index store) in the file /financials-portal/war/src/main/webapp/WEB-INF/conf/financials-portal/jcr/repository-configuration.xml as follows:
    <repository-service default-repository="repository">
       <repositories>
            <repository name="repository" system-workspace="${gatein.jcr.workspace.system:system}" default-workspace="${gatein.jcr.workspace.default:portal-system}">
    . . .
    <workspace name="financials-ws">
                   <container class="org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.CQJDBCWorkspaceDataContainer">
                      <properties>
                         <property name="source-name" value="${gatein.jcr.datasource.name}${container.name.suffix}" />
                         <property name="dialect" value="auto" />
                         <property name="multi-db" value="false" />
                         <property name="update-storage" value="true" />
                         <property name="max-buffer-size" value="204800" />
                         <property name="swap-directory" value="${gatein.jcr.data.dir}/swap/financials-ws${container.name.suffix}" />
                      </properties>
                      <value-storages>
                         <value-storage id="financials-ws" class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
                            <properties>
                               <property name="path" value="${gatein.jcr.storage.data.dir}/financials-ws${container.name.suffix}" />
                            </properties>
                            <filters>
                               <filter property-type="Binary" />
                            </filters>
                         </value-storage>
                      </value-storages>
                   </container>
    . . .
    <query-handler class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
                <properties>
                  <property name="index-dir" value="${gatein.jcr.index.data.dir}/financials-ws${container.name.suffix}"/>
    . . .
            </repository>
       </repositories></repository-service>
  17. Update the latter configuration files starting from the root portal configuration file financials-portal/war/src/main/webapp/WEB-INF/conf/financials-portal/portal/portal-configuration.xml as you learnt in the previous recipes following your specific needs for portal, pages, layout, and applications.
  18. Then, in the case where you have extended the portal application, add in the Maven POMs provided with this chapter and any new dependencies for your custom features and your own Java extensions.
  19. Finally, in order to build the new portal application, launch the following Maven commands: clean and then install. Notice that these commands can be executed using Eclipse or from a terminal command prompt. If you are using Eclipse you can follow these steps:
    • Right-click on the financials-portal/pom.xml
    • Select Run As | Maven clean and wait for a BUILD SUCCESS output
    • Select Run As | Maven install and wait for a BUILD SUCCESS output as follows:
      [INFO] Reactor Summary:
      [INFO] 
      [INFO] Financials Portal Configuration ................... SUCCESS [7.919s]
      [INFO] Financials Portal Java Classes .................... SUCCESS [9.990s]
      [INFO] Financials Portal War ............................. SUCCESS [1.850s]
      [INFO] Financials Portal Rest War ........................ SUCCESS [0.828s]
      [INFO] Financials Portal Ear ............................. SUCCESS [0.990s]
      [INFO] Financials Portal ................................. SUCCESS [0.111s]
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 22.644s
      [INFO] Finished at: Sun Apr 22 17:40:39 CEST 2012
      [INFO] Final Memory: 23M/81M
  20. If you are not using Eclipse, you can execute this command to build from the root of the project:
    mvn clean install
    
  21. Now you should find the EAR package in the following path: examples/financials-portal/ear/target
  22. Start the JBoss AS instance.
  23. Be sure to deploy the starter application provided by the GateIn source code (starter.ear, built from the Maven module starter). This is the web application provided with GateIn dedicated to enabling the extension mechanism of the portal.
  24. Deploy the new portal application (gatein.ear) in JBoss by copying the artifact in the deploy folder.
  25. Access the new portal application by visiting the following URL from your browser: http://localhost:8080/financials-portal
    How to do it...

Note that the portal container is now the financials-portal, and the URL path starts with this name. Note also that the regular portal named portal is still running in the portal container and can be called with http://localhost:8080/portal.

Note

Notice that if you want to build and deploy your custom portal WAR artifact, for example in Tomcat, you have to follow the instructions included in the README.txt file that can be downloaded from the Packt website (http://www.packtpub.com/support). All source code and code bundles are available for download from the above page. Select the book and the code bundles can then be downloaded.

How it works...

The example portal project provided by the GateIn source code consists of the following Maven modules:

  • config: Includes the portal configurations about the portlet container
  • jar: Includes Java code for your custom logic and filters
  • rest-war: Contains the configuration for all the REST API of the portal
  • war: Contains all the portal configuration files and builds the WAR artifact
  • ear: Builds the EAR package that includes all the previous module artifacts

As you have seen, for each of these modules, we need to configure correctly every portal component, starting from the storage and then the configurations of the specific portal pages, applications, and layouts.

Remember to adjust any references in POM files. This allows you to add references to the right Maven modules or to add any new library that you want to use in the Java classpath.

For a complete overview of all the settings that you need to update from an example portal project, please see the source code relating to this chapter. You can download it from http://www.packtpub.com/support.

Note

In this recipe, we introduced some configuration files about security concepts (realms) that will be discussed in detail in Chapter 5, Securing Portal Contents.

See also

  • The Managing portals using XML recipe
  • The Managing portal pages using XML recipe
  • The Managing the navigation tree using XML recipe
  • The Managing registered portlets using XML recipe
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.40.32