/** * Creates a Reference for the component type based on its name and Java interface */ private org.apache.tuscany.sca.assembly.Reference createReference(Class<?> interfaze, String name) throws InvalidInterfaceException { org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference(); JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract(); reference.setInterfaceContract(interfaceContract); // Set the name of the reference to the supplied name and the multiplicity of the reference // to 1..1 - for Spring implementations, this is the only multiplicity supported reference.setName(name); reference.setMultiplicity(Multiplicity.ONE_ONE); // For Spring references, we allow pass-by-reference reference.setAllowsPassByReference(true); // Set the call interface and, if present, the callback interface JavaInterface callInterface = javaFactory.createJavaInterface(interfaze); reference.getInterfaceContract().setInterface(callInterface); if (callInterface.getCallbackClass() != null) { JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass()); reference.getInterfaceContract().setCallbackInterface(callbackInterface); } return reference; }
/** * Use preProcess to validate and map the references and properties dynamically */ public void build(Component component) { for (Reference reference : component.getReferences()) { if (unresolvedBeanRef.containsKey(reference.getName())) { Reference ref = unresolvedBeanRef.get(reference.getName()); componentType.getReferences().add(createReference(reference, ref.getInterfaceContract())); unresolvedBeanRef.remove(reference.getName()); } } for (Property property : component.getProperties()) { if (unresolvedBeanRef.containsKey(property.getName())) { componentType.getProperties().add(createProperty(property)); this.setPropertyClass(property.getName(), property.getClass()); unresolvedBeanRef.remove(property.getName()); } } }
/** * Bindings from higher in the hierarchy take precedence * * @param componentReference the top service * @param componentTypeReference the bottom service */ private void calculateBindings(Reference componentReference, Reference componentTypeReference) { // forward bindings if (componentReference.getBindings().isEmpty()) { componentReference.getBindings().addAll(componentTypeReference.getBindings()); } // callback bindings if (componentReference.getCallback() == null) { componentReference.setCallback(componentTypeReference.getCallback()); } else if (componentReference.getCallback().getBindings().isEmpty() && componentTypeReference.getCallback() != null) { componentReference.getCallback().getBindings().addAll(componentTypeReference.getCallback().getBindings()); } }
protected Reference createReference(Reference reference, InterfaceContract interfaze) { Reference newReference; try { newReference = (Reference)reference.clone(); if (newReference.getInterfaceContract() == null) newReference.setInterfaceContract(interfaze); } catch (CloneNotSupportedException e) { throw new AssertionError(e); // should not ever happen } return newReference; }
private void reconcileReferenceMultiplicity(Component component, Reference componentReference, Reference componentTypeReference, Monitor monitor) { if (componentReference.getMultiplicity() != null) { if (!isValidMultiplicityOverride(componentTypeReference.getMultiplicity(), componentReference .getMultiplicity())) { Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION, "ReferenceIncompatibleMultiplicity", component.getName(), componentReference.getName()); } } else { componentReference.setMultiplicity(componentTypeReference.getMultiplicity()); } }
new XAttr(NAME, reference.getName()), writeMultiplicity(reference), writeTargets(reference), policyProcessor.writePolicies(reference)); extensionProcessor.write(reference.getInterfaceContract(), writer, context); for (Binding binding: reference.getBindings()) { extensionProcessor.write(binding, writer, context); if (reference.getCallback() != null) { Callback callback = reference.getCallback(); writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback));
InterfaceContract topInterfaceContract = topContract.getInterfaceContract(); InterfaceContract bottomInterfaceContract = bottomContract.getInterfaceContract(); topContract.setInterfaceContract(bottomInterfaceContract); } else if (bottomInterfaceContract != null) { Messages.ASSEMBLY_VALIDATION, "ReferenceInterfaceNotSubSet", topContract.getName(), incompatibilityReason);
private void reconcileReferenceMultiplicity(ComponentType componentType, Reference compositeReference, Reference promotedComponentReference, Monitor monitor) { if (compositeReference.getMultiplicity() != null) { if (!isValidMultiplicityOverride(promotedComponentReference.getTargets().size() > 0, promotedComponentReference.getMultiplicity(), compositeReference.getMultiplicity())) { Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION, "CompositeReferenceIncompatibleMultiplicity", componentType.getURI(), compositeReference.getName(), promotedComponentReference.getName()); } } else { compositeReference.setMultiplicity(promotedComponentReference.getMultiplicity()); } }
public Reference getReference(String name){ Reference reference = null; for (Reference tmp : getReferences()){ if (tmp.getName().equals(name)){ reference = tmp; break; } } return reference; }
implReference.setName(implService.getName()); implReference.setMultiplicity(Multiplicity.ZERO_N); try { InterfaceContract implContract = (InterfaceContract)implService.getInterfaceContract().clone(); implContract.setCallbackInterface(null); implContract.setNormalizedWSDLContract(null); implReference.setInterfaceContract(implContract); } catch (CloneNotSupportedException e) {
public WireFormatJMSTextReferenceProvider(ExtensionPointRegistry registry, RuntimeEndpointReference endpointReference) { super(); this.registry = registry; this.endpointReference = endpointReference; this.binding = (JMSBinding)endpointReference.getBinding(); // configure the reference based on this wire format // currently maintaining the message processor structure which // contains the details of jms message processing however override // any message processors specified in the SCDL in this case // this wire format doubles up as the execution logic for user defined // message processors so check the processor name is still set to default // before overwriting if ((this.binding.getRequestWireFormat() instanceof WireFormatJMSText) && (this.binding.getRequestMessageProcessorName().equals(JMSBindingConstants.DEFAULT_MP_CLASSNAME))){ this.binding.setRequestMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); } if ((this.binding.getResponseWireFormat() instanceof WireFormatJMSText) && (this.binding.getResponseMessageProcessorName().equals(JMSBindingConstants.DEFAULT_MP_CLASSNAME))){ this.binding.setResponseMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); } // just point to the reference interface contract so no // databinding transformation takes place interfaceContract = endpointReference.getReference().getReference().getInterfaceContract(); }
if (reference.getName().equals(theReference.getName())) duplicate = reference; theReference.getRequiredIntents().addAll(referenceElement.getRequiredIntents()); theReference.getPolicySets().addAll(referenceElement.getPolicySets()); componentType.getReferences().add(theReference); if (propertyElement.getName().equals(reference.getName())) { reference.setName(propertyRef); if (!excludedNames.contains(ref.getName()) && componentType.getReference(ref.getName()) == null) {
/** * ASM50042 - Checks that if a component reference with multiplicity="1..1" is marked * as nonOveridable then there are no composite references that promote it * * @param componentType * @param compositeReference * @param promotedComponentReference * @param monitor */ private void validateNonOverridable(ComponentType componentType, Reference compositeReference, Reference promotedComponentReference, Monitor monitor){ if ((promotedComponentReference.getMultiplicity() == Multiplicity.ONE_ONE) && (((ComponentReference)promotedComponentReference)).isNonOverridable() == true) { Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION, "CompositeReferencePromotesNonOverridableReference", componentType.getURI(), compositeReference.getName(), promotedComponentReference.getName()); } }
ref.setName(reader.getAttributeValue(null, "name")); String interfaceName = reader.getAttributeValue(null, "interface"); InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract(); ref.setInterfaceContract(interfaceContract); JavaInterface javaInterface = javaInterfaceFactory.createJavaInterface(); javaInterface.setUnresolved(true);
private void addReferencesFromComponentType(Component component, Monitor monitor) { // Create a component reference for each reference if (component.getImplementation() != null) { for (Reference reference : component.getImplementation().getReferences()) { // check for duplicate reference names in implementation if (reference != component.getImplementation().getReference(reference.getName())){ Monitor.error(monitor, this, Messages.ASSEMBLY_VALIDATION, "DuplicateImplementationReferenceName", component.getName(), reference.getName()); } ComponentReference componentReference = (ComponentReference)component.getReference(reference.getName()); // if the component doesn't have a reference with the same name as the // component type reference then create one if (componentReference == null) { componentReference = assemblyFactory.createComponentReference(); componentReference.setForCallback(reference.isForCallback()); componentReference.setName(reference.getName()); componentReference.setReference(reference); component.getReferences().add(componentReference); } } } }
JavaInterfaceContract contract = javaInterfaceFactory.createJavaInterfaceContract(); contract.setInterface(javaInterface); reference.setInterfaceContract(contract); String refName = (String)ds.getProperties().get(OSGiProperty.SCA_REFERENCE); if (refName == null) { refName = "ref" + (index++); reference.setName(refName); reference.setUnresolved(false); ct.getReferences().add(reference);
reference.setName(getString(reader, Constants.NAME)); reference.setWiredByImpl(getBoolean(reader, Constants.WIRED_BY_IMPL)); readMultiplicity(reference, reader); readTargets(reference, reader);
implReference.setInterfaceContract(interfaceContract); implReference.setName(referenceName); implReference.setForCallback(true);
String partnerlinkName = implementation.getReferencePartnerlinkName( reference.getName() ); List<org.apache.tuscany.sca.assembly.EndpointReference> eprs = reference.getEndpointReferences(); String eprCount = Integer.toString( eprs.size() ); invokeEndpoints.put( partnerlinkName, new Endpoint( new QName( TUSCANY_NAMESPACE, reference.getName() ), eprCount));
reference.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME); reference.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME); for (EndpointReference endpointReference : reference.getEndpointReferences()) { RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference; if (epr.getComponentTypeReferenceInterfaceContract() != null) {