public ComponentType read(XMLStreamReader reader, ProcessorContext context) throws XMLStreamException { int event = reader.getEventType(); ComponentType componentType = factory.createComponentType(); while (true) { switch (event) { Reference ref = factory.createReference(); ref.setName(reader.getAttributeValue(null, "name")); String interfaceName = reader.getAttributeValue(null, "interface"); componentType.getReferences().add(ref); } else if ("provide".equals(name.getLocalPart())) { Service service = factory.createService(); String interfaceName = reader.getAttributeValue(null, "interface"); InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract(); prop = Boolean.valueOf(propValue); Property property = factory.createProperty(); property.setName(propName); property.setValue(prop);
public Message invokeRequest(Message msg) { EndpointReference from = assemblyFactory.createEndpointReference(); Endpoint fromEndpoint = assemblyFactory.createEndpoint(); from.setTargetEndpoint(fromEndpoint); from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED); msg.setFrom(from); return msg; } // end method invokeRequest
public Composite getDomainComposite() { FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class); Composite domainComposite = assemblyFactory.createComposite(); domainComposite.setName(new QName(Base.SCA11_TUSCANY_NS, getDomainName())); domainComposite.setAutowire(false); domainComposite.setLocal(false); List<Composite> domainIncludes = domainComposite.getIncludes(); Map<String, List<String>> runningCompositeURIs = getRunningCompositeURIs(); for (String curi : runningCompositeURIs.keySet()) { for (String compositeURI : runningCompositeURIs.get(curi)) { domainIncludes.add(getRunningComposite(curi, compositeURI)); } } return domainComposite; }
public ComponentType read(XMLStreamReader reader, ProcessorContext context) throws XMLStreamException { int event = reader.getEventType(); ComponentType componentType = factory.createComponentType(); while (true) { switch (event) { Reference ref = factory.createReference(); ref.setName(reader.getAttributeValue(null, "id")); String interfaceName = reader.getAttributeValue(null, "interface"); componentType.getReferences().add(ref); } else if ("service".equals(name.getLocalPart())) { Service service = factory.createService(); String interfaceName = reader.getAttributeValue(null, "interface"); InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
composite = assemblyFactory.createComposite(); composite.setSpecVersion(Constants.SCA11_NS); if (contribution != null) { include = assemblyFactory.createComposite(); include.setName(getQName(reader, NAME)); include.setURI(getURIString(reader, URI)); componentService = assemblyFactory.createComponentService(); contract = componentService; componentService.setName(getString(reader, NAME)); compositeService = assemblyFactory.createCompositeService(); contract = compositeService; compositeService.setName(getString(reader, NAME)); Component promotedComponent = assemblyFactory.createComponent(); promotedComponent.setUnresolved(true); promotedComponent.setName(promotedComponentName); compositeService.setPromotedComponent(promotedComponent); ComponentService promotedService = assemblyFactory.createComponentService(); promotedService.setUnresolved(true); promotedService.setName(promotedServiceName); componentReference = assemblyFactory.createComponentReference(); contract = componentReference; componentReference.setName(getString(reader, NAME));
private RuntimeEndpointReference createEndpointReference(JavaInterfaceFactory javaInterfaceFactory, CompositeContext compositeContext, AssemblyFactory assemblyFactory, Endpoint endpoint, Class<?> businessInterface) throws CloneNotSupportedException, InvalidInterfaceException { Component component = endpoint.getComponent(); ComponentService service = endpoint.getService(); ComponentReference componentReference = assemblyFactory.createComponentReference(); componentReference.setName("$sca.client$." + service.getName()); EndpointReference endpointReference = assemblyFactory.createEndpointReference(); endpointReference.setComponent(component); endpointReference.setReference(componentReference);
private void addService(JAXRSImplementation implementation, Class<?> rootResourceClass) { Service service = assemblyFactory.createService(); JavaInterfaceContract contract = javaInterfaceFactory.createJavaInterfaceContract(); JavaInterface javaInterface; try { javaInterface = javaInterfaceFactory.createJavaInterface(rootResourceClass); } catch (InvalidInterfaceException e) { throw new ServiceRuntimeException(e); } contract.setInterface(javaInterface); service.setInterfaceContract(contract); RESTBinding binding = restBindingFactory.createRESTBinding(); // FIXME: The @ApplicationPath is available for JAX-RS 1.1 // binding.setURI("/"); Path path = rootResourceClass.getAnnotation(Path.class); if (path != null) { binding.setURI(path.value()); } service.getBindings().add(binding); service.setName(rootResourceClass.getSimpleName()); implementation.getServices().add(service); }
service.getInterfaceContract().getCallbackInterface() != null) { ComponentReference callbackReference = assemblyFactory.createComponentReference(); callbackReference.setForCallback(true); callbackReference.setName(service.getName()); CompositeReference implCompReference = assemblyFactory.createCompositeReference(); implReference = assemblyFactory.createReference();
if (reference.getInterfaceContract() != null && // can be null in unit tests reference.getInterfaceContract().getCallbackInterface() != null) { ComponentService callbackService = assemblyFactory.createComponentService(); callbackService.setForCallback(true); callbackService.setName(reference.getName()); CompositeService implCompService = assemblyFactory.createCompositeService(); implService = assemblyFactory.createService();
/** * Process Reference declaration in JavaScript code * Supported ways : * //@Reference * var catalog = new Reference("catalog"); * * //@Reference * catalog = new Reference("catalog"); * * @param scriptContent * @return */ private Reference processReferenceScript(String scriptContent) { Reference reference = null; String referenceName = null; String tokens[] = scriptContent.split("="); // find the string between the quotes tokens = tokens[1].split("\""); referenceName = tokens[1]; if(referenceName != null) { reference = assemblyFactory.createReference(); reference.setName(referenceName); } return reference; } }
/** * Helper method to create an Endpoint * @param unresolved * @return the endpoint */ private Endpoint createEndpoint(boolean unresolved) { Endpoint endpoint = assemblyFactory.createEndpoint(); endpoint.setUnresolved(unresolved); return endpoint; } // end method createEndpoint
public Extension read(QName attributeName, XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException { String attributeValue = reader.getAttributeValue(attributeName.getNamespaceURI(), attributeName.getLocalPart()); Extension ext = assemblyFactory.createExtension(); ext.setQName(attributeName); ext.setAttribute(true); ext.setValue(attributeValue); return ext; }
descriptions = resolver.resolveModel(ServiceDescriptions.class, descriptions, context); if (descriptions != null && !descriptions.isEmpty()) { ComponentType ct = assemblyFactory.createComponentType(); int index = 0; for (ServiceDescription ds : descriptions) { throw new ContributionResolveException(e); Reference reference = assemblyFactory.createReference(); JavaInterfaceContract contract = javaInterfaceFactory.createJavaInterfaceContract(); contract.setInterface(javaInterface);
/** * Helper method to create an Endpoint Reference * @param component * @param reference * @param unresolved * @return the endpoint reference */ private EndpointReference createEndpointRef(Component component, ComponentReference reference, boolean unresolved) { EndpointReference endpointRef = assemblyFactory.createEndpointReference(); endpointRef.setComponent(component); endpointRef.setReference(reference); endpointRef.setUnresolved(unresolved); return endpointRef; } // end method createEndpointRef
private void processComponentType(SpringImplementation springImplementation) { // Create a ComponentType and mark it unresolved ComponentType componentType = assemblyFactory.createComponentType(); componentType.setUnresolved(true); springImplementation.setComponentType(componentType); } // end processComponentType
/** * Process Property declaration in JavaScript code * Supported ways: * //@Property * var locale = Property("locale"); * * //@Property * locale = Property("locale"); * * @param scriptContent * @return */ private Property processPropertyScript(String scriptContent) { Property property = null; String propertyName = null; String tokens[] = scriptContent.split("="); tokens = tokens[0].split(" "); propertyName = tokens[tokens.length -1]; if(propertyName != null) { property = assemblyFactory.createProperty(); property.setName(propertyName); } return property; }
Property theProperty = assemblyFactory.createProperty(); theProperty.setName(scaproperty.getName()); ComponentType beanComponentType = assemblyFactory.createComponentType(); javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType); continue; ComponentType beanComponentType = assemblyFactory.createComponentType();
private Composite wrap(EndpointReference endpointReference) { try { Composite composite = assemblyFactory.createComposite(); composite.setName(ENDPOINT_REFERENCE_QNAME); composite.setLocal(false); Component component = (Component)endpointReference.getComponent().clone(); composite.getComponents().add(component); component.getReferences().clear(); component.getServices().clear(); ComponentReference reference = (ComponentReference)endpointReference.getReference().clone(); component.getReferences().add(reference); reference.getBindings().clear(); Binding binding = (Binding)endpointReference.getBinding().clone(); reference.getBindings().add(binding); //reference.setInterfaceContract(endpointReference.getInterfaceContract()); if (endpointReference.getStatus() != EndpointReference.Status.RESOLVED_BINDING){ ComponentService service = assemblyFactory.createComponentService(); service.setName(endpointReference.getTargetEndpoint().getURI()); reference.getTargets().clear(); reference.getTargets().add(service); } return composite; } catch (CloneNotSupportedException e) { return null; } }
private Composite wrap(Endpoint endpoint) { try { Composite composite = assemblyFactory.createComposite(); Callback callback = service.getCallback(); if(callback == null){ callback = assemblyFactory.createCallback();
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); } } } }