public void removedService()

in cdi-extender/src/main/java/org/apache/aries/cdi/container/internal/container/ExtensionPhase.java [245:298]


		public void removedService(ServiceReference<Extension> reference, final ExtendedExtensionDTO extensionDTO) {
			_log.debug(l -> l.debug("CCR Departing extension {} on {}", Conversions.convert(extensionDTO).to(ExtensionDTO.class), bundle()));

			containerState.bundleContext().ungetService(reference);

			if (!snapshots().removeIf(snap ->
					((ExtendedExtensionDTO)snap).serviceReference.equals(reference))) {
				return;
			}

			for (Iterator<ExtendedExtensionDTO> itr = _references.iterator();itr.hasNext();) {
				ExtendedExtensionDTO entry = itr.next();
				if (((ExtendedExtensionTemplateDTO)extensionDTO.template).filter.match(entry.serviceReference)) {
					entry.extension = containerState.bundleContext().getServiceObjects(entry.serviceReference);
					itr.remove();
					snapshots().add(entry);
					break;
				}
			}

			containerState.incrementChangeCount();

			next.ifPresent(
				next -> {
					Promise<Boolean> result = submit(next.closeOp(), next::close).then(
						s -> {
							if (extensionTemplates().stream().allMatch(tmpl -> snapshots().stream().anyMatch(ext -> ext.template == tmpl))) {
								return submit(next.openOp(), next::open).onFailure(
									f -> {
										_log.error(l -> l.error("CCR Error in extension open {} on {}", reference, bundle(), f));

										error(f);
									}
								);
							}

							return s;
						},
						f -> {
							_log.error(l -> l.error("CCR Error in extension close {} on {}", reference, bundle(), f.getFailure()));

							error(f.getFailure());
						}
					);

					try {
						result.getValue();
					}
					catch (Exception e) {
						Throw.exception(e);
					}
				}
			);
		}