private <T> LogicalComponent<NonManagedImplementation> createComponent(Class<T> interfaze, LogicalCompositeComponent domain, String root) { URI componentUri = URI.create(root + "/F3Synthetic"); InjectingComponentType componentType = new InjectingComponentType(); NonManagedImplementation implementation = new NonManagedImplementation(); implementation.setComponentType(componentType); Component<NonManagedImplementation> component = new Component<>("F3Synthetic"); component.setContributionUri(ContributionResolver.getContribution(interfaze)); component.setImplementation(implementation); return new LogicalComponent<>(componentUri, component, domain); }
private <T> LogicalComponent<NonManagedImplementation> createComponent(Class<T> interfaze, LogicalCompositeComponent domain, String root) { URI componentUri = URI.create(root + "/F3Synthetic"); InjectingComponentType componentType = new InjectingComponentType(); NonManagedImplementation implementation = new NonManagedImplementation(); implementation.setComponentType(componentType); Component<NonManagedImplementation> component = new Component<>("F3Synthetic"); component.setContributionUri(ContributionResolver.getContribution(interfaze)); component.setImplementation(implementation); return new LogicalComponent<>(componentUri, component, domain); }
private LogicalReference createReference(JavaServiceContract contract) { LogicalCompositeComponent domainComponent = lcm.getRootComponent(); 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); ComponentDefinition<NonManagedImplementation> componentDefinition = new ComponentDefinition<>(name); componentDefinition.setParent(composite); NonManagedImplementation implementation = new NonManagedImplementation(); componentDefinition.setImplementation(implementation); ComponentReference reference = new ComponentReference("reference", Multiplicity.ONE_ONE); componentDefinition.add(reference); LogicalComponent<NonManagedImplementation> logicalComponent = new LogicalComponent<>(componentUri, componentDefinition, domainComponent); logicalComponent.setZone(info.getZoneName()); 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; }
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 <T> LogicalProducer createProducer(Class<T> interfaze, URI channelUri) throws InterfaceException { JavaServiceContract contract = introspector.introspect(interfaze); LogicalCompositeComponent domainComponent = lcm.getRootComponent(); String domainRoot = domainComponent.getUri().toString(); URI componentUri = URI.create(domainRoot + "/F3Synthetic"); InjectingComponentType componentType = new InjectingComponentType(); NonManagedImplementation implementation = new NonManagedImplementation(); implementation.setComponentType(componentType); ComponentDefinition<NonManagedImplementation> componentDefinition = new ComponentDefinition<>("F3Synthetic"); componentDefinition.setContributionUri(ContributionResolver.getContribution(interfaze)); componentDefinition.setImplementation(implementation); LogicalComponent<NonManagedImplementation> logicalComponent = new LogicalComponent<>(componentUri, componentDefinition, domainComponent); ProducerDefinition producerDefinition = new ProducerDefinition("producer", contract); LogicalProducer producer = new LogicalProducer(URI.create(domainRoot + "/F3Synthetic#producer"), producerDefinition, logicalComponent); producer.addTarget(channelUri); return producer; }
@SuppressWarnings({"unchecked"}) public LogicalComponent instantiate(ComponentDefinition<?> definition, LogicalCompositeComponent parent, InstantiationContext context) { URI uri = URI.create(parent.getUri() + "/" + definition.getName()); LogicalComponent<?> component = new LogicalComponent(uri, definition, parent); if (parent.getComponent(uri) != null) { DuplicateComponent error = new DuplicateComponent(uri, parent); context.addError(error); } parent.addComponent(component); Implementation<?> impl = definition.getImplementation(); if (impl == null) { return component; } ComponentType componentType = impl.getComponentType(); if (componentTypeOverride) { // SCA policy conformance: override policy sets configured on the component type component.getPolicySets().removeAll(definition.getPolicySets()); } initializeProperties(component, definition, context); createServices(definition, component, componentType); createReferences(definition, component, componentType); createProducers(definition, component, componentType); createConsumers(definition, component, componentType); createResourceReferences(component, componentType); return component; }
@SuppressWarnings({"unchecked"}) public LogicalComponent instantiate(Component<?> component, LogicalCompositeComponent parent, InstantiationContext context) { URI uri = URI.create(parent.getUri() + "/" + component.getName()); LogicalComponent<?> logicalComponent = new LogicalComponent(uri, component, parent); if (parent.getComponent(uri) != null) { DuplicateComponent error = new DuplicateComponent(uri, parent); context.addError(error); } parent.addComponent(logicalComponent); ComponentType componentType = component.getComponentType(); if (componentType == null) { return logicalComponent; } initializeProperties(logicalComponent, component, context); createServices(component, logicalComponent, componentType); createReferences(component, logicalComponent, componentType); createProducers(component, logicalComponent, componentType); createConsumers(component, logicalComponent, componentType); createResourceReferences(logicalComponent, componentType); return logicalComponent; }
@SuppressWarnings({"unchecked"}) public LogicalComponent instantiate(Component<?> component, LogicalCompositeComponent parent, InstantiationContext context) { URI uri = URI.create(parent.getUri() + "/" + component.getName()); LogicalComponent<?> logicalComponent = new LogicalComponent(uri, component, parent); if (parent.getComponent(uri) != null) { DuplicateComponent error = new DuplicateComponent(uri, parent); context.addError(error); } parent.addComponent(logicalComponent); ComponentType componentType = component.getComponentType(); if (componentType == null) { return logicalComponent; } initializeProperties(logicalComponent, component, context); createServices(component, logicalComponent, componentType); createReferences(component, logicalComponent, componentType); createProducers(component, logicalComponent, componentType); createConsumers(component, logicalComponent, componentType); createResourceReferences(logicalComponent, componentType); return logicalComponent; }