Package org.apache.tuscany.sca.node.configuration

Examples of org.apache.tuscany.sca.node.configuration.NodeConfiguration


    private void bundleStarted(Bundle bundle) {
        if (!isSCABundle(bundle)) {
            return;
        }
        try {
            NodeConfiguration configuration = factory.getConfiguration(bundle, null);
            Node node = factory.createNode(configuration);
            node.start();
        } catch (Throwable e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
        }
View Full Code Here


    protected NodeConfiguration getConfiguration(Bundle bundle, String compositeContent) {
        init();

        // Create a node configuration
        NodeConfigurationFactory configurationFactory = modelFactories.getFactory(NodeConfigurationFactory.class);
        NodeConfiguration configuration = configurationFactory.createNodeConfiguration();

        URL location = bundle.getEntry("/");
        String uri = bundle.getSymbolicName();
        configuration.setURI(uri).addContribution(uri, location);

        if (compositeContent != null) {
            configuration.addDeploymentComposite(uri, new StringReader(compositeContent));
        } else {
            String compositeURI = (String)bundle.getHeaders().get("SCA-Composite");
            if (compositeURI == null) {
                compositeURI = "OSGI-INF/sca/bundle.composite";
            }
            if (compositeURI != null) {
                configuration.addDeploymentComposite(uri, compositeURI);
            }
        }
        // Set the bundle
        configuration.getExtensions().add(bundle);
        return configuration;
    }
View Full Code Here

     * after this call.
     * @return a new SCA node
     */
    public Node createNode(InputStream is) {
        try {
            NodeConfiguration configuration = loadConfiguration(is);
            is.close();
            return createNode(configuration);
        } catch (IOException e) {
            throw new ServiceRuntimeException(e);
        }
View Full Code Here

            if (locations.isEmpty()) {
                throw new ServiceRuntimeException("No SCA contributions are found on the classpath");
            }
            contributions = getContributions(locations);
        }
        NodeConfiguration configuration = createConfiguration(contributions);
        if (deploymentCompositeURI != null && configuration.getContributions().size() > 0) {
            configuration.getContributions().get(0).addDeploymentComposite(createURI(deploymentCompositeURI));
        }
        return createNode(configuration);
    }
View Full Code Here

     * Create a new SCA node using the list of SCA contributions
     * @param contributions
     * @return
     */
    public Node createNode(Contribution... contributions) {
        NodeConfiguration configuration = createConfiguration(contributions);
        return createNode(configuration);
    }
View Full Code Here

     * @param compositeContent the XML content of the deployment composite
     * @param contributions the URI of the contributions that provides the composites and related artifacts
     * @return a new SCA node.
     */
    public Node createNode(InputStream compositeContent, Contribution... contributions) {
        NodeConfiguration configuration = createConfiguration(contributions);
        if (compositeContent != null && configuration.getContributions().size() > 0) {
            configuration.getContributions().get(0).addDeploymentComposite(compositeContent);
        }
        return createNode(configuration);
    }
View Full Code Here

     * @param compositeContent the XML content of the deployment composite
     * @param contributions the URI of the contributions that provides the composites and related artifacts
     * @return a new SCA node.
     */
    public Node createNode(Reader compositeContent, Contribution... contributions) {
        NodeConfiguration configuration = createConfiguration(contributions);
        if (compositeContent != null && configuration.getContributions().size() > 0) {
            configuration.getContributions().get(0).addDeploymentComposite(compositeContent);
        }
        return createNode(configuration);
    }
View Full Code Here

        return createNode(contributions);
    }
   
    private NodeConfiguration createConfiguration(Contribution... contributions) {
        NodeConfigurationFactory factory = this;
        NodeConfiguration configuration = factory.createNodeConfiguration();
        if (contributions != null) {
            for (Contribution c : contributions) {
                configuration.addContribution(c.getURI(), c.getLocation());
            }
        }
        return configuration;
    }
View Full Code Here

        return NodeConfiguration.class;
    }

    public NodeConfiguration read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {

        NodeConfiguration node = null;
        ContributionConfiguration contribution = null;
        DeploymentComposite composite = null;
        BindingConfiguration binding = null;

        // Skip to end element
        while (true) {
            int event = reader.getEventType();
            switch (event) {
                case XMLStreamConstants.START_ELEMENT:
                    QName name = reader.getName();
                    if (NODE.equals(name)) {
                        node = nodeConfigurationFactory.createNodeConfiguration();
                        node.setURI(reader.getAttributeValue(null, "uri"));
                        node.setDomainURI(reader.getAttributeValue(null, "domain"));
                    } else if (CONTRIBUTION.equals(name)) {
                        contribution = nodeConfigurationFactory.createContributionConfiguration();
                        contribution.setURI(reader.getAttributeValue(null, "uri"));
                        contribution.setLocation(reader.getAttributeValue(null, "location"));
                        node.getContributions().add(contribution);
                    } else if (BINDING.equals(name)) {
                        binding = nodeConfigurationFactory.createBindingConfiguration();
                        binding.setBindingType(getQName(reader, "name"));
                        String baseURIs = reader.getAttributeValue(null, "baseURIs");
                        if (baseURIs != null) {
                            StringTokenizer tokenizer = new StringTokenizer(baseURIs);
                            while (tokenizer.hasMoreTokens()) {
                                binding.getBaseURIs().add(tokenizer.nextToken());
                            }
                        }
                        node.getBindings().add(binding);
                    } else if (DEPLOYMENT_COMPOSITE.equals(name)) {
                        composite = nodeConfigurationFactory.createDeploymentComposite();
                        composite.setLocation(reader.getAttributeValue(null, "location"));
                        if (contribution != null) {
                            contribution.getDeploymentComposites().add(composite);
View Full Code Here

            XMLInputFactory inputFactory = getFactory(XMLInputFactory.class);
            XMLOutputFactory outputFactory = getFactory(XMLOutputFactory.class);
            XMLStreamReader reader = inputFactory.createXMLStreamReader(xml);
            NodeConfigurationProcessor processor = new NodeConfigurationProcessor(this, inputFactory, outputFactory);
            reader.nextTag();
            NodeConfiguration config = processor.read(reader);
            xml.close();
            return config;
        } catch (Throwable e) {
            throw new ServiceRuntimeException(e);
        }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.node.configuration.NodeConfiguration

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.