use of org.osgi.service.blueprint.container.BlueprintContainer in project pentaho-metaverse by pentaho.
the class MetaverseBeanUtil method get.
public Object get(String id) {
BlueprintContainer service = null;
if (bundleContext == null) {
return null;
} else {
try {
Bundle bundle = bundleContext.getBundle();
if (bundle == null) {
return null;
}
Collection<ServiceReference<BlueprintContainer>> serviceReferences = bundleContext.getServiceReferences(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=" + bundle.getSymbolicName() + ")");
if (serviceReferences.size() != 0) {
ServiceReference<BlueprintContainer> reference = serviceReferences.iterator().next();
service = bundleContext.getService(reference);
}
} catch (InvalidSyntaxException e) {
// No-op, service will be null
}
if (service == null) {
return null;
}
return service.getComponentInstance(id);
}
}
use of org.osgi.service.blueprint.container.BlueprintContainer in project fabric8 by jboss-fuse.
the class WatcherBlueprintContainer method removePath.
protected void removePath(Path path) {
URL url = toUrl(path);
if (url != null) {
BlueprintContainer container = containerMap.remove(url);
closeContainer(url, container);
}
}
use of org.osgi.service.blueprint.container.BlueprintContainer in project fabric8 by jboss-fuse.
the class WatcherBlueprintContainer method destroy.
public void destroy() {
if (closing.compareAndSet(false, true)) {
Set<Map.Entry<URL, BlueprintContainer>> entries = containerMap.entrySet();
for (Map.Entry<URL, BlueprintContainer> entry : entries) {
URL url = entry.getKey();
BlueprintContainer container = entry.getValue();
closeContainer(url, container);
}
}
super.destroy();
}
use of org.osgi.service.blueprint.container.BlueprintContainer in project controller by opendaylight.
the class BlueprintBundleTracker method shutdownAllContainers.
private void shutdownAllContainers() {
shuttingDown = true;
restartService.close();
// Close all CSS modules first.
ConfigSystemService configSystem = getOSGiService(ConfigSystemService.class);
if (configSystem != null) {
configSystem.closeAllConfigModules();
}
LOG.info("Shutting down all blueprint containers...");
Collection<Bundle> containerBundles = new HashSet<>(Arrays.asList(bundleContext.getBundles()));
while (!containerBundles.isEmpty()) {
// eligible to be destroyed. We loop until we've destroyed them all.
for (Bundle bundle : getBundlesToDestroy(containerBundles)) {
containerBundles.remove(bundle);
BlueprintContainer container = blueprintExtenderService.getContainer(bundle);
if (container != null) {
blueprintExtenderService.destroyContainer(bundle, container);
}
}
}
LOG.info("Shutdown of blueprint containers complete");
}
use of org.osgi.service.blueprint.container.BlueprintContainer in project admin-console-beta by connexta.
the class BundleUtils method populateServices.
private void populateServices(Bundle bundle, BundleField toPopulate) {
Optional<BlueprintContainer> blueprintContainer = getBlueprintContainer(bundle);
if (blueprintContainer.isPresent()) {
List<ComponentMetadata> cmpMetas = blueprintContainer.get().getComponentIds().stream().map(id -> blueprintContainer.get().getComponentMetadata(id)).collect(Collectors.toList());
for (ComponentMetadata meta : cmpMetas) {
if (meta instanceof ReferenceListMetadata) {
populateServiceRefLists((ReferenceListMetadata) meta, bundle, toPopulate);
} else if (meta instanceof ReferenceMetadata) {
populateServiceRef((ReferenceMetadata) meta, bundle, toPopulate);
} else if (meta instanceof BeanMetadata || meta instanceof ServiceMetadata || meta instanceof PassThroughMetadata) {
continue;
} else {
LOGGER.warn("Unable to handle blueprint metadata of type {} for bundle {}.", meta.getClass(), bundle.getSymbolicName());
}
}
getRegisteredServices(bundle).forEach(ref -> toPopulate.addService(createServiceField(ref)));
}
}
Aggregations