Thursday 23 July 2020

Liferay OSGi framework

1. OSGi Framework provides runtime environment (container) and development environment (annotations, dependency injection)
Note: @Reference works for concrete classes only. That means not work for interface and abstract classes (getting null as object value) 

2. Component lifecycle - active, activated and deactivated

3. Component registered in OSGi Container and service registered in Service registry

4. invoke method (getTime()) from gogo shell - "osgi.command.function=getTime", "osgi.command.scope=custom"

5. We can determine multiple implementations for single interface by using 1. ranking, 2. target

6. Export-Package & Import-Package vs Provide-Capability & Require-Capability

7. Bundle lifecycle - 1. Installed, 2. Resolved, 3. Active, 4.

8. Spring beans generated by liferay service builder by which annotation can use/reference it ?
sol : @ServiceReference annotation.
Explanation : AssignmentServiceImpl is not OSGi component class. Hence, need to use @servicereference.

9. MVC Commands take care of the portlet life-cycle and interaction b/w UI & Back-end.
     a. MVC Commands are wired to a certain portlet life-cycle (render, action & resource)
     b. They respond to certain 'mvc.command.name' defined in component properties.
     c. they register to a certain portlet with the 'javax.portlet.name' component property.

10. To make silence the generated API under any xxxxLocalServiceImpl classes, simply override that API by @override and define to throw UnsupportedOperationException

11. what is the bundle State when its working as expected after deployment of fragment module ?
Sol : Resolved

12. how many ways override JSPs and what are those ?
Sol : 2 ways and  a. override that JSP by creating fragment module. b. update that JSP by creating render filter and customize the JSP output.

13. What is LifecycleAction and why will use it?
Sol : LifecycleAction allows us to customize liferay's application by using events. Events are 1. application.startup.events, 2. prelogin.events, 3. postlogin.events and etc.,

14. what is  the use of servicewrapper?
Sol : By using Servicewrapper we can customize service methods either pre or post execution.

15. How we can override struts action?

Sol : Our custom component class should extends BaseStrutsAction and property is "path=/portal/logout"

Sample :
1. Step 1 :  @Component(
2.        immediate = true,
3.        property = {
4.            "path=/portal/logout"
5.        },
6.        service = StrutsAction.class)

1.Step 2 :        @Override
2.        public String execute(
3.            StrutsAction originalStrutsAction, HttpServletRequest request,
4.            HttpServletResponse response)
5.            throws Exception {
6.    
7.            System.out.println("Overriding the Portal Logout Action!");
8.    
9.            originalStrutsAction.execute(request, response);
10.   
11.           response.sendRedirect("https://university.liferay.com");
12.   
13.           return null;
14.       }

16. How to override MVCActionCommand?
Sol : Our custom component class should extends BaseMVCActionCommand, and property is property = {
"javax.portlet.name=" + DLPortletKeys.DOCUMENT_LIBRARY,
"javax.portlet.name=" + DLPortletKeys.DOCUMENT_LIBRARY_ADMIN,
"javax.portlet.name=" + DLPortletKeys.MEDIA_GALLERY_DISPLAY,
"mvc.command.name=/document_library/edit_folder",
"service.ranking:Integer=100"
}
17. Model entity listener ?
Sol : Events we are able to listen for when an action on a Model Entity is executed in the persistence layer. There are a few use cases for Model Listeners such as an Audit Listener, Cache Clearing Listener, and Validation Listener. The use case we are implementing is the fourth use case, the Entity Update Listener.

Snippet : @Component(immediate = true, service = ModelListener.class)
public class UserPostUpdateModelListener extends BaseModelListener<User> {
}

18. message bus listener ?



No comments:

Post a Comment