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.
<GATEIN_SOURCE_ROOT>/examples/portal
Carry out the following steps in order to include all your components in a separate EAR:
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:examples
folder.financials-portal
for the new folder and click on the OK button./financials-portal/config/src/main/java/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"> <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>
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>
/financials-portal/ear/src/main/application/META-INF/application.xml
<?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>
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>
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>
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>
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>
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>
/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>
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.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:financials-portal/pom.xml
BUILD SUCCESS
outputBUILD 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
mvn clean install
examples/financials-portal/ear/target
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.gatein.ear
) in JBoss by copying the artifact in the deploy
folder.http://localhost:8080/financials-portal
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
.
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.
The example portal project provided by the GateIn source code consists of the following Maven modules:
config
: Includes the portal configurations about the portlet containerjar
: Includes Java code for your custom logic and filtersrest-war
: Contains the configuration for all the REST API of the portalwar
: Contains all the portal configuration files and builds the WAR artifactear
: Builds the EAR package that includes all the previous module artifactsAs 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.
In this recipe, we introduced some configuration files about security concepts (realms) that will be discussed in detail in Chapter 5, Securing Portal Contents.
3.142.40.32