/** * Constructor creates a new RegistryController based on the given scope and publishing registry data of the given builder. * * Node: By default this constructor filters sparsely registry data. * If you want to publish data of internal registries even if other internal registries are not ready * yet, use can use the other constructor of this class and set the filterSparselyRegistryData flag to false. * * @param jpScopePropery the scope which is used for registry communication and data publishing. * @param builder the builder to build the registry data message. * @throws InstantiationException */ public AbstractVirtualRegistryController(Class<? extends JPScope> jpScopePropery, MB builder) throws InstantiationException { super(jpScopePropery, builder); this.virtualRegistrySynchronizer = new VirtualRegistrySynchronizer(); this.registryRemoteList = new ArrayList<>(); }
@Override protected void activateRemoteRegistries() throws CouldNotPerformException, InterruptedException { /* The order here is important! * If the VirtualRegistrySynchronizer would be registered first the data type would be notified while the remote registries * have not synced. This way getter for the VirtualRegistryController would not contain the updated values when called within an observer. */ super.activateRemoteRegistries(); getRegistryRemotes().forEach((registryRemote) -> { registryRemote.addDataObserver(virtualRegistrySynchronizer); // perform initial sync if data already available if (registryRemote.isDataAvailable()) { try { virtualRegistrySynchronizer.update(null, (RM) registryRemote.getData()); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Initial sync of [" + this + "] failed", ex), logger, LogLevel.WARN); } } }); }
/** * Constructor creates a new RegistryController based on the given scope and publishing registry data of the given builder. * * @param jpScopePropery the scope which is used for registry communication and data publishing. * @param builder the builder to build the registry data message. * @param filterSparselyRegistryData if this flag is true the registry data is only published if non of the internal registries is busy. * @throws InstantiationException */ public AbstractVirtualRegistryController(final Class<? extends JPScope> jpScopePropery, MB builder, final boolean filterSparselyRegistryData) throws InstantiationException { super(jpScopePropery, builder, filterSparselyRegistryData); this.virtualRegistrySynchronizer = new VirtualRegistrySynchronizer(); this.registryRemoteList = new ArrayList<>(); }