/** * Sets the runtime modes for the composite. * * @param modes the runtime modes * @return the builder */ public CompositeBuilder mode(List<RuntimeMode> modes) { checkState(); composite.setModes(modes); return this; }
/** * Sets the runtime environments the composite is activated in. * * @param environments the runtime environments * @return the builder */ public CompositeBuilder environment(List<String> environments) { checkState(); composite.setEnvironments(environments); 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; }
/** * Makes the composite a deployable composite. * * @return the builder */ public CompositeBuilder deployable() { checkState(); composite.setDeployable(true); return this; }
/** * 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; }
/** * Builds the composite. * * @return the built composite */ public Composite build() { checkState(); freeze(); return composite; }
/** * 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; }
/** * 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; }