/** * Includes the composite in the current composite. * * @param included the name of the composite to include * @return the builder */ public CompositeBuilder include(Composite included) { checkState(); Include include = new Include(); include.setIncluded(included); include.setName(included.getName()); composite.add(include); return this; }
/** * Adds an included composite. * * @param include the composite to include */ public void add(Include include) { include.setParent(this); includes.put(include.getName(), include); componentsView.putAll(include.getIncluded().getComponents()); wiresView.addAll(include.getIncluded().getWires()); channelsView.putAll(include.getIncluded().getChannels()); resourcesView.addAll(include.getIncluded().getResources()); }
private void includeProperties(Composite composite, LogicalCompositeComponent domain, InstantiationContext context) { for (Property property : composite.getProperties().values()) { includeProperty(property, domain, context); } for (Include include : composite.getIncludes().values()) { for (Property property : include.getIncluded().getProperties().values()) { includeProperty(property, domain,context); } } }
private void includeProperties(Composite composite, LogicalCompositeComponent domain, InstantiationContext context) { for (Property property : composite.getProperties().values()) { includeProperty(property, domain, context); } for (Include include : composite.getIncludes().values()) { for (Property property : include.getIncluded().getProperties().values()) { includeProperty(property, domain,context); } } }
/** * Synthesizes a composite from a collection of composites using inclusion. A counter is maintained for each include name and used to generate include * names in situations where they may clash, e.g. when two composites from different contributions with the same name are deployed together. * * @param composites the composites to synthesize * @return the synthesized composite */ private Composite synthesizeComposite(List<Composite> composites) { Composite synthesized = new Composite(SYNTHETIC_COMPOSITE); Map<QName, AtomicInteger> counters = new HashMap<>(); for (Composite composite : composites) { Include include = new Include(); QName name = composite.getName(); include.setName(name); include.setIncluded(composite); if (synthesized.getIncludes().containsKey(name)) { AtomicInteger counter = counters.get(name); if (counter == null) { counter = new AtomicInteger(); counters.put(name, counter); } include.setName(new QName(name.getNamespaceURI(), name.getLocalPart() + counter.incrementAndGet())); } synthesized.add(include); } return synthesized; }
/** * Instantiates components in included composites. * * @param composite the root composite to instantiate * @param newComponents the collection to hold instantiated components * @param synthetic true if the root composite is synthetic * @param domain the domain * @param context the instantiation context */ private void instantiateIncludes(Composite composite, List<LogicalComponent<?>> newComponents, boolean synthetic, LogicalCompositeComponent domain, InstantiationContext context) { // instantiate the included components for (Include include : composite.getIncludes().values()) { for (Component<? extends Implementation<?>> definition : include.getIncluded().getComponents().values()) { LogicalComponent<?> logicalComponent = instantiate(definition, domain, context); newComponents.add(logicalComponent); // add to the domain since includes starting from a deployable composite are "collapsed" to the domain level domain.addComponent(logicalComponent); } } }
/** * Synthesizes a composite from a collection of composites using inclusion. A counter is maintained for each include name and used to generate include * names in situations where they may clash, e.g. when two composites from different contributions with the same name are deployed together. * * @param composites the composites to synthesize * @return the synthesized composite */ private Composite synthesizeComposite(List<Composite> composites) { Composite synthesized = new Composite(SYNTHETIC_COMPOSITE); Map<QName, AtomicInteger> counters = new HashMap<>(); for (Composite composite : composites) { Include include = new Include(); QName name = composite.getName(); include.setName(name); include.setIncluded(composite); if (synthesized.getIncludes().containsKey(name)) { AtomicInteger counter = counters.get(name); if (counter == null) { counter = new AtomicInteger(); counters.put(name, counter); } include.setName(new QName(name.getNamespaceURI(), name.getLocalPart() + counter.incrementAndGet())); } synthesized.add(include); } return synthesized; }
/** * Instantiates components in included composites. * * @param composite the root composite to instantiate * @param newComponents the collection to hold instantiated components * @param synthetic true if the root composite is synthetic * @param domain the domain * @param context the instantiation context */ private void instantiateIncludes(Composite composite, List<LogicalComponent<?>> newComponents, boolean synthetic, LogicalCompositeComponent domain, InstantiationContext context) { // instantiate the included components for (Include include : composite.getIncludes().values()) { for (Component<? extends Implementation<?>> definition : include.getIncluded().getComponents().values()) { LogicalComponent<?> logicalComponent = instantiate(definition, domain, context); newComponents.add(logicalComponent); // add to the domain since includes starting from a deployable composite are "collapsed" to the domain level domain.addComponent(logicalComponent); } } }
Composite included = include.getIncluded(); channelInstantiator.instantiateChannels(included, domain, context);
Composite included = include.getIncluded(); channelInstantiator.instantiateChannels(included, domain, context);
private void includeResources(Composite composite, LogicalCompositeComponent domain, boolean synthetic) { if (synthetic) { for (Include include : composite.getIncludes().values()) { Composite included = include.getIncluded(); for (Resource definition : included.getResources()) { LogicalResource<?> resource = new LogicalResource<>(definition, domain); domain.addResource(resource); } } } else { for (Resource definition : composite.getResources()) { LogicalResource<?> resource = new LogicalResource<>(definition, domain); domain.addResource(resource); } } }
private void includeResources(Composite composite, LogicalCompositeComponent domain, boolean synthetic) { if (synthetic) { for (Include include : composite.getIncludes().values()) { Composite included = include.getIncluded(); for (Resource definition : included.getResources()) { LogicalResource<?> resource = new LogicalResource<>(definition, domain); domain.addResource(resource); } } } else { for (Resource definition : composite.getResources()) { LogicalResource<?> resource = new LogicalResource<>(definition, domain); domain.addResource(resource); } } }