/** * Synthesizes a composite from a collection of composites using inclusion. * * @param composites the composites to synthesize * @return the synthesized composite */ private Composite synthesizeComposite(List<Composite> composites) { Composite synthesized = new Composite(SYNTHETIC_COMPOSITE); for (Composite composite : composites) { Include include = new Include(); include.setName(composite.getName()); include.setIncluded(composite); synthesized.add(include); } return synthesized; }
private Include loadFromSideFile(QName name, ClassLoader cl, URI contributionUri, URL url, XMLStreamReader reader, IntrospectionContext context) { Include include = new Include(); IntrospectionContext childContext = new DefaultIntrospectionContext(cl, contributionUri, url); Composite composite; try { composite = registry.load(url, Composite.class, childContext); } catch (LoaderException e) { InvalidValue failure = new InvalidValue("Error loading include", reader); context.addError(failure); return include; } if (childContext.hasErrors()) { context.addErrors(childContext.getErrors()); } if (childContext.hasWarnings()) { context.addWarnings(childContext.getWarnings()); } include.setName(name); include.setScdlLocation(url); include.setIncluded(composite); return include; }
private void handleInclude(Composite type, XMLStreamReader reader, IntrospectionContext childContext) throws XMLStreamException, UnrecognizedElementException { Include include = registry.load(reader, Include.class, childContext); if (include == null) { // errror encountered loading the include return; } QName includeName = include.getName(); if (type.getIncludes().containsKey(includeName)) { String identifier = includeName.toString(); DuplicateInclude failure = new DuplicateInclude(identifier, reader); childContext.addError(failure); return; } for (ComponentDefinition definition : include.getIncluded().getComponents().values()) { String key = definition.getName(); if (type.getComponents().containsKey(key)) { DuplicateComponentName failure = new DuplicateComponentName(key, reader); childContext.addError(failure); } } type.add(include); }
for (ComponentDefinition<? extends Implementation<?>> definition : include.getIncluded().getComponents().values()) { LogicalComponent<?> logicalComponent = instantiate(definition, domain, context); if (synthetic) { setDeployable(logicalComponent, include.getIncluded().getName()); } else { setDeployable(logicalComponent, composite.getName());
Composite included = include.getIncluded(); channelInstantiator.instantiateChannels(included, domain, context);
/** * Creates a wrapper used to include a composite at the domain level. The wrapper is thrown away during the inclusion. * * @param deployable the deployable being included * @return the composite wrapper * @throws DeploymentException if there is an error creating the composite wrapper */ private Composite createWrapper(QName deployable) throws DeploymentException { Composite composite = contributionHelper.findComposite(deployable); // In order to include a composite at the domain level, it must first be wrapped in a composite that includes it. // This wrapper is thrown away during the inclusion. Composite wrapper = new Composite(deployable); Include include = new Include(); include.setName(deployable); include.setIncluded(composite); wrapper.add(include); return wrapper; }
private void includeResources(Composite composite, LogicalCompositeComponent domain, boolean synthetic) { if (synthetic) { for (Include include : composite.getIncludes().values()) { Composite included = include.getIncluded(); for (ResourceDefinition definition : included.getResources()) { LogicalResource<?> resource = new LogicalResource<ResourceDefinition>(definition, domain); resource.setDeployable(included.getName()); domain.addResource(resource); } } } else { for (ResourceDefinition definition : composite.getResources()) { LogicalResource<?> resource = new LogicalResource<ResourceDefinition>(definition, domain); resource.setDeployable(composite.getName()); domain.addResource(resource); } } }
Include include = new Include(); include.setName(name); include.setIncluded(composite); return include; } catch (StoreException e) {