Felix GoGo Shell Custom Command with Liferay 7

Since its inception Liferay has maintained a reputation of using latest technologies to help build robust portal products and the legacy continues with Liferay 7 also. Liferay 7 has acquired many new concepts like development of single page application (SPA) , Arquillian extension for functional as well as integration testing of product, adapting OSGI framework etc.

 

As part of osgi adoption, Liferay supports Apache Felix, a project to implement osgi framework and service platform developed under Apache license, however Liferay supports variety of osgi containers like equinox and knopflerfish.

 

Apache Felix consist of many sub projects of which GoGo is a command line shell that allows to manage lifecycle of osgi bundle. It follows RFC147 standard and command syntax of it is based on Tiny Shell Language (TSL).

 

This can be useful, when apart from managing bundle lifecycle, a custom gogo command can be implemented to automate specific processes like bulk installation of bundles, bulk activation/deactivation of bundles etc.

 

Following below sequence of steps a custom GoGo command can be created.

> Create a Liferay Module Project with project template type as “api”.

> Set dependencies in build file as below

For Gradle set build.gradle as

For maven set pom.xml as

> Once dependencies are set build your module to add dependency jars to classpath.

> Now update a Component(that was created while creating module project) as below.

 

Note: Liferay IDE also provides sample GOGO command template that can be used as a reference.To Generate it Right click your Module Project > New > Liferay Component Class > provide package name, class name and select component class template as GoGo Command > finish.

> Here osgi.command.scope property is set to “blade” since it just need to print number of blogs in portal.

> Deploy your module.

> Connect to gogo shell.

 

Note : Below is a reference link to connect gogo shell. : connecting felix gogo shell

 

> Give command blogscount, which displays number of blogs count

Similarly this can be useful to execute our own programs with a custom command.

 

For more information Apache Felix GoGo, please refer https://www.packtpub.com/books/content/apache-felix-gogo.

For more information on custom GoGo command, please refer http://enroute.osgi.org/appnotes/gogo-cmd.html.

 

By,

Ripal Thakkar

Share it :

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz
  • Categories

  • Recent Comments

  • Recent Post

  • Tags