(English) Liferay 7 CE: How to add support for IBM DB2 Server

Liferay 7 CE: How to add support for IBM DB2 Server
Liferay 7 CE: How to add support for IBM DB2 Server

Ci spiace, ma questo articolo è disponibile soltanto in Inglese Americano. Per ragioni di convenienza del visitatore, il contenuto è mostrato sotto nella lingua alternativa. Puoi cliccare sul link per cambiare la lingua attiva.

Those who follow Liferay is aware of the fact that the Community Edition version 7 of Liferay, were eliminated quite a bit of components App Server, Database & Clustering Support. For more detail information you can read the blog post by Bryan Cheung published on April 7, 2016.

  • The Liferay 7 CE GA1 no more support OOTB (Out Of The Box):
  • Application Server: Oracle WebLogic, IBM WebSphere
  • Clustering
  • MultiVM Cache
  • Oracle Database, Microsoft SQL Server, IBM DB2, Sybase DB

This sample project demonstrates how to add support to the IBM DB2 database. Liferay has performed refactorting the code so that it is possible and easy to add support for databases no longer supported OOTB.

1. Introduction

To extend support to other databases, Liferay has decided to refactory code to use Java SPI (Service Provider Interface). SPI is the mechanism that allows you to extend / change the behavior within a system without changing the source. It includes interfaces, classes or methods that the user extends or implements in order to obtain a certain functionality.

In short we must:

The following code shows how service providers are loaded via SPI.

To register your service provider, you create a provider configuration file, which is stored in the META-INF/services directory of the service provider’s JAR file. The name of the configuration file is the fully qualified class name of the service provider, in which each component of the name is separated by a period (.), and nested classes are separated by a dollar sign ($).

The provider configuration file contains the fully qualified class names (FQDN) of your service providers, one name per line. The file must be UTF-8 encoded. Additionally, you can include comments in the file by beginning the comment line with the number sign (#).

Our file is called com.liferay.portal.kernel.dao.db.DBFactory and contain the FQDN of the class it.dontesta.labs.liferay.portal.dao.db.DB2DBFactory

In the figure below shows the complete class diagram for DB2.

Liferay Portal DB2 Database Support Class Diagram

Liferay Portal DB2 Database Support Class Diagram

2. Build project

Requirements for build project

  1. Sun/Oracle JDK 1.8
  2. Maven 3.x (for build project) or Gradle 2.x

The driver that adds support for DB2 database is a jar (liferay-portal-db2-support-${version}.jar) which then will be installed in ROOT/WEB-INF/lib (for apache tomcat).

To generate the driver for IBM DB2 database just follow the instructions below.

You can download the binary jar liferay-portal-db2-support-1.0-SNAPSHOT.jar, by doing so you can avoid doing the build.

the build process create the jar liferay-portal-db2-support-1.0-SNAPSHOT.jar inside the (maven) target directory:

If you have a Gradle build system, then you can build jar by the following command

the build process create the jar inside the build/libs directory.

3. Install Liferay CE 7 on DB2 Database

To install Liferay on DB2 you must have previously configured a schema for Liferay on an DB2 Database.

I have used Virtual Appliance with a DB2 Express-C 10.1 (FP2) installation on SUSE Linux Enterprise Server

The parameters of my DB2 instance are:

  • Username: db2inst1
  • Password: system
  • FQDN: db2.vm.local (IP: 192.168.56.101)
  • TCP/IP Port: 50001

For the installation of Liferay follow the following steps:

  1. Download Liferay CE 7 GA2 Tomcat Bundle from sourceforge
  2. Extract the Liferay bundle (in my case $LIFERAY_HOME is /opt/liferay-ce-portal-7.0-ga2-blog)
  3. Copy the jar liferay-portal-db2-support-${version}.jar in $LIFERAY_HOME/$TOMCAT_HOME/webapps/ROOT/WEB-INF/lib
  4. Download and install DB2 JDBC driver (xxxxxx.jar) in $LIFERAY_HOME/$TOMCAT_HOME/lib/ext.
  5. Create the portal-ext.properties in $LIFERAY_HOME with the content as the file below. You should modify the JDBC connection parameters to the your db and the value of liferay.home
  6. Launch the Liferay Portal through the command $LIFERAY_HOME/$TOMCAT_HOME/bin/startup.sh
  7. See the Liferay activities via the log file $LIFERAY_HOME/$TOMCAT_HOME/logs/catalina.out

Below you can see the portal-ext.properties

You can see the part of the catalina.out log file and the contents of the DB2 Liferay database.

 

0 Condivisioni

Antonio Musarra

I began my journey into the world of computing from an Olivetti M24 PC (http://it.wikipedia.org/wiki/Olivetti_M24) bought by my father for his work. Day after day, quickly taking control until … Now doing business consulting for projects in the enterprise application development using web-oriented technologies such as J2EE, Web Services, ESB, TIBCO, PHP.

Potrebbero interessarti anche...

Cos'è il progetto CIE/CNS Apache Docker - Developers Italia

In questo video https://youtu.be/TcAzn1POhsM introdurrò il progetto CIE/CNS Apache Docker di Developers Italia (https://developers.italia.it/it/cie/#resourcecontent-3) nato circa due anni fa.

L'obiettivo di questo progetto è quello di fornire un template pronto all'uso che realizza un sistema di autenticazione tramite la Smart Card TS-CNS (o CNS) e la CIE (Carta d'Identità Elettronica) basato su Apache HTTP. Ognuno può poi modificare o specializzare questo progetto sulla base delle proprie esigenze Si tratta di un progetto docker per la creazione di un container che implementa un sistema di mutua autenticazione o autenticazione bilaterale SSL/TLS.

Questo meccanismo di autenticazione richiede anche il certificato digitale da parte del client, certificato che in questo caso risiede all'interno della TS-CNS o della CIE. La particolarità del sistema implementato (attraverso questo container) è quella di consentire l'autenticazione tramite:

  • La TS-CNS (Tessera Sanitaria - Carta Nazionale Servizi), rilasciata dalla regione di appartenenza;
  • La CIE (Carta d'Identità Elettronica), rilasciata dal comune di residenza.

Nella versione 2.0.0 il progetto è stato aggiornato per essere uniforme alle linee guida di Bootstrap Italia. A seguire alcune risorse che possono essere utili.

  • Cos’è il progetto CIE/CNS Apache Docker (http://bit.ly/3aJ5Gbl)
  • CIE Carta d'Identità Elettronica (https://developers.italia.it/it/cie/)
  • Carta Nazionale dei Servizi (https://www.agid.gov.it/it/piattaforme/carta-nazionale-servizi)
  • Raspberry Pi – Un esempio di applicazione della TS-CNS (https://bit.ly/3hkJ8Aj)
  • Pubblicare il servizio CIE/CNS Apache Docker su Azure Cloud (http://bit.ly/3aPoq8V)
  • Come accedere al portale VETINFO tramite TS-CNS e Mac OS (http://bit.ly/2VFMKq7)