From 7e89b5e3348be487110bd8a5c60336ff363cf9d6 Mon Sep 17 00:00:00 2001 From: "S.W" Date: Fri, 21 Sep 2018 10:01:52 +0200 Subject: OSGi resource registration via SCR (#11166) * Changed the way resources, themes, and widgetsets are registered to the HttpService by only using the VaadinResourceTrackerComponent --- .../vaadin/server/osgi/BootstrapContribution.java | 38 ++++++++-------------- 1 file changed, 14 insertions(+), 24 deletions(-) (limited to 'server') diff --git a/server/src/main/java/com/vaadin/server/osgi/BootstrapContribution.java b/server/src/main/java/com/vaadin/server/osgi/BootstrapContribution.java index 05966f4f2b..17e2e711e6 100644 --- a/server/src/main/java/com/vaadin/server/osgi/BootstrapContribution.java +++ b/server/src/main/java/com/vaadin/server/osgi/BootstrapContribution.java @@ -15,15 +15,13 @@ */ package com.vaadin.server.osgi; -import org.osgi.service.component.annotations.Activate; +import java.util.ArrayList; +import java.util.List; + import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Reference; -import org.osgi.service.http.HttpService; -import org.osgi.service.http.NamespaceException; -import com.vaadin.osgi.resources.OsgiVaadinResources; -import com.vaadin.osgi.resources.OsgiVaadinResources.ResourceBundleInactiveException; -import com.vaadin.osgi.resources.VaadinResourceService; +import com.vaadin.osgi.resources.OsgiVaadinContributor; +import com.vaadin.osgi.resources.OsgiVaadinResource; /** * OSGi service component registering bootstrap JS as published resources in @@ -32,26 +30,18 @@ import com.vaadin.osgi.resources.VaadinResourceService; * @author Vaadin Ltd * @since 8.1 */ -@Component(immediate = true) -public class BootstrapContribution { +@Component +public class BootstrapContribution implements OsgiVaadinContributor { private static final String[] RESOURCES = { "vaadinBootstrap.js", "vaadinBootstrap.js.gz" }; - private HttpService httpService; - @Activate - void startup() throws NamespaceException, ResourceBundleInactiveException { - VaadinResourceService service = OsgiVaadinResources.getService(); - for (String resourceName : RESOURCES) { - service.publishResource(resourceName, httpService); + @Override + public List getContributions() { + final List contributions = new ArrayList<>( + RESOURCES.length); + for (final String theme : RESOURCES) { + contributions.add(OsgiVaadinResource.create(theme)); } - } - - @Reference - void setHttpService(HttpService service) { - httpService = service; - } - - void unsetHttpService(HttpService service) { - httpService = null; + return contributions; } } -- cgit v1.2.3