Sunday 8 November 2020

Q:-What is OSGI and OSGI Architecture ?

Q:-Problems With Non Modular Applications in liferay 7?

Ans:-Two major things

1:-Increases complexity

2:-maintenance becomes harder over time

Q:-What is OSGI and OSGI  Architecture ?

Ans:-OSGI stands for Open Services Gateway Initiative

OSGI is a  framework like we have spring framework  , we have hibernate framework , we have Struts framework

OSGI also one framework  here in liferay 7, so here we can use OSGI and we can build small modularity kind of application

Modularity is nothing but the small small piece of application that is called Modularity .OSGI allow you to divide your application into multiple module

in liferay 7 every things as a services compare to old version. liferay6.2 we have a concept called SDK(software development kits)

Where we can build portlet there , layout , hook and ext but liferay 7 we have concept called portlet, theme , layout but every thing as a services

OSGI can understand only services if you want exectute any program using OSGI architecture we have to define our services OSGI can understand only service.


OSGi is providing environment where all these bundles and components can communicate each other.

each component can independent. So when ever you want to call my service , we can access application that is work of OSGi architecture .

 

OSGI provides an architecture for developing and deploying modular applications.


Q:-Architecture Of OSGI:/How its work

Ans:-OSGi architecture divided into three layers.

1:-Module Layer:- 

module layer is concern with packaging and sharing the code

Module layer define osgi module concept called "Bundle" OSGI bundle is nothing but a JAR file.

bundle contains our class files and their related resources.


2:-Lifecycle layer:- 

-------------------

OSGI lifecycle layer define How bundle are dynamically installed and manage in the OSGI framework.

Life Cycle is responsible to manage lifecycle of bundles. OSGi bundle have several lifecycle stages install, start, update, stop and uninstall.

All these stages handles in this layer.


lifecycle is concern with providing execution time , model management and access to the underline OSGI framework.


3:-Service layer:- 

------------------

Service layer is concern with interaction and communication among module.

Services layer provide mechanism to share services between bundles. It will provide environment to register services and make available to other bundles.


Service Registry:- you are adding service in the service registry , what it will do it will register your service in the SGI and make available to other bundle

service register is interface it will handle the service.


Q:-liferay cycle of OSGI:- it manage by OSGI container.

start, stop, update, and uninstall bundles.


INSTALLED : The bundle has been successfully installed.

RESOLVED : All Java classes that the bundle needs are available. This state indicates that the bundle is either ready to be started or has stopped.

STARTING: The bundle is being started, the BundleActivator.start

ACTIVE : The bundle has been successfully activated and is running. Its Bundle Activator start method has been called and returned.

STOPPING : The bundle is being stopped. The BundleActivator.stop method has been called but the stop method has not yet returned.


Q:- What are the Benefits Of OSGi:-

Ans:-

using OSGI we can separate them as independent modules.

Easy maintenance

Each Module with its own clear responsibility

Restrict and Expose the visibility of classes properly



Q:-What Is OSGI Container?

OSGI Container manages the Lifecycle of  Components, Services and Bundle or Modules

Q:-We have deployed the service. How would we know whether the service is registered or not.?

ans:- For a quick check open the Gogo Shell.

We will find the bundle id of deployed bundle. The Active status of a bundle indicates that the bundle is active inside the container.

Finding Bundle ID

g! lb proliferay

START LEVEL 20

   ID|State      |Level|Name

  513|Active     |    1|com.proliferay.demo (1.0.0.201611210957)

  514|Active     |   10|com.proliferay.sample.osgi.service (1.0.0.201611210909)

g!


 Q1:-What is Portlet Name Space?

 Portlet Name Space will give unique name to the elements in the page and these elements are associated to respective portlet.

This will avoid name conflicts in the page.


We may use many portlets within one page and there may be chance to get name collision among elements in the page. 

portlet name space will avoid those name conflicts in the page.

 

Each portlet have its own portlet name space value so that we need to append these portlet name space value to each element in the portlet 

like HTML tag names or ids and we can use this for request parameters.

Q2:-How can i get Portlet Namespace Value?

 

We can use following two ways

 

Using <portlet:namespace/> Tag.:-We can use <portlet:namespace/> Tag so that we can append portlet name space value for element names,ids and request parameters.


Using renderResponse Object:- We can also use renderResponse object to get portet Name space value. renderResponse is liferay implicit object and  these Objects will be available in JSP page.

Example:-

<input type="text" name="<%=renderResponse.getNamespace()%>employeeName" id="<%=renderResponse.getNamespace()%>employeeName"/>



Q:-Follow below steps to complete CRUD operation for your custom entity.

ans:-1)Create service-builder module for your custom entity

a.Go to liferay workspace project → modules → new

b.Select other → Liferay → Liferay Module Project and Click on “Next”

c.Enter project name

d.Select “Project Template Name” as “service-builder” and Click on “Next”

e.Enter Package name and click on “Finish”. The necessary file structure for service-builder automatically get created as below


2) Add entity in xxx-service/service.xml like as below.

3) Build the service-builder module.


4) Create MVC Portlet

a.Go to liferay workspace project → modules → new

b.Select other → Liferay → Liferay Module Project and Click on “Next”

c.Enter project name

d.Select “Project Template Name” as “mvc-portlet” and Click on “Next”

e.Enter Package name and Click on “Finish”. The necessary file structure for mvc module will gets created as below.


5)In order to add dependency of student-api in mvc portlet, add below line in “build.gradle” of your mvc portlet.

in build.gradle

uild.gradle


No comments:

Post a Comment