/** * Read a component from his StreamRef and create a new component (suffixed with `-partial`, and the base component * name aliased) with only matching contributions of the extensionPoints parameter. * * @param ctx RuntimeContext in which the new component will be deployed * @param extensionPoints Set of white listed TargetExtensions * @param component Reference to the original component * @throws IOException Signals that an I/O exception has occurred. */ protected void deployPartialComponent(RuntimeContext ctx, Set<TargetExtensions> extensionPoints, StreamRef component) throws IOException { RegistrationInfo ri = ((DefaultRuntimeContext) ctx).createRegistrationInfo(component); String name = ri.getName().getName() + "-partial"; // Flatten Target Extension Points Set<String> targets = extensionPoints.stream() .map(TargetExtensions::getTargetExtensions) .flatMap(Set::stream) .collect(Collectors.toSet()); String ext = Arrays.stream(ri.getExtensions()) .filter(e -> targets.contains(TargetExtensions.newTargetExtension( e.getTargetComponent().getName(), e.getExtensionPoint()))) .map(Extension::toXML) .collect(joining()); ctx.deploy(new InlineRef(name, String.format("<component name=\"%s\">%s</component>", name, ext))); }
protected static boolean isServiceOverriden(RegistrationInfo ri, String serviceName) { try { Class<?> typeof = Class.forName(serviceName); final Object adapter = ri.getComponent().getAdapter(typeof); final Object service = Framework.getService(typeof); if (adapter == service) { return false; } return service.getClass() != adapter.getClass(); } catch (ClassNotFoundException cause) { return false; } catch (NullPointerException cause) { return false; } }
String cname = ri.getName().getName(); Bundle bundle = ri.getContext().getBundle(); BundleInfoImpl binfo = null; if (ri.getExtensionPoints() != null) { for (ExtensionPoint xp : ri.getExtensionPoints()) { ExtensionPointInfoImpl xpinfo = new ExtensionPointInfoImpl(component, xp.getName()); Class<?>[] ctypes = xp.getContributions(); component.setXmlFileUrl(ri.getXmlFileUrl()); if (ri.getProvidedServiceNames() != null) { for (String serviceName : ri.getProvidedServiceNames()) { component.addService(serviceName, isServiceOverriden(ri, serviceName)); if (ri.getExtensions() != null) { for (Extension xt : ri.getExtensions()) { ExtensionInfoImpl xtinfo = new ExtensionInfoImpl(component, xt.getExtensionPoint()); xtinfo.setTargetComponentName(xt.getTargetComponent()); component.setComponentClass(ri.getImplementation()); component.setDocumentation(ri.getDocumentation());
public static synchronized SimplifiedServerInfo getInfo() { if (info == null) { RuntimeService runtime = Framework.getRuntime(); Collection<RegistrationInfo> registrations = runtime.getComponentManager().getRegistrations(); bundleIds = new ArrayList<>(); List<SimplifiedBundleInfo> bundles = new ArrayList<>(); for (RegistrationInfo ri : registrations) { Bundle bundle = ri.getContext().getBundle(); if (bundle != null && !bundleIds.contains(bundle.getSymbolicName())) { SimplifiedBundleInfo bi = getBundleSimplifiedInfo(bundle); bundleIds.add(bundle.getSymbolicName()); if (bi != null) { bundles.add(bi); } } } Collections.sort(bundles); info = new SimplifiedServerInfo(); info.setBundleInfos(bundles); info.setRuntimeVersion(runtime.getVersion().toString()); info.setWarnings(runtime.getWarnings()); } return info; }
public static synchronized SimplifiedServerInfo getInfo() { if (info == null) { RuntimeService runtime = Framework.getRuntime(); Collection<RegistrationInfo> registrations = runtime.getComponentManager().getRegistrations(); bundleIds = new ArrayList<>(); List<SimplifiedBundleInfo> bundles = new ArrayList<>(); for (RegistrationInfo ri : registrations) { Bundle bundle = ri.getContext().getBundle(); if (bundle != null && !bundleIds.contains(bundle.getSymbolicName())) { SimplifiedBundleInfo bi = getBundleSimplifiedInfo(bundle); bundleIds.add(bundle.getSymbolicName()); if (bi != null) { bundles.add(bi); } } } Collections.sort(bundles); info = new SimplifiedServerInfo(); info.setBundleInfos(bundles); info.setRuntimeVersion(runtime.getVersion().toString()); RuntimeMessageHandler runtimeMessageHandler = runtime.getMessageHandler(); info.setWarnings(runtimeMessageHandler.getWarnings()); info.setErrors(runtimeMessageHandler.getErrors()); } return info; }