ServiceController<InternalApplicationExtension> extController = (ServiceController<InternalApplicationExtension>) this.registry.getService(Services.applicationExtension(appId, this.resourceId)); ServiceController<InternalApplicationExtension> extensionController = (ServiceController<InternalApplicationExtension>) extController.getServiceContainer().getService(Services.applicationExtension(appId, this.resourceId));
public InternalApplicationExtension extend(String extensionId, String resourceId, ObjectNode configuration, boolean boottime) throws Exception { ServiceTarget target = this.target.subTarget(); StabilityMonitor monitor = new StabilityMonitor(); target.addMonitor(monitor); ServiceName resourceServiceName = Services.applicationExtension(this.id, resourceId); ApplicationExtensionService appExt = new ApplicationExtensionService(extensionId, resourceId, configuration, boottime); ServiceController<InternalApplicationExtension> controller = target.addService(resourceServiceName, appExt) .addDependency(Services.extension(extensionId), Extension.class, appExt.extensionInjector()) .addDependency(Services.application(this.id), InternalApplication.class, appExt.applicationInjector()) .addDependency(Services.SERVICE_REGISTRY, ServiceRegistry.class, appExt.serviceRegistryInjector()) .install(); monitor.awaitStability(); InternalApplicationExtension intAppExt = controller.awaitValue(); if (intAppExt.exception() != null) { intAppExt.remove(); log.error(intAppExt.exception()); throw intAppExt.exception(); } target.removeMonitor(monitor); return intAppExt; }
@Override public void start(StartContext context) throws StartException { log.debug("application resources service: START: " + this.resourcesTree); if (this.resourcesTree == null) { createGitCommitService(context, null); return; } context.asynchronous(); try { new Thread(() -> { try { Set<ServiceName> dependencies = new HashSet<>(); Set<String> fields = this.resourcesTree.getPropertyNames(); for (String resourceId : fields) { dependencies.add(Services.applicationExtension(this.applicationInjector.getValue().id(), resourceId)); ResourceState resourceState = (ResourceState) this.resourcesTree.getProperty(resourceId); log.debug("BOOTTIME INSTALL OF: " + resourceId); this.applicationInjector.getValue().extend(resourceId, resourceState, true); } createGitCommitService(context, dependencies); context.complete(); } catch (Throwable e) { context.failed(new StartException(e)); } }, "ApplicationResourcesService starter - " + this.applicationInjector.getValue().name()).start(); } catch (Throwable e) { context.failed(new StartException(e)); } }