public boolean hasNext() { return pos < composite.getComponents().size(); }
/** * Recursively adds composite children to the collection of components * * @param component the top-level composite component * @param components the collection */ private void flatten(LogicalCompositeComponent component, List<LogicalComponent<?>> components) { for (LogicalComponent<?> child : component.getComponents()) { components.add(child); if (child instanceof LogicalCompositeComponent) { flatten((LogicalCompositeComponent) child, components); } } }
public Object next() { if (!hasNext()) { throw new IndexOutOfBoundsException(); } int i = 0; for (LogicalComponent<?> component : composite.getComponents()) { if (i == pos) { pos++; return component; } i++; } throw new AssertionError(); }
/** * Topologically sorts components in the domain according to their URI. * * @param domain the domain composite * @return a sorted collection */ private List<LogicalComponent<?>> topologicalSort(LogicalCompositeComponent domain) { List<LogicalComponent<?>> sorted = new ArrayList<LogicalComponent<?>>(); for (LogicalComponent<?> component : domain.getComponents()) { sorted.add(component); if (component instanceof LogicalCompositeComponent) { flatten((LogicalCompositeComponent) component, sorted); } } Collections.sort(sorted, COMPARATOR); return sorted; }
/** * Sets the component state. * * @param state the instance state */ @Override public void setState(LogicalState state) { super.setState(state); for (LogicalComponent<?> component : getComponents()) { component.setState(state); } }
public void instantiate(LogicalComponent<?> component, InstantiationContext context) { resolveReferences(component, context); if (component instanceof LogicalCompositeComponent) { LogicalCompositeComponent compositeComponent = (LogicalCompositeComponent) component; for (LogicalComponent<?> child : compositeComponent.getComponents()) { instantiate(child, context); } } }
public void instantiate(LogicalComponent<?> component, InstantiationContext context) { resolveReferences(component, context); if (component instanceof LogicalCompositeComponent) { LogicalCompositeComponent compositeComponent = (LogicalCompositeComponent) component; for (LogicalComponent<?> child : compositeComponent.getComponents()) { instantiate(child, context); } } }
public void instantiate(LogicalComponent<?> component, InstantiationContext context) { resolveReferences(component, context); if (component instanceof LogicalCompositeComponent) { LogicalCompositeComponent compositeComponent = (LogicalCompositeComponent) component; for (LogicalComponent<?> child : compositeComponent.getComponents()) { instantiate(child, context); } } }
/** * Recurses the composite hierarchy for the component with the given URI * * @param uri the uri * @param composite the composite to recurse * @return the component or null if not found */ private LogicalComponent find(String uri, LogicalCompositeComponent composite) { for (LogicalComponent child : composite.getComponents()) { if (child.getUri().getSchemeSpecificPart().equals(uri)) { return child; } if (child instanceof LogicalCompositeComponent) { LogicalComponent component = find(uri, (LogicalCompositeComponent) child); if (component != null) { return component; } } } return null; } }
public void resolve(LogicalComponent<?> component, InstantiationContext context) { resolveReferences(component, context); resolveServices(component, context); if (component instanceof LogicalCompositeComponent) { LogicalCompositeComponent compositeComponent = (LogicalCompositeComponent) component; for (LogicalComponent<?> child : compositeComponent.getComponents()) { resolve(child, context); } } }
/** * Normalizes the component hierarchy by calculating autowire and promotion settings through a depth-first traversal of leaf/atomic components. * * @param component the component to normalize * @param context the instantiation context */ private void normalize(LogicalComponent<?> component, InstantiationContext context) { autowireNormalizer.normalize(component); if (component instanceof LogicalCompositeComponent) { LogicalCompositeComponent composite = (LogicalCompositeComponent) component; for (LogicalComponent<?> child : composite.getComponents()) { normalize(child, context); } } else { promotionNormalizer.normalize(component, context); } }
public void markAsProvisioned(LogicalCompositeComponent composite) { for (LogicalComponent<?> component : composite.getComponents()) {
public void selectBindings(LogicalCompositeComponent domain) throws BindingSelectionException { if (RuntimeMode.CONTROLLER != info.getRuntimeMode() || disable) { // there are no remote wires when the domain is contained withing a single VM (including Participant mode, which has a runtime domain) return; } Collection<LogicalComponent<?>> components = domain.getComponents(); for (LogicalComponent<?> component : components) { if (component.getState() == LogicalState.NEW) { selectBindings(component); } } for (LogicalChannel channel : domain.getChannels()) { selectBinding(channel); } }
public void allocate(LogicalComponent<?> component, DeploymentPlan plan) throws AllocationException { if (Names.LOCAL_ZONE.equals(component.getZone())) { if (component instanceof LogicalCompositeComponent) { LogicalCompositeComponent composite = (LogicalCompositeComponent) component; for (LogicalComponent<?> child : composite.getComponents()) { allocate(child, plan); } for (LogicalResource<?> resource : composite.getResources()) { allocate(resource, plan); } for (LogicalChannel channel : composite.getChannels()) { allocate(channel, plan); } } component.setZone(zoneName); } }
public void allocate(LogicalComponent<?> component, DeploymentPlan plan) throws AllocationException { if (Names.LOCAL_ZONE.equals(component.getZone())) { if (component instanceof LogicalCompositeComponent) { LogicalCompositeComponent composite = (LogicalCompositeComponent) component; for (LogicalComponent<?> child : composite.getComponents()) { allocate(child, plan); } for (LogicalResource<?> resource : composite.getResources()) { allocate(resource, plan); } for (LogicalChannel channel : composite.getChannels()) { allocate(channel, plan); } } selectZone(component, plan); } }
private InstantiationContext include(LogicalCompositeComponent domain, Composite composite, boolean synthetic) { InstantiationContext context = new InstantiationContext(); // merge the property values into the parent includeProperties(composite, domain, context); // merge resources includeResources(composite, domain, synthetic); // instantiate all the components in the composite and add them to the parent instantiate(composite, domain, synthetic, context); // resolve services and references - evaluate all references since reinjection may apply if (domain.isAutowire()) { for (LogicalComponent<?> component : domain.getComponents()) { autowireInstantiator.instantiate(component, context); } } return context; }
private InstantiationContext include(LogicalCompositeComponent domain, Composite composite, boolean synthetic) { InstantiationContext context = new InstantiationContext(); // merge the property values into the parent includeProperties(composite, domain, context); // merge resources includeResources(composite, domain, synthetic); // instantiate all the components in the composite and add them to the parent instantiate(composite, domain, synthetic, context); // resolve services and references - evaluate all references since reinjection may apply if (domain.isAutowire()) { for (LogicalComponent<?> component : domain.getComponents()) { autowireInstantiator.instantiate(component, context); } } return context; }
/** * Recursively sets the deployable composite the logical component was instantiated from. * * @param component the logical component * @param deployable the deployable */ private void setDeployable(LogicalComponent<?> component, QName deployable) { if (component instanceof LogicalCompositeComponent) { LogicalCompositeComponent composite = (LogicalCompositeComponent) component; for (LogicalComponent<?> child : composite.getComponents()) { setDeployable(child, deployable); } for (LogicalResource<?> resource : composite.getResources()) { resource.setDeployable(deployable); } for (LogicalChannel channel : composite.getChannels()) { channel.setDeployable(deployable); } } component.setDeployable(deployable); }
private InstantiationContext include(LogicalCompositeComponent domain, Composite composite, boolean synthetic) { InstantiationContext context = new InstantiationContext(); // merge the property values into the parent includeProperties(composite, domain, context); // merge resources includeResources(composite, domain, synthetic); // instantiate all the components in the composite and add them to the parent List<LogicalComponent<?>> newComponents = instantiate(composite, domain, synthetic, context); // normalize autowire settings and bindings for each new component - this must come before resolution since target URIs may be inherited for (LogicalComponent<?> component : newComponents) { normalize(component, context); } // resolve services and references - evaluate all references since reinjection may apply for (LogicalComponent<?> component : domain.getComponents()) { promotionResolutionService.resolve(component, context); autowireInstantiator.instantiate(component, context); } return context; }
/** * Delegates to the Allocator to determine which runtimes to deploy the given collection of components to. * * @param domain the domain component * @param plan the deployment plan * @throws AllocationException if an allocation error occurs */ private void allocate(LogicalCompositeComponent domain, DeploymentPlan plan) throws AllocationException { if (allocator == null) { // allocator is an optional extension return; } for (LogicalResource<?> resource : domain.getResources()) { if (resource.getState() == LogicalState.NEW) { allocator.allocate(resource, plan); } } for (LogicalChannel channel : domain.getChannels()) { if (channel.getState() == LogicalState.NEW) { allocator.allocate(channel, plan); } } Collection<LogicalComponent<?>> components = domain.getComponents(); for (LogicalComponent<?> component : components) { if (component.getState() == LogicalState.NEW) { allocator.allocate(component, plan); } } }