/** * Adds a component definition to the composite. * * @param definition the component definition * @return the builder */ public CompositeBuilder component(Component<?> definition) { checkState(); composite.add(definition); return this; }
/** * Adds a channel definition to the composite. * * @param definition the channel definition * @return the builder */ public CompositeBuilder channel(Channel definition) { checkState(); composite.add(definition); return this; }
/** * Adds a resource definition to the composite. * * @param definition the resource definition * @return the builder */ public CompositeBuilder resource(Resource definition) { checkState(); composite.add(definition); return this; }
/** * Adds the wire definition to the composite. * * @param wire the wire definition * @return the builder */ public CompositeBuilder wire(Wire wire) { checkState(); composite.add(wire); return this; }
public void deploy(Channel channel) throws Fabric3Exception { Composite wrapper = createWrapperComposite(channel.getName()); wrapper.add(channel); domain.include(wrapper); }
public void deploy(Channel channel) throws Fabric3Exception { Composite wrapper = createWrapperComposite(channel.getName()); wrapper.add(channel); domain.include(wrapper); }
/** * Adds a property to the composite parsed from the XML source. * * @param name the property name * @param source the XML source * @return the builder * @throws ModelBuilderException if an error reading the source occurs */ public CompositeBuilder property(String name, URL source) { checkState(); try { Document document = DOCUMENT_FACTORY.newDocumentBuilder().parse(source.openStream()); // all properties have a root <values> element, append the existing root to it. The existing root will be taken as a property <value>. Element oldRoot = document.getDocumentElement(); Element newRoot = document.createElement("values"); document.removeChild(oldRoot); document.appendChild(newRoot); newRoot.appendChild(oldRoot); Property property = new Property(name); property.setDefaultValue(document); composite.add(property); } catch (IOException | ParserConfigurationException | SAXException e) { throw new ModelBuilderException(e); } return this; }
/** * 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; }
/** * 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; }
private Composite createComposite(WebImplementation implementation, Contribution contribution) { URI contributionUri = contribution.getUri(); String localPart = createLocalPart(contributionUri); QName compositeName = new QName(HostNamespaces.SYNTHESIZED, localPart); Composite composite = new Composite(compositeName); composite.setContributionUri(contributionUri); Component<WebImplementation> component = new Component<>(localPart, implementation); component.setContributionUri(contributionUri); composite.add(component); return composite; }
public void deploy(Component<?> component) throws Fabric3Exception { URI uri = ContributionResolver.getContribution(); DefaultIntrospectionContext context = new DefaultIntrospectionContext(uri, getClass().getClassLoader()); component.setContributionUri(uri); componentProcessor.process(component, context); checkErrors(context); Composite wrapper = createWrapperComposite(component.getName()); wrapper.add(component); domain.include(wrapper); }
public void deploy(Component<?> component) throws Fabric3Exception { URI uri = ContributionResolver.getContribution(); DefaultIntrospectionContext context = new DefaultIntrospectionContext(uri, getClass().getClassLoader()); component.setContributionUri(uri); componentProcessor.process(component, context); checkErrors(context); Composite wrapper = createWrapperComposite(component.getName()); wrapper.add(component); domain.include(wrapper); }
public void deploy(ComponentDefinition<?> definition) throws DeploymentException { URI uri = ContributionResolver.getContribution(); DefaultIntrospectionContext context = new DefaultIntrospectionContext(uri, getClass().getClassLoader()); definition.setContributionUri(uri); componentProcessor.process(definition, context); checkErrors(context); try { Composite wrapper = createWrapperComposite(definition.getName()); wrapper.add(definition); domain.include(wrapper, false); } catch (org.fabric3.api.host.domain.DeploymentException e) { throw new DeploymentException(e); } }
/** * 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; }
public void deploy(ChannelDefinition definition) throws DeploymentException { try { URI uri = ContributionResolver.getContribution(); definition.setContributionUri(uri); Composite wrapper = createWrapperComposite(definition.getName()); wrapper.add(definition); domain.include(wrapper, false); } catch (org.fabric3.api.host.domain.DeploymentException e) { throw new DeploymentException(e); } }
private LogicalReference createReference(Class<?> interfaze) { LogicalCompositeComponent domainComponent = lcm.getDomainComposite(); int id = idCounter.getAndIncrement(); String name = "Synthetic" + id; URI componentUri = URI.create(domainComponent.getUri().toString() + "/" + name); URI referenceUri = URI.create(componentUri.toString() + "#reference"); QName qName = new QName(HostNamespaces.SYNTHESIZED, "SyntheticComposite" + id); Composite composite = new Composite(qName); Component<NonManagedImplementation> component = new Component<>(name); component.setParent(composite); component.setContributionUri(Names.HOST_CONTRIBUTION); NonManagedImplementation implementation = new NonManagedImplementation(); component.setImplementation(implementation); Reference<ComponentType> reference = new Reference<>("reference", Multiplicity.ONE_ONE); composite.add(reference); JavaServiceContract contract = introspector.introspect(interfaze); LogicalComponent<NonManagedImplementation> logicalComponent = new LogicalComponent<>(componentUri, component, domainComponent); reference.setServiceContract(contract); LogicalReference logicalReference = new LogicalReference(referenceUri, reference, logicalComponent); logicalReference.setServiceContract(contract); logicalComponent.addReference(logicalReference); return logicalReference; }
private LogicalReference createReference(Class<?> interfaze) { LogicalCompositeComponent domainComponent = lcm.getDomainComposite(); int id = idCounter.getAndIncrement(); String name = "Synthetic" + id; URI componentUri = URI.create(domainComponent.getUri().toString() + "/" + name); URI referenceUri = URI.create(componentUri.toString() + "#reference"); QName qName = new QName(HostNamespaces.SYNTHESIZED, "SyntheticComposite" + id); Composite composite = new Composite(qName); Component<NonManagedImplementation> component = new Component<>(name); component.setParent(composite); component.setContributionUri(Names.HOST_CONTRIBUTION); NonManagedImplementation implementation = new NonManagedImplementation(); component.setImplementation(implementation); Reference<ComponentType> reference = new Reference<>("reference", Multiplicity.ONE_ONE); composite.add(reference); JavaServiceContract contract = introspector.introspect(interfaze); LogicalComponent<NonManagedImplementation> logicalComponent = new LogicalComponent<>(componentUri, component, domainComponent); reference.setServiceContract(contract); LogicalReference logicalReference = new LogicalReference(referenceUri, reference, logicalComponent); logicalReference.setServiceContract(contract); logicalComponent.addReference(logicalReference); return logicalReference; }