diff --git a/bundles/org.eclipse.passage.loc.licenses.core/OSGI-INF/org.eclipse.passage.loc.internal.licenses.core.LicenseDomainRegistry.xml b/bundles/org.eclipse.passage.loc.licenses.core/OSGI-INF/org.eclipse.passage.loc.internal.licenses.core.LicenseDomainRegistry.xml index 81419e614..5acdf60dd 100644 --- a/bundles/org.eclipse.passage.loc.licenses.core/OSGI-INF/org.eclipse.passage.loc.internal.licenses.core.LicenseDomainRegistry.xml +++ b/bundles/org.eclipse.passage.loc.licenses.core/OSGI-INF/org.eclipse.passage.loc.internal.licenses.core.LicenseDomainRegistry.xml @@ -1,12 +1,12 @@ - + + - - + \ No newline at end of file diff --git a/bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/LicenseDomainRegistry.java b/bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/LicenseDomainRegistry.java index 5c8b68e32..51c44cc17 100644 --- a/bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/LicenseDomainRegistry.java +++ b/bundles/org.eclipse.passage.loc.licenses.core/src/org/eclipse/passage/loc/internal/licenses/core/LicenseDomainRegistry.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; @@ -48,13 +49,21 @@ @Component(property = { EditingDomainRegistryAccess.PROPERTY_DOMAIN_NAME + '=' + LicensesPackage.eNAME, EditingDomainRegistryAccess.PROPERTY_FILE_EXTENSION + '=' + "licenses_xmi" }) -public class LicenseDomainRegistry extends BaseDomainRegistry +public final class LicenseDomainRegistry extends BaseDomainRegistry implements LicenseRegistry, EditingDomainRegistry { private final Map plans = new HashMap<>(); + private final List events = new ArrayList<>(); + @Reference - private EventAdmin events; + public void bindEventAdmin(EventAdmin admin) { + this.events.add(admin); + } + + public void unbindEventAdmin(EventAdmin admin) { + this.events.remove(admin); + } @Override @Reference @@ -68,14 +77,12 @@ public void unbindGear(OperatorGearSupplier supplier) { } @Activate - @Override - public void activate(Map properties) { + public void load(Map properties) { super.activate(properties); } @Deactivate - @Override - public void deactivate(Map properties) { + public void unload(Map properties) { plans.clear(); super.deactivate(properties); } @@ -113,17 +120,20 @@ void registerLicensePlan(LicensePlan licensePlan) { licensePlan); Platform.getLog(getClass()).warn(msg); } - events.postEvent(new EquinoxEvent(LicenseRegistryEvents.LICENSE_PLAN_CREATE, licensePlan).get()); + events().postEvent(new EquinoxEvent(LicenseRegistryEvents.LICENSE_PLAN_CREATE, licensePlan).get()); } void unregisterLicensePlan(String identifier) { LicensePlan removed = plans.remove(identifier); if (removed != null) { - events.postEvent(new EquinoxEvent(LicenseRegistryEvents.LICENSE_PLAN_DELETE, removed).get()); - + events().postEvent(new EquinoxEvent(LicenseRegistryEvents.LICENSE_PLAN_DELETE, removed).get()); } } + private EventAdmin events() { + return events.stream().findAny().get(); + } + @Override protected DomainContentAdapter createContentAdapter() { return new LicensesDomainRegistryTracker(this);