summaryrefslogtreecommitdiffstats
path: root/documentation/portal/portal-osgi.asciidoc
blob: 0f31698f7e9c8b2da04be1f9119d73ce22d4ad8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
title: OSGi Portlets on Liferay 7
order: 3
layout: page
---

[[portal.osgi]]
= OSGi Portlets on Liferay 7

Lifeary 7 supports modular portlet development using OSGi, and enables e.g.
using multiple different Vaadin versions in different portlets on a page. 

For general OSGi considerations with Vaadin Framework such as packaging and
bundle manifests, and how to publish static resources such as themes and
widget sets, see
<<dummy/../../../framework/advanced/advanced-osgi#advanced.osgi,"Vaadin OSGi Support">>.


[[portal.osgi.portlet]]
== Publishing a Portlet With OSGi

Publishing an OSGi portlet on Liferay 7+ can be done in two ways: using
annotations or using properties.

Annotating a UI class with [interfacename]#@VaadinLiferayPortletConfiguration#
(available in `vaadin-liferay-integration`) and making it an OSGi service of type
[classname]#UI# is the easiest way to automatically publish the UI as a portlet
and configure it to use the correct static resources.

[source, java]
----
@Theme(MyTheme.THEME_NAME)
@VaadinLiferayPortletConfiguration(name = "Vaadin.Tutorial.1", displayName = "Vaadin Tutorial App")
@Component(service = UI.class)
public class MyUI extends UI {
  ...
}
----

When using this approach, it is not necessary to create all the portlet
property files that plain JSR-362 portlets require.

Alternatively, the property [literal]#com.vaadin.osgi.liferay.portlet-ui=true#
can be used when publishing a UI as an OSGi service to publish the UI as a portlet.

[source, java]
----
@Theme(MyTheme.THEME_NAME)
@Component(service = UI.class, property = {
        "com.liferay.portlet.display-category=category.vaadin",
        "javax.portlet.name=my.vaadin.app.app.1.0.0",
        "javax.portlet.display-name=Tutorial Portlet",
        "javax.portlet.security-role-ref=power-user,user",
        "com.vaadin.osgi.liferay.portlet-ui=true"})
public class MyUI extends UI {
  ...
}
----


[[portal.osgi.portlet.gradle]]
== Deployment a Portlet With OSGi (Gradle)
Here is an example of a Liferay workspace with a portlet module and a short readme on how to deploy that to a Liferay portal.
link:https://github.com/elmot/liferay-7-solid-portlet-example/[]

[[portal.osgi.portlet]]
== Deployment a Portlet With OSGi (Maven)
An OSGi portlet should be packaged as a JAR with a proper OSGi bundle
manifest, and deployed to a portal that has its required bundles installed.
The maven archetype `com.vaadin:vaadin-archetype-liferay-portlet:8.1.0` is a good starting point to build an OSGi portlet application.
The required bundles (and the application as well) can be installed using link:https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/blade-cli[blade client].
The latest client binary can be downloaded from the link: link:https://releases.liferay.com/tools/blade-cli/latest/blade.jar[]

Here is an example script for doing that:
[source, shell]
----
java -jar blade.jar sh start https://repo1.maven.org/maven2/org/jsoup/jsoup/1.8.3/jsoup-1.8.3.jar
java -jar blade.jar sh start https://repo1.maven.org/maven2/com/vaadin/external/gentyref/1.2.0.vaadin1/gentyref-1.2.0.vaadin1.jar
java -jar blade.jar sh start https://repo1.maven.org/maven2/com/vaadin/vaadin-shared/8.1.0/vaadin-shared-8.1.0.jar
java -jar blade.jar sh start https://repo1.maven.org/maven2/com/vaadin/vaadin-server/8.1.0/vaadin-server-8.1.0.jar
java -jar blade.jar sh start https://repo1.maven.org/maven2/com/vaadin/vaadin-osgi-integration/8.1.0/vaadin-osgi-integration-8.1.0.jar
java -jar blade.jar sh start https://repo1.maven.org/maven2/com/vaadin/vaadin-client-compiled/8.1.0/vaadin-client-compiled-8.1.0.jar
java -jar blade.jar sh start https://repo1.maven.org/maven2/com/vaadin/vaadin-themes/8.1.0/vaadin-themes-8.1.0.jar
java -jar blade.jar sh start https://repo1.maven.org/maven2/com/vaadin/vaadin-liferay-integration/8.1.0/vaadin-liferay-integration-8.1.0.jar
java -jar blade.jar sh start file:<path_to_liferay_portlet.jar>
----