Package org.apache.tuscany.sca.contribution.service

Examples of org.apache.tuscany.sca.contribution.service.ContributionReadException


            return contribution;

        } catch (ContributionReadException e) {
            throw e;
        } catch (ContributionResolveException e) {
            throw new ContributionReadException(e);
        } catch (MalformedURLException e) {
            throw new ContributionReadException(e);
        }
    }
View Full Code Here


                                XPath xpath = xPathFactory.newXPath();
                                xpath.setNamespaceContext(reader.getNamespaceContext());
                                try {
                                    componentProperty.setSourceXPathExpression(xpath.compile(source));
                                } catch (XPathExpressionException e) {
                                    throw new ContributionReadException(e);
                                }
                            }
                            componentProperty.setFile(getString(reader, FILE));
                            policyProcessor.readPolicies(property, reader);
                            readAbstractProperty(componentProperty, reader);
                           
                            // Read the property value
                            Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
                            property.setValue(value);
                           
                            component.getProperties().add(componentProperty);
                        } else {

                            // Read a <composite><property>
                            property = assemblyFactory.createProperty();
                            policyProcessor.readPolicies(property, reader);
                            readAbstractProperty(property, reader);
                           
                            // Read the property value
                            Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader);
                            property.setValue(value);
                           
                            composite.getProperties().add(property);
                        }
                       
                        // TUSCANY-1949
                        // If the proerty doesn't have a value, the END_ELEMENT event is read by the readPropertyValue
                        if (reader.getEventType() == END_ELEMENT && PROPERTY_QNAME.equals(reader.getName())) {
                            property = null;
                            componentProperty = null;
                        }

                    } else if (COMPONENT_QNAME.equals(name)) {

                        // Read a <component>
                        component = assemblyFactory.createComponent();
                        component.setName(getString(reader, NAME));
                        if (isSet(reader, AUTOWIRE)) {
                            component.setAutowire(getBoolean(reader, AUTOWIRE));
                        }
                        if (isSet(reader, URI)) {
                            component.setURI(getString(reader, URI));
                        }
                        component.setConstrainingType(readConstrainingType(reader));
                        composite.getComponents().add(component);
                        policyProcessor.readPolicies(component, reader);

                    } else if (WIRE_QNAME.equals(name)) {

                        // Read a <wire>
                        wire = assemblyFactory.createWire();
                        ComponentReference source = assemblyFactory.createComponentReference();
                        source.setUnresolved(true);
                        source.setName(getString(reader, SOURCE));
                        wire.setSource(source);

                        ComponentService target = assemblyFactory.createComponentService();
                        target.setUnresolved(true);
                        target.setName(getString(reader, TARGET));
                        wire.setTarget(target);

                        composite.getWires().add(wire);
                        policyProcessor.readPolicies(wire, reader);

                    } else if (CALLBACK_QNAME.equals(name)) {

                        // Read a <callback>
                        callback = assemblyFactory.createCallback();
                        contract.setCallback(callback);
                        policyProcessor.readPolicies(callback, reader);

                    } else if (OPERATION_QNAME.equals(name)) {

                        // Read an <operation>
                        ConfiguredOperation operation = assemblyFactory.createConfiguredOperation();
                        operation.setName(getString(reader, NAME));
                        operation.setUnresolved(true);
                        if (callback != null) {
                            policyProcessor.readPolicies(operation, reader);
                        } else {
                            policyProcessor.readPolicies(operation, reader);
                        }
                       
                        OperationsConfigurator opConfigurator = null;
                        if ( compositeService != null ) {
                            opConfigurator = compositeService;
                        } else if ( componentService != null ) {
                            opConfigurator = componentService;
                        } else if ( compositeReference != null ) {
                            opConfigurator = compositeReference;
                        } else if ( componentReference != null ) {
                            opConfigurator = componentReference;
                        }
                       
                        opConfigurator.getConfiguredOperations().add(operation);
                    } else if (IMPLEMENTATION_COMPOSITE_QNAME.equals(name)) {

                        // Read an implementation.composite
                        Composite implementation = assemblyFactory.createComposite();
                        implementation.setName(getQName(reader, NAME));
                        implementation.setUnresolved(true);
                        component.setImplementation(implementation);
                        policyProcessor.readPolicies(implementation, reader);
                    } else {

                        // Read an extension element
                        Object extension = extensionProcessor.read(reader);
                        if (extension != null) {
                            if (extension instanceof InterfaceContract) {

                                // <service><interface> and
                                // <reference><interface>
                                if (contract != null) {
                                    contract.setInterfaceContract((InterfaceContract)extension);
                                } else {
                                    if (name.getNamespaceURI().equals(SCA10_NS)) {
                                        throw new ContributionReadException(
                                                                            "Unexpected <interface> element found. It should appear inside a <service> or <reference> element");
                                    } else {
                                        composite.getExtensions().add(extension);
                                    }
                                }
                            } else if (extension instanceof Binding) {
                                if ( extension instanceof PolicySetAttachPoint ) {
                                    IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType();
                                    bindingType.setName(name);
                                    bindingType.setUnresolved(true);
                                    ((PolicySetAttachPoint)extension).setType(bindingType);
                                }
                                // <service><binding> and
                                // <reference><binding>
                                if (callback != null) {
                                    callback.getBindings().add((Binding)extension);
                                } else {
                                    if (contract != null) {
                                        contract.getBindings().add((Binding)extension);
                                    } else {
                                        if (name.getNamespaceURI().equals(SCA10_NS)) {
                                            throw new ContributionReadException(
                                                                                "Unexpected <binding> element found. It should appear inside a <service> or <reference> element");
                                        } else {
                                            composite.getExtensions().add(extension);
                                        }
                                    }
                                }

                            } else if (extension instanceof Implementation) {
                                if ( extension instanceof PolicySetAttachPoint ) {
                                    IntentAttachPointType implType = intentAttachPointTypeFactory.createImplementationType();
                                    implType.setName(name);
                                    implType.setUnresolved(true);
                                    ((PolicySetAttachPoint)extension).setType(implType);
                                }
                                // <component><implementation>
                                if (component != null) {
                                    component.setImplementation((Implementation)extension);
                                } else {
                                    if (name.getNamespaceURI().equals(SCA10_NS)) {
                                        throw new ContributionReadException(
                                                                            "Unexpected <implementation> element found. It should appear inside a <component> element");
                                    } else {
                                        composite.getExtensions().add(extension);
                                    }
                                }
View Full Code Here

            }

            return contribution;
           
        } catch (XMLStreamException e) {
            throw new ContributionReadException(e);
        } catch (IOException e) {
            throw new ContributionReadException(e);
        } finally {
            try {
                if (urlStream != null) {
                    urlStream.close();
                    urlStream = null;
View Full Code Here

                       
                       
                        // Read <deployable>
                        QName compositeName = getQName(reader, "composite");
                        if (compositeName == null) {
                            throw new ContributionReadException("Attribute 'composite' is missing");
                        }

                        if (contribution != null) {
                            Composite composite = assemblyFactory.createComposite();
                            composite.setName(compositeName);
View Full Code Here

        Boolean wsdlElementIsBinding = null;
        String wsdlElement = reader.getAttributeValue(null, WSDL_ELEMENT);
        if (wsdlElement != null) {
            int index = wsdlElement.indexOf('#');
            if (index == -1) {
                throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
            }
            String namespace = wsdlElement.substring(0, index);
            wsBinding.setNamespace(namespace);
            String localName = wsdlElement.substring(index + 1);
            if (localName.startsWith("wsdl.service")) {

                // Read a wsdl.service
                localName = localName.substring("wsdl.service(".length(), localName.length() - 1);
                wsBinding.setServiceName(new QName(namespace, localName));

            } else if (localName.startsWith("wsdl.port")) {

                // Read a wsdl.port
                localName = localName.substring("wsdl.port(".length(), localName.length() - 1);
                int s = localName.indexOf('/');
                if (s == -1) {
                    throw new ContributionReadException(
                                                        "Invalid WebService binding wsdlElement attribute: " + wsdlElement);
                }
                wsBinding.setServiceName(new QName(namespace, localName.substring(0, s)));
                wsBinding.setPortName(localName.substring(s + 1));

            } else if (localName.startsWith("wsdl.endpoint")) {

                // Read a wsdl.endpoint
                localName = localName.substring("wsdl.endpoint(".length(), localName.length() - 1);
                int s = localName.indexOf('/');
                if (s == -1) {
                    throw new ContributionReadException(
                                                        "Invalid WebService binding wsdlElement attribute: " + wsdlElement);
                }
                wsBinding.setServiceName(new QName(namespace, localName.substring(0, s)));
                wsBinding.setEndpointName(localName.substring(s + 1));

            } else if (localName.startsWith("wsdl.binding")) {

                // Read a wsdl.service
                localName = localName.substring("wsdl.binding(".length(), localName.length() - 1);
                wsBinding.setBindingName(new QName(namespace, localName));

                wsdlElementIsBinding = true;

            } else {
                throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
            }
        }

        // Read wsdlLocation
        wsBinding.setLocation(reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION));

        ConfiguredOperation confOp = null;
        // Skip to end element
        while (reader.hasNext()) {
            int event = reader.next();
            switch (event) {
                case START_ELEMENT: {
                    if (END_POINT_REFERENCE.equals(reader.getName().getLocalPart())) {
                        if (wsdlElementIsBinding != null && wsdlElementIsBinding) {
                            throw new ContributionReadException(
                                                                wsdlElement + " must use wsdl.binding when using wsa:EndpointReference");
                        }
                        wsBinding.setEndPointReference(EndPointReferenceHelper.readEndPointReference(reader));
                    } else if (Constants.OPERATION_QNAME.equals(reader.getName())) {
                        confOp = configuredOperationProcessor.read(reader);
View Full Code Here

        SpringImplementation springImplementation = new SpringImplementation();

        // Read the location attribute for the spring implementation
        String springLocation = reader.getAttributeValue(null, LOCATION);
        if (springLocation == null) {
            throw new ContributionReadException(MSG_LOCATION_MISSING);
        }
        springImplementation.setLocation(springLocation);

        // Skip to end element
        while (reader.hasNext()) {
View Full Code Here

            if (sessionType.equals("stateless")) {
                ejbBinding.setSessionType(EJBBinding.SessionType.STATELESS);
            } else if (sessionType.equals("stateful")) {
                ejbBinding.setSessionType(EJBBinding.SessionType.STATEFUL);
            } else {
                throw new ContributionReadException("Unknown EJB Session Type of " + sessionType + " for " + name);
            }
        }

        String ejbVersion = reader.getAttributeValue(null, EJBBinding.EJB_VERSION);
        if (ejbVersion != null) {
            if (ejbVersion.equals("EJB2")) {
                ejbBinding.setEjbVersion(EJBBinding.EJBVersion.EJB2);
            } else if (ejbVersion.equals("EJB3")) {
                ejbBinding.setEjbVersion(EJBBinding.EJBVersion.EJB3);
            } else {
                throw new ContributionReadException("Unknown EJB Version of " + sessionType + " for " + name);
            }
        }

        // TODO: Read requires
        String requires = reader.getAttributeValue(null, EJBBinding.REQUIRES);
View Full Code Here

        try {
            rootFolder = new File(packageSourceURL.toURI());
            if (rootFolder.isDirectory()) {
                if (!rootFolder.exists()) {
                    throw new ContributionReadException(rootFolder.getAbsolutePath());
                }

                traverse(artifacts, rootFolder, rootFolder);
            }

        } catch (URISyntaxException e) {
            throw new ContributionReadException(packageSourceURL.toExternalForm(), e);
        }

        return artifacts;
    }
View Full Code Here

        }
        if (notificationType != null) {
            try {
                binding.setNotificationType(new URI(notificationType));
            } catch(URISyntaxException e) {
                throw new ContributionReadException(e);
            }
        }
        return binding;
    }
View Full Code Here

                else if (refCallbackName != null)
                    refCallbackProperties.put(refCallbackName, props);
                else if (serviceCallbackName != null)
                    serviceCallbackProperties.put(serviceCallbackName, props);
                else
                    throw new ContributionReadException("Properties in implementation.osgi should specify service or reference");               
            }

        }
           
        OSGiImplementation implementation = new OSGiImplementation(
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.service.ContributionReadException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.