diff options
author | S.W <wimmesberger@gmail.com> | 2019-06-27 09:58:37 +0200 |
---|---|---|
committer | Zhe Sun <31067185+ZheSun88@users.noreply.github.com> | 2019-06-27 10:58:36 +0300 |
commit | 583920f327c338a020d4e09e420548f44127cb7f (patch) | |
tree | 4319908dd2887bd780fb89a64d79c7690721c252 /liferay-integration | |
parent | 4c4d0375c1efdf5d943ee2112bdd2160e0045af7 (diff) | |
download | vaadin-framework-583920f327c338a020d4e09e420548f44127cb7f.tar.gz vaadin-framework-583920f327c338a020d4e09e420548f44127cb7f.zip |
OSGi: Removed static VaadinResourceService access in liferay-integration, osgi-integration (#11335)
* Made VaadinResourceService a OSGi component, removed static access of OsgiVaadinResources
Diffstat (limited to 'liferay-integration')
-rw-r--r-- | liferay-integration/src/main/java/com/vaadin/osgi/liferay/VaadinPortletProvider.java | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/liferay-integration/src/main/java/com/vaadin/osgi/liferay/VaadinPortletProvider.java b/liferay-integration/src/main/java/com/vaadin/osgi/liferay/VaadinPortletProvider.java index cb5f6cfa1b..0bdab7b480 100644 --- a/liferay-integration/src/main/java/com/vaadin/osgi/liferay/VaadinPortletProvider.java +++ b/liferay-integration/src/main/java/com/vaadin/osgi/liferay/VaadinPortletProvider.java @@ -17,7 +17,6 @@ package com.vaadin.osgi.liferay; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceObjects; -import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Deactivate; @@ -26,7 +25,6 @@ import org.osgi.service.component.annotations.ReferenceCardinality; import org.osgi.service.log.LogService; import org.osgi.util.tracker.ServiceTracker; -import com.vaadin.osgi.resources.OsgiVaadinResources; import com.vaadin.osgi.resources.VaadinResourceService; import com.vaadin.ui.UI; @@ -45,19 +43,28 @@ public class VaadinPortletProvider { private ServiceTracker<UI, ServiceObjects<UI>> serviceTracker; private PortletUIServiceTrackerCustomizer portletUIServiceTrackerCustomizer; + private VaadinResourceService vaadinService; private LogService logService; @Activate - void activate(ComponentContext componentContext) throws Exception { - BundleContext bundleContext = componentContext.getBundleContext(); - VaadinResourceService service = OsgiVaadinResources.getService(); - + void activate(BundleContext bundleContext) throws Exception { portletUIServiceTrackerCustomizer = new PortletUIServiceTrackerCustomizer( - service, logService); + vaadinService, logService); serviceTracker = new ServiceTracker<UI, ServiceObjects<UI>>( bundleContext, UI.class, portletUIServiceTrackerCustomizer); serviceTracker.open(); } + + @Reference + void setVaadinResourceService(VaadinResourceService vaadinService) { + this.vaadinService = vaadinService; + } + + void unsetVaadinResourceService(VaadinResourceService vaadinService) { + if(this.vaadinService == vaadinService) { + this.vaadinService = null; + } + } @Reference(cardinality = ReferenceCardinality.OPTIONAL) void setLogService(LogService logService) { @@ -65,7 +72,9 @@ public class VaadinPortletProvider { } void unsetLogService(LogService logService) { - this.logService = null; + if(this.logService == logService) { + this.logService = null; + } } @Deactivate |