private void addReference(InjectingComponentType componentType, TypeMapping typeMapping, String name, Type parameterType, InjectionSite site, IntrospectionContext context) { Class<?> type = helper.getBaseType(parameterType, typeMapping); ServiceContract contract = contractProcessor.introspect(type, context, componentType); Reference<ComponentType> reference = new Reference<>(name, contract); helper.processMultiplicity(reference, false, parameterType, typeMapping); componentType.add(reference, site); } }
private Reference<ComponentType> createDefinition(String name, boolean required, Type type, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { TypeMapping typeMapping = context.getTypeMapping(implClass); Class<?> baseType = helper.getBaseType(type, typeMapping); ServiceContract contract = contractProcessor.introspect(baseType, implClass, context, componentType); Reference<ComponentType> definition = new Reference<>(name, contract); helper.processMultiplicity(definition, required, type, typeMapping); return definition; }
@SuppressWarnings({"unchecked"}) private void addReference(InjectingComponentType componentType, String name, Class<?> parameterType, Class<?> declaringClass, InjectionSite site, IntrospectionContext context) { TypeMapping typeMapping = context.getTypeMapping(declaringClass); ServiceContract contract = contractProcessor.introspect(parameterType, context, componentType); Reference reference = new Reference(name, contract); helper.processMultiplicity(reference, false, parameterType, typeMapping); componentType.add(reference, site); } }
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; }
/** * Adds a reference with the given name and target. * * @param name the reference name * @param target the target */ public T reference(String name, String target, boolean required) { checkState(); Component<?> definition = getComponent(); Multiplicity multiplicity = required ? Multiplicity.ONE_ONE : Multiplicity.ZERO_ONE; Reference<Component> reference = new Reference<>(name, multiplicity); reference.addTarget(new Target(target)); definition.add(reference); return builder(); }
/** * Adds a reference with the given name and target. * * @param name the reference name * @param target the target */ public T reference(String name, String target) { checkState(); Component<?> definition = getComponent(); Reference<Component> reference = new Reference<>(name, Multiplicity.ONE_ONE); reference.addTarget(new Target(target)); definition.add(reference); return builder(); }
/** * Adds a reference with the given name and target. * * @param name the reference name * @param target the target * @param multiplicity the multiplicity */ public T reference(String name, String target, Multiplicity multiplicity) { checkState(); Component<?> definition = getComponent(); Reference<Component> reference = new Reference<>(name, multiplicity); reference.addTarget(new Target(target)); definition.add(reference); return builder(); }