Showing posts with label Liferay GoGo Shell. Show all posts
Showing posts with label Liferay GoGo Shell. Show all posts

Saturday, February 29, 2020

Apache Gogo Shell Commands Description


lb
Display list of bundles installed in OSGi module framework

lb | grep <BUNDLE_MATCH_PATTERN>
List of bundles with filter using grep command and you can pass any string or valid regex pattern.

bundle <BUNDLE_ID>
Print specific bundle information. It required bundle Id as parameter

headers <BUNDLE_ID>
Print all OSGi headers which is used by specified bundle. These headers are in MANIFEST.MF file. It is required bundle Id as parameter.

install [URI_JAR_FILE_PATH]
Install bundle into OSGi container and we need to specify the valid URI path.

start [BUNDLE_ID]
Command will start bundle and it is required bundle Id.

stop [BUNDLE_ID]
Command will stop bundle and it is required bundle Id.

uninstall [BUNDLE_ID]
Uninstall bundle and it required bundle Id.

inspect requirement service [BUNDLE_ID]
List all services required by bundle. Require-Capability header is in MANIFEST.MF file is relevant to this command.

inspect capability service [BUNDLE_ID]
List all services provided by bundle. Provide-Capability header is in MANIFEST.MF file is related to this command.

diag [BUNDLE_ID]
Command will print unsatisfied constraints to specific bundle and its required bundle Id.

upgrade:check
Command will display all Upgrade Step Process Steps registered in the registry.

system:check
Command will show all unsatisfied components list along with Gogo shell commands to troubleshoot in detail. It will run Declarative Service Soft Circular Dependency Checker, Declarative Service Unsatisfied Component Checker, Spring Extender Unavailable Component Checker

history
history will print all commands used in the current session. It is similar to Unix/Linux history command.

help
It will show all available commands and its description.

services
Command will print all registered service components available in the OSGi module framework.

services grep [SEARCH-PATTERN]
Command will print all registered service components available in the OSGi module framework with filter. It will narrow down the list.

ds:unsatisfied
Command will display all unsatisfied service component list in the OSGi module framework.

ds:unsatisfied [BUNDLE_ID]
Command will display unsatisfied service components to specified bundle. It’s required bundle Id

scr:info [COMPONENT_ID]
Command will print detailed information of given component. It required the component Id and we can get component Id when we use services/ ds:unsatisfied commands.

scr:list
It will display all components registered in service registry.

scr:list | grep [SEARCH-PATTERN]
It will display matching components registered in service registry.

dm
List all dependency manager components and these are mostly service builder service components from Liferay OSGi Module Framework.

dm OR grep [SEARCH-PATTERN]
List all matching dependency manager components and these are mostly service builder service components from Liferay OSGi Module Framework.

dm cp OR  dm compact
Display components in compact from.

dm nd OR dm nodeps
Command will display only components and it is hiding dependencies of the component.

dm na OR dm notavail
It will print only not available dependency components. It is very useful when we troubleshoot unsatisfied service builder components.

dm wtf
Detects where are the root failures for components. This is also most useful command to troubleshoot service builder components

Example Usage of Commands

lb

lb | grep student

bundle 1076

headers 1076

install "file:C://Liferay/Liferay7.2/student-web/target/student-web-1.0.0.jar"

start 1076

stop 1076

uninstall 1076

inspect requirement service 1076

inspect capability service 1076

diag 1076

upgrade:check
system:check
history
help

services

services | grep student

ds:unsatisfied

ds:unsatisfied 1075

scr:info 4884

scr:list

scr:list | grep student

dm

dm | grep student

dm cp

dm nd

dm na

dm wtf

Author

Useful Apache Gogo Shell Commands in Liferay 7.2/DXP


Apache Gogo Shell is command line interface (CLI) to interact with OSGi module framework or OSGi container.

Apache Gogo shell is very useful in trouble shooting of module issues, getting module information and perform certain action like install, active and de-active OSGi bundles.

Liferay is already using Apache Gogo Shell and when we start Liferay 7.2/DXP portal, it will start automatically and we can use different ways to access Apache Gogo Shell in Liferay Portal Environment.


We can categorize Gogo shell commands in the following types.

Basic Commands
Declarative Services (DS) | Service Component Registry Commands (SCR) Commands
Dependency Management (DM) Commands

Basic Commands

Its regular usage commands to get bundles/module information like list bundles and its status.
Following are list of useful basic commands.


lb
lb | grep <BUNDLE_MATCH_PATTERN>
bundle <BUNDLE_ID>
headers <BUNDLE_ID>
install [URI_JAR_FILE_PATH]
start [BUNDLE_ID]
stop [BUNDLE_ID]
uninstall [BUNDLE_ID]
inspect requirement service [BUNDLE_ID]
inspect capability service [BUNDLE_ID]
diag [BUNDLE_ID]
upgrade:check
system:check
history
help

Example Usage


lb
lb | grep student
bundle 1076
headers 1076
install "file:C://Liferay/Liferay7.2/student-web/target/student-web-1.0.0.jar"
start 1076
stop 1076
uninstall 1076
inspect requirement service 1076
inspect capability service 1076
diag 1076
upgrade:check
system:check
history
help


Identify Bundle ID

Use lb command in the Gogo shell it will display the list of bundles installed in the OSGi modules framework. In the console view first column represent the BUNDLE ID.

Example


Declarative Services (DS) | Service Component Registry Commands (SCR)

Liferay module framework uses the OSGi Declarative Services/Service Component Registry to manage module components and its services references. Gogo shell leverage the Service Component Registry and Declarative Services. We can access services information using Gogo shell commands. 
In Liferay 7.2/DXP most of modules are using DS/SCR framework. Only service builder components are using the Apache Felix Dependency Management Framework to register and manage service components.

If you see any @Component or @Reference annotations in the java class, it implies that module components are using the Declarative Services/Service Component Registry Framework.

The following are some of useful Gogo Shell commands to insect components and its references.

services
services grep [SEARCH-PATTERN]
ds:unsatisfied
ds:unsatisfied [BUNDLE_ID]
scr:info [COMPONENT_ID]
scr:list
scr:list | grep [SEARCH-PATTERN]


Example Usage


services
services | grep student
ds:unsatisfied
ds:unsatisfied 1075
scr:info 4884
scr:list
scr:list | grep student


Identify COMPONENT ID

Use services/ ds:unsatisfied go shell commands and it will display component information and its ID.

Example 1


Example 2


Dependency Management (DM) Commands

Liferay Service Builder is using Apache Felix Dependency Management framework to manage components and its dependencies. Apache Gogo Shell leverage the Dependency Management framework and have set of predefined commands to provide more details of service components.
These commands are very useful when we trouble shoot about unsatisfied services in the registry.

The following are some of useful Gogo Shell commands related to Dependency Management

dm
dm | grep [SEARCH-PATTERN]
dm cp
dm nd
dm na
dm wtf


OR

dm
dm | grep [SEARCH-PATTERN]
dm compact
dm nodeps
dm notavail
dm wtf

Example Usage

dm
dm | grep student
dm cp
dm nd
dm na
dm wtf


Example usage screen



Reference


Author


Tuesday, October 10, 2017

Liferay 7 / DXP Modularity Introduction

Liferay 7 /DXP is new release from Liferay Inc. Liferay 7 / DXP came up with new architecture based development that is OSGi.

As we know OSGi (Open Services Gateway Initiative) is Dynamic Component Development for Java platform. Its modular framework, where we can compose the application into several module and the modules communicate each other.  Liferay 7 / DXP have OSGi support so we can develop liferay applications as OSGi modules.  Modularity is interesting feature and have many capabilities to make application into several modules.

Follow the bellow articles to know more about OSGi


Interesting features of OSGi

Reduce the complexity and make the application sampler
Easy Deployment of applications
Reasonability of the components and modules
Easy version management
Cross platform support we can run anywhere
Widely used platform now a days.

When we consider all above interesting features OSGi promising platform to deliver many interesting capabilities.

Liferay 7 / DXP have used OSGi modularity features to build and develop the Liferay 7/ DXPApplications.

OSGi specification available in two popular implementations such as Apache Felix and Eclipse Equinox.


Liferay 7 have used both implementation capabilities to strengthen the Liferay Modular Application development.

Traditional Web application development have application servers, which runs the web applications. It means, we will develop applications based on web application standards using some J2EE Web application frameworks. We will package these applications as WAR files and deploy into the Application Servers. This is basic web application development and runs the applications.

Whereas OSGi environment have OSGi container to run the OSGi applications.
OSGi applications can call it as OSGi bundles. OSGi bundles is JAR file, which consist of Java and other configuration files. These bundle developments follow the OSGi specification so that it can run in OSGi containers.

When we are talking about OSGi bundles, we use Component terminology many times.  Component is piece of code, which runs independently and deliver some reusable feature or task.

OSGi application composed of several components and these components are talk each other and all together deliver complex feature or task.

We package the group of components as bundle. Bundles is an OSGi application based on OSGi specification and runs in OSGi containers. Interesting feature of OSGi is application composed into small components.  

OSGi have other interesting artifact called OSGi Service Registry, which manage the component and its service registration and manage the references. OSGi component dependency management controlled via OSGi service registry. OSGi service registry implemented by OSGi Declarative Services and shorty we call it as DS.


We also have other implementation called Apache Blueprint, which is similar to DS.


Liferay 7 /DXP can use both implementation while develop Liferay Application Modules.

Structure of OSGi Module

As per OSGi module development, we have following pieces in the application.

Service API: Service API bundles container the all service interfaces

Service Provider: Service provider bundles provide the implementation for the interfaces which definer in the Service API

Service Client: It will consume the component services.


Liferay 7 / DXP module development follows the same structure while developing the Liferay 7/DXP application bundles.

Structure of a Modular App in Liferay 7 / DXP

As per OSGi, we can break the application into several bundles. Same way Liferay 7 / DXP have several bundles/modules.

The following are important parts or bundles in the Liferay 7 / DXP module development.

API

API contains all interfaces java classes. It is separated from implementation bundle.

Service

Contains the service (business logic) and persistence implementations.

Web

Web contains the presentation layer files such as HTML, JSP, CSS and JavaScript files.

Test

Contains the tests. These are not included in the app for production.

Liferay Modular Architecture


Picture source form Liferay.com

Liferay 7/DXP have several layers in the architecture like Liferay Core, Foundation, and Web experience, Collaboration, Forms & Workflows and Independent Apps.

Liferay Core

Liferay Core consist of all core APIs and Liferay Kernel. Its basic components which will used by all other modules or layers in the Liferay portal.

Foundation

This layer consist of Liferay building blocks implementation such as Users, Roles, Groups, Themes and Permission System.

Applications Layer

Liferay application layer separated with different group of modules and these all are independent apps separated from Liferay Core and Foundation. It uses the both Liferay Core and Foundation layer APIs and Its independent modules.

Liferay core and Foundation layers are packaged as WAR file deployed in the traditional application layer. Usually all these APIs and Implementations available in ROOT directory that deployed in Application server deployment directory.

Liferay independent Apps are made it as OSGi bundles, deployed in the OSGi container. All liferay bundles are found in OSGi directory of Liferay portal.

Liferay have provides the gateway which communicate with Liferay Core and Foundation layer to fulfill liferay application features.

Liferay 7 /DXP still support the plugins development and its deployment. This is a reason still we can see traditional application server. Liferay older versions migration to Liferay 7 / DXP possible through to keep traditional application server in the Liferay 7/DXP.

To customize or develop new features in Liferay 7/DXP, Developer follows the OSGi modularity specification to develop Liferay 7 / DXP apps.

Now all liferay applications possible through the OSGi bundles. Still some of the limitations for Liferay Themes, so we follows the Web based development for themes. Portlets, hooks can make it as OSGi bundles and themes can make it as WARs. Liferay 7 / DXP still support Plugins SDK so that we can develop liferay applications as plugin wars.

Liferay 7 / DXP suggested using OSGi Declarative Services (DS) framework to develop Liferay 7 application bundles. We can use Apache Blueprint framework as well.

Liferay have used Apache Gogo shell Command Line Interface to manage bundles, its means Activate/Deactivate Start/Stop bundles in the OSGi container. Bundles lifecycle controlled via Apache Gogo shell.

Interesting point is, we can disable/ enable Liferay features through Apache Gogo shell and we do not need to un-deploy or remove bundle from OSGi container. Just we can deactivate or activate is enough.

Liferay have provided good tools to develop Liferay 7/DXP modules. Follow the below articles to know more about Liferay 7/DXP Module Development. Follow below link to find more details about Liferay Application Development Tools


Author

Recent Posts

Recent Posts Widget

Popular Posts